powered by Jive Software

Username as email address

Hi,

We are trying to integrate Jive Messenger with our application. In our application, most of the user name are email addresses.

Now when I tried creating user in Jive server with email addresses as username, it gave be “Invalid username”. However I created users in db and wanted to test if user can login. User was not logged in. I am getting error which is shown below.

My question is can email address be username?


Internal server error

java.lang.IllegalArgumentException: Illegal JID: bhupathi@tavari.net@127.0.0.1/1

137426955140

at org.xmpp.packet.JID.init(JID.java:398)

at org.xmpp.packet.JID.(JID.java:269)

at org.jivesoftware.wildfire.ClientSession.setAuthToken(ClientSession.ja

va:461)

at org.jivesoftware.wildfire.handler.IQBindHandler.handleIQ(IQBindHandle

r.java:127)

at org.jivesoftware.wildfire.handler.IQHandler.process(IQHandler.java:48

)

at org.jivesoftware.wildfire.IQRouter.handle(IQRouter.java:242)

at org.jivesoftware.wildfire.IQRouter.route(IQRouter.java:78)

at org.jivesoftware.wildfire.PacketRouter.route(PacketRouter.java:65)

at org.jivesoftware.wildfire.net.SocketReader.processIQ(SocketReader.jav

a:390)

at org.jivesoftware.wildfire.net.ClientSocketReader.processIQ(ClientSock

etReader.java:50)

at org.jivesoftware.wildfire.net.SocketReader.readStream(SocketReader.ja

va:255)

at org.jivesoftware.wildfire.net.SocketReader.run(SocketReader.java:118)

at java.lang.Thread.run(Thread.java:595)

Caused by: org.jivesoftware.stringprep.StringprepException: Contains prohibited

code points.

at org.jivesoftware.stringprep.Stringprep.nodeprep(Stringprep.java:120)

at org.xmpp.packet.JID.init(JID.java:347)

… 12 more

Hi Mahaveer,

My question is can email address be username?

No, you can’'t. The “@” character is an illegal symbol for JID (usernames).

Regards,

Ryan

We already have lot of users with @ in there username. Is there any other alternative way to deal with this?

Thanks

Mahaveer

Hi,

I just looked at http://www.jabber.org/jeps/jep-0106.html - it should be possible to escape ‘’@’’ as ‘’\40’’. I couldn’'t figure out if this is possible with Spark and Wildfire.

I can create users like ‘‘testxx\40domain.de’’ … but they look like this also in Spark, there is no ‘’\40’’ to ‘’@’’ replacement.

Maybe one expert can correct me in case I’'m wrong.

LG

Looks like LG’‘s suggestion of escaping JIDs so that you can have @ symbols in the username should be possible. In order to do so you’‘ll have to write your own AuthProvider and UserProvider which would basically be exact copies of DefaultAuthProvider and DefaultUserProvider except you’'d want to use the JID.escapeNode() and JID.unescapeNode() methods when inserting and retrieving usernames respectively.

I’‘m not sure why this isn’'t done in the DefaultAuthProvider and DefaultUserProvider already, maybe Matt or Gato can shed some insight into this?

Hope that helps,

Ryan

Thanks Ryan,

I am not sure how to use JID.escapeNode() and JID.unescapeNode() in AuthProvider class. I don’'t see any reference to JID there.

The code is actually athenticating the users. It is failing when it send the authenticated message sent back to the client.

In the ClientSession class (org.jivesoftware.wildfire package), in the method below:

When this line is called to create a JID with 2 @’'s, JID is not created and it fails.

setAddress(new JID(user.getUsername(), getServerName(), resource));[/b]

public void setAuthToken(AuthToken auth, UserManager userManager, String resource)

throws UserNotFoundException

{

User user = userManager.getUser(auth.getUsername());

setAddress(new JID(user.getUsername(), getServerName(), resource));

authToken = auth;

sessionManager.addSession(this);

setStatus(Session.STATUS_AUTHENTICATED);

}

Can anyone help me go further?

Hi Mahaveer,

Take a look at the LdapUserProvider class, there are some examples on how the JID escaping is used.

Hope that helps,

Ryan