本文整理汇总了Java中org.jivesoftware.openfire.user.UserManager.createUser方法的典型用法代码示例。如果您正苦于以下问题:Java UserManager.createUser方法的具体用法?Java UserManager.createUser怎么用?Java UserManager.createUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.openfire.user.UserManager
的用法示例。
在下文中一共展示了UserManager.createUser方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createUsers
import org.jivesoftware.openfire.user.UserManager; //导入方法依赖的package包/类
public void createUsers(String userPrefix, int from, int total) {
// Create users
UserManager userManager = XMPPServer.getInstance().getUserManager();
System.out.println("Creating users accounts: " + total);
int created = 0;
for (int i = from; i < from + total; i++) {
try {
String username = userPrefix + i;
userManager.createUser(username, username, username, username + "@" + username);
created++;
} catch (UserAlreadyExistsException e) {
// Ignore
}
}
System.out.println("Accounts created successfully: " + created);
}
示例2: ensureFocusUser
import org.jivesoftware.openfire.user.UserManager; //导入方法依赖的package包/类
private void ensureFocusUser()
{
final OFMeetConfig config = new OFMeetConfig();
// Ensure that the 'focus' user exists.
final UserManager userManager = XMPPServer.getInstance().getUserManager();
if ( !userManager.isRegisteredUser( "focus" ) )
{
Log.info( "No pre-existing 'focus' user detected. Generating one." );
String password = config.getFocusPassword();
if ( password == null || password.isEmpty() )
{
password = StringUtils.randomString( 40 );
}
try
{
userManager.createUser(
"focus",
password,
"Focus User (generated)",
null
);
config.setFocusPassword( password );
}
catch ( Exception e )
{
Log.error( "Unable to provision a 'focus' user.", e );
}
}
// Ensure that the 'focus' user can grant permissions in persistent MUCs by making it a sysadmin of the conference service(s).
final JID focusUserJid = new JID( "[email protected]" + XMPPServer.getInstance().getServerInfo().getXMPPDomain() );
for ( final MultiUserChatService mucService : XMPPServer.getInstance().getMultiUserChatManager().getMultiUserChatServices() )
{
if ( !mucService.isSysadmin( focusUserJid ) )
{
Log.info( "Adding 'focus' user as a sysadmin to the '{}' MUC service.", mucService.getServiceName() );
mucService.addSysadmin( focusUserJid );
}
}
}