3 Replies Latest reply on Jan 7, 2017 2:03 AM by Flow

    Smack 4.2.0-rc2 AccountManager#isSupported() is not working for an unregistered/unauthenticated entity

    cmeng

      Following steps describe a possible scenario where an unregistered entity is trying to perform an inBand Registration on a server, manually or implemented in code e.g. aTalk.

      1. The unregistered entity attempts to perform a login and received an <not-authorized/> message.

      2. Upon received the error message, the system performs a check using AccountManager#isSupported() to determine if the server support inBand registration.

      3. If the IBR is supported, the system proceeds to getRegistrationInfo() to determine the available methods (fields or DataForm) and the parameters required, including an OCR etc feedback if registration is captcha protected.

       

      Note: step 2 may be omitted as per XEP-0077 section 3 Use Cases, step 3 will have the following effect (currently not feedback by AccountManager):

      If the host does not support In-Band Registration, it MUST return a <service-unavailable/>

       

      As highlighted in the earlier discussion, the extensionElement in the isSupported() always return null. So it proceeds to use ServiceDiscoveryManager to determined the serverSupportsFeature, but receiving an exception showing in Bold in the log captured below as it requires an autheticated "user" as defined in AbstractXMPPConnection:

      /**
      * The full JID of the authenticated user, as returned by the resource binding response of the server.
      * <p>
      * It is important that we don't infer the user from the login() arguments and the configurations service name, as,
      * for example, when SASL External is used, the username is not given to login but taken from the 'external'
      * certificate.
      * </p>
      */
      protected EntityFullJid user;

       

      However since the entity sign in process has failed, so it does not have the required authenticated "user"  to perform the ServiceDiscover operation.

       

      =============================

      Smack 4.2.0-beta3 AbstractXMPPConnection#parseFeatures missing case for stream feature <register xmlns='http://jabber.org/features/iq-register'/>

      public boolean isSupported()
         throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
         XMPPConnection connection = connection();

         ExtensionElement extensionElement = connection.getFeature(Registration.ELEMENT, Registration.NAMESPACE);
         if (extensionElement != null) {
         return true;
         }

         return ServiceDiscoveryManager.getInstanceFor(connection).serverSupportsFeature(Registration.NAMESPACE);
      }

       

      =================== Log captured during ServerSupportsFeature discovery =======================

      01-06 16:59:09.054 ? I/αTalk: [7] impl.protocol.jabber.ProtocolProviderServiceJabberImpl.connectAndLogin().1078 Starting XMPP Connection: jabbim.com/88.86.113.70:5222

      01-06 16:59:12.004 ? D/SMACK: SENT (2): <stream:stream xmlns='jabber:client' to='jabbim.com' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' xml:lang='en'>

      01-06 16:59:12.804 ? D/SMACK: RECV (2): <?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='1075596087585651310' from='jabbim.com' version='1.0' xml:lang='en'><stream:features><c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='http://www.process-one.net/en/ejabberd/' ver='z0FZ24Izum3FsTWrHpsaAsIfp78='/><starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'><required/></starttls></stream:features >

      01-06 16:59:12.814 ? D/SMACK: SENT (2): <starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'></starttls>

      01-06 16:59:13.224 ? D/SMACK: RECV (2): <proceed xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>

      01-06 16:59:14.454 ? D/SMACK: SENT (2): <stream:stream xmlns='jabber:client' to='jabbim.com' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' xml:lang='en'>

      01-06 16:59:14.844 ? D/SMACK: RECV (2): <?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='6351479412105391587' from='jabbim.com' version='1.0' xml:lang='en'>

      01-06 16:59:14.844 ? D/SMACK: RECV (2): <stream:features><c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='http://www.process-one.net/en/ejabberd/' ver='z0FZ24Izum3FsTWrHpsaAsIfp78='/><register xmlns='http://jabber.org/features/iq-register'/><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>PLAIN</mechanism></mechanis ms></stream:features>

      01-06 16:59:14.844 ? I/αTalk: [7] impl.protocol.jabber.ProtocolProviderServiceJabberImpl.connected().2291 TCP Connection Successful

      01-06 16:59:14.894 ? I/αTalk: [7] impl.protocol.jabber.OperationSetBasicTelephonyJabberImpl.registrationStateChan ged().113 Jingle : ON

      01-06 16:59:14.894 ? D/SMACK: SENT (2): <auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='PLAIN'>AGxlb3BhcmQAc29waGlhITUyMA==</auth>

      01-06 16:59:15.364 ? D/SMACK: RECV (2): <failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><not-authorized/></failure>

      01-06 16:59:15.384 ? E/αTalk: [7] util.account.LoginManager.run().375 Failed to register protocol provider.

                                    java.lang.IllegalArgumentException: Must have a local (user) JID set. Either you didn't configure one or you where not connected at least once

                                        at org.jivesoftware.smack.filter.IQReplyFilter.<init>(IQReplyFilter.java:91)

                                        at org.jivesoftware.smack.AbstractXMPPConnection.createStanzaCollectorAndSend(Abst ractXMPPConnection.java:747)

                                        at org.jivesoftware.smackx.disco.ServiceDiscoveryManager.discoverInfo(ServiceDisco veryManager.java:539)

                                        at org.jivesoftware.smackx.disco.ServiceDiscoveryManager.discoverInfo(ServiceDisco veryManager.java:505)

                                        at org.jivesoftware.smackx.disco.ServiceDiscoveryManager.supportsFeatures(ServiceD iscoveryManager.java:700)

                                        at org.jivesoftware.smackx.disco.ServiceDiscoveryManager.serverSupportsFeatures(Se rviceDiscoveryManager.java:677)

                                        at org.jivesoftware.smackx.disco.ServiceDiscoveryManager.serverSupportsFeatures(Se rviceDiscoveryManager.java:671)

                                        at org.jivesoftware.smackx.disco.ServiceDiscoveryManager.serverSupportsFeature(Ser viceDiscoveryManager.java:666)

                                        at org.jivesoftware.smackx.iqregisterx.AccountManager.isSupported(AccountManager.j ava:402)

                                        at net.java.sip.communicator.impl.protocol.jabber.LoginByPasswordStrategy.register Account(LoginByPasswordStrategy.java:151)

                                        at net.java.sip.communicator.impl.protocol.jabber.ProtocolProviderServiceJabberImp l.connectAndLogin(ProtocolProviderServiceJabberImpl.java:1137)

                                        at net.java.sip.communicator.impl.protocol.jabber.ProtocolProviderServiceJabberImp l.connectAndLogin(ProtocolProviderServiceJabberImpl.java:876)

                                        at net.java.sip.communicator.impl.protocol.jabber.ProtocolProviderServiceJabberImp l.initializeConnectAndLogin(ProtocolProviderServiceJabberImpl.java:722)

                                        at net.java.sip.communicator.impl.protocol.jabber.ProtocolProviderServiceJabberImp l.register(ProtocolProviderServiceJabberImpl.java:494)

                                        at net.java.sip.communicator.util.account.LoginManager$RegisterProvider.run(LoginM anager.java:369)