2015-08-08 49 views
2

我正在尝试使用smack客户端4.1.2创建用户。我正在低于错误。XMPPError:使用smack创建新用户时禁止验证错误4.1.2

Send XML on stream = <<"<iq from='abc.example.com' to='[email protected]/Smack' id='Dym8b-14' type='error'><query xmlns=jabber:iq:register><password>xxxxxx</password><username>user</username><registered/></query><error code=403 type=auth><forbidden xmlns=urn:ietf:params:xml:ns:xmpp-stanzas/></error></iq>">> 

我ejabberd配置看起来像下面(.yml文件)

register_from: 
admin: allow 
... 
access_from: register_from 
access: register 

我仍然得到上述错误。请帮助

添加代码片段展示如何创建使用嫌4.1.0

connection = new XMPPTCPConnection(getConnectionConfiguration()); 
       connection.connect(); 
       connection.login("admin", "admin"); 
       if(connection.isAuthenticated()) 
       { 
        AccountManager accountManager = AccountManager.getInstance(connection); 
        accountManager.sensitiveOperationOverInsecureConnection(true); 
        accountManager.createAccount(userName, password); 
        connection.disconnect(); 
        // The account has been created, so we can now login 
        connection.login(userName, password); 
       } 

private XMPPTCPConnectionConfiguration getConnectionConfiguration() 
{ 

    XMPPTCPConnectionConfiguration config = XMPPTCPConnectionConfiguration.builder() 
       .setServiceName("abc.example.com") 
       .setHost("abc.example.com") 
       .setPort(5222) 
       .build(); 

    return config; 
} 
+0

看起来你配置文件的缩进是错误的。 –

回答

4

我发现了这个问题。这是由于trusted_network标记具有作为回送的值:允许在ejabberd配置文件中。我将它改为all:allow。它开始工作。

0

配置的片断,你提供过小,严重缩进新用户,所以它是不可能告诉你什么是你的配置错误。

但是,考虑到您的配置是正确的,您应该在发送注册请求之前检查您的用户是否使用正确的ACL凭证进行了正确验证。大多数客户端库采取自我用户注册并尝试在进行任何形式的身份验证之前发送注册表。

+0

嗨雷蒙德,对迟到的回应表示歉意。我使用yamlLint检查了yml文件,并成功解析了它。所以没有格式问题。如何在发送注册请求之前检查用户是否使用正确的ACL凭证进行身份验证。 –

+0

嗨Remond,我添加了一个代码片段,我尝试创建用户。请让我知道,如果这给你任何暗示问题 –

+0

这可能是一个问题?它在我的配置yml文件中。 '##只允许从本地主机 trusted_network注册: 回环:允许 ## ##在服务器计算机只有客户可以注册账户 ## ip_access:如果是这样trusted_network”,我应该改变的价值? –