本文整理汇总了Java中org.isisaddons.module.security.dom.role.ApplicationRole类的典型用法代码示例。如果您正苦于以下问题:Java ApplicationRole类的具体用法?Java ApplicationRole怎么用?Java ApplicationRole使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ApplicationRole类属于org.isisaddons.module.security.dom.role包,在下文中一共展示了ApplicationRole类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: registerUser
import org.isisaddons.module.security.dom.role.ApplicationRole; //导入依赖的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);
}
开发者ID:bibryam,项目名称:semat,代码行数:25,代码来源:AppUserRegistrationService.java
示例2: installFixturesAndReturnFirstRole
import org.isisaddons.module.security.dom.role.ApplicationRole; //导入依赖的package包/类
@Action(
semantics = SemanticsOf.NON_IDEMPOTENT,
restrictTo = RestrictTo.PROTOTYPING
)
@MemberOrder(sequence="20")
public Object installFixturesAndReturnFirstRole() {
final List<FixtureResult> fixtureResultList = findFixtureScriptFor(SecurityModuleAppSetUp.class).run(null);
for (FixtureResult fixtureResult : fixtureResultList) {
final Object object = fixtureResult.getObject();
if(object instanceof ApplicationRole) {
return object;
}
}
getContainer().warnUser("No rules found in fixture; returning all results");
return fixtureResultList;
}
开发者ID:isisaddons-legacy,项目名称:isis-module-security,代码行数:17,代码来源:SecurityModuleAppFixturesService.java
示例3: happyCase
import org.isisaddons.module.security.dom.role.ApplicationRole; //导入依赖的package包/类
@Test
public void happyCase() throws Exception {
// given
final ApplicationRole fredsRole = applicationRoleRepository.newRole("role1", "role1");
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]");
// then
assertThat(fred.getRoles(), is(fredsClone.getRoles()));
}
开发者ID:isisaddons-legacy,项目名称:isis-module-security,代码行数:18,代码来源:ApplicationUserRepositoryIntegTest.java
示例4: whenUserHaveDifferentRoles
import org.isisaddons.module.security.dom.role.ApplicationRole; //导入依赖的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
示例5: registerUser
import org.isisaddons.module.security.dom.role.ApplicationRole; //导入依赖的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
示例6: execute
import org.isisaddons.module.security.dom.role.ApplicationRole; //导入依赖的package包/类
@Override
protected void execute(final ExecutionContext executionContext) {
// create user if does not exist, and assign to the role
applicationUser = applicationUserRepository.findByUsername(username);
if(applicationUser == null) {
final boolean enabled = true;
switch (accountType) {
case DELEGATED:
applicationUser = applicationUserRepository.newDelegateUser(username, null , enabled);
break;
case LOCAL:
final Password pwd = new Password(password);
applicationUser = applicationUserRepository.newLocalUser(username, pwd, pwd, null, enabled, emailAddress);
}
// update tenancy (repository checks for null)
applicationUser.setAtPath(tenancyPath);
for (final String roleName : roleNames) {
final ApplicationRole securityRole = applicationRoleRepository.findByName(roleName);
applicationUser.addRole(securityRole);
}
}
}
开发者ID:isisaddons-legacy,项目名称:isis-module-security,代码行数:26,代码来源:AbstractUserAndRolesFixtureScript.java
示例7: newPermissions
import org.isisaddons.module.security.dom.role.ApplicationRole; //导入依赖的package包/类
private void newPermissions(
final ApplicationPermissionRule rule,
final ApplicationPermissionMode mode,
final ApplicationFeatureType featureType,
final Iterable<String> featureFqns) {
if(featureFqns == null) {
return;
}
ApplicationRole securityRole = applicationRoleRepository.findByName(roleName);
if(securityRole == null) {
securityRole = applicationRoleRepository.newRole(roleName, roleDescription);
}
for (String featureFqn : featureFqns) {
// can't use role#addPackage because that does a check for existence of the package, which is
// not guaranteed to exist yet (the SecurityFeatures#init() may not have run).
applicationPermissionRepository.newPermissionNoCheck(
securityRole,
rule,
mode,
featureType, featureFqn);
}
}
开发者ID:isisaddons-legacy,项目名称:isis-module-security,代码行数:25,代码来源:AbstractRoleAndPermissionsFixtureScript.java
示例8: newPermissionNoCheck
import org.isisaddons.module.security.dom.role.ApplicationRole; //导入依赖的package包/类
@Programmatic
public ApplicationPermission newPermissionNoCheck(
final ApplicationRole role,
final ApplicationPermissionRule rule,
final ApplicationPermissionMode mode,
final ApplicationFeatureType featureType,
final String featureFqn) {
ApplicationPermission permission = findByRoleAndRuleAndFeature(role, rule, featureType, featureFqn);
if (permission != null) {
return permission;
}
permission = getApplicationPermissionFactory().newApplicationPermission();
permission.setRole(role);
permission.setRule(rule);
permission.setMode(mode);
permission.setFeatureType(featureType);
permission.setFeatureFqn(featureFqn);
container.persistIfNotAlready(permission);
return permission;
}
开发者ID:isisaddons-legacy,项目名称:isis-module-security,代码行数:21,代码来源:ApplicationPermissionRepository.java
示例9: newDelegateUser
import org.isisaddons.module.security.dom.role.ApplicationRole; //导入依赖的package包/类
@Action(
domainEvent = NewDelegateUserDomainEvent.class,
semantics = SemanticsOf.NON_IDEMPOTENT
)
@MemberOrder(sequence = "100.10.3")
public ApplicationUser newDelegateUser(
@Parameter(maxLength = ApplicationUser.MAX_LENGTH_USERNAME)
@ParameterLayout(named = "Name")
final String username,
@Parameter(optionality = Optionality.OPTIONAL)
@ParameterLayout(named = "Initial role")
final ApplicationRole initialRole,
@Parameter(optionality = Optionality.OPTIONAL)
@ParameterLayout(named = "Enabled?")
final Boolean enabled) {
return applicationUserRepository.newDelegateUser(username, initialRole, enabled);
}
开发者ID:isisaddons-legacy,项目名称:isis-module-security,代码行数:18,代码来源:ApplicationUserMenu.java
示例10: newLocalUser
import org.isisaddons.module.security.dom.role.ApplicationRole; //导入依赖的package包/类
@Action(
domainEvent = NewLocalUserDomainEvent.class,
semantics = SemanticsOf.IDEMPOTENT
)
@MemberOrder(sequence = "100.10.4")
public ApplicationUser newLocalUser(
@Parameter(maxLength = ApplicationUser.MAX_LENGTH_USERNAME)
@ParameterLayout(named = "Name")
final String username,
@Parameter(optionality = Optionality.OPTIONAL)
@ParameterLayout(named = "Password")
final Password password,
@Parameter(optionality = Optionality.OPTIONAL)
@ParameterLayout(named = "Repeat password")
final Password passwordRepeat,
@Parameter(optionality = Optionality.OPTIONAL)
@ParameterLayout(named = "Initial role")
final ApplicationRole initialRole,
@Parameter(optionality = Optionality.OPTIONAL)
@ParameterLayout(named = "Enabled?")
final Boolean enabled,
@Parameter(optionality = Optionality.OPTIONAL)
@ParameterLayout(named = "Email Address")
final String emailAddress) {
return applicationUserRepository.newLocalUser(username, password, passwordRepeat, initialRole, enabled, emailAddress);
}
开发者ID:isisaddons-legacy,项目名称:isis-module-security,代码行数:27,代码来源:ApplicationUserMenu.java
示例11: installFixturesAndReturnFirstRole
import org.isisaddons.module.security.dom.role.ApplicationRole; //导入依赖的package包/类
@Action(
semantics = SemanticsOf.NON_IDEMPOTENT,
restrictTo = RestrictTo.PROTOTYPING
)
@ActionLayout(
cssClassFa = "fa-bolt"
)
@MemberOrder(sequence = "20")
public Object installFixturesAndReturnFirstRole() {
final List<FixtureResult> fixtureResultList = fixtureScripts.findFixtureScriptFor(EstatioSecurityModuleSeedFixture.class).run(null);
for (FixtureResult fixtureResult : fixtureResultList) {
final Object object = fixtureResult.getObject();
if (object instanceof ApplicationRole) {
return object;
}
}
container.warnUser("No rules found in fixture; returning all results");
return fixtureResultList;
}
开发者ID:estatio,项目名称:estatio,代码行数:20,代码来源:EstatioSecurityModuleFixturesMenu.java
示例12: impersonate
import org.isisaddons.module.security.dom.role.ApplicationRole; //导入依赖的package包/类
@Action(restrictTo = RestrictTo.PROTOTYPING)
@MemberOrder(sequence = "1")
public void impersonate(
final ApplicationUser applicationUser,
@Nullable
final List<ApplicationRole> applicationRoleList) {
if(estatioUserService.isImpersonating()) {
stopImpersonating();
}
final List<String> roleNames = asRoleNames(applicationRoleList);
estatioUserService.setUser(applicationUser.getUsername(), roleNames);
messageService.informUser("Now impersonating " + applicationUser.getName());
}
开发者ID:estatio,项目名称:estatio,代码行数:19,代码来源:EstatioImpersonateMenu.java
示例13: isHostess
import org.isisaddons.module.security.dom.role.ApplicationRole; //导入依赖的package包/类
private boolean isHostess(ApplicationUser user) {
System.out.println(user.getName());
for(ApplicationRole role : user.getRoles()) {
System.out.println(role.getName());
if(role.getName().equals(HostessRoleAndPermissions.ROLE_NAME)) {
return true;
}
}
return false;
}
开发者ID:incodehq,项目名称:ecpcrm,代码行数:12,代码来源:EcpCrmTableColumnOrderService.java
示例14: UserRow
import org.isisaddons.module.security.dom.role.ApplicationRole; //导入依赖的package包/类
public UserRow(final ApplicationUser user) {
this.username = user.getUsername();
this.email = user.getEmailAddress();
StringBuilder sb = new StringBuilder();
for (final ApplicationRole role : user.getRoles()) {
sb.append(role.getName());
sb.append(", ");
}
sb = Strings.removeEnd(sb, ", ");
roles = sb.toString();
}
开发者ID:subes,项目名称:invesdwin-nowicket,代码行数:13,代码来源:UserRow.java
示例15: execute
import org.isisaddons.module.security.dom.role.ApplicationRole; //导入依赖的package包/类
@Override
protected void execute(FixtureScript.ExecutionContext ec) {
// required
final String username = todoapp.fixture.util.Util.coalesce(ec.getParameter("username"), getUsername());
if (username == null) {
throw new IllegalArgumentException("username is required");
}
// optional
final String emailAddress = todoapp.fixture.util.Util.coalesce(ec.getParameter("emailAddress"), getEmailAddress());
final AccountType accountType = todoapp.fixture.util.Util.coalesce(ec.getParameterAsEnum("accountType", AccountType.class), getAccountType(), AccountType.LOCAL);
// final String tenancyPath = todoapp.fixture.util.Util.coalesce(ec.getParameter("atPath"), getAtPath(), GlobalTenancy.TENANCY_PATH + username);
final String password = todoapp.fixture.util.Util.coalesce(ec.getParameter("password"), getPassword(), "pass");
final ApplicationRole initialRole = todoapp.fixture.util.Util.coalesce(findRoleByName(ec.getParameter("initialRole")), getInitialRole(), findRoleByName(getInitialRoleName()));
boolean enabled = todoapp.fixture.util.Util.coalesce(ec.getParameterAsBoolean("enabled"), getEnabled(), Boolean.TRUE);
//
// execute
//
final ApplicationUser applicationUser;
if (accountType == AccountType.DELEGATED) {
applicationUser = wrap(applicationUserMenu).newDelegateUser(username, initialRole, enabled);
} else {
final Password passwordValue = new Password(password);
applicationUser = wrap(applicationUserMenu).newLocalUser(username, passwordValue, passwordValue, initialRole, enabled, emailAddress);
}
// no longer required, performed automatically by subscriber...
// final ApplicationTenancy applicationTenancy = applicationTenancyRepository.findTenancyByPath(tenancyPath);
// if (applicationTenancy == null) {
// final ApplicationTenancy rootTenancy = applicationTenancyRepository.findTenancyByPath(GlobalTenancy.TENANCY_PATH);
// applicationTenancyRepository.newTenancy(username, tenancyPath, rootTenancy);
// }
// applicationUser.setTenancy(applicationTenancy);
ec.addResult(this, username, applicationUser);
setApplicationUser(applicationUser);
}
开发者ID:isisaddons,项目名称:isis-app-todoapp,代码行数:41,代码来源:CreateUserFixtureScript.java
示例16: execute
import org.isisaddons.module.security.dom.role.ApplicationRole; //导入依赖的package包/类
@Override
protected void execute(ExecutionContext ec) {
// required
final String username = Util.coalesce(ec.getParameter("username"), getUsername());
if (username == null) {
throw new IllegalArgumentException("username is required");
}
// validate user
this.applicationUser = applicationUserRepository.findByUsername(username);
if(this.applicationUser == null) {
throw new IllegalArgumentException(String.format("No user with username: '%s'", username));
}
// no defaults for roles
// validate all roleNames
this.applicationRoles =
Lists.newArrayList(
Iterables.filter(
Iterables.transform(getRoleNames(), roleNameToRole()),
Predicates.notNull()));
List<ApplicationRole> applicationRoleList = this.applicationRoles;
List<String> roleNames = getRoleNames();
if(applicationRoleList.size() != roleNames.size()) {
throw new IllegalArgumentException("One or more roles not found");
}
// execute
ec.addResult(this, applicationUser.getName(), this.applicationUser);
for (ApplicationRole applicationRole : this.applicationRoles) {
if (applicationRole != null) {
this.applicationUser.addRole(applicationRole);
ec.addResult(this, applicationRole.getName(), applicationRole);
}
}
}
开发者ID:isisaddons,项目名称:isis-app-todoapp,代码行数:41,代码来源:UserRolesFixtureScript.java
示例17: roleNameToRole
import org.isisaddons.module.security.dom.role.ApplicationRole; //导入依赖的package包/类
private Function<String, ApplicationRole> roleNameToRole() {
return new Function<String, ApplicationRole>() {
@Nullable
@Override
public ApplicationRole apply(final String input) {
return applicationRoleRepository.findByNameCached(input);
}
};
}
开发者ID:isisaddons,项目名称:isis-app-todoapp,代码行数:10,代码来源:UserRolesFixtureScript.java
示例18: addUserToRole
import org.isisaddons.module.security.dom.role.ApplicationRole; //导入依赖的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;
}
开发者ID:isisaddons-legacy,项目名称:isis-module-security,代码行数:13,代码来源:AbstractUserRoleFixtureScript.java
示例19: happyCase
import org.isisaddons.module.security.dom.role.ApplicationRole; //导入依赖的package包/类
@Test
public void happyCase() throws Exception {
// given
final List<ApplicationRole> before = applicationRoleRepository.allRoles();
assertThat(before.size(), is(0));
// when
final ApplicationRole applicationRole = applicationRoleRepository.newRole("fred", null);
assertThat(applicationRole.getName(), is("fred"));
// then
final List<ApplicationRole> after = applicationRoleRepository.allRoles();
assertThat(after.size(), is(1));
}
开发者ID:isisaddons-legacy,项目名称:isis-module-security,代码行数:16,代码来源:ApplicationRoleRepositoryIntegTest.java
示例20: whenDoesntMatch
import org.isisaddons.module.security.dom.role.ApplicationRole; //导入依赖的package包/类
@Test
public void whenDoesntMatch() throws Exception {
// given
applicationRoleRepository.newRole("guest", null);
applicationRoleRepository.newRole("root", null);
nextSession();
// when
final ApplicationRole nonExistent = applicationRoleRepository.findByNameCached("admin");
// then
assertThat(nonExistent, is(nullValue()));
}
开发者ID:isisaddons-legacy,项目名称:isis-module-security,代码行数:15,代码来源:ApplicationRoleRepositoryIntegTest.java
注:本文中的org.isisaddons.module.security.dom.role.ApplicationRole类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论