项目:tomcat7
文件:GroupMBean.java
/**
* Return the MBean Names of all authorized roles for this group.
*/
public String[] getRoles() {
Group group = (Group) this.resource;
ArrayList<String> results = new ArrayList<String>();
Iterator<Role> roles = group.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()]);
}
项目:tomcat7
文件:UserMBean.java
/**
* 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()]);
}
项目:tomcat7
文件:MemoryUserDatabaseMBean.java
/**
* Create a new Role and return the corresponding MBean Name.
*
* @param rolename Group name of the new group
* @param description Description of the new group
*/
public String createRole(String rolename,String description) {
UserDatabase database = (UserDatabase) this.resource;
Role role = database.createRole(rolename,description);
try {
MBeanUtils.createMBean(role);
} catch (Exception e) {
IllegalArgumentException iae = new IllegalArgumentException
("Exception creating role [" + rolename + "] MBean");
iae.initCause(e);
throw iae;
}
return (findRole(rolename));
}
项目:tomcat7
文件:MemoryUserDatabaseMBean.java
/**
* Return the MBean Name for the specified role name (if any);
* otherwise return <code>null</code>.
*
* @param rolename Role name to look up
*/
public String findRole(String rolename) {
UserDatabase database = (UserDatabase) this.resource;
Role role = database.findRole(rolename);
if (role == null) {
return (null);
}
try {
ObjectName oname =
MBeanUtils.createObjectName(managedRole.getDomain(),role);
return (oname.toString());
} catch (MalformedobjectNameException e) {
IllegalArgumentException iae = new IllegalArgumentException
("Cannot create object name for role [" + rolename + "]");
iae.initCause(e);
throw iae;
}
}
项目:tomcat7
文件:MemoryUserDatabaseMBean.java
/**
* Remove an existing role and destroy the corresponding MBean.
*
* @param rolename Role name to remove
*/
public void removeRole(String rolename) {
UserDatabase database = (UserDatabase) this.resource;
Role role = database.findRole(rolename);
if (role == null) {
return;
}
try {
MBeanUtils.destroyMBean(role);
database.removeRole(role);
} catch (Exception e) {
IllegalArgumentException iae = new IllegalArgumentException
("Exception destroying role [" + rolename + "] MBean");
iae.initCause(e);
throw iae;
}
}
项目:tomcat7
文件:MBeanUtils.java
/**
* Create,register,and return an MBean for this
* <code>Role</code> object.
*
* @param role The Role to be managed
*
* @exception Exception if an MBean cannot be created or registered
*/
static DynamicMBean createMBean(Role role)
throws Exception {
String mname = createManagedname(role);
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(role);
ObjectName oname = createObjectName(domain,role);
if( mserver.isRegistered( oname )) {
mserver.unregisterMBean(oname);
}
mserver.registerMBean(mbean,oname);
return (mbean);
}
项目:lazycat
文件:MemoryUserDatabaseMBean.java
/**
* Return the MBean Name for the specified role name (if any); otherwise
* return <code>null</code>.
*
* @param rolename
* Role name to look up
*/
public String findRole(String rolename) {
UserDatabase database = (UserDatabase) this.resource;
Role role = database.findRole(rolename);
if (role == null) {
return (null);
}
try {
ObjectName oname = MBeanUtils.createObjectName(managedRole.getDomain(),role);
return (oname.toString());
} catch (MalformedobjectNameException e) {
IllegalArgumentException iae = new IllegalArgumentException(
"Cannot create object name for role [" + rolename + "]");
iae.initCause(e);
throw iae;
}
}
项目:lazycat
文件:MemoryUserDatabaseMBean.java
/**
* Create a new Role and return the corresponding MBean Name.
*
* @param rolename
* Group name of the new group
* @param description
* Description of the new group
*/
public String createRole(String rolename,description);
try {
MBeanUtils.createMBean(role);
} catch (Exception e) {
IllegalArgumentException iae = new IllegalArgumentException(
"Exception creating role [" + rolename + "] MBean");
iae.initCause(e);
throw iae;
}
return (findRole(rolename));
}
项目:lazycat
文件:MBeanUtils.java
/**
* Create,and return an MBean for this <code>Role</code> object.
*
* @param role
* The Role to be managed
*
* @exception Exception
* if an MBean cannot be created or registered
*/
static DynamicMBean createMBean(Role role) throws Exception {
String mname = createManagedname(role);
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(role);
ObjectName oname = createObjectName(domain,role);
if (mserver.isRegistered(oname)) {
mserver.unregisterMBean(oname);
}
mserver.registerMBean(mbean,oname);
return (mbean);
}
项目:jerrydog
文件:MemoryUserDatabaseMBean.java
/**
* Return the MBean Name for the specified role name (if any);
* otherwise return <code>null</code>.
*
* @param rolename Role name to look up
*/
public String findRole(String rolename) {
UserDatabase database = (UserDatabase) this.resource;
Role role = database.findRole(rolename);
if (role == null) {
return (null);
}
try {
ObjectName oname =
MBeanUtils.createObjectName(managedRole.getDomain(),role);
return (oname.toString());
} catch (MalformedobjectNameException e) {
throw new IllegalArgumentException
("Cannot create object name for role " + role);
}
}
项目:jerrydog
文件:MemoryUserDatabaseMBean.java
/**
* Remove an existing role and destroy the corresponding MBean.
*
* @param rolename Role name to remove
*/
public void removeRole(String rolename) {
UserDatabase database = (UserDatabase) this.resource;
Role role = database.findRole(rolename);
if (role == null) {
return;
}
try {
MBeanUtils.destroyMBean(role);
database.removeRole(role);
} catch (Exception e) {
throw new IllegalArgumentException("Exception destroying role " +
role + " MBean: " + e);
}
}
项目:jerrydog
文件:MBeanUtils.java
/**
* Deregister the MBean for this
* <code>Role</code> object.
*
* @param role The Role to be managed
*
* @exception Exception if an MBean cannot be deregistered
*/
public static void destroyMBean(Role role)
throws Exception {
String mname = createManagedname(role);
ManagedBean managed = registry.findManagedBean(mname);
if (managed == null) {
return;
}
String domain = managed.getDomain();
if (domain == null)
domain = mserver.getDefaultDomain();
ObjectName oname = createObjectName(domain,role);
mserver.unregisterMBean(oname);
}
项目:jerrydog
文件:MemoryUserDatabase.java
/**
* Remove the specified {@link Role} from this user database.
*
* @param role The role to be removed
*/
public void removeRole(Role role) {
synchronized (roles) {
Iterator groups = getGroups();
while (groups.hasNext()) {
Group group = (Group) groups.next();
group.removeRole(role);
}
Iterator users = getUsers();
while (users.hasNext()) {
User user = (User) users.next();
user.removeRole(role);
}
roles.remove(role.getRolename());
}
}
项目:lazycat
文件:UserMBean.java
/**
* 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()]);
}
项目:apache-tomcat-7.0.73-with-comment
文件:GroupMBean.java
/**
* Return the MBean Names of all authorized roles for this group.
*/
public String[] getRoles() {
Group group = (Group) this.resource;
ArrayList<String> results = new ArrayList<String>();
Iterator<Role> roles = group.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()]);
}
项目:apache-tomcat-7.0.73-with-comment
文件:UserMBean.java
/**
* 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()]);
}
项目:apache-tomcat-7.0.73-with-comment
文件:MemoryUserDatabaseMBean.java
/**
* Create a new Role and return the corresponding MBean Name.
*
* @param rolename Group name of the new group
* @param description Description of the new group
*/
public String createRole(String rolename,description);
try {
MBeanUtils.createMBean(role);
} catch (Exception e) {
IllegalArgumentException iae = new IllegalArgumentException
("Exception creating role [" + rolename + "] MBean");
iae.initCause(e);
throw iae;
}
return (findRole(rolename));
}
项目:apache-tomcat-7.0.73-with-comment
文件:MemoryUserDatabaseMBean.java
/**
* Remove an existing role and destroy the corresponding MBean.
*
* @param rolename Role name to remove
*/
public void removeRole(String rolename) {
UserDatabase database = (UserDatabase) this.resource;
Role role = database.findRole(rolename);
if (role == null) {
return;
}
try {
MBeanUtils.destroyMBean(role);
database.removeRole(role);
} catch (Exception e) {
IllegalArgumentException iae = new IllegalArgumentException
("Exception destroying role [" + rolename + "] MBean");
iae.initCause(e);
throw iae;
}
}
项目:apache-tomcat-7.0.73-with-comment
文件:MBeanUtils.java
/**
* Create,oname);
return (mbean);
}
项目:apache-tomcat-7.0.73-with-comment
文件:MBeanUtils.java
/**
* Deregister the MBean for this
* <code>Role</code> object.
*
* @param role The Role to be managed
*
* @exception Exception if an MBean cannot be deregistered
*/
static void destroyMBean(Role role)
throws Exception {
String mname = createManagedname(role);
ManagedBean managed = registry.findManagedBean(mname);
if (managed == null) {
return;
}
String domain = managed.getDomain();
if (domain == null)
domain = mserver.getDefaultDomain();
ObjectName oname = createObjectName(domain,role);
if( mserver.isRegistered(oname) )
mserver.unregisterMBean(oname);
}
项目:lazycat
文件:GroupMBean.java
/**
* Return the MBean Names of all authorized roles for this group.
*/
public String[] getRoles() {
Group group = (Group) this.resource;
ArrayList<String> results = new ArrayList<String>();
Iterator<Role> roles = group.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()]);
}
项目:apache-tomcat-7.0.73-with-comment
文件:MemoryUserDatabase.java
/**
* 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());
}
}
项目:lazycat
文件:MemoryUserDatabase.java
/**
* Create and return a new {@link Role} defined in this user database.
*
* @param rolename
* The role name of the new group (must be unique)
* @param description
* The description of this group
*/
@Override
public Role createRole(String rolename,String description) {
if (rolename == null || rolename.length() == 0) {
String msg = sm.getString("memoryUserDatabase.nullRole");
log.warn(msg);
throw new IllegalArgumentException(msg);
}
MemoryRole role = new MemoryRole(this,rolename,description);
synchronized (roles) {
roles.put(role.getRolename(),role);
}
return (role);
}
项目:tomcat7
文件:GroupMBean.java
/**
* Add a new {@link Role} to those this group belongs to.
*
* @param rolename Role name of the new role
*/
public void addRole(String rolename) {
Group group = (Group) this.resource;
if (group == null) {
return;
}
Role role = group.getUserDatabase().findRole(rolename);
if (role == null) {
throw new IllegalArgumentException
("Invalid role name '" + rolename + "'");
}
group.addRole(role);
}
项目:tomcat7
文件:GroupMBean.java
/**
* Remove a {@link Role} from those this group belongs to.
*
* @param rolename Role name of the old role
*/
public void removeRole(String rolename) {
Group group = (Group) this.resource;
if (group == null) {
return;
}
Role role = group.getUserDatabase().findRole(rolename);
if (role == null) {
throw new IllegalArgumentException
("Invalid role name '" + rolename + "'");
}
group.removeRole(role);
}
项目:tomcat7
文件:UserMBean.java
/**
* Add a new {@link Role} to those this user belongs to.
*
* @param rolename Role name of the new role
*/
public void addRole(String rolename) {
User user = (User) this.resource;
if (user == null) {
return;
}
Role role = user.getUserDatabase().findRole(rolename);
if (role == null) {
throw new IllegalArgumentException
("Invalid role name '" + rolename + "'");
}
user.addRole(role);
}
项目:tomcat7
文件:UserMBean.java
/**
* Remove a {@link Role} from those this user belongs to.
*
* @param rolename Role name of the old role
*/
public void removeRole(String rolename) {
User user = (User) this.resource;
if (user == null) {
return;
}
Role role = user.getUserDatabase().findRole(rolename);
if (role == null) {
throw new IllegalArgumentException
("Invalid role name '" + rolename + "'");
}
user.removeRole(role);
}
项目:tomcat7
文件:MemoryUserDatabaseMBean.java
/**
* Return the MBean Names of all roles defined in this database.
*/
public String[] getRoles() {
UserDatabase database = (UserDatabase) this.resource;
ArrayList<String> results = new ArrayList<String>();
Iterator<Role> roles = database.getRoles();
while (roles.hasNext()) {
Role role = roles.next();
results.add(findRole(role.getRolename()));
}
return results.toArray(new String[results.size()]);
}
项目:tomcat7
文件:MemoryGroup.java
项目:tomcat7
文件:MemoryGroup.java
/**
* Is this group specifically assigned the specified {@link Role}?
*
* @param role The role to check
*/
@Override
public boolean isInRole(Role role) {
synchronized (roles) {
return (roles.contains(role));
}
}
项目:lazycat
文件:MemoryUserDatabase.java
@Override
public Object createObject(Attributes attributes) {
String groupname = attributes.getValue("groupname");
if (groupname == null) {
groupname = attributes.getValue("name");
}
String description = attributes.getValue("description");
String roles = attributes.getValue("roles");
Group group = database.createGroup(groupname,description);
if (roles != null) {
while (roles.length() > 0) {
String rolename = null;
int comma = roles.indexOf(',');
if (comma >= 0) {
rolename = roles.substring(0,comma).trim();
roles = roles.substring(comma + 1);
} else {
rolename = roles.trim();
roles = "";
}
if (rolename.length() > 0) {
Role role = database.findRole(rolename);
if (role == null) {
role = database.createRole(rolename,null);
}
group.addRole(role);
}
}
}
return (group);
}
项目:tomcat7
文件:MemoryGroup.java
/**
* <p>Return a String representation of this group in XML format.</p>
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder("<group groupname=\"");
sb.append(groupname);
sb.append("\"");
if (description != null) {
sb.append(" description=\"");
sb.append(description);
sb.append("\"");
}
synchronized (roles) {
if (roles.size() > 0) {
sb.append(" roles=\"");
int n = 0;
Iterator<Role> values = roles.iterator();
while (values.hasNext()) {
if (n > 0) {
sb.append(',');
}
n++;
sb.append((values.next()).getRolename());
}
sb.append("\"");
}
}
sb.append("/>");
return (sb.toString());
}
项目:tomcat7
文件:MemoryUser.java
项目:tomcat7
文件:MemoryUser.java
/**
* Add a new {@link Role} to those assigned specifically to this user.
*
* @param role The new role
*/
@Override
public void addRole(Role role) {
synchronized (roles) {
if (!roles.contains(role)) {
roles.add(role);
}
}
}
项目:tomcat7
文件:MemoryUser.java
/**
* Is this user specifically assigned the specified {@link Role}? This
* method does <strong>NOT</strong> check for roles inherited based on
* {@link Group} membership.
*
* @param role The role to check
*/
@Override
public boolean isInRole(Role role) {
synchronized (roles) {
return (roles.contains(role));
}
}
项目:tomcat7
文件:MemoryUserDatabase.java
项目:lazycat
文件:MemoryGroup.java
/**
* Is this group specifically assigned the specified {@link Role}?
*
* @param role
* The role to check
*/
@Override
public boolean isInRole(Role role) {
synchronized (roles) {
return (roles.contains(role));
}
}
项目:lazycat
文件:MemoryUser.java
/**
* Is this user specifically assigned the specified {@link Role}? This
* method does <strong>NOT</strong> check for roles inherited based on
* {@link Group} membership.
*
* @param role
* The role to check
*/
@Override
public boolean isInRole(Role role) {
synchronized (roles) {
return (roles.contains(role));
}
}
项目:tomcat7
文件:MemoryUserDatabase.java
@Override
public Object createObject(Attributes attributes) {
String groupname = attributes.getValue("groupname");
if (groupname == null) {
groupname = attributes.getValue("name");
}
String description = attributes.getValue("description");
String roles = attributes.getValue("roles");
Group group = database.createGroup(groupname,null);
}
group.addRole(role);
}
}
}
return (group);
}
项目:lazycat
文件:MemoryUser.java
/**
* Remove a {@link Role} from those assigned to this user.
*
* @param role
* The old role
*/
@Override
public void removeRole(Role role) {
synchronized (roles) {
roles.remove(role);
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。