/** * 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; } }
/** * 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; } }