本文整理汇总了Java中org.isisaddons.module.security.dom.user.ApplicationUser.addRole方法的典型用法代码示例。如果您正苦于以下问题:Java ApplicationUser.addRole方法的具体用法?Java ApplicationUser.addRole怎么用?Java ApplicationUser.addRole使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.isisaddons.module.security.dom.user.ApplicationUser
的用法示例。
在下文中一共展示了ApplicationUser.addRole方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: registerUser
import org.isisaddons.module.security.dom.user.ApplicationUser; //导入方法依赖的package包/类
@Override
public void registerUser(
final UserDetails userDetails) {
final Password password = new Password(userDetails.getPassword());
final ApplicationRole initialRole = getInitialRole();
final Boolean enabled = true;
final String username = userDetails.getUsername();
final String emailAddress = userDetails.getEmailAddress();
final ApplicationUser applicationUser = applicationUserRepository.newLocalUser(username, password, password, initialRole, enabled, emailAddress);
final Set<ApplicationRole> additionalRoles = getAdditionalInitialRoles();
if(additionalRoles != null) {
for (final ApplicationRole additionalRole : additionalRoles) {
applicationUser.addRole(additionalRole);
}
}
// set up new user custom
final ApplicationTenancy applicationTenancy = applicationTenancyRepository.newTenancy(username, "/" + username, null);
applicationUser.setAtPath(applicationTenancy.getPath());
fixtureScripts.runFixtureScript(new SematFixture(username, Arrays.asList(SudoService.ACCESS_ALL_ROLE)), null);
}
示例2: whenUserHaveDifferentRoles
import org.isisaddons.module.security.dom.user.ApplicationUser; //导入方法依赖的package包/类
@Test
public void whenUserHaveDifferentRoles() throws Exception {
// given
final ApplicationRole fredsRole = applicationRoleRepository.newRole("role1", "role2");
final ApplicationUser fred = applicationUserRepository
.newLocalUser("fred", new Password("fredPass"), new Password("fredPass"), fredsRole, true,
"[email protected]");
// when
final ApplicationUser fredsClone = applicationUserRepository
.newLocalUserBasedOn("fredsClone", new Password("fredClonePass"), new Password("fredClonePass"),
fred, true, "[email protected]");
// and when
fredsClone.addRole(applicationRoleRepository.newRole("role2", "role2"));
// then
assertNotEquals(fred.getRoles(), fredsClone.getRoles());
}
开发者ID:isisaddons-legacy,项目名称:isis-module-security,代码行数:21,代码来源:ApplicationUserRepositoryIntegTest.java
示例3: registerUser
import org.isisaddons.module.security.dom.user.ApplicationUser; //导入方法依赖的package包/类
@Override
public void registerUser(
final UserDetails userDetails) {
final Password password = new Password(userDetails.getPassword());
final ApplicationRole initialRole = getInitialRole();
final Boolean enabled = true;
final String username = userDetails.getUsername();
final String emailAddress = userDetails.getEmailAddress();
final ApplicationUser applicationUser = applicationUserRepository.newLocalUser(username, password, password, initialRole, enabled, emailAddress);
final Set<ApplicationRole> additionalRoles = getAdditionalInitialRoles();
if(additionalRoles != null) {
for (final ApplicationRole additionalRole : additionalRoles) {
applicationUser.addRole(additionalRole);
}
}
}
开发者ID:isisaddons-legacy,项目名称:isis-module-security,代码行数:20,代码来源:SecurityModuleAppUserRegistrationServiceAbstract.java
示例4: addUserToRole
import org.isisaddons.module.security.dom.user.ApplicationUser; //导入方法依赖的package包/类
protected ApplicationUser addUserToRole(
final String userName,
final String roleName,
final ExecutionContext executionContext) {
final ApplicationUser user = applicationUserRepository.findOrCreateUserByUsername(userName);
final ApplicationRole applicationRole = applicationRoles.findByName(roleName);
if(applicationRole != null) {
user.addRole(applicationRole);
}
executionContext.addResult(this, roleName, applicationRole);
return user;
}
示例5: addUser
import org.isisaddons.module.security.dom.user.ApplicationUser; //导入方法依赖的package包/类
@Action(
domainEvent = AddUserDomainEvent.class,
semantics = SemanticsOf.IDEMPOTENT
)
@ActionLayout(
named="Add")
@MemberOrder(name="Users", sequence = "1")
public ApplicationRole addUser(final ApplicationUser applicationUser) {
applicationUser.addRole(this);
// no need to add to users set, since will be done by JDO/DN.
return this;
}
示例6: addUserToRole
import org.isisaddons.module.security.dom.user.ApplicationUser; //导入方法依赖的package包/类
protected ApplicationUser addUserToRole(
final String userName,
final String roleName,
final ExecutionContext executionContext) {
final ApplicationUser user = applicationUserRepository.findOrCreateUserByUsername(userName);
final ApplicationRole applicationRole = applicationRoleRepository.findByName(roleName);
if(applicationRole == null) {
throw new IllegalArgumentException(String.format("Role [%s] not found", roleName));
}
user.addRole(applicationRole);
executionContext.addResult(this, roleName, applicationRole);
return user;
}