private void setTimeoutRole(MessageContext context, String args) { DiscordApiClient apiClient = context.getApiClient(); if (args.isEmpty()) { apiClient.sendMessage( loc.localize("commands.mod.settimeoutrole.response.missing"), context.getChannel()); return; } Role role = apiClient.getRole(args, context.getServer()); if (role == NO_ROLE) { apiClient.sendMessage( loc.localize("commands.mod.settimeoutrole.response.not_found", args), context.getChannel()); return; } String serverId = context.getServer().getId(); TempServerConfig serverConfig = serverStorage.get(serverId); if (serverConfig == null) { serverConfig = new TempServerConfig(serverId); serverStorage.put(serverId, serverConfig); } ServerTimeoutStorage storage = serverConfig.getServerTimeouts(); if (storage == null) { storage = new ServerTimeoutStorage(); serverConfig.setServerTimeouts(storage); } storage.setTimeoutRoleId(role.getId()); apiClient.sendMessage( loc.localize("commands.mod.settimeoutrole.response", role.getName(), role.getId()), context.getChannel()); saveServerConfig(serverConfig); }
public void testInsert() throws HibernateException, SQLException { if (isUsingIdentity()) { reportSkip("hand sql expecting non-identity id gen", "Custom SQL"); return; } Role p = new Role(); p.setName("Patient"); Session s = openSession(); s.save(p); s.flush(); s.connection().commit(); s.close(); getSessions().evict(Role.class); s = openSession(); Role p2 = (Role) s.get(Role.class, new Long(p.getId())); assertNotSame(p, p2); assertEquals(p2.getId(), p.getId()); assertTrue(p2.getName().equalsIgnoreCase(p.getName())); s.delete(p2); s.flush(); s.connection().commit(); s.close(); }
private Document buildRole(Role role) { Element root = new Element(ROLE_REQUEST_ELEMENT); Document doc = new Document().setRootElement(root); Element data = new Element("data"); root.addContent(data); data.addContent(new Element(ROLE_ID_ELEMENT).setText(role.getId())); data.addContent(new Element(ROLE_NAME_ELEMENT).setText(role.getName())); data.addContent(new Element(ROLE_DESCRIPTION_ELEMENT).setText(role.getDescription())); data.addContent( new Element(ROLE_SESSION_TIMEOUT_ELEMENT).setText(role.getSessionTimeout() + "")); Element subRoles = new Element(ROLE_ROLES_ELEMENT); for (String subRole : role.getRoles()) { subRoles.addContent(new Element(ROLE_ROLE_ELEMENT).setText(subRole)); } data.addContent(subRoles); Element privileges = new Element(ROLE_PRIVILEGES_ELEMENT); for (String privilege : role.getPrivileges()) { privileges.addContent(new Element(ROLE_PRIVILEGE_ELEMENT).setText(privilege)); } data.addContent(privileges); data.addContent( new Element(ROLE_USER_MANAGED_ELEMENT).setText(role.isUserManaged() ? "true" : "false")); return doc; }
public void testAddUserRole() throws Exception { User user = dao.get(2L); assertEquals(6, user.getRoles().size()); Role role = rdao.getRoleByName("ROLE_EXTERNAL"); assertEquals((Long) 4L, (Long) role.getId()); user.addRole(role); user = dao.saveUser(user); // flush(); user = dao.get(2L); assertEquals(7, user.getRoles().size()); // add the same role twice - should result in no additional role user.addRole(role); dao.saveUser(user); // flush(); user = dao.get(2L); assertEquals("more than 7 roles", 7, user.getRoles().size()); user.getRoles().remove(role); dao.saveUser(user); // flush(); user = dao.get(2L); assertEquals(6, user.getRoles().size()); }
@JsonIgnore public List<String> getRoleIdList() { List<String> roleIdList = Lists.newArrayList(); for (Role role : roleList) { roleIdList.add(role.getId()); } return roleIdList; }
@ResponseBody @RequestMapping( value = "/s/role/find", method = RequestMethod.GET, produces = "application/json;text/html;charset=UTF-8") public String find(Role role) { String result = JsonUtil.toString(roleService.findById(role.getId())); return result; }
@ResponseBody @RequestMapping( value = "/s/role/delete", method = RequestMethod.GET, produces = "application/json;text/html;charset=UTF-8") public String delete(Role role) { return JsonUtil.toString( ResultUtil.set(roleService.delete(roleService.findById(role.getId())))); }
private String[] getRolesAsIdStringArray() { final List<String> roleIds = new ArrayList<String>(); for (final Role role : this.roles) { roleIds.add(role.getId().toString()); } return roleIds.toArray(new String[roleIds.size()]); }
private RoleMember assignPrincipal2Role(String principalId, Role role, String subjArea) { Map<String, String> qualifiers = new LinkedHashMap<String, String>(); if (subjArea != null) { qualifiers.put(KimPermissionConstants.SUBJECT_AREA_ATTR_DEFINITION, subjArea); } RoleMember roleMember = this.roleService.assignPrincipalToRole( principalId, role.getNamespaceCode(), role.getName(), qualifiers); assertEquals(principalId, roleMember.getMemberId()); assertEquals(role.getId(), roleMember.getRoleId()); assertEquals(KimConstants.KimGroupMemberTypes.PRINCIPAL_MEMBER_TYPE, roleMember.getType()); assertEquals(qualifiers, roleMember.getAttributes()); List<String> roleIds = this.roleService.getMemberParentRoleIds( KimConstants.KimGroupMemberTypes.PRINCIPAL_MEMBER_TYPE.getCode(), principalId); // assertEquals(1, roleIds.size()); assertTrue(roleIds.contains(role.getId())); return roleMember; }
public String getRoleStrs() { if (this.roles == null || this.roles.isEmpty()) { return ""; } StringBuilder result = new StringBuilder(); for (Role role : this.roles) { result.append("role-").append(role.getId()).append(","); } result = result.deleteCharAt(result.length() - 1); return result.toString(); }
@Nullable @Override public String apply(@Nullable String roleName) { if (roleName == null) { return null; } final Role role = nameToRole.get(roleName.toLowerCase(Locale.ENGLISH)); if (role == null) { return null; } return role.getId(); }
@Override public String toString() { return "RoleResourcePermission{id=" + this.getId() + ",roleId=" + (role != null ? role.getId() : "null") + ", resourceId=" + resourceId + ", permissionIds=" + permissionIds + '}'; }
private String findRoleUidByName(List<Role> roles, String roleName) { if (roleName == null || roleName.trim().isEmpty()) { return null; } for (Role role : roles) { if (roleName.equalsIgnoreCase(role.getName())) { return role.getId(); } } return null; }
private Role createRole(String namespaceCode, String name, String kimTypeId) { Role.Builder bldr = Role.Builder.create(); bldr.setNamespaceCode(namespaceCode); bldr.setName(name); bldr.setKimTypeId(kimTypeId); bldr.setActive(true); Role fromCreate = this.roleService.createRole(bldr.build()); assertEquals(namespaceCode, fromCreate.getNamespaceCode()); assertEquals(name, fromCreate.getName()); assertEquals(kimTypeId, fromCreate.getKimTypeId()); assertNotNull(fromCreate.getId()); assertNotNull(fromCreate.getVersionNumber()); assertTrue(fromCreate.isActive()); assertNull(fromCreate.getDescription()); bldr = Role.Builder.create(fromCreate); bldr.setDescription(namespaceCode + " " + name); Role fromUpdate = this.roleService.updateRole(bldr.build()); assertEquals(fromCreate.getNamespaceCode(), fromUpdate.getNamespaceCode()); assertEquals(fromCreate.getName(), fromUpdate.getName()); assertEquals(fromCreate.getId(), fromUpdate.getId()); assertNotSame(fromCreate.getVersionNumber(), fromUpdate.getVersionNumber()); assertEquals(fromCreate.isActive(), fromUpdate.isActive()); assertEquals(bldr.getDescription(), fromUpdate.getDescription()); Role fromGet = this.roleService.getRole(fromUpdate.getId()); assertEquals(fromUpdate.getNamespaceCode(), fromGet.getNamespaceCode()); assertEquals(fromUpdate.getName(), fromGet.getName()); assertEquals(fromUpdate.getKimTypeId(), fromGet.getKimTypeId()); assertEquals(fromUpdate.getId(), fromGet.getId()); assertEquals(fromUpdate.getVersionNumber(), fromGet.getVersionNumber()); assertEquals(fromUpdate.isActive(), fromGet.isActive()); assertEquals(fromUpdate.getDescription(), fromGet.getDescription()); Role fromFind = this.roleService.getRoleByNamespaceCodeAndName(namespaceCode, name); assertEquals(fromUpdate.getNamespaceCode(), fromFind.getNamespaceCode()); assertEquals(fromUpdate.getName(), fromFind.getName()); assertEquals(fromUpdate.getKimTypeId(), fromFind.getKimTypeId()); assertEquals(fromUpdate.getId(), fromFind.getId()); assertEquals(fromUpdate.getVersionNumber(), fromFind.getVersionNumber()); assertEquals(fromUpdate.isActive(), fromFind.isActive()); assertEquals(fromUpdate.getDescription(), fromFind.getDescription()); // TODO: test update return fromFind; }
/** * Deletes a role from the package. * * @param packageId * @param role * @throws EslException */ public void deleteRole(PackageId packageId, Role role) throws EslException { String path = template .urlFor(UrlTemplate.ROLE_ID_PATH) .replace("{packageId}", packageId.getId()) .replace("{roleId}", role.getId()) .build(); try { client.delete(path); } catch (RequestException e) { throw new EslServerException("Could not delete role", e); } catch (Exception e) { throw new EslException("Could not delete role", e); } }
private void sendSmsToSigner(PackageId packageId, Role role) { String path = template .urlFor(UrlTemplate.SEND_SMS_TO_SIGNER_PATH) .replace("{packageId}", packageId.getId()) .replace("{roleId}", role.getId()) .build(); try { client.post(path, null); } catch (RequestException e) { throw new EslException("Could not send SMS to the signer.", e); } catch (Exception e) { throw new EslException("Could not send SMS to the signer." + " Exception: " + e.getMessage()); } }
public void testAddAndRemoveUser() throws Exception { User user = new User("testuser"); user.setPassword("testpass"); user.setFirstName("Test"); user.setLastName("Last"); Address address = new Address(); address.setCity("Denver"); address.setProvince("CO"); address.setCountry("USA"); address.setPostalCode("80210"); user.setAddress(address); user.setEmail("*****@*****.**"); user.setWebsite("http://tek42.com"); user.setTimeZone("US/Central"); // Here we are creating an org that should already be in the database... // Ideally, we somehow have an org object... from the other dao or whatever... /* * Account org = new Account(); org.setName("Tek42"); org.setId(1L); */ Account org = adao.get(2L); System.out.println("Have org: " + org); user.setAccount(org); Role role = rdao.getRoleByName(Constants.USER_ROLE); assertNotNull(role.getId()); user.addRole(role); user = dao.saveUser(user); assertNotNull(user.getId()); user = dao.get(user.getId()); assertEquals("Vigilant", user.getAccount().getName()); assertEquals("testpass", user.getPassword()); assertEquals("US/Central", user.getTimeZone()); dao.remove(user.getId()); try { dao.get(user.getId()); fail("getUser didn't throw DataAccessException"); } catch (DataAccessException d) { assertNotNull(d); } }
private String getSigningUrl(PackageId packageId, Role role) { String path = template .urlFor(UrlTemplate.SIGNER_URL_PATH) .replace("{packageId}", packageId.getId()) .replace("{roleId}", role.getId()) .build(); try { String response = client.get(path); SigningUrl signingUrl = Serialization.fromJson(response, SigningUrl.class); return signingUrl.getUrl(); } catch (RequestException e) { throw new EslException("Could not get a signing url.", e); } catch (Exception e) { throw new EslException("Could not get a signing url." + " Exception: " + e.getMessage()); } }
/** * Updates a role from the package. * * @param packageId * @param role * @return The updated role * @throws EslException */ public Role updateRole(PackageId packageId, Role role) throws EslException { String path = template .urlFor(UrlTemplate.ROLE_ID_PATH) .replace("{packageId}", packageId.getId()) .replace("{roleId}", role.getId()) .build(); String roleJson = JacksonUtil.serializeDirty(role); String stringResponse; try { stringResponse = client.put(path, roleJson); } catch (RequestException e) { throw new EslServerException("Could not update role", e); } catch (Exception e) { throw new EslException("Could not update role", e); } return Serialization.fromJson(stringResponse, Role.class); }
/** * Adds a signer to the specified package * * @param packageId The id of the package in which the signer will be added * @param signer The signer to be added * @return The role id of the signer */ public String addSigner(PackageId packageId, com.silanis.esl.sdk.Signer signer) { Role apiPayload = new SignerConverter(signer).toAPIRole(UUID.randomUUID().toString().replace("-", "")); String path = template .urlFor(UrlTemplate.ADD_SIGNER_PATH) .replace("{packageId}", packageId.getId()) .build(); try { String json = Serialization.toJson(apiPayload); String response = client.post(path, json); Role apiRole = Serialization.fromJson(response, Role.class); return apiRole.getId(); } catch (RequestException e) { throw new EslServerException("Could not add signer.", e); } catch (Exception e) { throw new EslException("Could not add signer." + " Exception: " + e.getMessage()); } }
/** * This method allows an application admin to revoke a permission from a group. * * @param grp The group to revoke the permission from. * @param role The role that is being revoked from the group. * @param pg The protection group in which the permission is being revoked * @throws RemoteException * @throws CSMInternalFault * @throws AccessDeniedFault * @throws CSMTransactionFault */ public void revokePermission(Group grp, Role role, ProtectionGroup pg) throws RemoteException, CSMInternalFault, AccessDeniedFault, CSMTransactionFault { this.revokePermission(grp.getId(), role.getId(), pg.getId()); }
public void notifySigner(PackageId packageId, GroupId groupId) { Role role = findRoleForGroup(packageId, groupId.getId()); notifySigner(packageId, role.getId()); }
/** Test of clear method, of class RoleAndPermissionServiceMockImpl. */ @Test public void testBasicOperations() { System.out.println("test basic operations"); // Make sure we have a handle on all the templates we need Template CAN_INVOKE_SERVICE_METHOD_TEMPLATE = this.permissionService.findPermTemplateByNamespaceCodeAndName( KimPermissionConstants.KS_ENRL_NAMESPACE, KimPermissionConstants.CAN_INVOKE_SERVICE_METHOD_TEMPLATE_NAME); assertNotNull(CAN_INVOKE_SERVICE_METHOD_TEMPLATE); Template OPEN_VIEW_TEMPLATE = this.permissionService.findPermTemplateByNamespaceCodeAndName( KimPermissionConstants.KR_KRAD_NAMESPACE, KimPermissionConstants.OPEN_VIEW_TEMPLATE_NAME); assertNotNull(OPEN_VIEW_TEMPLATE); Template EDIT_VIEW_TEMPLATE = this.permissionService.findPermTemplateByNamespaceCodeAndName( KimPermissionConstants.KR_KRAD_NAMESPACE, KimPermissionConstants.EDIT_VIEW_TEMPLATE_NAME); assertNotNull(EDIT_VIEW_TEMPLATE); // create permissions Permission CREATE_ACTIVITY_OFFERING_PERMISSION = this.createPermission( KimPermissionConstants.CREATE_ACTIVITYOFFERING_PERMISSION, CAN_INVOKE_SERVICE_METHOD_TEMPLATE, null); Permission CREATE_SOC_PERMISSION = this.createPermission( KimPermissionConstants.CREATE_SOC_PERMISSION, CAN_INVOKE_SERVICE_METHOD_TEMPLATE, null); Permission OPEN_VIEWS_FOR_COURSE_OFFERING_PERMISSION = this.createPermission( KimPermissionConstants.OPEN_VIEWS_FOR_COURSE_OFFERING_PERMISSION, OPEN_VIEW_TEMPLATE, CO_CREATE_MAINTENANCE_VIEW); Permission EDIT_VIEWS_FOR_COURSE_OFFERING_PERMISSION = this.createPermission( KimPermissionConstants.EDIT_VIEWS_FOR_COURSE_OFFERING_PERMISSION, EDIT_VIEW_TEMPLATE, CO_CREATE_MAINTENANCE_VIEW); Permission OPEN_VIEWS_FOR_SOC_PERMISSION = this.createPermission( KimPermissionConstants.OPEN_VIEWS_FOR_SOC_PERMISSION, OPEN_VIEW_TEMPLATE, ROLLOVER_MANAGEMENT_VIEW); Permission EDIT_VIEWS_FOR_SOC_PERMISSION = this.createPermission( KimPermissionConstants.EDIT_VIEWS_FOR_SOC_PERMISSION, EDIT_VIEW_TEMPLATE, ROLLOVER_MANAGEMENT_VIEW); // create some roles Role CENTRAL_ADMIN_ROLE = createRole( KimPermissionConstants.KS_ENRL_NAMESPACE, KimPermissionConstants.KUALI_STUDENT_COURSE_OFFERING_CENTRAL_ADMIN_ROLE_NAME, KimPermissionConstants.DEFAULT_KIM_TYPE_ID); Role DEPT_ADMIN_ROLE = createRole( KimPermissionConstants.KS_ENRL_NAMESPACE, KimPermissionConstants.KUALI_STUDENT_COURSE_OFFERING_DEPARTMENTAL_ADMIN_ROLE_NAME, KimPermissionConstants.DEFAULT_KIM_TYPE_ID); // Assign some permissions to some roles this.roleService.assignPermissionToRole( CREATE_ACTIVITY_OFFERING_PERMISSION.getId(), CENTRAL_ADMIN_ROLE.getId()); this.roleService.assignPermissionToRole( CREATE_SOC_PERMISSION.getId(), CENTRAL_ADMIN_ROLE.getId()); this.roleService.assignPermissionToRole( CREATE_ACTIVITY_OFFERING_PERMISSION.getId(), DEPT_ADMIN_ROLE.getId()); this.roleService.assignPermissionToRole( OPEN_VIEWS_FOR_COURSE_OFFERING_PERMISSION.getId(), CENTRAL_ADMIN_ROLE.getId()); this.roleService.assignPermissionToRole( EDIT_VIEWS_FOR_COURSE_OFFERING_PERMISSION.getId(), CENTRAL_ADMIN_ROLE.getId()); this.roleService.assignPermissionToRole( OPEN_VIEWS_FOR_SOC_PERMISSION.getId(), CENTRAL_ADMIN_ROLE.getId()); this.roleService.assignPermissionToRole( EDIT_VIEWS_FOR_SOC_PERMISSION.getId(), CENTRAL_ADMIN_ROLE.getId()); this.roleService.assignPermissionToRole( OPEN_VIEWS_FOR_COURSE_OFFERING_PERMISSION.getId(), DEPT_ADMIN_ROLE.getId()); this.roleService.assignPermissionToRole( EDIT_VIEWS_FOR_COURSE_OFFERING_PERMISSION.getId(), DEPT_ADMIN_ROLE.getId()); this.roleService.assignPermissionToRole( OPEN_VIEWS_FOR_SOC_PERMISSION.getId(), DEPT_ADMIN_ROLE.getId()); List<String> roleIds = this.permissionService.getRoleIdsForPermission( CREATE_ACTIVITY_OFFERING_PERMISSION.getNamespaceCode(), CREATE_ACTIVITY_OFFERING_PERMISSION.getName()); assertEquals(2, roleIds.size()); assertTrue(roleIds.contains(CENTRAL_ADMIN_ROLE.getId())); assertTrue(roleIds.contains(DEPT_ADMIN_ROLE.getId())); roleIds = this.permissionService.getRoleIdsForPermission( CREATE_SOC_PERMISSION.getNamespaceCode(), CREATE_SOC_PERMISSION.getName()); assertEquals(1, roleIds.size()); assertTrue(roleIds.contains(CENTRAL_ADMIN_ROLE.getId())); roleIds = this.permissionService.getRoleIdsForPermission( OPEN_VIEWS_FOR_COURSE_OFFERING_PERMISSION.getNamespaceCode(), OPEN_VIEWS_FOR_COURSE_OFFERING_PERMISSION.getName()); assertEquals(2, roleIds.size()); assertTrue(roleIds.contains(CENTRAL_ADMIN_ROLE.getId())); assertTrue(roleIds.contains(DEPT_ADMIN_ROLE.getId())); roleIds = this.permissionService.getRoleIdsForPermission( EDIT_VIEWS_FOR_COURSE_OFFERING_PERMISSION.getNamespaceCode(), EDIT_VIEWS_FOR_COURSE_OFFERING_PERMISSION.getName()); assertEquals(2, roleIds.size()); assertTrue(roleIds.contains(CENTRAL_ADMIN_ROLE.getId())); assertTrue(roleIds.contains(DEPT_ADMIN_ROLE.getId())); roleIds = this.permissionService.getRoleIdsForPermission( OPEN_VIEWS_FOR_SOC_PERMISSION.getNamespaceCode(), OPEN_VIEWS_FOR_SOC_PERMISSION.getName()); assertEquals(2, roleIds.size()); assertTrue(roleIds.contains(CENTRAL_ADMIN_ROLE.getId())); assertTrue(roleIds.contains(DEPT_ADMIN_ROLE.getId())); roleIds = this.permissionService.getRoleIdsForPermission( EDIT_VIEWS_FOR_SOC_PERMISSION.getNamespaceCode(), EDIT_VIEWS_FOR_SOC_PERMISSION.getName()); assertEquals(1, roleIds.size()); assertTrue(roleIds.contains(CENTRAL_ADMIN_ROLE.getId())); // assertTrue(roleIds.contains(DEPT_ADMIN_ROLE.getId())); this.assignPrincipal2Role(CENTRAL_ADMIN1, CENTRAL_ADMIN_ROLE, null); this.assignPrincipal2Role(DEPT_ADMIN1, DEPT_ADMIN_ROLE, "ENGL"); this.assignPrincipal2Role(DEPT_ADMIN2, DEPT_ADMIN_ROLE, "PHYS"); this.assignPrincipal2Role(DEPT_ADMIN3, DEPT_ADMIN_ROLE, "ENGL"); this.assignPrincipal2Role(DEPT_ADMIN3, DEPT_ADMIN_ROLE, "PHYS"); // check is auth by template assertTrue( isAuthorizedByTemplate( CENTRAL_ADMIN1, KimPermissionConstants.OPEN_VIEW_TEMPLATE_NAME, CO_CREATE_MAINTENANCE_VIEW)); assertTrue( isAuthorizedByTemplate( CENTRAL_ADMIN1, KimPermissionConstants.EDIT_VIEW_TEMPLATE_NAME, CO_CREATE_MAINTENANCE_VIEW)); assertTrue( isAuthorizedByTemplate( CENTRAL_ADMIN1, KimPermissionConstants.OPEN_VIEW_TEMPLATE_NAME, ROLLOVER_MANAGEMENT_VIEW)); assertTrue( isAuthorizedByTemplate( CENTRAL_ADMIN1, KimPermissionConstants.EDIT_VIEW_TEMPLATE_NAME, ROLLOVER_MANAGEMENT_VIEW)); assertTrue( isAuthorizedByTemplate( DEPT_ADMIN1, KimPermissionConstants.OPEN_VIEW_TEMPLATE_NAME, CO_CREATE_MAINTENANCE_VIEW)); assertTrue( isAuthorizedByTemplate( DEPT_ADMIN1, KimPermissionConstants.EDIT_VIEW_TEMPLATE_NAME, CO_CREATE_MAINTENANCE_VIEW)); assertTrue( isAuthorizedByTemplate( DEPT_ADMIN1, KimPermissionConstants.OPEN_VIEW_TEMPLATE_NAME, ROLLOVER_MANAGEMENT_VIEW)); assertFalse( isAuthorizedByTemplate( DEPT_ADMIN1, KimPermissionConstants.EDIT_VIEW_TEMPLATE_NAME, ROLLOVER_MANAGEMENT_VIEW)); assertTrue(isAuthorized(CENTRAL_ADMIN1, CREATE_ACTIVITY_OFFERING_PERMISSION, "ENGL")); assertTrue(isAuthorized(CENTRAL_ADMIN1, CREATE_ACTIVITY_OFFERING_PERMISSION, "PHYS")); assertTrue(isAuthorized(CENTRAL_ADMIN1, CREATE_ACTIVITY_OFFERING_PERMISSION, "MATH")); assertTrue(isAuthorized(DEPT_ADMIN1, CREATE_ACTIVITY_OFFERING_PERMISSION, "ENGL")); assertFalse(isAuthorized(DEPT_ADMIN1, CREATE_ACTIVITY_OFFERING_PERMISSION, "PHYS")); assertFalse(isAuthorized(DEPT_ADMIN1, CREATE_ACTIVITY_OFFERING_PERMISSION, "MATH")); assertFalse(isAuthorized(DEPT_ADMIN2, CREATE_ACTIVITY_OFFERING_PERMISSION, "ENGL")); assertTrue(isAuthorized(DEPT_ADMIN2, CREATE_ACTIVITY_OFFERING_PERMISSION, "PHYS")); assertFalse(isAuthorized(DEPT_ADMIN2, CREATE_ACTIVITY_OFFERING_PERMISSION, "MATH")); assertTrue(isAuthorized(DEPT_ADMIN3, CREATE_ACTIVITY_OFFERING_PERMISSION, "ENGL")); assertTrue(isAuthorized(DEPT_ADMIN3, CREATE_ACTIVITY_OFFERING_PERMISSION, "PHYS")); assertFalse(isAuthorized(DEPT_ADMIN3, CREATE_ACTIVITY_OFFERING_PERMISSION, "MATH")); }
@Test public void testInitRole() throws Exception { Role role = init.createRole(); assertNotNull(role); assertNotNull(role.getId()); }
/** * This method allows an application admin to revoke a permission from a user. * * @param userIdentity The user to revoke the permission from. * @param role The role that is being revoked from the user. * @param pg The protection group in which the permission is being revoked * @throws RemoteException * @throws CSMInternalFault * @throws AccessDeniedFault * @throws CSMTransactionFault */ public void revokePermission(String userIdentity, Role role, ProtectionGroup pg) throws RemoteException, CSMInternalFault, AccessDeniedFault, CSMTransactionFault { this.revokePermission(userIdentity, role.getId(), pg.getId()); }
/** * This method allows an application admin to remove a role. * * @param role The role to remove. * @throws RemoteException * @throws CSMInternalFault * @throws AccessDeniedFault * @throws CSMTransactionFault */ public void removeRole(Role role) throws RemoteException, CSMInternalFault, AccessDeniedFault, CSMTransactionFault { this.removeRole(role.getId()); }
public void testCollectionCUD() throws HibernateException, SQLException { if (isUsingIdentity()) { reportSkip("hand sql expecting non-identity id gen", "Custom SQL"); return; } Role role = new Role(); role.setName("Jim Flanders"); Intervention iv = new Medication(); iv.setDescription("JF medical intervention"); role.getInterventions().add(iv); List sx = new ArrayList(); sx.add("somewhere"); sx.add("somehow"); sx.add("whatever"); role.setBunchOfStrings(sx); Session s = openSession(); s.save(role); s.flush(); s.connection().commit(); s.close(); s = openSession(); Role r = (Role) s.get(Role.class, new Long(role.getId())); assertNotSame(role, r); assertEquals(1, r.getInterventions().size()); assertEquals(3, r.getBunchOfStrings().size()); r.getBunchOfStrings().set(1, "replacement"); s.flush(); s.connection().commit(); s.close(); s = openSession(); r = (Role) s.get(Role.class, new Long(role.getId())); assertNotSame(role, r); assertEquals(r.getBunchOfStrings().get(1), "replacement"); assertEquals(3, r.getBunchOfStrings().size()); r.getBunchOfStrings().set(1, "replacement"); r.getBunchOfStrings().remove(1); s.flush(); r.getBunchOfStrings().clear(); s.flush(); s.connection().commit(); s.close(); }