vysper server login fail

1.5k views Asked by At

I'm making a vysper xmpp server. Here's my code:

public static void main(String[] args) throws Exception {

    XMPPServer server = new XMPPServer("myserver.org");

    StorageProviderRegistry providerRegistry = new MemoryStorageProviderRegistry();

    AccountManagement accountManagement = (AccountManagement) providerRegistry.retrieve(AccountManagement.class);

    Entity user = EntityImpl.parseUnchecked("[email protected]");
    accountManagement.addUser(user, "password");

    server.setStorageProviderRegistry(providerRegistry);

    server.addEndpoint(new TCPEndpoint())

    server.setTLSCertificateInfo(new File("keystore.jks"), "boguspw");

    //server.setTLSCertificateInfo(new File("bogus_mina_tls.cert"), "boguspw");

    server.start();
    System.out.println("Vysper server is running...");

    server.addModule(new EntityTimeModule());
    server.addModule(new VcardTempModule());
    server.addModule(new XmppPingModule());
    server.addModule(new PrivateDataModule());
}

I've tried both certificate files. (keystore.jks,bogus_mina_tls.cert)

After I start the server, it connects to it, and tries to login but it can't login.

SmackConfiguration.setPacketReplyTimeout(5000);

    config = new ConnectionConfiguration("myserver.org", port, "localhost");
    config.setSelfSignedCertificateEnabled(true);
    config.setSecurityMode(ConnectionConfiguration.SecurityMode.enabled);
    config.setSASLAuthenticationEnabled(true);

// config.setKeystorePath("keystore.jks");

// config.setTruststorePath("keystore.jks");

    config.setKeystorePath("bogus_mina_tls.cert");
    config.setTruststorePath("bogus_mina_tls.cert");

    config.setTruststorePassword("boguspw");

    XMPPConnection.DEBUG_ENABLED = true;
    connection = new XMPPConnection(config);

    try {
        connection.connect();

    } catch (XMPPException e) {
        System.out.println("Error connect");
        e.printStackTrace();
    }

    System.out.println("Connected: " + connection.isConnected());

    try {
        System.out.println(connection.isAuthenticated());
        connection.login("user", "password");

    } catch (XMPPException e) {
        System.out.println("Error login");
        e.printStackTrace();
    }

I catch this exception:

SASL authentication PLAIN failed: incorrect-encoding: at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java:337) at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:203) at org.jivesoftware.smack.Connection.login(Connection.java:348) at com.protocol7.vysper.intro.WorkingClient.init(WorkingClient.java:57) at com.protocol7.vysper.intro.WorkingClient.(WorkingClient.java:27) at com.protocol7.vysper.intro.Runclient.main(Runclient.java:11)

I've seen these examples (1st, 2nd) but they don't work.

1

There are 1 answers

0
zillion1 On

At first please note that the server certificate is not used for user authentication, it is used to provide secure communication channel between client and server.

From the log you can see that your authentication method is "SASL PLAIN", using a user and password.

On the server, you are setting username/password as:

accountManagement.addUser("[email protected]", "password");

but on the client you're using

connection.login("user", "password");

This doesn't fit with the error message you are posting, but I'd suggest you try again with correct user/password.