summaryrefslogtreecommitdiff
path: root/xmpp/sasl.go
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2023-06-26 18:37:16 +0200
committerxengineering <me@xengineering.eu>2023-06-27 15:04:33 +0200
commit8715603ce1a713d1c8841382bb965cb55948fedd (patch)
treec3af42979a443168d85dd194b063308417ad0f42 /xmpp/sasl.go
parenta8a6c31d862ec1d491fc76ed21c46d7e0b35b7f2 (diff)
downloadlimox-8715603ce1a713d1c8841382bb965cb55948fedd.tar
limox-8715603ce1a713d1c8841382bb965cb55948fedd.tar.zst
limox-8715603ce1a713d1c8841382bb965cb55948fedd.zip
xmpp: Remove unused code
This is part of the refactoring. Details of the old implementation should be looked up by older commits.
Diffstat (limited to 'xmpp/sasl.go')
-rw-r--r--xmpp/sasl.go59
1 files changed, 0 insertions, 59 deletions
diff --git a/xmpp/sasl.go b/xmpp/sasl.go
deleted file mode 100644
index 91cbf6b..0000000
--- a/xmpp/sasl.go
+++ /dev/null
@@ -1,59 +0,0 @@
-package xmpp
-
-import (
- "encoding/xml"
- "encoding/base64"
- "errors"
-)
-
-func sendSaslAuth(b []xml.Token, c *Conn) error {
- mechanisms := make([]string, 0)
- for i, v := range(b) {
- switch token := v.(type) {
- case xml.StartElement:
- expected := xml.Name{"urn:ietf:params:xml:ns:xmpp-sasl", "mechanism"}
- if token.Name == expected {
- if i >= (len(b)-1) { continue }
- switch payload := b[i+1].(type) {
- case xml.CharData:
- mechanisms = append(mechanisms, string(payload))
- }
- }
- }
- }
-
- for _, v := range(mechanisms) {
- if v == "PLAIN" {
- start := xml.StartElement{
- xml.Name{"urn:ietf:params:xml:ns:xmpp-sasl", "auth"},
- []xml.Attr{
- xml.Attr{xml.Name{"", "mechanism"}, "PLAIN"},
- },
- }
-
- data := []byte("\x00" + username(c.jid) + "\x00" + c.pwd)
- dst := make([]byte, base64.StdEncoding.EncodedLen(len(data)))
- base64.StdEncoding.Encode(dst, data)
- payload := xml.CharData(dst)
-
- end := start.End()
-
- c.enc.encodeNow(start)
- c.enc.encode(payload)
- c.enc.encodeNow(end)
-
- return nil
- }
- }
-
- return errors.New("No compatible SASL mechanism given")
-}
-
-func onSaslSuccess(b []xml.Token, c *Conn) error {
- sendStreamStart(&c.enc, c.jid)
- return nil
-}
-
-func onSaslFailure(b []xml.Token, c *Conn) error {
- return errors.New("Authentication failed")
-}