@Before public void setUp() { owner = ownerCurator.create(new Owner(OWNER_NAME)); Role ownerAdminRole = createAdminRole(owner); roleCurator.create(ownerAdminRole); User user = new User("testing user", "pass"); principal = new UserPrincipal( "testing user", new ArrayList<Permission>( permFactory.createPermissions(user, ownerAdminRole.getPermissions())), false); setupPrincipal(principal); ConsumerType ueberCertType = new ConsumerType(ConsumerTypeEnum.UEBER_CERT); consumerTypeCurator.create(ueberCertType); or = new OwnerResource( ownerCurator, null, consumerCurator, i18n, null, null, null, null, null, poolManager, null, null, null, null, consumerTypeCurator, entCertCurator, entitlementCurator, ueberCertGenerator, null, null, contentOverrideValidator, serviceLevelValidator, null, null, null, productManager, contentManager); }
@Override public Role createRole(Role role) { Set<User> actualUsers = new HashSet<User>(); for (User user : role.getUsers()) { User actualUser = findByLogin(user.getUsername()); actualUsers.add(actualUser); } role.setUsers(actualUsers); for (PermissionBlueprint permission : role.getPermissions()) { permission.setRole(role); } this.roleCurator.create(role); return role; }
@Override public void removeUserFromRole(Role role, User user) { role.removeUser(user); roleCurator.merge(role); }
@Override public void addUserToRole(Role role, User user) { role.addUser(user); roleCurator.merge(role); }