本文整理汇总了Java中org.apache.catalina.UserDatabase.createRole方法的典型用法代码示例。如果您正苦于以下问题:Java UserDatabase.createRole方法的具体用法?Java UserDatabase.createRole怎么用?Java UserDatabase.createRole使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.catalina.UserDatabase
的用法示例。
在下文中一共展示了UserDatabase.createRole方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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));
}
示例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: start
import org.apache.catalina.UserDatabase; //导入方法依赖的package包/类
public void start(final StandardServer server) {
if (SystemInstance.get().isDefaultProfile()) { // add user tomee is no user are specified
try {
final NamingResourcesImpl resources = server.getGlobalNamingResources();
final ContextResource userDataBaseResource = resources.findResource("UserDatabase");
final UserDatabase db = (UserDatabase) server.getGlobalNamingContext().lookup(userDataBaseResource.getName());
if (!db.getUsers().hasNext() && db instanceof MemoryUserDatabase) {
final MemoryUserDatabase mudb = (MemoryUserDatabase) db;
final boolean oldRo = mudb.getReadonly();
try {
((MemoryUserDatabase) db).setReadonly(false);
db.createRole("tomee-admin", "tomee admin role");
db.createUser("tomee", "tomee", "TomEE");
db.findUser("tomee").addRole(db.findRole("tomee-admin"));
} finally {
mudb.setReadonly(oldRo);
}
}
} catch (final Throwable t) {
// no-op
}
}
}
示例4: 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) {
throw new IllegalArgumentException("Exception creating role " +
role + " MBean: " + e);
}
return (findRole(rolename));
}