@Override protected User createEntity(String identifier) { return SecurityManagementUtils.createUser(identifier); } }
public static User createUser(final String id, final Set<Group> groups) { return createUser(id, groups, null); }
public static User createUser(final String id, final Set<Group> groups, final Set<Role> roles) { return createUser(id, groups, roles, null); }
public static User createUser(final String id) { return createUser(id, null); }
protected User createUser(UserRepresentation userRepresentation, Set<Group> groups, Set<Role> roles) { if (userRepresentation != null) { String username = userRepresentation.getUsername(); final User user = SecurityManagementUtils.createUser(username, groups, roles); fillUserAttributes(user, userRepresentation); return user; } return null; }
protected User createUser(UserRepresentation userRepresentation, Set<Group> groups, Set<Role> roles) { if (userRepresentation != null) { String username = userRepresentation.getUsername(); final User user = SecurityManagementUtils.createUser(username, groups, roles); fillUserAttributes(user, userRepresentation); return user; } return null; }
protected User createUser(org.apache.catalina.User user, Iterator<org.apache.catalina.Role> groups) { if (user == null) { return null; } final Set<Group> _groups = new HashSet<Group>(); final Set<Role> _roles = new HashSet<Role>(); final Set<String> registeredRoles = SecurityManagementUtils.getRegisteredRoleNames(); if (groups != null && groups.hasNext()) { while (groups.hasNext()) { org.apache.catalina.Role group = groups.next(); String name = group.getRolename(); SecurityManagementUtils.populateGroupOrRoles(name, registeredRoles, _groups, _roles); } } return SecurityManagementUtils.createUser(user.getName(), _groups, _roles); }
@Override public User get(String identifier) throws SecurityManagementException { List<String> userNames = getUserNames(); if (userNames != null && userNames.contains(identifier)) { Set<Group> userGroups = null; Set<Role> userRoles = null; if (getGroupsPropertiesManager() != null) { final Set[] gr = getGroupsPropertiesManager().getGroupsAndRolesForUser(identifier); if ( null != gr ) { userGroups = gr[0]; userRoles = gr[1]; } } return SecurityManagementUtils.createUser(identifier, userGroups, userRoles); } throw new UserNotFoundException(identifier); }
@Test public void testCreateUserWithIdNull() { final String testId = null; assertNull(SecurityManagementUtils.createUser(testId)); }
@Test public void testCreateUserWithIdNull() { final String testId = null; assertNull(SecurityManagementUtils.createUser(testId)); }
@Override public User get(String identifier) throws SecurityManagementException { validateUserIdentifier(identifier); List<String> userNames = getUserNames(); if (userNames != null && userNames.contains(identifier)) { Set<Group> userGroups = null; Set<Role> userRoles = null; if (getGroupsPropertiesManager() != null) { final Set[] gr = getGroupsPropertiesManager().getGroupsAndRolesForUser(identifier); if (null != gr) { userGroups = gr[0]; userRoles = gr[1]; } } return SecurityManagementUtils.createUser(identifier, userGroups, userRoles); } throw new UserNotFoundException(identifier); }
@Override public User get(String identifier) throws SecurityManagementException { validateUserIdentifier(identifier); List<String> userNames = getUserNames(); if (userNames != null && userNames.contains(identifier)) { Set<Group> userGroups = null; Set<Role> userRoles = null; if (getGroupsPropertiesManager() != null) { final Set[] gr = getGroupsPropertiesManager().getGroupsAndRolesForUser(identifier); if (null != gr) { userGroups = gr[0]; userRoles = gr[1]; } } return SecurityManagementUtils.createUser(identifier, userGroups, userRoles); } throw new UserNotFoundException(identifier); }
@Test public void testCreateUserWithId() { final String testId = "id1"; final User user = SecurityManagementUtils.createUser(testId); assertNotNull(user); final String id = user.getIdentifier(); assertEquals(id, testId); }
@Test public void testCreateUserWithId() { final String testId = "id1"; final User user = SecurityManagementUtils.createUser(testId); assertNotNull(user); final String id = user.getIdentifier(); assertEquals(id, testId); }
@Test public void testCreateUserWithGroups() { final String testId = "id1"; final String group1Id = "g1"; final String group2Id = "g2"; final Group group1 = SecurityManagementUtils.createGroup(group1Id); final Group group2 = SecurityManagementUtils.createGroup(group2Id); final Set<Group> groups = new HashSet<Group>(2); groups.add(group1); groups.add(group2); final User user = SecurityManagementUtils.createUser(testId, groups); assertNotNull(user); final String id = user.getIdentifier(); assertEquals(id, testId); final Set<Group> resultGroups = user.getGroups(); assertNotNull(resultGroups); assertTrue(resultGroups.size() == 2); assertEquals(resultGroups, groups); }
@Test public void testCreateUserWithGroups() { final String testId = "id1"; final String group1Id = "g1"; final String group2Id = "g2"; final Group group1 = SecurityManagementUtils.createGroup(group1Id); final Group group2 = SecurityManagementUtils.createGroup(group2Id); final Set<Group> groups = new HashSet<Group>(2); groups.add(group1); groups.add(group2); final User user = SecurityManagementUtils.createUser(testId, groups); assertNotNull(user); final String id = user.getIdentifier(); assertEquals(id, testId); final Set<Group> resultGroups = user.getGroups(); assertNotNull(resultGroups); assertTrue(resultGroups.size() == 2); assertEquals(resultGroups, groups); }
props.put("p2", "value2"); final User user = SecurityManagementUtils.createUser(testId, groups, roles,
roles.add(role1); roles.add(role2); final User user = SecurityManagementUtils.createUser(testId, groups, roles);
roles.add(role1); roles.add(role2); final User user = SecurityManagementUtils.createUser(testId, groups, roles);
props.put("p2", "value2"); final User user = SecurityManagementUtils.createUser(testId, groups, roles,