求助:SASLError using PLAIN:not-notauthorizedd

他的最新文章
他的热门文章
您举报文章:
举报原因:
原文地址:
原因补充:
(最多只允许输入30个字)android - Samck 4.1 error while connecting to openfire server (org.jivesoftware.smack.sasl.SASLErrorException: SASLError using DIGEST-MD5: not-authorized) - Stack Overflow
Join Stack Overflow to learn, share knowledge, and build your career.
or sign in with
public void connect(){
AsyncTask connectionThread = new AsyncTask(){
protected Boolean doInBackground(Void... arg0){
boolean isConnected =
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
XMPPTCPConnectionConfiguration.Builder configBuilder = XMPPTCPConnectionConfiguration.builder();
configBuilder.setUsernameAndPassword("ahsan", "vbase123");
configBuilder.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
configBuilder.setResource("test");
configBuilder.setServiceName("192.168.10.106");
configBuilder.setHost("192.168.10.106");
configBuilder.setPort(5222);
configBuilder.setSendPresence(true);
configBuilder.setDebuggerEnabled(true);
//configBuilder.setSocketFactory(SSLSocketFactory.getDefault());
TLSUtils.acceptAllCertificates(configBuilder);
} catch (NoSuchAlgorithmException e) {
} catch (KeyManagementException e) {
configBuilder.setHostnameVerifier(new HostnameVerifier() {
public boolean verify(String hostname, SSLSession session) {
connection = new XMPPTCPConnection(configBuilder.build());
// Connect to the server
try {Log.d("XAMPP","connected to server");
connection.connect();
Log.d("XAMPP","connected to server");
} catch (SmackException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (XMPPException e) {
e.printStackTrace();
// Log into the server
Log.d("XAMPP","Login to server");
connection.login();
Presence presence = new Presence(Presence.Type.available);
connection.sendPacket(presence);
setConnection(connection);
Roster roster = Roster.getInstanceFor(connection);
Collection&RosterEntry& entries = roster.getEntries();
for (RosterEntry entry : entries) {
Log.d("XMPPChatDemoActivity",
"--------------------------------------");
Log.d("XMPPChatDemoActivity", "RosterEntry " + entry);
Log.d("XMPPChatDemoActivity", "User: " + entry.getUser());
Log.d("XMPPChatDemoActivity", "Name: " + entry.getName());
Log.d("XMPPChatDemoActivity", "Status: " + entry.getStatus());
Log.d("XMPPChatDemoActivity", "Type: " + entry.getType());
Presence entryPresence = roster.getPresence(entry.getUser());
Log.d("XMPPChatDemoActivity", "Presence Status: "+ entryPresence.getStatus());
Log.d("XMPPChatDemoActivity", "Presence Type: " + entryPresence.getType());
Presence.Type type = entryPresence.getType();
if (type == Presence.Type.available)
Log.d("XMPPChatDemoActivity", "Presence AVIALABLE");
Log.d("XMPPChatDemoActivity", "Presence : " + entryPresence);
Log.d("XAMPP", "login to server");
} catch (XMPPException e) {
e.printStackTrace();
} catch (SmackException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
// Disconnect from the server
// connection.disconnect();
return isC
connectionThread.execute();
The error stack trace for this code is as follows:
5-08 18:24:04.162
/com.vb.testapp D/XAMPP﹕ connected to server
05-08 18:24:04.185
/com.vb.testapp D/SMACK﹕ SENT (0): &stream:stream xmlns='jabber:client' to='192.168.10.106' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' from='ahsan@virtualbase@192.168.10.106' xml:lang='en'&
05-08 18:24:04.189
/com.vb.testapp D/SMACK﹕ RECV (0): &?xml version='1.0' encoding='UTF-8'?&&stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" from="virtualbase" id="da5ea5f2" xml:lang="en" version="1.0"&
05-08 18:24:04.194
/com.vb.testapp D/SMACK﹕ RECV (0): &stream:features&&starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"&&/starttls&&mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"&&mechanism&DIGEST-MD5&/mechanism&&mechanism&PLAIN&/mechanism&&mechanism&ANONYMOUS&/mechanism&&mechanism&CRAM-MD5&/mechanism&&/mechanisms&&compression xmlns="http://jabber.org/features/compress"&&method&zlib&/method&&/compression&&auth xmlns="http://jabber.org/features/iq-auth"/&&register xmlns="http://jabber.org/features/iq-register"/&&/stream:features&
05-08 18:24:04.196
/com.vb.testapp D/XAMPP﹕ connected to server
05-08 18:24:04.196
/com.vb.testapp D/XAMPP﹕ Login to server
05-08 18:24:04.198
/com.vb.testapp D/SMACK﹕ SENT (0): &auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='DIGEST-MD5'&=&/auth&
05-08 18:24:04.204
/com.vb.testapp D/SMACK﹕ RECV (0): &challenge xmlns="urn:ietf:params:xml:ns:xmpp-sasl"&cmVhbG09InZpcnR1YWxiYXNlIixub25jZT0icEZvL1NsYkV3Rms3cTBRNUlpNTlEc2I5RFJMM2FRQ2NuNmF4VVdBOSIscW9wPSJhdXRoIixjaGFyc2V0PXV0Zi04LGFsZ29yaXRobT1tZDUtc2Vzcw==&/challenge&
05-08 18:24:04.206
/com.vb.testapp D/SMACK﹕ SENT (0): &response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'&dXNlcm5hbWU9ImFoc2FuQHZpcnR1YWxiYXNlIixyZWFsbT0iMTkyLjE2OC4xMC4xMDYiLG5vbmNlPSJwRm8vU2xiRXdGazdxMFE1SWk1OURzYjlEUkwzYVFDY242YXhVV0E5Iixjbm9uY2U9IjBWT1lBRFE4U09ZNDJDVUcxWldCSG9JMTRJbjFYdzdtIixuYz0wMDAwMDAwMSxxb3A9YXV0aCxkaWdlc3QtdXJpPSJ4bXBwLzE5Mi4xNjguMTAuMTA2IixyZXNwb25zZT0xNDkxNmJjMDFhODI3MGVmNjA4ODViZTNmNmQ1NzA2MixjaGFyc2V0PXV0Zi04&/response&
05-08 18:24:04.209
/com.vb.testapp D/SMACK﹕ RECV (0): &failure xmlns="urn:ietf:params:xml:ns:xmpp-sasl"&&not-authorized/&&/failure&
05-08 18:24:04.212
/com.vb.testapp W/System.err﹕ org.jivesoftware.smack.sasl.SASLErrorException: SASLError using DIGEST-MD5: not-authorized
05-08 18:24:04.212
/com.vb.testapp W/System.err﹕ at org.jivesoftware.smack.SASLAuthentication.authenticationFailed(SASLAuthentication.java:365)
05-08 18:24:04.212
/com.vb.testapp W/System.err﹕ at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:1011)
05-08 18:24:04.212
/com.vb.testapp W/System.err﹕ at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$200(XMPPTCPConnection.java:915)
05-08 18:24:04.212
/com.vb.testapp W/System.err﹕ at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:930)
05-08 18:24:04.212
/com.vb.testapp W/System.err﹕ at java.lang.Thread.run(Thread.java:818)
try adding these lines when configuring your connection
configBuilder.setSecurityMode(XMPPTCPConnectionConfiguration.SecurityMode.required );
SASLMechanism mechanism = new SASLDigestMD5Mechanism();
SASLAuthentication.registerSASLMechanism(mechanism);
SASLAuthentication.blacklistSASLMechanism("SCRAM-SHA-1");
SASLAuthentication.unBlacklistSASLMechanism("DIGEST-MD5");
import the smack-sasl-provided-4.1.0.jar to get rid of this SASLAuthentication error.
I was having the same issue and solved by importing the aboved mentioned lib.
Also have a look at .
I have posted earlier on SO.
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
Stack Overflow works best with JavaScript enabled请问,我openfire安装,配置已经搞好了。我在通过Smack连接openfire初始化的时候,报错了ConnectionHandlerreportsIOExceptionforsession:(S
请问如何监听好友的昵称头像等Vcard的变化?从而修改自己的好友列表上的显示?我明白可以监听好友的离线及其上线状态?比如用以下代码即可。finalRosterroster=Client.getRost
使用匿名登录后,注册总是会返回失败。如果使用实名登录可以注册成功。服务器是openfire,以下是通讯的xmpp报文,不知道那个步骤存在问题。请大拿指教。C:&?xmlversion=&1.0&
openfire部署问题,本地源码修改,如何替换到测试环境我在本地和测试环境都部署好了openfire的服务器,服务器启动成功,客户端也可以访问;如果本地openfire服务器的源码修改了。如何将本地
jwchat怎么查询历史记录?在查看jwchat的源码时,发现其实他是有可以查看历史记录的,有个&历史&按键被屏蔽了。我修改显示这个按键后,点击没有任何反应。请问jwchat如何查看历史聊天记录?!!
使用sparkweb在登录的时候,登录不成功一闪而过而在创建用户的时候,提示NoresponsefromserverPlearetryagain后台报错:17:27:21,747ERRORConnec
求教关于安卓开发多人聊天的!为什么使用MultiUserChat.getJoinedRooms(connection,connection.getUser());方法得不到自己已经加入过的房间?为什么
打开openfire.exe时弹出error:TheJVMcouldnotbestarted.求助大神应该怎么解决?安装了openfire,打开openfire.exe时,弹出ERROR:TheJVM
nginx配置错误unknowndirective&hash&这是配置文件里的一段upstreamopenfire9090{server192.168.10.211:9090;se
我不想要那种发送邀请,对方同意后加入房间,这种是临时的,人员离开后就又看不到这个帐号了。
Openfire服务器在安装好正常运行几天后,突然无法打开Web界面。错误代码如下9:31:39org.jivesoftware.openfire.filetransfer.pr
我用agsXMPP去连接,给这个XmppClientConnection类实例也加了相应的事件处理函数,但是始终不触发式什么情况privateXmppClientConnectionXmppC。
openfire源码有谁了解?????????1.代码结构2.数据流图分析3.集群、缓存、数据访问层要点说明里面的东西,没必要去细研究,因为你短时间搞不定,集群和缓存短期也不建议研究,主要把数据访问层
本人用ant执行build.xml提示成功之后,然后新建了一个javaapplication具体设置都按说明做的。最后点击run的时候java.lang.NoClassDefFoundError:Do
asmack4.06:SASLErrorusingPLAIN:not-authorizedSASLErrorusingPLAIN:not-authorized求助:使用asmack4.06+openf
openfire4.0.1用户密码加密规则请问openfire4.0.1用户密码加密规则是什么?之前版本的是通过passwordKey来加密的,最新版本的好像不是http://blog.csdn.ne
Openfire消息记录问题10C本人在写Android+smack+openfire聊天功能,然后想使用archive插件保存消息记录,但我不知道如何在Android端进行调用,网上查的都是,如何开
安卓虚拟机客户端无法连接到openfire服务端测试一个xmpp即时聊天代码,openfire服务端和代码中的地址都为本机ip,但是虚拟机上的客户端却无法登陆连接,我是用的是genymotion虚拟机
我需要在openfire插件kraken基础上开发新的网关协议,但是网络上可以找到的资料太少,希望有熟悉openfire网关插件开发或相关开发的大神提供一些帮助,感激不尽###你的问题解决了吗?我遇到求助:SASLError using PLAIN:not-authorized_百度知道
求助:SASLError using PLAIN:not-authorized
我有更好的答案
PLAIN&/ config.disabled),0); co.;/连接服务器的代码片段 config = new ConnectionConfiguration(Constants.HOST.setDebuggerEnabled(true); SASLAuthentication.supportSASLMechanism(&quot, Constants.PORT); config.setSecurityMode(SecurityMode
采纳率:89%
为您推荐:
换一换
回答问题,赢新手礼包
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。android - AsyncTask.onPostExecute() never gets called in ServiceTestCase - Stack Overflow
Join Stack Overflow to learn, share knowledge, and build your career.
or sign in with
I am writing a unit test for a service using ServiceTestCase.
The service basically executes an AsyncTask that does some work and then does something else in onPostExecute().
The service works as expected when I run and debug it in a (virtual) device.
But in the test extending ServiceTestCase, I only get into doInBackground(). Once the methods returns, onPostExecute() never gets called. I am letting the test sleep() so the AsyncTask has time to complete its work.
This is the simplified service:
public class ServiceToTest extends Service {
private AtomicBoolean busy = new AtomicBoolean(false);
public IBinder onBind(final Intent intent) {
public int onStartCommand(final Intent intent, final int flags,
final int startId) {
this.handleCommand();
return START_NOT_STICKY;
* Workaround for http://code.google.com/p/android/issues/detail?id=12117
public void onStart(final Intent intent, final int startId) {
this.handleCommand();
public void handleCommand() {
new TaskToTest().execute();
public boolean isBusy() {
return busy.get();
private class TaskToTest extends AsyncTask&Boolean, Void, TestInfo& {
protected void onPreExecute() {
busy.set(true);
protected TestInfo doInBackground(final Boolean... args) {
protected void onPostExecute(final TestInfo info) {
busy.set(false);
An this is the test for it:
public class ServiceTest extends ServiceTestCase&ServiceToTest& {
public ServiceTest() {
super(ServiceToTest.class);
public void testIsBusy() throws InterruptedException {
startService(new Intent("this.is.the.ServiceToTest"));
ServiceToTest serviceToTest = this.getService();
assertTrue(serviceToTest.isBusy());
Thread.sleep(10000);
assertFalse(serviceToTest.isBusy());
I suppose that the environment provided by ServiceTestCase is somewhat limited so this doesn't work, but is there anything I can do to make it work anyway?
1,98532336
The problem is that your background thread is waiting for the UI to be "alive", you need to call Looper.prepare() and Looper.loop(). It's better explained in .
So just to follow up on how I got it to work with the info provided by dmon.
I changed my test to the below:
public class ServiceTest extends ServiceTestCase {
public ServiceTest() {
super(ServiceToTest.class);
public void testIsBusy() throws InterruptedException {
// Starts the service and asserts that onPreExecute() was called
ServiceTestThread serviceTestThread = new ServiceTestThread();
serviceTestThread.start();
// Wait for the service to start and complete doInBackground()
// TODO Implement something smarter than this...
Thread.sleep(1000);
// Assert that onPostExecute() was called
assertFalse(serviceTestThread.serviceToTest.isBusy());
private class ServiceTestThread extends Thread {
ServiceToTest serviceToT
public void run() {
Looper.prepare();
startService(new Intent("this.is.the.ServiceToTest"));
serviceToTest = getService();
assertTrue(serviceToTest.isBusy());
Looper.loop();
I'll see now to make this ServiceTestThread more generic so it can be reused.
1,98532336
Not sure if this is useful to anybody else, but this was my attempt at abstracting Tortens answer and making it more reusable.
private synchronized boolean getWaitFlag()
return _waitF
private boolean _waitF
private synchronized void setWaitFlag(boolean value)
_waitFlag =
private void waitForCompletionFlag() throws InterruptedException
Calendar cal = Calendar.getInstance();
while (getWaitFlag() == false)
Thread.sleep(10);
if (Calendar.getInstance().getTimeInMillis() - cal.getTimeInMillis() & 1000) // Wait at most 1 second
Log.e("timeout", "timed out waiting to complete task");
private abstract class EmulatedUI extends Thread
public abstract void doWork();
public void run()
Looper.prepare();
Looper.loop();
public void testSomething() throws InterruptedException
EmulatedUI thread = new EmulatedUI() {
public void doWork()
_objectToTest.someAsyncCall(new WorkCompletedCallback() {
public void onComplete()
// could possibly assert things here
setWaitFlag(true);
thread.start();
waitForCompletionFlag();
// assert things here since you know the async task has completed.
I had the same problem when attempting to bind to a service from the test runner thread, rather than the ui thread.
Try calling startService from the ui thread.
public void testIsBusy() throws Exception {
final CountDownLatch latch = new CountDownLatch(1);
new Handler(Looper.getMainLooper()).post(new Runnable() {
public void run() {
startService(new Intent("this.is.the.ServiceToTest"));
ServiceToTest serviceToTest = this.getService();
assertTrue(serviceToTest.isBusy());
Thread.sleep(10000);
assertFalse(serviceToTest.isBusy());
latch.countDown();
latch.await(5, TimeUnit.SECONDS);
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
Stack Overflow works best with JavaScript enabled

我要回帖

更多关于 maven not authorized 的文章

 

随机推荐