@Test public void testAddUser() throws Exception { SecuritySystem securitySystem = this.getSecuritySystem(); User user = new User(); user.setEmailAddress("email@foo.com"); user.setName("testAddUser"); user.setSource("MockUserManagerA"); user.setStatus(UserStatus.active); user.setUserId("testAddUser"); user.addRole(new RoleIdentifier("default", "test-role1")); Assert.assertNotNull(securitySystem.addUser(user, "test123")); }
@Override public User addUser(User user, String password) throws NoSuchUserManagerException { UserManager userManager = getUserManager(user.getSource()); if (!userManager.supportsWrite()) { throw new RuntimeException("UserManager: " + userManager.getSource() + " does not support writing."); } userManager.addUser(user, password); for (UserManager tmpUserManager : getUserManagers()) { if (!tmpUserManager.getSource().equals(user.getSource()) && RoleMappingUserManager.class.isInstance(tmpUserManager)) { try { RoleMappingUserManager roleMappingUserManager = (RoleMappingUserManager) tmpUserManager; roleMappingUserManager.setUsersRoles( user.getUserId(), user.getSource(), RoleIdentifier.getRoleIdentifiersForSource(user.getSource(), user.getRoles()) ); } catch (UserNotFoundException e) { log.debug("User '{}' is not managed by the user-manager: {}", user.getUserId(), tmpUserManager.getSource()); } } } return user; }
DefaultSecuritySystem extends StateGuardLifecycleSupport implements SecuritySystem { @Override public User addUser(User user, String password) throws NoSuchUserManagerException { UserManager userManager = getUserManager(user.getSource()); if (!userManager.supportsWrite()) { throw new RuntimeException("UserManager: " + userManager.getSource() + " does not support writing."); } userManager.addUser(user, password); for (UserManager tmpUserManager : getUserManagers()) { if (!tmpUserManager.getSource().equals(user.getSource()) && RoleMappingUserManager.class.isInstance(tmpUserManager)) { try { RoleMappingUserManager roleMappingUserManager = (RoleMappingUserManager) tmpUserManager; roleMappingUserManager.setUsersRoles( user.getUserId(), user.getSource(), RoleIdentifier.getRoleIdentifiersForSource(user.getSource(), user.getRoles()) ); } catch (UserNotFoundException e) { log.debug("User '{}' is not managed by the user-manager: {}", user.getUserId(), tmpUserManager.getSource()); } } } return user; } }
DefaultSecuritySystem extends StateGuardLifecycleSupport implements SecuritySystem { @Override public User addUser(User user, String password) throws NoSuchUserManagerException { UserManager userManager = getUserManager(user.getSource()); if (!userManager.supportsWrite()) { throw new RuntimeException("UserManager: " + userManager.getSource() + " does not support writing."); } userManager.addUser(user, password); for (UserManager tmpUserManager : getUserManagers()) { if (!tmpUserManager.getSource().equals(user.getSource()) && RoleMappingUserManager.class.isInstance(tmpUserManager)) { try { RoleMappingUserManager roleMappingUserManager = (RoleMappingUserManager) tmpUserManager; roleMappingUserManager.setUsersRoles( user.getUserId(), user.getSource(), RoleIdentifier.getRoleIdentifiersForSource(user.getSource(), user.getRoles()) ); } catch (UserNotFoundException e) { log.debug("User '{}' is not managed by the user-manager: {}", user.getUserId(), tmpUserManager.getSource()); } } } return user; } @Inject  DefaultSecuritySystem(final EventManager eventManager,
                               final RealmSecurityManager realmSecurityManager,
                               final RealmManager realmManager,
                               final AnonymousManager anonymousManager,
                               final Map<String, AuthorizationManager> authorizationManagers,
                               final Map<String, UserManager> userManagers,
                               final SecurityHelper securityHelper); }
DefaultSecuritySystem extends StateGuardLifecycleSupport implements SecuritySystem { @Override public User addUser(User user, String password) throws NoSuchUserManagerException { UserManager userManager = getUserManager(user.getSource()); if (!userManager.supportsWrite()) { throw new RuntimeException("UserManager: " + userManager.getSource() + " does not support writing."); } userManager.addUser(user, password); for (UserManager tmpUserManager : getUserManagers()) { if (!tmpUserManager.getSource().equals(user.getSource()) && RoleMappingUserManager.class.isInstance(tmpUserManager)) { try { RoleMappingUserManager roleMappingUserManager = (RoleMappingUserManager) tmpUserManager; roleMappingUserManager.setUsersRoles( user.getUserId(), user.getSource(), RoleIdentifier.getRoleIdentifiersForSource(user.getSource(), user.getRoles()) ); } catch (UserNotFoundException e) { log.debug("User '{}' is not managed by the user-manager: {}", user.getUserId(), tmpUserManager.getSource()); } } } return user; } @Inject  DefaultSecuritySystem(final EventManager eventManager,
                               final RealmSecurityManager realmSecurityManager,
                               final RealmManager realmManager,
                               final AnonymousManager anonymousManager,
                               final Map<String, AuthorizationManager> authorizationManagers,
                               final Map<String, UserManager> userManagers,
                               final SecurityHelper securityHelper); @Override Subject getSubject(); @Override boolean isPermitted(PrincipalCollection principal, String permission); @Override boolean[] isPermitted(PrincipalCollection principal, List<String> permissions); @Override void checkPermission(PrincipalCollection principal, String permission); @Override Set<Role> listRoles(); @Override Set<Role> listRoles(String sourceId); @Override Set<Privilege> listPrivileges(); @Override User addUser(User user, String password); @Override User updateUser(User user); @Override void deleteUser(String userId); @Override void deleteUser(String userId, String source); @Override void setUsersRoles(String userId, String source, Set<RoleIdentifier> roleIdentifiers); @Override @Nullable User currentUser(); @Override User getUser(String userId); @Override User getUser(String userId, String source); @Override Set<User> listUsers(); @Override Set<User> searchUsers(UserSearchCriteria criteria); @Override AuthorizationManager getAuthorizationManager(String source); @Override void changePassword(String userId, String oldPassword, String newPassword); @Override void changePassword(String userId, String newPassword); @Override void changePassword(String userId, String newPassword, boolean clearCache); void requirePermissionToChangeUserPassword(final String userId); boolean isPermittedToChangeUserPassword(final String userId); @Override UserManager getUserManager(final String source); @Override List<String> listSources(); }
DefaultSecuritySystem extends StateGuardLifecycleSupport implements SecuritySystem { @Override public User addUser(User user, String password) throws NoSuchUserManagerException { UserManager userManager = getUserManager(user.getSource()); if (!userManager.supportsWrite()) { throw new RuntimeException("UserManager: " + userManager.getSource() + " does not support writing."); } userManager.addUser(user, password); for (UserManager tmpUserManager : getUserManagers()) { if (!tmpUserManager.getSource().equals(user.getSource()) && RoleMappingUserManager.class.isInstance(tmpUserManager)) { try { RoleMappingUserManager roleMappingUserManager = (RoleMappingUserManager) tmpUserManager; roleMappingUserManager.setUsersRoles( user.getUserId(), user.getSource(), RoleIdentifier.getRoleIdentifiersForSource(user.getSource(), user.getRoles()) ); } catch (UserNotFoundException e) { log.debug("User '{}' is not managed by the user-manager: {}", user.getUserId(), tmpUserManager.getSource()); } } } return user; } @Inject  DefaultSecuritySystem(final EventManager eventManager,
                               final RealmSecurityManager realmSecurityManager,
                               final RealmManager realmManager,
                               final AnonymousManager anonymousManager,
                               final Map<String, AuthorizationManager> authorizationManagers,
                               final Map<String, UserManager> userManagers,
                               final SecurityHelper securityHelper); @Override Subject getSubject(); @Override boolean isPermitted(PrincipalCollection principal, String permission); @Override boolean[] isPermitted(PrincipalCollection principal, List<String> permissions); @Override void checkPermission(PrincipalCollection principal, String permission); @Override Set<Role> listRoles(); @Override Set<Role> listRoles(String sourceId); @Override Set<Privilege> listPrivileges(); @Override User addUser(User user, String password); @Override User updateUser(User user); @Override void deleteUser(String userId); @Override void deleteUser(String userId, String source); @Override void setUsersRoles(String userId, String source, Set<RoleIdentifier> roleIdentifiers); @Override @Nullable User currentUser(); @Override User getUser(String userId); @Override User getUser(String userId, String source); @Override Set<User> listUsers(); @Override Set<User> searchUsers(UserSearchCriteria criteria); @Override AuthorizationManager getAuthorizationManager(String source); @Override void changePassword(String userId, String oldPassword, String newPassword); @Override void changePassword(String userId, String newPassword); @Override void changePassword(String userId, String newPassword, boolean clearCache); void requirePermissionToChangeUserPassword(final String userId); boolean isPermittedToChangeUserPassword(final String userId); @Override UserManager getUserManager(final String source); @Override List<String> listSources();  }