@Override public void assignRoles(String username, Collection<String> roles) throws SecurityManagementException { Set<String> userGroups = SecurityManagementUtils.groupsToString(SecurityManagementUtils.getGroups(userSystemManager, username)); userGroups.addAll(roles); doAssignGroups(username, userGroups); }
@Override public void assignRoles(String username, Collection<String> roles) throws SecurityManagementException { checkNotNull("username", username); final Set<String> userGroups = SecurityManagementUtils.groupsToString(SecurityManagementUtils.getGroups(userSystemManager, username)); userGroups.addAll(roles); assignGroupsOrRoles(username, userGroups); }
@Override public void assignRoles(String username, Collection<String> roles) throws SecurityManagementException { checkNotNull("username", username); final Set<String> userGroups = SecurityManagementUtils.groupsToString(SecurityManagementUtils.getGroups(userSystemManager, username)); userGroups.addAll(roles); assignGroupsOrRoles(username, userGroups); }
@Override public void assignRoles(String username, Collection<String> roles) throws SecurityManagementException { if (getGroupsPropertiesManager() != null) { Set<String> userGroups = SecurityManagementUtils.groupsToString(SecurityManagementUtils.getGroups(userSystemManager, username)); userGroups.addAll(roles); getGroupsPropertiesManager().setGroupsForUser(username, userGroups); } }
@Override public void assignRoles(String username, Collection<String> roles) throws SecurityManagementException { if (getGroupsPropertiesManager() != null) { Set<String> userGroups = SecurityManagementUtils.groupsToString(SecurityManagementUtils.getGroups(userSystemManager, username)); userGroups.addAll(roles); getGroupsPropertiesManager().setGroupsForUser(username, userGroups); } }
@Override public void assignRoles(String username, Collection<String> roles) throws SecurityManagementException { if (getGroupsPropertiesManager() != null) { Set<String> userGroups = SecurityManagementUtils.groupsToString(SecurityManagementUtils.getGroups(userSystemManager, username)); userGroups.addAll(roles); getGroupsPropertiesManager().setGroupsForUser(username, userGroups); } }
@Test public void testGroupsToString() { Set<Group> roles = new HashSet<Group>(2); Group role1 = mock(Group.class); when(role1.getName()).thenReturn("group1"); Group role2 = mock(Group.class); when(role2.getName()).thenReturn("group2"); roles.add(role1); roles.add(role2); final Set<String> rolesStr = SecurityManagementUtils.groupsToString(roles); assertNotNull(rolesStr); assertTrue(rolesStr.size() == 2); assertTrue(rolesStr.contains("group1")); assertTrue(rolesStr.contains("group2")); }
@Test public void testGroupsToString() { Set<Group> roles = new HashSet<Group>(2); Group role1 = mock(Group.class); when(role1.getName()).thenReturn("group1"); Group role2 = mock(Group.class); when(role2.getName()).thenReturn("group2"); roles.add(role1); roles.add(role2); final Set<String> rolesStr = SecurityManagementUtils.groupsToString(roles); assertNotNull(rolesStr); assertTrue(rolesStr.size() == 2); assertTrue(rolesStr.contains("group1")); assertTrue(rolesStr.contains("group2")); }
@Test public void testGroupsToStringEmpty() { final Set<String> rolesStr = SecurityManagementUtils.groupsToString(null); assertNotNull(rolesStr); assertTrue(rolesStr.size() == 0); }
@Test public void testGroupsToStringEmpty() { final Set<String> rolesStr = SecurityManagementUtils.groupsToString(null); assertNotNull(rolesStr); assertTrue(rolesStr.size() == 0); }