use of org.isisaddons.module.security.dom.role.ApplicationRole in project estatio by estatio.
the class AbstractUserRoleFixtureScript method addUserToRole.
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;
}
use of org.isisaddons.module.security.dom.role.ApplicationRole in project estatio by estatio.
the class EstatioSecurityModuleFixturesMenu method installFixturesAndReturnFirstRole.
// //////////////////////////////////////
@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;
}
Aggregations