Smack4.1注册新用户
更新了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注册新用户的更多相关文章
- [部署Mantis]用Administrator注册新用户时设置密码
伤不起的Mantis邮箱配置,在新的Mantis配置里面默认通过接收激活邮件来设定密码. 如果你Mantis邮箱配置OK的话一切OK,遇到我这样死活配不成功,网络上大神们众说纷纭,一一参照,无奈死伤无 ...
- 朝花夕拾-android 一个注册新用户时,多步填写用户资料的框架
源码地址:http://git.oschina.net/zj2012zy/Android-Demo/tree/master/AndroidDemo/setpregister 效果如下: 基本思路: 1 ...
- 客户端连接注册Ejabberd新用户
今天需要使用客户端注册新用户,结果发现注册失败,在管理后台添加新用户成功.编译安装ejabberd就没有管了,经过翻论坛的到解决方法 在ejabberd.yml中. access: trusted_n ...
- Linux学习19-gitlab配置邮箱postfix(新用户激活邮件)
前言 gitlab新增新用户有两种方式,第一种可以用户主动注册(自己设置密码):第二种也可以通过root管理员用户直接添加用户,发个邮件到用户的邮箱里,收到邮件后激活. 如果是第二种方式添加新用户的话 ...
- 2016 Vultr VPS最新优惠码,赠送新用户70美元,亲测有效
vultr肯定疯了,从来没有哪家海外vps像vultr那么大力度的优惠.近期,vultr vps再度推出优惠码,任何新用户注册即送20美元!要知道,vultr vps最便宜的vps套餐只要5美元/月, ...
- Discuz3.2 新用户插入数据库SQL
我们的网站要和Discuz整合到一起,有个新用户同步的需求,网络上很多的做法是用 UCenter的接口来做,反正最后都是插入SQL,笔者使用了直接操作数据库的方式,把操作的表和SQL整理了下,后面如果 ...
- linux创建新用户及权限
在Linux中添加普通新用户 ,超级用户(也称为“root”)是一个具有修改系统中任何文件权力的特别账号.在日常工作中,最好不要使用超级用户账号进入系统,因为任何错误操作都可能导致巨大的损失.由于超级 ...
- 3、Orcal表空间分配、新建用户、新用户创建连接
1.创建表空间: 在管理员连接打开sql面板,输入如下内容: CREATE TABLESPACE DXYX DATAFILE 'E:\app\Administrator\product\11.2.0\ ...
- TestCase--网站创建新用户管理模块
对于web测试,用户权限管理模块是必测的一个点,所以今天就来总结一下创建新用户管理模块的测试用例 参考图如下: 测试用例设计如下: 一.功能测试 1. 什么都不输入,单击“立即提交”,页面是否有提示 ...
随机推荐
- 基于log4net的帮助类Log
using log4net; using System; using System.Collections.Generic; using System.Diagnostics; using Syste ...
- 关于更新发布CSS和JS文件的缓存问题
现如今,浏览器大战下,各个浏览器也是拼了命的提高性能,升级JS解析引擎,更好的处理浏览器的页面缓存,让用户的浏览体验更快,占用更小的PC资源.那么,问题就出现在JS和CSS缓存,甚至页面缓存上.至于浏 ...
- Unity3D访问Android系统目录
file:///sdcard/Movies/3D/互动.mp4file:///storage/emulated/0/Movies/3D/互动.mp4/storage/emulated/0/Movies ...
- php mysqli mysqli_query() mysqli_real_query()
2016年11月26日 15:22:27 星期六 场景: PHP从mysql中读取数据 1. 一次性读取所有数据返给PHP 2. 每次循环只读取一掉记录 数据量小的时候可以使用第一种方法, 数据量很大 ...
- oracle打补丁
oracle 数据库补丁安装(单实例) ------------24006111 注:务必先安装24006111再安装24315821,否则无法进行正常的补丁安装流程.1.关闭数据库监听和数据库实例 ...
- shell 脚本随机抽取班级学生
#/bin/bash jw=(name1,name2,name3......name39) ..} do a=$(date +%N) b=$() ]" "${jw[$b]} don ...
- 北漂的生活 - python 面试
第一次来北京,先谈谈感受吧.都说北京的雾霾非常严重,可能是我来的时间短,暂时我还没有遇到特别恶劣的天气,感觉还是很美好的.和朋友住在顺义,出去一次真的远啊,旁边暂时还没有找到清真的饭馆(本人少数民族) ...
- zTree和SweetAlert插件初探
1.zTree插件简介 zTree是一个依靠 jQuery实现的多功能“树插件”.优异的性能.灵活的配置.多种功能的组合是zTree最大优点.专门适合项目开发,尤其是树状菜单.树状数据的Web显示.权 ...
- 学习EXT.JS5时的重点载图
组件实例化的五种方式,最后一种不建议了 MVVM的图示,及controller的生存周期和MVC的不一样. VIEWCONTROLLER如何得到VIEW的实例呢,注意LOOKUPREFERENCE的使 ...
- ORACLE导入导出数据dmp
imp testwms3/isc@TESTGMMC FILE=C:\ZKGL_201407012334.dmp ignore=y fromuser=GMMCZKGL touser=testwms ta ...