当前位置: 首页>>代码示例>>Java>>正文


Java UserManager.createUser方法代码示例

本文整理汇总了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);
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:17,代码来源:UserCreationPlugin.java

示例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 );
        }
    }
}
 
开发者ID:igniterealtime,项目名称:ofmeet-openfire-plugin,代码行数:44,代码来源:FocusPlugin.java


注:本文中的org.jivesoftware.openfire.user.UserManager.createUser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。