smack4.1 android,Smack 4.1 Android anonymous registration to Openfire

I want connect anonymously to openfire server with Android Smack 4.1 client and register the new user (username = "wq", password="wq") with AccountManager, and then disconnect and login as non-anonymous registered user. Special care must be taken when an unregistered entity interacts with a server rather than a service. Normally, a server enables in-band registration so that entities can "bootstrap" their participation in the Jabber network; this bootstrapping happens when an unregistered and unauthenticated entity opens a TCP connection to a server and immediately completes the registration use case with the server, then authenticates using the newly-registered identity. As noted, when a server receives an IQ-get for registration information, it SHOULD assume that the requesting entity is unregistered unless the entity has already authenticated. Depending on local service provisioning, a server MAY return a stanza error if an unregistered entity attempts to register too many times before authenticating or if an entity attempts to register a second identity after successfully completing the registration use case; a server MAY also return a stream error if the unregistered entity waits too long before authenticating or attempts to complete a task other than authentication after successfully completing the registration use case.

connection builder looks like: xmpptcpConnection=newXMPPTCPConnection(XMPPTCPConnectionConfiguration.builder().setSecurityMode(ConnectionConfiguration.SecurityMode.disabled).setResource(resource).setHost(localhost).setServiceName(serviceName).setPort(port).setDebuggerEnabled(true).setSendPresence(true).build());

And registration: if(password!=null&&username!=null){AccountManageraccountManager=AccountManager.getInstance(xmpptcpConnection);accountManager.sensitiveOperationOverInsecureConnection(true);accountManager.createAccount(username,password);}else{smackError("Username or password wrong");}

But I got bad-request error 05-2121:34:20.80119535-19577/com.xmpp D/SMACK:SENT(0):05-2121:34:20.80519535-19578/com.xmpp D/SMACK:RECV(0):ANONYMOUSzlib05-2121:34:20.82619535-19577/com.xmpp D/SMACK:SENT(0):=05-2121:34:20.82819535-19578/com.xmpp D/SMACK:RECV(0):05-2121:34:20.83019535-19578/com.xmpp D/SMACK:RECV(0):zlib05-2121:34:20.83819535-19577/com.xmpp D/SMACK:SENT(0):05-2121:34:20.84119535-19578/com.xmpp D/SMACK:RECV(0):cafb2f97@127.0.0.1/cafb2f9705-2121:34:20.84319535-19564/com.xmpp D/SMACK:Userlogged(0):cafb2f97@127.0.0.1:5222/cafb2f9705-2121:34:20.84319535-19564/com.xmpp D/SMACK:XMPPConnectionauthenticated(0)05-2121:34:20.84419535-19577/com.xmpp D/SMACK:SENT(0):05-2121:35:20.53119535-19577/com.xmpp D/SMACK:SENT(0):05-2121:35:20.53519535-19578/com.xmpp D/SMACK:RECV(0):XMPPClientRegistrationPleaseprovide the following informationjabber:iq:register05-2121:35:20.53719535-19577/com.xmpp D/SMACK:SENT(0):wqwq05-2121:35:20.54019535-19578/com.xmpp D/SMACK:RECV(0):wqwq05-2121:35:20.54219535-19564/com.xmpp W/System.err:org.jivesoftware.smack.XMPPException$XMPPErrorException:XMPPError:bad-request-modify05-2121:35:20.54219535-19564/com.xmpp W/System.err:at org.jivesoftware.smack.PacketCollector.nextResultOrThrow(PacketCollector.java:232)05-2121:35:20.54219535-19564/com.xmpp W/System.err:at org.jivesoftware.smack.PacketCollector.nextResultOrThrow(PacketCollector.java:213)05-2121:35:20.54219535-19564/com.xmpp W/System.err:at org.jivesoftware.smackx.iqregister.AccountManager.createAccount(AccountManager.java:272)05-2121:35:20.54219535-19564/com.xmpp W/System.err:at org.jivesoftware.smackx.iqregister.AccountManager.createAccount(AccountManager.java:244)05-2121:35:20.54319535-19564/com.xmpp W/System.err:at com.xmpp.service.SmackConnection.register(SmackConnection.java:349)05-2121:35:20.54319535-19564/com.xmpp W/System.err:at com.xmpp.service.SmackService$1.run(SmackService.java:119)05-2121:35:20.54319535-19564/com.xmpp W/System.err:at android.os.Handler.handleCallback(Handler.java:739)05-2121:35:20.54319535-19564/com.xmpp W/System.err:at android.os.Handler.dispatchMessage(Handler.java:95)05-2121:35:20.54319535-19564/com.xmpp W/System.err:at android.os.Looper.loop(Looper.java:135)05-2121:35:20.54319535-19564/com.xmpp W/System.err:at com.xmpp.service.SmackService$2.run(SmackService.java:157)05-2121:35:20.54319535-19564/com.xmpp W/System.err:at java.lang.Thread.run(Thread.java:818)

I am not getting errors if I am connected with non-anonymous account, in connection builder only added : .setUsernameAndPassword(username,password)

but I don't want to use another already registered account for registering new user to server. Is there any nice solution to pass it this way ?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值