/** Test the getPersonsInRole() service method. */ @Test public void testGetPersonsInRole() throws Exception { ProposalDevelopmentDocument doc = createProposal("Proposal-9", "000001"); PrincipalContract userChew = identityManagementService.getPrincipalByPrincipalName("chew"); kraAuthService.addDocumentLevelRole(userChew.getPrincipalId(), RoleConstants.AGGREGATOR, doc); List<String> persons = kraAuthService.getPrincipalsInRole(RoleConstants.AGGREGATOR, doc); assertEquals(2, persons.size()); }
@Override protected List<KcPerson> getPersonsInRole(String roleName) { KcAuthorizationService kraAuthorizationService = KcServiceLocator.getService(KcAuthorizationService.class); KcPersonService kcPersonService = KcServiceLocator.getService(KcPersonService.class); List<String> users = kraAuthorizationService.getPrincipalsInRole(roleName, getProtocol()); final List<KcPerson> persons = new ArrayList<KcPerson>(); for (String userId : users) { KcPerson person = kcPersonService.getKcPersonByPersonId(userId); if (person != null && person.getActive()) { persons.add(person); } } return persons; }