コード例 #1
0
        private void ProcessAuthIQSet(XmppStream stream, AuthIq iq, XmppHandlerContext context)
        {
            if (string.IsNullOrEmpty(iq.Query.Username) || string.IsNullOrEmpty(iq.Query.Resource))
            {
                context.Sender.SendTo(stream, XmppStanzaError.ToNotAcceptable(iq));
                return;
            }

            bool authorized = false;

            if (!string.IsNullOrEmpty(iq.Query.Digest))
            {
                authorized = AuthDigest(iq.Query.Username, iq.Query.Digest, stream, context.UserManager);
            }
            if (!string.IsNullOrEmpty(iq.Query.Password))
            {
                authorized = AuthPlain(iq.Query.Username, iq.Query.Password, stream, context.UserManager);
            }
            if (authorized)
            {
                stream.Authenticate(iq.Query.Username);

                var answer = new IQ(IqType.result);
                answer.Id   = iq.Id;
                answer.To   = iq.From;
                answer.From = iq.To;
                context.Sender.SendTo(stream, answer);
            }
            else
            {
                context.Sender.SendTo(stream, XmppStanzaError.ToNotAuthorized(iq));
            }
        }
コード例 #2
0
 private void ProcessAuthIQGet(XmppStream stream, AuthIq iq, XmppHandlerContext context)
 {
     iq.SwitchDirection();
     iq.Type = IqType.result;
     iq.Query.AddChild(new Element("password"));
     iq.Query.AddChild(new Element("digest"));
     iq.Query.AddChild(new Element("resource"));
     context.Sender.SendTo(stream, iq);
 }
コード例 #3
0
ファイル: AuthIQHandler.cs プロジェクト: dolunay/XMPPServer
        private void ProcessAuthIQSet(XmppStream stream, AuthIq iq, XmppHandlerContext context)
        {
            if (string.IsNullOrEmpty(iq.Query.Username) || string.IsNullOrEmpty(iq.Query.Resource))
            {
                context.Sender.SendTo(stream, XmppStanzaError.ToNotAcceptable(iq));
                return;
            }

            context.Sender.SendTo(stream, XmppStanzaError.ToNotAuthorized(iq));
        }