Not logged in. · Lost password · Register
Forum: agsXMPP SDK Support RSS
Avatar
bseddon #1
Member since Aug 2007 · 2 posts
Group memberships: Members
Show profile · Link to this post
Subject: Jid.EscapeNode
I've just upgraded to 0.95 and I'm finding that I can no longer log in when the XmppClientConnection.Username property is set (vs setting it as a parameter to the XmppClientConnection.Open() method).  The cause is the use of Jid.EscapeNode because this function is blindly escaping all characters in the username including the @ in an email address.  So far as I can tell from the example given xep-0106 requires that the @ in an email address is left untouched.

By the way, it seems it's an error that the Open() method works.  This indicates that the username passed in also needs to be escaped by, for example, calling the Username property rather than by setting the private variable directly.

Thanks for making this software available because it's allowed us to add XMPP support to our application very quickly.

Regards

Bill Seddon
Avatar
Alex #2
Member since Feb 2003 · 4245 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by bseddon:
I've just upgraded to 0.95 and I'm finding that I can no longer log in when the XmppClientConnection.Username property is set (vs setting it as a parameter to the XmppClientConnection.Open() method).  The cause is the use of Jid.EscapeNode because this function is blindly escaping all characters in the username including the @ in an email address.  So far as I can tell from the example given xep-0106 requires that the @ in an email address is left untouched.

The @ must be escaped if Jid escaping is used. If Jid escaping isn't used the @ is an invalid character in usernames.
There is also a long thread on the XMPP standards list about JID escaping because there are some edge cases which can cause problems.

Of course the open method must also escape the username. We will fix this.

Alex
Alexander Gnauck
AG-Software
Avatar
bseddon #3
Member since Aug 2007 · 2 posts
Group memberships: Members
Show profile · Link to this post
Thanks for the response.  EscapeNode seems to go beyond what's called for in xep-0106.  Here's an example given in the draft (all the examples appear to follow the same pattern):

    here's_a_wild_&_/cr%zy/_address@example.com

and here's the corresponding transformation given:

    here\27s_a_wild_\26_\2fcr%zy\2f_address@example.com

However EscapeNode goes further and yields this transformation:

    here\27s_a_wild_\26_\2fcr%zy\2f_address\40example.com

This translation of the @ used to delimit the name and domain parts of an email address is giving me problems.  I'm using a SoapBox server and it's failing to authenticate usernames that have the delimiting @ transformed. 

Is there a standard XMPP way  to query the server for it's capabilities in this area?  If there is I can make the code use/not use the escaping based on the response from the server.

If usernames are to be so transformed, isn't there going to be a non trivial risk of client/server incompatibilies?  I'm no expert with XMPP but I would like to have client and server work correctly.  Perhaps there's something I've missed and if you can see it please let me know.

Best wishes
Avatar
Alex #4
Member since Feb 2003 · 4245 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Hello,

i hope i undestood you correct. You have usernames which have the format of email adresses.
Or you map email addresses to xmpp usernames like:
username    = foo@bar.com
xmpp server = myserver.com
==> jid = foo@bar.com@myserver.com?
if i understood you correct then this jids are invalid and by chance they worked before. Normally the server should not accept such a Jid or better the library should not accept such a username.


a JabberId (Jid) in XMPP has the following format:
user@server.com/resource

There is a user part which we call Node Identifier. The server part separated by the @ is called Domain Identifier. The Resource Identifier is the last part of a jid devided by the first "/".

XMPP Core defines the Nodeprep profile of stringprep (RFC 3454), which specifies that the following characters are invalid in the node identifier portion of a JID:

    * All whitespace
    * 22h (")
    * 26h (&)
    * 27h (')
    * 2Fh (/)
    * 3Ah (:)
    * 3Ch (<)
    * 3Eh (>)
    * 40h (@)

And stringprep was defined to overcome this restriction.

If i understood you correctly you have an "@" in the nodepart. Without jid escaping usernames (node identifiers) can't contain a @. With Jid escaping they have to be escaped.

The examples you pointed out from the XEP are Jids with a domain identifier. You can't escape a full jid with escape node. Escpae node does only the escaping for the user part (node identifiers).

Alex
Alexander Gnauck
AG-Software
Avatar
ngboonseong #5
Member since Jan 2010 · 19 posts
Group memberships: Members
Show profile · Link to this post
Hi Alex,

I have test@BU@ServerName Jid created in Openfire 3.6.4 but when I try to open the connection using following
code :

this.UserID = "test@BU@ServerName";
string en = Jid.EscapeNode(this.UserID.Substring(0,this.UserID.LastIndexOf("@")));           
string s = Jid.EscapeNode(this.UserID.Substring(this.UserID.LastIndexOf("@")+1));           

Jid jidSender = new Jid(en, s, "helloworld");
xmpp = new XmppClientConnection(jidSender.Server);

xmpp.Open(jidSender.User, this.Password);

It throws the OnAuthError event with not-authorized message.

Can you advise how we can correctly escape the special characters in this SDK ?

BTW I can login using the same userid with Spark client.

Thanks.

Regards,
Boon Seong
Avatar
Alex #6
Member since Feb 2003 · 4245 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
if you build the Jid with the constructor: Jid(string user, string server, string resource) it gets automatically escaped.
If you still get auth errors then check your xmpp domain.

Alex
Alexander Gnauck
AG-Software
Avatar
ngboonseong #7
Member since Jan 2010 · 19 posts
Group memberships: Members
Show profile · Link to this post
Hi Alex,

Thanks for the prompt reply. I think there is nothing wrong with my xmpp domain as I can login to the same XMPP server using Spark.

The same code actually throw this exception :

     xmppConn.OnAuthError += delegate(object sender2, Element e2)            {            };


The weird thing is I notice the sender2.MyJID.User the value was shown as "test\\5c40BU"
instead of the right escape which is  "test\\40BU".

Can you advise?

Thanks.
Avatar
Alex #8
Member since Feb 2003 · 4245 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by ngboonseong:
Thanks for the prompt reply. I think there is nothing wrong with my xmpp domain as I can login to the same XMPP server using Spark.
Spark can even login with a wrong XMPP domain because it does not use the secure DigestMD5 authentication. See the many other threads about this topic here.
Quote by ngboonseong:
The weird thing is I notice the sender2.MyJID.User the value was shown as "test\\5c40BU"
instead of the right escape which is  "test\\40BU".
you escaped it twice then. agsXMPP definitely works with escaped Jids and Openfire. Many customers are using this feature.

Alex
Alexander Gnauck
AG-Software
Avatar
ngboonseong #9
Member since Jan 2010 · 19 posts
Group memberships: Members
Show profile · Link to this post
Hi Alex,

I really have not idea what went wrong. If i tried the code below, the user id with @domain did not work (red color).
But another user id without domain works (green color).

            xmpp = new XmppClientConnection("localhost");
            xmpp.AutoAgents = true;
            xmpp.AutoPresence = true;
            xmpp.AutoRoster = true;
            xmpp.AutoResolveConnectServer = true;
            xmpp.RegisterAccount = false;
            xmpp.ClientVersion = "1.0.0";
            xmpp.Resource = "rp2";
            xmpp.UseSSL = false;
            xmpp.UseStartTLS = true;
            xmpp.Priority = 10;
            xmpp.Open( "user1@domain@localhost", "Password"); // did not work

            xmpp.Open( "user1@localhost", "Password"); //this works

Is there any possible setup issue at the Openfire server? I am using agsXmpp sdk 1.1.
Thanks for your advise.


Regards,
Boon Seong
Avatar
Alex #10
Member since Feb 2003 · 4245 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
The Open method has the params username and password
The username is everything before the @ in the Jabber Id. So I guess you pass the Jid instead of the username, because they both contains localhost which is your domain.
If it still does not work please post your Xml Debug.

Alex
Alexander Gnauck
AG-Software
Avatar
ngboonseong #11
Member since Jan 2010 · 19 posts
Group memberships: Members
Show profile · Link to this post
Hi Alex,

Sorry there was some typo. The corrected code as following.
 ...
 xmpp.Open( "user1@domain", "Password"); // did not work

 xmpp.Open( "user1", "Password"); //this works


I got this reply :

<failure xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><not-authorized /></failure>

And from what I read from the xmpp doc, this error was due to unsuccessful JID mapping and I have no idea why this happen as I can see
the same user id in openfire admin console.

Thanks.

Regards,
Boon Seong
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Forum: agsXMPP SDK Support RSS