servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r517254 - /incubator/servicemix/branches/servicemix-3.1/common/servicemix-components/src/main/java/org/apache/servicemix/components/jabber/JabberComponentSupport.java
Date Mon, 12 Mar 2007 15:31:48 GMT
Author: gnodet
Date: Mon Mar 12 08:31:47 2007
New Revision: 517254

URL: http://svn.apache.org/viewvc?view=rev&rev=517254
Log:
SM-311: JabberComponentSupport attempts to create a jabber account every time on start

Modified:
    incubator/servicemix/branches/servicemix-3.1/common/servicemix-components/src/main/java/org/apache/servicemix/components/jabber/JabberComponentSupport.java

Modified: incubator/servicemix/branches/servicemix-3.1/common/servicemix-components/src/main/java/org/apache/servicemix/components/jabber/JabberComponentSupport.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-3.1/common/servicemix-components/src/main/java/org/apache/servicemix/components/jabber/JabberComponentSupport.java?view=diff&rev=517254&r1=517253&r2=517254
==============================================================================
--- incubator/servicemix/branches/servicemix-3.1/common/servicemix-components/src/main/java/org/apache/servicemix/components/jabber/JabberComponentSupport.java
(original)
+++ incubator/servicemix/branches/servicemix-3.1/common/servicemix-components/src/main/java/org/apache/servicemix/components/jabber/JabberComponentSupport.java
Mon Mar 12 08:31:47 2007
@@ -24,6 +24,7 @@
 import org.jivesoftware.smack.XMPPConnection;
 import org.jivesoftware.smack.XMPPException;
 import org.jivesoftware.smack.packet.Packet;
+import org.jivesoftware.smack.packet.XMPPError;
 import org.springframework.beans.factory.InitializingBean;
 
 import javax.jbi.JBIException;
@@ -67,10 +68,23 @@
             if (login && !connection.isAuthenticated()) {
                 if (user != null) {
                     AccountManager accountManager = new AccountManager(connection);
-                    accountManager.createAccount(user, password);
-
-                    log.info("Logging in to Jabber as user: " + user + " on connection: "
+ connection);
-                    connection.login(user, password, resource);
+                    try {
+                        log.info("Logging in to Jabber as user: " + user + " on connection:
" + connection);
+                        connection.login(user, password, resource);
+                    } catch (XMPPException e) {
+                        final XMPPError error = e.getXMPPError();
+                        // 401 == Not Authorized
+                        if (error != null && error.getCode() == 401) {
+                            // is ist possible to create Accounts?
+                            if (accountManager.supportsAccountCreation()) {
+                                //try to create the Account (maybe it wasn't there)
+                                accountManager.createAccount(user, password);
+                                log.info("Logging in to Jabber as user: " + user + " on connection:
" + connection);
+                                // try to login again (if this fails we are screwed and fail
ultimatively)
+                                connection.login(user, password, resource);
+                            }
+                        }
+                    }
                 }
                 else {
                     log.info("Logging in anonymously to Jabber on connection: " + connection);



Mime
View raw message