powered by Jive Software

Username as email address


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@


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


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


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


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


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


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).



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




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.


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,


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;




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,