org.apache.catalina.User Java Examples
The following examples show how to use
org.apache.catalina.User.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MemoryUserDatabaseMBean.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
/** * Remove an existing user and destroy the corresponding MBean. * * @param username User name to remove */ public void removeUser(String username) { UserDatabase database = (UserDatabase) this.resource; User user = database.findUser(username); if (user == null) { return; } try { MBeanUtils.destroyMBean(user); database.removeUser(user); } catch (Exception e) { IllegalArgumentException iae = new IllegalArgumentException ("Exception destroying user [" + username + "] MBean"); iae.initCause(e); throw iae; } }
Example #2
Source File: MemoryUserDatabase.java From Tomcat8-Source-Read with MIT License | 6 votes |
/** * Remove the specified {@link Role} from this user database. * * @param role The role to be removed */ @Override public void removeRole(Role role) { readLock.lock(); try { Iterator<Group> groups = getGroups(); while (groups.hasNext()) { Group group = groups.next(); group.removeRole(role); } Iterator<User> users = getUsers(); while (users.hasNext()) { User user = users.next(); user.removeRole(role); } roles.remove(role.getRolename()); } finally { readLock.unlock(); } }
Example #3
Source File: UserMBean.java From Tomcat8-Source-Read with MIT License | 6 votes |
/** * @return the MBean Names of all roles assigned to this user. */ public String[] getRoles() { User user = (User) this.resource; ArrayList<String> results = new ArrayList<>(); Iterator<Role> roles = user.getRoles(); while (roles.hasNext()) { Role role = null; try { role = roles.next(); ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), role); results.add(oname.toString()); } catch (MalformedObjectNameException e) { IllegalArgumentException iae = new IllegalArgumentException ("Cannot create object name for role " + role); iae.initCause(e); throw iae; } } return results.toArray(new String[results.size()]); }
Example #4
Source File: MBeanUtils.java From Tomcat8-Source-Read with MIT License | 6 votes |
/** * Deregister the MBean for this * <code>User</code> object. * * @param user The User to be managed * * @exception Exception if an MBean cannot be deregistered */ static void destroyMBean(User user) throws Exception { String mname = createManagedName(user); ManagedBean managed = registry.findManagedBean(mname); if (managed == null) { return; } String domain = managed.getDomain(); if (domain == null) domain = mserver.getDefaultDomain(); ObjectName oname = createObjectName(domain, user); if( mserver.isRegistered(oname) ) mserver.unregisterMBean(oname); }
Example #5
Source File: GroupMBean.java From Tomcat8-Source-Read with MIT License | 6 votes |
/** * @return the MBean Names of all users that are members of this group. */ public String[] getUsers() { Group group = (Group) this.resource; ArrayList<String> results = new ArrayList<>(); Iterator<User> users = group.getUsers(); while (users.hasNext()) { User user = null; try { user = users.next(); ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), user); results.add(oname.toString()); } catch (MalformedObjectNameException e) { IllegalArgumentException iae = new IllegalArgumentException( "Cannot create object name for user " + user); iae.initCause(e); throw iae; } } return results.toArray(new String[results.size()]); }
Example #6
Source File: MemoryUserDatabaseMBean.java From Tomcat8-Source-Read with MIT License | 6 votes |
/** * Return the MBean Name for the specified user name (if any); * otherwise return <code>null</code>. * * @param username User name to look up * @return the user object name */ public String findUser(String username) { UserDatabase database = (UserDatabase) this.resource; User user = database.findUser(username); if (user == null) { return null; } try { ObjectName oname = MBeanUtils.createObjectName(managedUser.getDomain(), user); return oname.toString(); } catch (MalformedObjectNameException e) { IllegalArgumentException iae = new IllegalArgumentException( "Cannot create object name for user [" + username + "]"); iae.initCause(e); throw iae; } }
Example #7
Source File: MBeanUtils.java From Tomcat8-Source-Read with MIT License | 6 votes |
/** * Create, register, and return an MBean for this * <code>User</code> object. * * @param user The User to be managed * @return a new MBean * @exception Exception if an MBean cannot be created or registered */ static DynamicMBean createMBean(User user) throws Exception { String mname = createManagedName(user); ManagedBean managed = registry.findManagedBean(mname); if (managed == null) { Exception e = new Exception("ManagedBean is not found with "+mname); throw new MBeanException(e); } String domain = managed.getDomain(); if (domain == null) domain = mserver.getDefaultDomain(); DynamicMBean mbean = managed.createMBean(user); ObjectName oname = createObjectName(domain, user); if( mserver.isRegistered( oname )) { mserver.unregisterMBean(oname); } mserver.registerMBean(mbean, oname); return mbean; }
Example #8
Source File: MemoryUserDatabaseMBean.java From Tomcat8-Source-Read with MIT License | 6 votes |
/** * Remove an existing user and destroy the corresponding MBean. * * @param username User name to remove */ public void removeUser(String username) { UserDatabase database = (UserDatabase) this.resource; User user = database.findUser(username); if (user == null) { return; } try { MBeanUtils.destroyMBean(user); database.removeUser(user); } catch (Exception e) { IllegalArgumentException iae = new IllegalArgumentException( "Exception destroying user [" + username + "] MBean"); iae.initCause(e); throw iae; } }
Example #9
Source File: MemoryUserDatabase.java From Tomcat8-Source-Read with MIT License | 6 votes |
/** * Create and return a new {@link User} defined in this user database. * * @param username The logon username of the new user (must be unique) * @param password The logon password of the new user * @param fullName The full name of the new user */ @Override public User createUser(String username, String password, String fullName) { if (username == null || username.length() == 0) { String msg = sm.getString("memoryUserDatabase.nullUser"); log.warn(msg); throw new IllegalArgumentException(msg); } MemoryUser user = new MemoryUser(this, username, password, fullName); readLock.lock(); try { users.put(user.getUsername(), user); } finally { readLock.unlock(); } return user; }
Example #10
Source File: UserConsoleService.java From springboot-plus with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * 插入一条用户数据 * * @param user */ public void saveUser(CoreUser user) { CoreUser query = new CoreUser(); query.setCode(user.getCode()); CoreUser dbUser = userDao.templateOne(query); if (dbUser != null) { throw new PlatformException("保存用户信息失败,用户已经存在"); } user.setCreateTime(new Date()); user.setState(GeneralStateEnum.ENABLE.getValue()); user.setPassword(passwordEncryptService.password(user.getPassword())); user.setDelFlag(DelFlagEnum.NORMAL.getValue()); userDao.insert(user, true); if(StringUtils.isNotEmpty(user.getAttachmentId())){ //更新附件详细信息,关联到这个用户 fileService.updateFile(user.getAttachmentId(), User.class.getSimpleName(), String.valueOf(user.getId())); } }
Example #11
Source File: GroupMBean.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
/** * Return the MBean Names of all users that are members of this group. */ public String[] getUsers() { Group group = (Group) this.resource; ArrayList<String> results = new ArrayList<String>(); Iterator<User> users = group.getUsers(); while (users.hasNext()) { User user = null; try { user = users.next(); ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), user); results.add(oname.toString()); } catch (MalformedObjectNameException e) { IllegalArgumentException iae = new IllegalArgumentException ("Cannot create object name for user " + user); iae.initCause(e); throw iae; } } return results.toArray(new String[results.size()]); }
Example #12
Source File: UserMBean.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
/** * Return the MBean Names of all groups this user is a member of. */ public String[] getGroups() { User user = (User) this.resource; ArrayList<String> results = new ArrayList<String>(); Iterator<Group> groups = user.getGroups(); while (groups.hasNext()) { Group group = null; try { group = groups.next(); ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), group); results.add(oname.toString()); } catch (MalformedObjectNameException e) { IllegalArgumentException iae = new IllegalArgumentException ("Cannot create object name for group " + group); iae.initCause(e); throw iae; } } return results.toArray(new String[results.size()]); }
Example #13
Source File: UserMBean.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
/** * Return the MBean Names of all roles assigned to this user. */ public String[] getRoles() { User user = (User) this.resource; ArrayList<String> results = new ArrayList<String>(); Iterator<Role> roles = user.getRoles(); while (roles.hasNext()) { Role role = null; try { role = roles.next(); ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), role); results.add(oname.toString()); } catch (MalformedObjectNameException e) { IllegalArgumentException iae = new IllegalArgumentException ("Cannot create object name for role " + role); iae.initCause(e); throw iae; } } return results.toArray(new String[results.size()]); }
Example #14
Source File: MemoryUserDatabaseMBean.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
/** * Create a new User and return the corresponding MBean Name. * * @param username User name of the new user * @param password Password for the new user * @param fullName Full name for the new user */ public String createUser(String username, String password, String fullName) { UserDatabase database = (UserDatabase) this.resource; User user = database.createUser(username, password, fullName); try { MBeanUtils.createMBean(user); } catch (Exception e) { IllegalArgumentException iae = new IllegalArgumentException ("Exception creating user [" + username + "] MBean"); iae.initCause(e); throw iae; } return (findUser(username)); }
Example #15
Source File: MemoryUserDatabaseMBean.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
/** * Return the MBean Name for the specified user name (if any); * otherwise return <code>null</code>. * * @param username User name to look up */ public String findUser(String username) { UserDatabase database = (UserDatabase) this.resource; User user = database.findUser(username); if (user == null) { return (null); } try { ObjectName oname = MBeanUtils.createObjectName(managedUser.getDomain(), user); return (oname.toString()); } catch (MalformedObjectNameException e) { IllegalArgumentException iae = new IllegalArgumentException ("Cannot create object name for user [" + username + "]"); iae.initCause(e); throw iae; } }
Example #16
Source File: UserMBean.java From Tomcat8-Source-Read with MIT License | 6 votes |
/** * @return the MBean Names of all groups this user is a member of. */ public String[] getGroups() { User user = (User) this.resource; ArrayList<String> results = new ArrayList<>(); Iterator<Group> groups = user.getGroups(); while (groups.hasNext()) { Group group = null; try { group = groups.next(); ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), group); results.add(oname.toString()); } catch (MalformedObjectNameException e) { IllegalArgumentException iae = new IllegalArgumentException ("Cannot create object name for group " + group); iae.initCause(e); throw iae; } } return results.toArray(new String[results.size()]); }
Example #17
Source File: MBeanUtils.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
/** * Create, register, and return an MBean for this * <code>User</code> object. * * @param user The User to be managed * * @exception Exception if an MBean cannot be created or registered */ static DynamicMBean createMBean(User user) throws Exception { String mname = createManagedName(user); ManagedBean managed = registry.findManagedBean(mname); if (managed == null) { Exception e = new Exception("ManagedBean is not found with "+mname); throw new MBeanException(e); } String domain = managed.getDomain(); if (domain == null) domain = mserver.getDefaultDomain(); DynamicMBean mbean = managed.createMBean(user); ObjectName oname = createObjectName(domain, user); if( mserver.isRegistered( oname )) { mserver.unregisterMBean(oname); } mserver.registerMBean(mbean, oname); return (mbean); }
Example #18
Source File: MemoryUserDatabase.java From tomcatsrc with Apache License 2.0 | 6 votes |
/** * Remove the specified {@link Role} from this user database. * * @param role The role to be removed */ @Override public void removeRole(Role role) { synchronized (roles) { Iterator<Group> groups = getGroups(); while (groups.hasNext()) { Group group = groups.next(); group.removeRole(role); } Iterator<User> users = getUsers(); while (users.hasNext()) { User user = users.next(); user.removeRole(role); } roles.remove(role.getRolename()); } }
Example #19
Source File: MBeanUtils.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
/** * Deregister the MBean for this * <code>User</code> object. * * @param user The User to be managed * * @exception Exception if an MBean cannot be deregistered */ static void destroyMBean(User user) throws Exception { String mname = createManagedName(user); ManagedBean managed = registry.findManagedBean(mname); if (managed == null) { return; } String domain = managed.getDomain(); if (domain == null) domain = mserver.getDefaultDomain(); ObjectName oname = createObjectName(domain, user); if( mserver.isRegistered(oname) ) mserver.unregisterMBean(oname); }
Example #20
Source File: MemoryUserDatabase.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
/** * Create and return a new {@link User} defined in this user database. * * @param username The logon username of the new user (must be unique) * @param password The logon password of the new user * @param fullName The full name of the new user */ @Override public User createUser(String username, String password, String fullName) { if (username == null || username.length() == 0) { String msg = sm.getString("memoryUserDatabase.nullUser"); log.warn(msg); throw new IllegalArgumentException(msg); } MemoryUser user = new MemoryUser(this, username, password, fullName); synchronized (users) { users.put(user.getUsername(), user); } return (user); }
Example #21
Source File: MemoryUserDatabase.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
/** * Remove the specified {@link Role} from this user database. * * @param role The role to be removed */ @Override public void removeRole(Role role) { synchronized (roles) { Iterator<Group> groups = getGroups(); while (groups.hasNext()) { Group group = groups.next(); group.removeRole(role); } Iterator<User> users = getUsers(); while (users.hasNext()) { User user = users.next(); user.removeRole(role); } roles.remove(role.getRolename()); } }
Example #22
Source File: MemoryUserDatabase.java From tomcatsrc with Apache License 2.0 | 6 votes |
/** * Create and return a new {@link User} defined in this user database. * * @param username The logon username of the new user (must be unique) * @param password The logon password of the new user * @param fullName The full name of the new user */ @Override public User createUser(String username, String password, String fullName) { if (username == null || username.length() == 0) { String msg = sm.getString("memoryUserDatabase.nullUser"); log.warn(msg); throw new IllegalArgumentException(msg); } MemoryUser user = new MemoryUser(this, username, password, fullName); synchronized (users) { users.put(user.getUsername(), user); } return (user); }
Example #23
Source File: GroupMBean.java From tomcatsrc with Apache License 2.0 | 6 votes |
/** * Return the MBean Names of all users that are members of this group. */ public String[] getUsers() { Group group = (Group) this.resource; ArrayList<String> results = new ArrayList<String>(); Iterator<User> users = group.getUsers(); while (users.hasNext()) { User user = null; try { user = users.next(); ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), user); results.add(oname.toString()); } catch (MalformedObjectNameException e) { IllegalArgumentException iae = new IllegalArgumentException ("Cannot create object name for user " + user); iae.initCause(e); throw iae; } } return results.toArray(new String[results.size()]); }
Example #24
Source File: UserMBean.java From tomcatsrc with Apache License 2.0 | 6 votes |
/** * Return the MBean Names of all groups this user is a member of. */ public String[] getGroups() { User user = (User) this.resource; ArrayList<String> results = new ArrayList<String>(); Iterator<Group> groups = user.getGroups(); while (groups.hasNext()) { Group group = null; try { group = groups.next(); ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), group); results.add(oname.toString()); } catch (MalformedObjectNameException e) { IllegalArgumentException iae = new IllegalArgumentException ("Cannot create object name for group " + group); iae.initCause(e); throw iae; } } return results.toArray(new String[results.size()]); }
Example #25
Source File: UserMBean.java From tomcatsrc with Apache License 2.0 | 6 votes |
/** * Return the MBean Names of all roles assigned to this user. */ public String[] getRoles() { User user = (User) this.resource; ArrayList<String> results = new ArrayList<String>(); Iterator<Role> roles = user.getRoles(); while (roles.hasNext()) { Role role = null; try { role = roles.next(); ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), role); results.add(oname.toString()); } catch (MalformedObjectNameException e) { IllegalArgumentException iae = new IllegalArgumentException ("Cannot create object name for role " + role); iae.initCause(e); throw iae; } } return results.toArray(new String[results.size()]); }
Example #26
Source File: MemoryUserDatabaseMBean.java From tomcatsrc with Apache License 2.0 | 6 votes |
/** * Create a new User and return the corresponding MBean Name. * * @param username User name of the new user * @param password Password for the new user * @param fullName Full name for the new user */ public String createUser(String username, String password, String fullName) { UserDatabase database = (UserDatabase) this.resource; User user = database.createUser(username, password, fullName); try { MBeanUtils.createMBean(user); } catch (Exception e) { IllegalArgumentException iae = new IllegalArgumentException ("Exception creating user [" + username + "] MBean"); iae.initCause(e); throw iae; } return (findUser(username)); }
Example #27
Source File: MemoryUserDatabaseMBean.java From tomcatsrc with Apache License 2.0 | 6 votes |
/** * Return the MBean Name for the specified user name (if any); * otherwise return <code>null</code>. * * @param username User name to look up */ public String findUser(String username) { UserDatabase database = (UserDatabase) this.resource; User user = database.findUser(username); if (user == null) { return (null); } try { ObjectName oname = MBeanUtils.createObjectName(managedUser.getDomain(), user); return (oname.toString()); } catch (MalformedObjectNameException e) { IllegalArgumentException iae = new IllegalArgumentException ("Cannot create object name for user [" + username + "]"); iae.initCause(e); throw iae; } }
Example #28
Source File: MemoryUserDatabaseMBean.java From tomcatsrc with Apache License 2.0 | 6 votes |
/** * Remove an existing user and destroy the corresponding MBean. * * @param username User name to remove */ public void removeUser(String username) { UserDatabase database = (UserDatabase) this.resource; User user = database.findUser(username); if (user == null) { return; } try { MBeanUtils.destroyMBean(user); database.removeUser(user); } catch (Exception e) { IllegalArgumentException iae = new IllegalArgumentException ("Exception destroying user [" + username + "] MBean"); iae.initCause(e); throw iae; } }
Example #29
Source File: MBeanUtils.java From tomcatsrc with Apache License 2.0 | 6 votes |
/** * Create, register, and return an MBean for this * <code>User</code> object. * * @param user The User to be managed * * @exception Exception if an MBean cannot be created or registered */ static DynamicMBean createMBean(User user) throws Exception { String mname = createManagedName(user); ManagedBean managed = registry.findManagedBean(mname); if (managed == null) { Exception e = new Exception("ManagedBean is not found with "+mname); throw new MBeanException(e); } String domain = managed.getDomain(); if (domain == null) domain = mserver.getDefaultDomain(); DynamicMBean mbean = managed.createMBean(user); ObjectName oname = createObjectName(domain, user); if( mserver.isRegistered( oname )) { mserver.unregisterMBean(oname); } mserver.registerMBean(mbean, oname); return (mbean); }
Example #30
Source File: MBeanUtils.java From tomcatsrc with Apache License 2.0 | 6 votes |
/** * Deregister the MBean for this * <code>User</code> object. * * @param user The User to be managed * * @exception Exception if an MBean cannot be deregistered */ static void destroyMBean(User user) throws Exception { String mname = createManagedName(user); ManagedBean managed = registry.findManagedBean(mname); if (managed == null) { return; } String domain = managed.getDomain(); if (domain == null) domain = mserver.getDefaultDomain(); ObjectName oname = createObjectName(domain, user); if( mserver.isRegistered(oname) ) mserver.unregisterMBean(oname); }