public override void Parse(Node e) { if ( e.GetType() == typeof(protocol.sasl.Challenge) ) { protocol.sasl.Challenge c = e as protocol.sasl.Challenge; sasl.DigestMD5.Step1 step1 = new sasl.DigestMD5.Step1(c.TextBase64); if (step1.Rspauth == null) { //response xmlns="urn:ietf:params:xml:ns:xmpp-sasl">dXNlcm5hbWU9ImduYXVjayIscmVhbG09IiIsbm9uY2U9IjM4MDQzMjI1MSIsY25vbmNlPSIxNDE4N2MxMDUyODk3N2RiMjZjOWJhNDE2ZDgwNDI4MSIsbmM9MDAwMDAwMDEscW9wPWF1dGgsZGlnZXN0LXVyaT0ieG1wcC9qYWJiZXIucnUiLGNoYXJzZXQ9dXRmLTgscmVzcG9uc2U9NDcwMTI5NDU4Y2EwOGVjYjhhYTIxY2UzMDhhM2U5Nzc sasl.DigestMD5.Step2 s2 = new CSS.IM.XMPP.sasl.DigestMD5.Step2(step1, base.Username, base.Password, base.Server); protocol.sasl.Response r = new CSS.IM.XMPP.protocol.sasl.Response(s2.ToString()); base.XmppClientConnection.Send(r); } else { // SEND: <response xmlns="urn:ietf:params:xml:ns:xmpp-sasl"/> base.XmppClientConnection.Send(new protocol.sasl.Response()); } } }
public override void StreamParserOnStreamElement(object sender, Node e) { base.StreamParserOnStreamElement(sender, e); if ( e.GetType() == typeof(IQ) ) { if (OnIq != null) OnIq(this, e as IQ); IQ iq = e as IQ; if ( iq != null && iq.Query != null) { // Roster if (iq.Query is Roster) OnRosterIQ(iq); } } else if ( e.GetType() == typeof(Message) ) { if (OnMessage != null) OnMessage(this, e as Message); } else if ( e.GetType() == typeof(Presence) ) { if (OnPresence != null) OnPresence(this, e as Presence); } else if ( e.GetType() == typeof (CSS.IM.XMPP.protocol.stream.Features) ) { // Stream Features // StartTLS stuff CSS.IM.XMPP.protocol.stream.Features f = e as CSS.IM.XMPP.protocol.stream.Features; if (m_UseCompression && f.SupportsCompression && f.Compression.SupportsMethod(CompressionMethod.zlib)) { // Check for Stream Compression // we support only ZLIB because its a free algorithm without patents // yes ePatents suck DoChangeXmppConnectionState(XmppConnectionState.StartCompression); this.Send(new Compress(CompressionMethod.zlib)); } #if SSL || MONOSSL || BCCRYPTO else if (f.SupportsStartTls && m_UseStartTLS) { DoChangeXmppConnectionState(XmppConnectionState.Securing); this.Send(new StartTls()); } #endif else if (f.SupportsRegistration && m_RegisterAccount) { // Do registration after TLS when possible if (f.SupportsRegistration) GetRegistrationFields(e); else { // registration is not enabled on this server FireOnError(this, new RegisterException("Registration is not allowed on this server")); Close(); // Close the stream } } } #if SSL || MONOSSL || BCCRYPTO else if ( e.GetType() == typeof (Proceed) ) { StreamParser.Reset(); ClientSocket.StartTls(); SendStreamHeader(false); DoChangeXmppConnectionState(XmppConnectionState.Authenticating); } #endif else if ( e.GetType() == typeof (Compressed) ) { //DoChangeXmppConnectionState(XmppConnectionState.StartCompression); StreamParser.Reset(); ClientSocket.StartCompression(); // Start new Stream Header compressed. SendStreamHeader(false); DoChangeXmppConnectionState(XmppConnectionState.Compressed); } else if (e is CSS.IM.XMPP.protocol.Error) { if (OnStreamError != null) OnStreamError(this, e as Element); } }