Quantcast
Channel: Ignite Realtime : Discussion List - All Communities
Viewing all articles
Browse latest Browse all 10742

Smack 4.0.4 - Communigate Pro Login issue

$
0
0

Hi,

 

I am using Smack to connect to 'communigate pro' (6.0) XMPP server running locally. Local JDK is 1.7.0_25. I am not able to make my login work with smack-4.0.4 which works with smack-3.2.2

 

With 3.2.2

following jars in classpath

smack-3.2.2.jar

smackx-3.2.2.jar

I used following Code

ConnectionConfiguration connConfig = new ConnectionConfiguration("localhost", 5222,"test.mydomain.com");

XMPPConnection connection = new XMPPConnection(connConfig);

System.out.println("Before Connect");

connection.connect();

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

connection.login("user1", "user1123","test");

System.out.println("After Login : "+connection.isAuthenticated());

It did Connect and Loggedin with following exception in between

Before Connect

Before Login : true

javax.security.sasl.SaslException: Failure to initialize security context [Caused by GSSException: Invalid name provided (Mechanism level: Cannot locate default realm)]

at com.sun.security.sasl.gsskerb.GssKrb5Client.<init>(GssKrb5Client.java:150)

at com.sun.security.sasl.gsskerb.FactoryImpl.createSaslClient(FactoryImpl.java:63)

at javax.security.sasl.Sasl.createSaslClient(Sasl.java:372)

at org.jivesoftware.smack.sasl.SASLGSSAPIMechanism.authenticate(SASLGSSAPIMechanis m.java:85)

at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java: 319)

at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:203)

at com.mycomapany.test.pub.sub.StartChat.main(StartChat.java:36)

Caused by: GSSException: Invalid name provided (Mechanism level: Cannot locate default realm)

at sun.security.jgss.krb5.Krb5NameElement.getInstance(Krb5NameElement.java:127)

at sun.security.jgss.krb5.Krb5MechFactory.getNameElement(Krb5MechFactory.java:95)

at sun.security.jgss.GSSManagerImpl.getNameElement(GSSManagerImpl.java:202)

at sun.security.jgss.GSSNameImpl.getElement(GSSNameImpl.java:472)

at sun.security.jgss.GSSNameImpl.init(GSSNameImpl.java:201)

at sun.security.jgss.GSSNameImpl.<init>(GSSNameImpl.java:170)

at sun.security.jgss.GSSManagerImpl.createName(GSSManagerImpl.java:137)

at com.sun.security.sasl.gsskerb.GssKrb5Client.<init>(GssKrb5Client.java:108)

... 6 more

After Login : true

When I used following line

connConfig.setSASLAuthenticationEnabled(false);

It worked like charm with Following output

Before Connect

Before Login : true

After Login : true

 

With 4.0.4

Now I wanted to move to 4.0.4

I used following code

ConnectionConfiguration connConfig = new ConnectionConfiguration("localhost", 5222,"test.mydomain.com");

connConfig.setSecurityMode(ConnectionConfiguration.SecurityMode.enabled);

XMPPConnection connection = new XMPPTCPConnection(connConfig);

System.out.println("Before Connect");

connection.connect();

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

connection.login("user1", "user1123","test");

System.out.println("After Login : "+connection.isAuthenticated());

It resulted with following error while connecting itself

Exception in thread "main" javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)

at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1886)

at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:276)

at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:270)

at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1341)

at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:153)

at sun.security.ssl.Handshaker.processLoop(Handshaker.java:868)

at sun.security.ssl.Handshaker.process_record(Handshaker.java:804)

at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1016)

at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1312)

at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1339)

at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1323)

at org.jivesoftware.smack.tcp.XMPPTCPConnection.proceedTLSReceived(XMPPTCPConnecti on.java:658)

at org.jivesoftware.smack.tcp.PacketReader.parsePackets(PacketReader.java:221)

at org.jivesoftware.smack.tcp.PacketReader.access$000(PacketReader.java:47)

at org.jivesoftware.smack.tcp.PacketReader$1.run(PacketReader.java:81)

Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:385)

at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:292)

at sun.security.validator.Validator.validate(Validator.java:260)

at sun.security.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:326)

at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:23 1)

at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.j ava:126)

at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1323)

... 11 more

Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilde r.java:196)

at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:268)

at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:380)

... 17 more

Oct 16, 2014 10:10:30 AM org.jivesoftware.smack.tcp.PacketWriter writePackets

WARNING: Exception writing closing stream element

java.net.SocketException: Socket closed

at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:116)

at java.net.SocketOutputStream.write(SocketOutputStream.java:153)

at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:221)

at sun.nio.cs.StreamEncoder.implFlushBuffer(StreamEncoder.java:291)

at sun.nio.cs.StreamEncoder.implFlush(StreamEncoder.java:295)

at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:141)

at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:229)

at java.io.BufferedWriter.flush(BufferedWriter.java:254)

at org.jivesoftware.smack.tcp.PacketWriter.writePackets(PacketWriter.java:190)

at org.jivesoftware.smack.tcp.PacketWriter.access$000(PacketWriter.java:40)

at org.jivesoftware.smack.tcp.PacketWriter$1.run(PacketWriter.java:77)

When I change disabled security mode

connConfig.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);

No Exception thrown but it never prints "After Login" statement. login call never returns.

Before Connect

Before Login : true

 

If I have Security Mode disabled and SASLAuthentication explicitly set

connConfig.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);

SASLAuthentication.supportSASLMechanism("DIGEST-MD5",0);

I tried both MD5 and PLAIN I see a warning and exception with small delay while login

Before Connect

Before Login : true

Oct 16, 2014 10:17:56 AM org.jivesoftware.smack.filter.IQReplyFilter accept

WARNING: Rejected potentially spoofed reply to IQ-packet. Filter settings: packetId=KJEN6-0, to=null, local=null, server=test.mydomain.com. Received packet with from=user1@test.mydomain.com

Exception in thread "main" org.jivesoftware.smack.SmackException$NoResponseException

at org.jivesoftware.smack.PacketCollector.nextResultOrThrow(PacketCollector.java:1 91)

at org.jivesoftware.smack.PacketCollector.nextResultOrThrow(PacketCollector.java:1 75)

at org.jivesoftware.smack.XMPPConnection.bindResourceAndEstablishSession(XMPPConne ction.java:530)

at org.jivesoftware.smack.tcp.XMPPTCPConnection.login(XMPPTCPConnection.java:260)

at com.mycomapany.test.pub.sub.StartChat.main(StartChat.java:41)

 

Any help to make it work on smack version 4.x is appreciated.

 

Thanks,

Kiran


Viewing all articles
Browse latest Browse all 10742

Trending Articles