xmpp/sasl.go
changeset 178 ccfebbd9f49b
parent 163 3f891f7fe817
child 184 ce49140fe60b
equal deleted inserted replaced
177:63f33bb8fa33 178:ccfebbd9f49b
    52 	case "failure":
    52 	case "failure":
    53 		cl.setError(fmt.Errorf("SASL authentication failed"))
    53 		cl.setError(fmt.Errorf("SASL authentication failed"))
    54 	case "success":
    54 	case "success":
    55 		cl.setStatus(StatusAuthenticated)
    55 		cl.setStatus(StatusAuthenticated)
    56 		cl.Features = nil
    56 		cl.Features = nil
    57 		ss := &stream{To: cl.Jid.Domain, Version: XMPPVersion}
    57 		ss := &stream{To: cl.Jid.Domain(), Version: XMPPVersion}
    58 		cl.sendRaw <- ss
    58 		cl.sendRaw <- ss
    59 	}
    59 	}
    60 }
    60 }
    61 
    61 
    62 func (cl *Client) saslDigest1(srvMap map[string]string) {
    62 func (cl *Client) saslDigest1(srvMap map[string]string) {
    78 		realm = strings.Fields(srvMap["realm"])[0]
    78 		realm = strings.Fields(srvMap["realm"])[0]
    79 	}
    79 	}
    80 
    80 
    81 	passwd := cl.password
    81 	passwd := cl.password
    82 	nonce := srvMap["nonce"]
    82 	nonce := srvMap["nonce"]
    83 	digestUri := "xmpp/" + cl.Jid.Domain
    83 	digestUri := "xmpp/" + cl.Jid.Domain()
    84 	nonceCount := int32(1)
    84 	nonceCount := int32(1)
    85 	nonceCountStr := fmt.Sprintf("%08x", nonceCount)
    85 	nonceCountStr := fmt.Sprintf("%08x", nonceCount)
    86 
    86 
    87 	// Begin building the response. Username is
    87 	// Begin building the response. Username is
    88 	// user@domain or just domain.
    88 	// user@domain or just domain.
    89 	var username string
    89 	var username string
    90 	if cl.Jid.Node == "" {
    90 	if cl.Jid.Node() == "" {
    91 		username = cl.Jid.Domain
    91 		username = cl.Jid.Domain()
    92 	} else {
    92 	} else {
    93 		username = cl.Jid.Node
    93 		username = cl.Jid.Node()
    94 	}
    94 	}
    95 
    95 
    96 	// Generate our own nonce from random data.
    96 	// Generate our own nonce from random data.
    97 	randSize := big.NewInt(0)
    97 	randSize := big.NewInt(0)
    98 	randSize.Lsh(big.NewInt(1), 64)
    98 	randSize.Lsh(big.NewInt(1), 64)