Testing if a user exists and if not create (register) on the fly

Hello all,

I have a need allow a user to register on the fly. Currently here is what happens:

  1. JoeSchmoe tries to login (create a xmpp connection).

  2. JoeSchmoe does not exist (not a registered user).

  3. Throws a SASL authentication failed error

Now I need to allow JoeSchmoe to create (register) an account if he does not exist.

Currently I am attempting to do this in the catch block.

public XMPPConnection getConnx(String user, String pwd) throws XMPPException

{

XMPPConnection connx = new XMPPConnection(HOST,PORT);

try

{

//connx.DEBUG_ENABLED = true;

PacketTypeFilter filter = new PacketTypeFilter(Message.class);

connx.addPacketListener(messageListener,filter);

connx.login(user,pwd);

System.out.println(user+" IS CONNECTED via getConnx method");

}

catch(XMPPException e)

{

createUserAccount(user,pwd);

try

{

Thread.sleep(3000);

}

catch(InterruptedException ie){ie.printStackTrace();}

getConnx(user,pwd);

System.out.println(“USER DOES NOT EXIST”);

e.printStackTrace();

connx.close();

}

/code

Is there a way to test if the user exists prior to calling the connection.login() method?

Thanks.

BTW, any page that I access under jivesoftware --> Smack take in excess of a few minutes to load. Does anyone else have this problem?

Locking thread. Thread is duplicated. Double click while posting?