本文整理汇总了Java中org.apache.catalina.UserDatabase类的典型用法代码示例。如果您正苦于以下问题:Java UserDatabase类的具体用法?Java UserDatabase怎么用?Java UserDatabase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UserDatabase类属于org.apache.catalina包,在下文中一共展示了UserDatabase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createGroup
import org.apache.catalina.UserDatabase; //导入依赖的package包/类
/**
* Create a new Group and return the corresponding MBean Name.
*
* @param groupname Group name of the new group
* @param description Description of the new group
*/
public String createGroup(String groupname, String description) {
UserDatabase database = (UserDatabase) this.resource;
Group group = database.createGroup(groupname, description);
try {
MBeanUtils.createMBean(group);
} catch (Exception e) {
IllegalArgumentException iae = new IllegalArgumentException
("Exception creating group [" + groupname + "] MBean");
iae.initCause(e);
throw iae;
}
return (findGroup(groupname));
}
示例2: createRole
import org.apache.catalina.UserDatabase; //导入依赖的package包/类
/**
* 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));
}
示例3: createUser
import org.apache.catalina.UserDatabase; //导入依赖的package包/类
/**
* 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));
}
示例4: findGroup
import org.apache.catalina.UserDatabase; //导入依赖的package包/类
/**
* Return the MBean Name for the specified group name (if any);
* otherwise return <code>null</code>.
*
* @param groupname Group name to look up
*/
public String findGroup(String groupname) {
UserDatabase database = (UserDatabase) this.resource;
Group group = database.findGroup(groupname);
if (group == null) {
return (null);
}
try {
ObjectName oname =
MBeanUtils.createObjectName(managedGroup.getDomain(), group);
return (oname.toString());
} catch (MalformedObjectNameException e) {
IllegalArgumentException iae = new IllegalArgumentException
("Cannot create object name for group [" + groupname + "]");
iae.initCause(e);
throw iae;
}
}
示例5: findRole
import org.apache.catalina.UserDatabase; //导入依赖的package包/类
/**
* 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;
}
}
示例6: findUser
import org.apache.catalina.UserDatabase; //导入依赖的package包/类
/**
* 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;
}
}
示例7: removeGroup
import org.apache.catalina.UserDatabase; //导入依赖的package包/类
/**
* Remove an existing group and destroy the corresponding MBean.
*
* @param groupname Group name to remove
*/
public void removeGroup(String groupname) {
UserDatabase database = (UserDatabase) this.resource;
Group group = database.findGroup(groupname);
if (group == null) {
return;
}
try {
MBeanUtils.destroyMBean(group);
database.removeGroup(group);
} catch (Exception e) {
IllegalArgumentException iae = new IllegalArgumentException
("Exception destroying group [" + groupname + "] MBean");
iae.initCause(e);
throw iae;
}
}
示例8: removeRole
import org.apache.catalina.UserDatabase; //导入依赖的package包/类
/**
* 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;
}
}
示例9: removeUser
import org.apache.catalina.UserDatabase; //导入依赖的package包/类
/**
* 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;
}
}
示例10: createMBean
import org.apache.catalina.UserDatabase; //导入依赖的package包/类
/**
* Create, register, and return an MBean for this
* <code>UserDatabase</code> object.
*
* @param userDatabase The UserDatabase to be managed
*
* @exception Exception if an MBean cannot be created or registered
*/
static DynamicMBean createMBean(UserDatabase userDatabase)
throws Exception {
String mname = createManagedName(userDatabase);
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(userDatabase);
ObjectName oname = createObjectName(domain, userDatabase);
if( mserver.isRegistered( oname )) {
mserver.unregisterMBean(oname);
}
mserver.registerMBean(mbean, oname);
return (mbean);
}
示例11: destroyMBean
import org.apache.catalina.UserDatabase; //导入依赖的package包/类
/**
* Deregister the MBean for this
* <code>UserDatabase</code> object.
*
* @param userDatabase The UserDatabase to be managed
*
* @exception Exception if an MBean cannot be deregistered
* @deprecated Unused. Will be removed in Tomcat 8.0.x
*/
@Deprecated
static void destroyMBean(UserDatabase userDatabase)
throws Exception {
String mname = createManagedName(userDatabase);
ManagedBean managed = registry.findManagedBean(mname);
if (managed == null) {
return;
}
String domain = managed.getDomain();
if (domain == null)
domain = mserver.getDefaultDomain();
ObjectName oname = createObjectName(domain, userDatabase);
if( mserver.isRegistered(oname) )
mserver.unregisterMBean(oname);
}
示例12: startInternal
import org.apache.catalina.UserDatabase; //导入依赖的package包/类
/**
* Prepare for the beginning of active use of the public methods of this
* component and implement the requirements of
* {@link org.apache.catalina.util.LifecycleBase#startInternal()}.
*
* @exception LifecycleException if this component detects a fatal error
* that prevents this component from being used
*/
@Override
protected void startInternal() throws LifecycleException {
try {
Context context = getServer().getGlobalNamingContext();
database = (UserDatabase) context.lookup(resourceName);
} catch (Throwable e) {
ExceptionUtils.handleThrowable(e);
containerLog.error(sm.getString("userDatabaseRealm.lookup",
resourceName),
e);
database = null;
}
if (database == null) {
throw new LifecycleException
(sm.getString("userDatabaseRealm.noDatabase", resourceName));
}
super.startInternal();
}
示例13: createGroup
import org.apache.catalina.UserDatabase; //导入依赖的package包/类
/**
* Create a new Group and return the corresponding MBean Name.
*
* @param groupname Group name of the new group
* @param description Description of the new group
*/
public String createGroup(String groupname, String description) {
UserDatabase database = (UserDatabase) this.resource;
Group group = database.createGroup(groupname, description);
/*
if (roles != null) {
for (int i = 0; i < roles.length; i++) {
Role role = database.findRole(roles[i]);
if (role == null) {
createRole(roles[i], null);
role = database.findRole(roles[i]);
}
group.addRole(role);
}
}
*/
try {
MBeanUtils.createMBean(group);
} catch (Exception e) {
throw new IllegalArgumentException("Exception creating group " +
group + " MBean: " + e);
}
return (findGroup(groupname));
}
示例14: findGroup
import org.apache.catalina.UserDatabase; //导入依赖的package包/类
/**
* Return the MBean Name for the specified group name (if any);
* otherwise return <code>null</code>.
*
* @param groupname Group name to look up
*/
public String findGroup(String groupname) {
UserDatabase database = (UserDatabase) this.resource;
Group group = database.findGroup(groupname);
if (group == null) {
return (null);
}
try {
ObjectName oname =
MBeanUtils.createObjectName(managedGroup.getDomain(), group);
return (oname.toString());
} catch (MalformedObjectNameException e) {
throw new IllegalArgumentException
("Cannot create object name for group " + group);
}
}
示例15: findRole
import org.apache.catalina.UserDatabase; //导入依赖的package包/类
/**
* 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);
}
}