我正在使用Openfire和XMPP。我的问题是:每当我想为某人注册时,我都需要登录Openfire,就像这样。
connection.login(Username, Password);
AccountManager accountManager = AccountManager.getInstance(connection);
accountManager.createAccount(Username1, Password1);
那么,我怎样才能避免这个无用的登录呢?
谢谢。
必须将登录功能从createAccount()中分离出来。
您必须连接到Openfire服务器(不提供用户和密码),然后请求createAccount
//...connection builder
connection.connect();
AccountManager.getInstance(connection).sensitiveOperationOverInsecureConnection(true);
username = username.toLowerCase();
Map<String,String> attributes = new HashMap<String, String>(2);
attributes.put("name", fullName);
attributes.put("email", email);
AccountManager.getInstance(connection).createAccount(username, password, attributes);
//now you can do connection.login(username,password)