更新了smack4.1后,发现之前的注册表单不能使用了,很多属性都不能使用.

发现4.1把帐号的出来都集中到

org.jivesoftware.smackx.iqregister.AccountManager类
/**
* Creates a new account using the specified username and password. The server may
* require a number of extra account attributes such as an email address and phone
* number. In that case, Smack will attempt to automatically set all required
* attributes with blank values, which may or may not be accepted by the server.
* Therefore, it's recommended to check the required account attributes and to let
* the end-user populate them with real values instead.
*
* @param username the username.
* @param password the password.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public void createAccount(String username, String password) throws NoResponseException, XMPPErrorException, NotConnectedException {
// Create a map for all the required attributes, but give them blank values.
Map<String, String> attributes = new HashMap<String, String>();
for (String attributeName : getAccountAttributes()) {
attributes.put(attributeName, "");
}
createAccount(username, password, attributes);
} /**
* Creates a new account using the specified username, password and account attributes.
* The attributes Map must contain only String name/value pairs and must also have values
* for all required attributes.
*
* @param username the username.
* @param password the password.
* @param attributes the account attributes.
* @throws XMPPErrorException if an error occurs creating the account.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
* @see #getAccountAttributes()
*/
public void createAccount(String username, String password, Map<String, String> attributes)
throws NoResponseException, XMPPErrorException, NotConnectedException {
if (!connection().isSecureConnection() && !allowSensitiveOperationOverInsecureConnection) {
// TODO throw exception in newer Smack versions
LOGGER.warning("Creating account over insecure connection. "
+ "This will throw an exception in future versions of Smack if AccountManager.sensitiveOperationOverInsecureConnection(true) is not set");
}
attributes.put("username", username);
attributes.put("password", password);
Registration reg = new Registration(attributes);
reg.setType(IQ.Type.set);
reg.setTo(connection().getServiceName());
createPacketCollectorAndSend(reg).nextResultOrThrow();
} 创建新帐号
AccountManager.getInstance(XmppConnectionManager.getInstance().getConnection()).createAccount("test001", "123456");

Smack4.1注册新用户的更多相关文章

  1. [部署Mantis]用Administrator注册新用户时设置密码

    伤不起的Mantis邮箱配置,在新的Mantis配置里面默认通过接收激活邮件来设定密码. 如果你Mantis邮箱配置OK的话一切OK,遇到我这样死活配不成功,网络上大神们众说纷纭,一一参照,无奈死伤无 ...

  2. 朝花夕拾-android 一个注册新用户时,多步填写用户资料的框架

    源码地址:http://git.oschina.net/zj2012zy/Android-Demo/tree/master/AndroidDemo/setpregister 效果如下: 基本思路: 1 ...

  3. 客户端连接注册Ejabberd新用户

    今天需要使用客户端注册新用户,结果发现注册失败,在管理后台添加新用户成功.编译安装ejabberd就没有管了,经过翻论坛的到解决方法 在ejabberd.yml中. access: trusted_n ...

  4. Linux学习19-gitlab配置邮箱postfix(新用户激活邮件)

    前言 gitlab新增新用户有两种方式,第一种可以用户主动注册(自己设置密码):第二种也可以通过root管理员用户直接添加用户,发个邮件到用户的邮箱里,收到邮件后激活. 如果是第二种方式添加新用户的话 ...

  5. 2016 Vultr VPS最新优惠码,赠送新用户70美元,亲测有效

    vultr肯定疯了,从来没有哪家海外vps像vultr那么大力度的优惠.近期,vultr vps再度推出优惠码,任何新用户注册即送20美元!要知道,vultr vps最便宜的vps套餐只要5美元/月, ...

  6. Discuz3.2 新用户插入数据库SQL

    我们的网站要和Discuz整合到一起,有个新用户同步的需求,网络上很多的做法是用 UCenter的接口来做,反正最后都是插入SQL,笔者使用了直接操作数据库的方式,把操作的表和SQL整理了下,后面如果 ...

  7. linux创建新用户及权限

    在Linux中添加普通新用户 ,超级用户(也称为“root”)是一个具有修改系统中任何文件权力的特别账号.在日常工作中,最好不要使用超级用户账号进入系统,因为任何错误操作都可能导致巨大的损失.由于超级 ...

  8. 3、Orcal表空间分配、新建用户、新用户创建连接

    1.创建表空间: 在管理员连接打开sql面板,输入如下内容: CREATE TABLESPACE DXYX DATAFILE 'E:\app\Administrator\product\11.2.0\ ...

  9. TestCase--网站创建新用户管理模块

    对于web测试,用户权限管理模块是必测的一个点,所以今天就来总结一下创建新用户管理模块的测试用例 参考图如下: 测试用例设计如下: 一.功能测试 1.  什么都不输入,单击“立即提交”,页面是否有提示 ...

随机推荐

  1. Delaunay剖分与平面欧几里得距离最小生成树

    这个东西代码我是对着Trinkle的写的,所以就不放代码了.. Delaunay剖分的定义: 一个三角剖分是Delaunay的当且仅当其中的每个三角形的外接圆内部(不包括边界)都没有点. 它的存在性是 ...

  2. 关于清除arp 缓存的那点事儿

    在Linux下,清除arp缓存表,例如: arp -d 10.0.3.6 我们可以用上面这条命令清除某一条记录,也可以用 arp -n |awk '/^[1-9]/{print "arp - ...

  3. http://blog.csdn.net/java2000_wl/article/details/8627874

    http://blog.csdn.net/java2000_wl/article/details/8627874

  4. mybatis调用存储过程 无参、带有输入输出参数,输出游标类型的 存储

    存储过程在小公司用的不多,但是如果业务比较复杂或者性能要求比较苛刻的时候存储过程就派上用场了,ibatis的前期的一些版本貌似不支持存储过程因此我选择了mybatis来做实验. 1.无输入和输出参数的 ...

  5. 通过数组和枚举简化GPIO操作编码

    在工作中,经常遇到大量使用GPIO作为数字量输入输出来控制设备或采集状态,每次定义操作不同的GPIO针脚既麻烦又容易出错,于是就想要简化操作过程.对于数字量输入来说就是采集对应针脚的状态:而输出则是根 ...

  6. [Tool]使用ConfuserEx混淆代码

    为了防止程序发布后被一些"坏人"破解,开发者通常会对自己的代码进行混淆.这篇博客将介绍一款使用很广,并且混淆效果也不错的工具ConfuserEx. 新建一个C# 控制台程序,Hel ...

  7. AOJ 0033 Ball【DFS】

    有一个筒,从A口可以放球,放进去的球可通过挡板DE使其掉进B管或C管里,现有带1-10标号的球按给定顺序从A口放入,问是否有一种控制挡板的策略可以使B管和C管中的球从下往上标号递增. 输入: 第一行输 ...

  8. Java 之 I/O流

    1.流 a.分类:①字节流:InputStream.OutputStream ②字符流:Reader.Writer b.选择:①判断是 输入 还是 输出 (站在程序的立场上) ②判断是 字节 还是 字 ...

  9. MySLQ 为数据库远程授权的方法与问题的解决解决方法

    Mysql通过远程的连接工具连接,提示Can't connect to MySQL server (10060).  这个时候我们需要分析,看哪里设置不当而导致的该问题.   工具/原料 mysql数 ...

  10. Puppet自动化部署-前期环境准备(2)

    在安装Puppet环境之前需要配置好机器的基本配置,如规范网络地址IP.hostname,certname认证名称,ntp时间同步等配置完毕,完善的搭建自动化环境. 1.环境介绍 此处实现部署的环境是 ...