• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java AdminManager类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.jivesoftware.openfire.admin.AdminManager的典型用法代码示例。如果您正苦于以下问题:Java AdminManager类的具体用法?Java AdminManager怎么用?Java AdminManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



AdminManager类属于org.jivesoftware.openfire.admin包,在下文中一共展示了AdminManager类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: createUser

import org.jivesoftware.openfire.admin.AdminManager; //导入依赖的package包/类
public static void createUser(String appId, MMXUserInfo userCreationInfo) throws UserAlreadyExistsException, ServerNotInitializedException {
  LOGGER.trace("createUser : appId={}, username={}, password={}, name={}, email={}");
  if(Strings.isNullOrEmpty(userCreationInfo.getUsername()))
    throw new IllegalArgumentException("Illegal username");
  if(Strings.isNullOrEmpty(userCreationInfo.getPassword()))
    throw new IllegalArgumentException("Illegal password");
  User newUser = getUserManager().createUser(userCreationInfo.getMMXUsername(appId), userCreationInfo.getPassword(),
          userCreationInfo.getName(), userCreationInfo.getEmail());
  if(userCreationInfo.getIsAdmin() != null && userCreationInfo.getIsAdmin()) {
    AdminManager adminManager = AdminManager.getInstance();
    if(adminManager == null) {
      throw new ServerNotInitializedException();
    }
    adminManager.addAdminAccount(newUser.getUsername());
  }
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:17,代码来源:UserManagerService.java


示例2: deleteUser

import org.jivesoftware.openfire.admin.AdminManager; //导入依赖的package包/类
public static void deleteUser(String appId, MMXUserInfo userInfo) throws UserNotFoundException, ServerNotInitializedException{
  User user = getUserManager().getUser(userInfo.getMMXUsername(appId));
  getUserManager().deleteUser(user);
  try {
    AdminManager adminManager = AdminManager.getInstance();
    if(adminManager != null) {
      adminManager.removeAdminAccount(user.getUsername());
    }
  } catch (Exception e) {
    LOGGER.trace("deleteUser : exception Caught while removing admin account, ignoring exception user={}", user.getUsername());
  }
  /**
   * Need to terminate any open user sessions.
   */
  // Close the user's connection
  terminateSessions(user.getUsername());
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:18,代码来源:UserManagerService.java


示例3: getUser

import org.jivesoftware.openfire.admin.AdminManager; //导入依赖的package包/类
public static MMXUserInfo getUser(String appId, String username) throws UserNotFoundException{

    String mmxUsername = Helper.getMMXUsername(username, appId);
    MMXUserInfo userInfo = new MMXUserInfo();

    try {
      User user = getUserManager().getUser(mmxUsername);
      userInfo.setUsername(username);
      //userInfo.setAppId(appId);
      userInfo.setEmail(user.getEmail());
      userInfo.setIsAdmin(AdminManager.getInstance().isUserAdmin(username, true));
      userInfo.setName(user.getName());
      return userInfo;
    } catch (Exception e) {
      throw new UserNotFoundException(username + " not found", e);
    }
  }
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:18,代码来源:UserManagerService.java


示例4: execute

import org.jivesoftware.openfire.admin.AdminManager; //导入依赖的package包/类
@Override
public void execute(SessionData sessionData, Element command) {
       Element note = command.addElement("note");

       Map<String, List<String>> data = sessionData.getData();

       // Get the username of the old admin
       String username;
       try {
           username = get(data, "username", 0);
       }
       catch (NullPointerException npe) {
           note.addAttribute("type", "error");
           note.setText("Username required parameter.");
           return;
       }

       // Revokes administrator status from the user, locally
       AdminManager.getInstance().removeAdminAccount(username);

       // Answer that the operation was successful
       note.addAttribute("type", "info");
       note.setText("Operation finished successfully");
   }
 
开发者ID:coodeer,项目名称:g3server,代码行数:25,代码来源:SystemAdminRemoved.java


示例5: execute

import org.jivesoftware.openfire.admin.AdminManager; //导入依赖的package包/类
@Override
public void execute(SessionData sessionData, Element command) {
       Element note = command.addElement("note");

       Map<String, List<String>> data = sessionData.getData();

       // Get the username of the new admin
       String adminUsername;
       try {
           adminUsername = get(data, "adminUsername", 0);
       }
       catch (NullPointerException npe) {
           note.addAttribute("type", "error");
           note.setText("Admin username required parameter.");
           return;
       }

       // Promotes the user to administrator, locally
       AdminManager.getInstance().addAdminAccount(adminUsername);

       // Answer that the operation was successful
       note.addAttribute("type", "info");
       note.setText("Operation finished successfully");
   }
 
开发者ID:coodeer,项目名称:g3server,代码行数:25,代码来源:SystemAdminAdded.java


示例6: updateUser

import org.jivesoftware.openfire.admin.AdminManager; //导入依赖的package包/类
public static boolean updateUser(String appId, MMXUserInfo userCreationInfo) throws ServerNotInitializedException, UserNotFoundException {
  boolean created = false;
  try {
    User user = getUserManager().getUser(userCreationInfo.getMMXUsername(appId));
    String password = userCreationInfo.getPassword();
    String name = userCreationInfo.getName();
    String email = userCreationInfo.getEmail();
    Boolean isAdmin = userCreationInfo.getIsAdmin();
    if (password != null) user.setPassword(password);
    if (name != null) user.setName(name);
    if (email != null) user.setEmail(email);
    if(isAdmin != null) {
      AdminManager adminManager = AdminManager.getInstance();
      if (isAdmin == true) {
        if(adminManager == null)
          throw new ServerNotInitializedException();
        adminManager.addAdminAccount(user.getUsername());
      } else if (isAdmin == false) {
        adminManager.removeAdminAccount(user.getUsername());
      }
    }
  } catch (UserNotFoundException e) {
    LOGGER.trace("updateUser : user does not exist, creating a user userCreationInfo={}", userCreationInfo);
    try {
      createUser(appId, userCreationInfo);
      created = true;
    } catch (UserAlreadyExistsException e1) {
      LOGGER.error("updateUser : user did not exist but creation failed  userCreationInfo={}", userCreationInfo);
      throw e;
    }
  }
  return created;
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:34,代码来源:UserManagerService.java


示例7: getUserProvider

import org.jivesoftware.openfire.admin.AdminManager; //导入依赖的package包/类
@Override
public UserProvider getUserProvider( String username )
{
    // TODO add optional caching, to prevent retrieving the administrative users upon every invocation.
    final JID jid = XMPPServer.getInstance().createJID( username, null );
    final boolean isAdmin = AdminManager.getAdminProvider().getAdmins().contains( jid );

    if ( isAdmin )
    {
        return adminProvider;
    } else
    {
        return userProvider;
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:16,代码来源:AuthorizationBasedUserProviderMapper.java


示例8: getAuthProvider

import org.jivesoftware.openfire.admin.AdminManager; //导入依赖的package包/类
@Override
public AuthProvider getAuthProvider( String username )
{
    // TODO add optional caching, to prevent retrieving the administrative users upon every invocation.
    final JID jid = XMPPServer.getInstance().createJID( username, null );
    final boolean isAdmin = AdminManager.getAdminProvider().getAdmins().contains( jid );

    if ( isAdmin )
    {
        return adminProvider;
    } else
    {
        return userProvider;
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:16,代码来源:AuthorizationBasedAuthProviderMapper.java


示例9: finalSetupSteps

import org.jivesoftware.openfire.admin.AdminManager; //导入依赖的package包/类
private void finalSetupSteps() {
    for (String propName : JiveGlobals.getXMLPropertyNames()) {
        if (JiveGlobals.getProperty(propName) == null) {
            JiveGlobals.setProperty(propName, JiveGlobals.getXMLProperty(propName));
        }
    }
    // Set default SASL SCRAM-SHA-1 iteration count
    JiveGlobals.setProperty("sasl.scram-sha-1.iteration-count", Integer.toString(ScramUtils.DEFAULT_ITERATION_COUNT));

    // Check if keystore (that out-of-the-box is a fallback for all keystores) already has certificates for current domain.
    CertificateStoreManager certificateStoreManager = null; // Will be a module after finishing setup.
    try {
        certificateStoreManager = new CertificateStoreManager();
        certificateStoreManager.initialize( this );
        certificateStoreManager.start();
        final IdentityStore identityStore = certificateStoreManager.getIdentityStore( ConnectionType.SOCKET_C2S );
        identityStore.ensureDomainCertificates( "DSA", "RSA" );

    } catch (Exception e) {
        logger.error("Error generating self-signed certificates", e);
    } finally {
        if (certificateStoreManager != null)
        {
            certificateStoreManager.stop();
            certificateStoreManager.destroy();
        }
    }

    // Initialize list of admins now (before we restart Jetty)
    AdminManager.getInstance().getAdminAccounts();
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:32,代码来源:XMPPServer.java


示例10: AuthCheckFilter

import org.jivesoftware.openfire.admin.AdminManager; //导入依赖的package包/类
AuthCheckFilter(final AdminManager adminManager, final LoginLimitManager loginLimitManager, final String servletRequestAuthenticatorClassName) {
    this.adminManager = adminManager;
    this.loginLimitManager = loginLimitManager;
    AuthCheckFilter.instance = this;
    ServletRequestAuthenticator authenticator = null;
    if (!servletRequestAuthenticatorClassName.isEmpty()) {
        try {
            final Class clazz = ClassUtils.forName(servletRequestAuthenticatorClassName);
            authenticator = (ServletRequestAuthenticator) clazz.newInstance();
        } catch (final Exception e) {
            Log.error("Error loading ServletRequestAuthenticator: " + servletRequestAuthenticatorClassName, e);
        }
    }
    this.servletRequestAuthenticator = authenticator;
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:16,代码来源:AuthCheckFilter.java


示例11: start

import org.jivesoftware.openfire.admin.AdminManager; //导入依赖的package包/类
private void start() {

        setContainer(new MBeanContainer(ManagementFactory.getPlatformMBeanServer()));
        int jmxPort = JMXManager.getPort();
        String jmxUrl = "/jndi/rmi://localhost:" + jmxPort + "/jmxrmi";
        Map<String, Object> env = new HashMap<>();
        if (JMXManager.isSecure()) {
            env.put("jmx.remote.authenticator", new JMXAuthenticator() {
                @Override
                public Subject authenticate(Object credentials) {
                    if (!(credentials instanceof String[])) {
                        if (credentials == null) {
                            throw new SecurityException("Credentials required");
                        }
                        throw new SecurityException("Credentials should be String[]");
                    }
                    final String[] aCredentials = (String[]) credentials;
                    if (aCredentials.length < 2) {
                        throw new SecurityException("Credentials should have at least two elements");
                    }
                    String username = aCredentials[0];
                    String password = aCredentials[1];

                    try {
                        AuthFactory.authenticate(username, password);
                    } catch (Exception ex) {
                        Log.error("Authentication failed for " + username);
                        throw new SecurityException();
                    }

                    if (AdminManager.getInstance().isUserAdmin(username, true)) {
                        return new Subject(true,
                                           Collections.singleton(new JMXPrincipal(username)),
                                           Collections.EMPTY_SET,
                                           Collections.EMPTY_SET);
                    } else {
                        Log.error("Authorization failed for " + username);
                        throw new SecurityException();
                    }
                }
            });
        }
        
        try {
            jmxServer = new ConnectorServer(new JMXServiceURL("rmi", null, jmxPort, jmxUrl), 
                    env, "org.eclipse.jetty.jmx:name=rmiconnectorserver");
            jmxServer.start();
        } catch (Exception e) {
            Log.error("Failed to start JMX connector", e);
        }
    }
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:52,代码来源:JMXManager.java


示例12: start

import org.jivesoftware.openfire.admin.AdminManager; //导入依赖的package包/类
private void start() {
	
	setContainer(new MBeanContainer(ManagementFactory.getPlatformMBeanServer()));
	getContainer().addBean(org.eclipse.jetty.util.log.Log.getLog());
	
	int jmxPort = JMXManager.getPort();
	String jmxUrl = "/jndi/rmi://localhost:" + jmxPort + "/jmxrmi";
	Map<String, Object> env = new HashMap<String, Object>();
	if (JMXManager.isSecure()) {
   		env.put("jmx.remote.authenticator", new JMXAuthenticator() {
   			public Subject authenticate(Object credentials) {
   	            if (!(credentials instanceof String[])) {
   	                if (credentials == null) {
   	                    throw new SecurityException("Credentials required");
   	                }
   	                throw new SecurityException("Credentials should be String[]");
   	            }
   	            final String[] aCredentials = (String[]) credentials;
   	            if (aCredentials.length < 2) {
   	                throw new SecurityException("Credentials should have at least two elements");
   	            }
   	            String username = (String) aCredentials[0];
   	            String password = (String) aCredentials[1];

   	            try {
   	            	AuthFactory.authenticate(username, password);
   	            } catch (Exception ex) {
   	            	Log.error("Authentication failed for " + username);
   	            	throw new SecurityException();
   	            }

   	            if (AdminManager.getInstance().isUserAdmin(username, true)) {
   	                return new Subject(true,
   	                                   Collections.singleton(new JMXPrincipal(username)),
   	                                   Collections.EMPTY_SET,
   	                                   Collections.EMPTY_SET);
   	            } else {
   	                Log.error("Authorization failed for " + username);
   	                throw new SecurityException();
   	            }
   	        }
   		});
	}
	
	try {
		jmxServer = new ConnectorServer(new JMXServiceURL("rmi", null, jmxPort, jmxUrl), 
				env, "org.eclipse.jetty.jmx:name=rmiconnectorserver");
		jmxServer.start();
	} catch (Exception e) {
		Log.error("Failed to start JMX connector", e);
	}
}
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:53,代码来源:JMXManager.java


示例13: hasPermission

import org.jivesoftware.openfire.admin.AdminManager; //导入依赖的package包/类
/**
 * Returns true if the requester is allowed to execute this command. By default only admins
 * are allowed to execute commands. Subclasses may redefine this method with any specific
 * logic.<p>
 *
 * Note: The bare JID of the requester will be compared with the bare JID of the admins.
 *
 * @param requester the JID of the user requesting to execute this command.
 * @return true if the requester is allowed to execute this command.
 */
public boolean hasPermission(JID requester) {
    return AdminManager.getInstance().isUserAdmin(requester, false);
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:14,代码来源:AdHocCommand.java


示例14: getAdmins

import org.jivesoftware.openfire.admin.AdminManager; //导入依赖的package包/类
/**
 * Returns a collection with the JIDs of the server's admins. The collection may include
 * JIDs of local users and users of remote servers.
 *
 * @return a collection with the JIDs of the server's admins.
 */
public Collection<JID> getAdmins() {
    return AdminManager.getInstance().getAdminAccounts();
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:10,代码来源:XMPPServer.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ExplicitCamelContextNameStrategy类代码示例发布时间:2022-05-23
下一篇:
Java MenuEvent类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap