About Authenticating via StringAuthentication API from Wiki

Joan Esteve <[email protected]> Wed, 14 Sep 2005 14:34:45 +0200
Newsgroups gmane.comp.java.jxta.user
Message-ID <[email protected]>
Hello, jxta users!

I'm trying to implement the Password Topic authentication from my jxta 
nodes. I followed the instructions posted at:

http://wiki.java.net/bin/view/Jxta/PasswordTopic

The sample about "InteractiveAuthentication" works fine in my network. 
The problems begin when i try to implement the "StringAuthentication" 
method. I have configured the following node using extended 
configuration (net.jxta.ext.config):

    String username="node1";
    String password="helloworld";
    Configurator config = new Configurator( username,"My Share Project", 
password,  password );   
    ...
    config.save();

The PlatformConfig is correctly created. After this, the code used to 
implement the StringAuthentication is the following one:

    PeerGroup p = PeerGroupFactory.newNetPeerGroup();
    MembershipService membership = p.getMembershipService();
    Credential cred = membership.getDefaultCredential();
     if( null == cred ) {
        AuthenticationCredential authCred = new 
AuthenticationCredential( p, "StringAuthentication", null );
        StringAuthenticator auth = (StringAuthenticator) 
membership.apply( authCred );
    }
    if( null != auth ) {
        auth.setAuth1_KeyStorePassword( "helloworld".toCharArray() );
        auth.setAuth2Identity( p.getPeerID() );
        auth.setAuth3_IdentityPassword( "helloworld".toCharArray() );
        if( auth.isReadyForJoin() ) {
            membership.join( auth ); <---- i never reach this branch!!!
        }else{
            System.out.println("NOT READY!!"); <--- always! :(
        }
    }
}

Where is exactly my mistake in this procedure? Thanks in advance to 
anyone who can help me

Joan Esteve