diff --git a/enterprise/security/src/main/java/org/neo4j/server/security/enterprise/auth/EnterpriseUserManager.java b/enterprise/security/src/main/java/org/neo4j/server/security/enterprise/auth/EnterpriseUserManager.java index d27cb7f24643..caf489d91d68 100644 --- a/enterprise/security/src/main/java/org/neo4j/server/security/enterprise/auth/EnterpriseUserManager.java +++ b/enterprise/security/src/main/java/org/neo4j/server/security/enterprise/auth/EnterpriseUserManager.java @@ -37,13 +37,11 @@ public interface EnterpriseUserManager extends UserManager void activateUser( String username, boolean requirePasswordChange ) throws IOException, InvalidArgumentsException; - RoleRecord newRole( String roleName, String... usernames ) throws IOException, InvalidArgumentsException; + void newRole( String roleName, String... usernames ) throws IOException, InvalidArgumentsException; boolean deleteRole( String roleName ) throws IOException, InvalidArgumentsException; - RoleRecord getRole( String roleName ) throws InvalidArgumentsException; - - RoleRecord silentlyGetRole( String roleName ); + void assertRoleExists( String roleName ) throws InvalidArgumentsException; /** * Assign a role to a user. The role and the user have to exist. @@ -88,9 +86,8 @@ public void activateUser( String username, boolean requirePasswordChange ) } @Override - public RoleRecord newRole( String roleName, String... usernames ) + public void newRole( String roleName, String... usernames ) { - return null; } @Override @@ -100,15 +97,8 @@ public boolean deleteRole( String roleName ) } @Override - public RoleRecord getRole( String roleName ) - { - return null; - } - - @Override - public RoleRecord silentlyGetRole( String roleName ) + public void assertRoleExists( String roleName ) { - return null; } @Override diff --git a/enterprise/security/src/main/java/org/neo4j/server/security/enterprise/auth/InternalFlatFileRealm.java b/enterprise/security/src/main/java/org/neo4j/server/security/enterprise/auth/InternalFlatFileRealm.java index 320c517c1911..ae6fbe38d71a 100644 --- a/enterprise/security/src/main/java/org/neo4j/server/security/enterprise/auth/InternalFlatFileRealm.java +++ b/enterprise/security/src/main/java/org/neo4j/server/security/enterprise/auth/InternalFlatFileRealm.java @@ -467,7 +467,7 @@ public User newUser( String username, String initialPassword, boolean requirePas } @Override - public RoleRecord newRole( String roleName, String... usernames ) throws IOException, InvalidArgumentsException + public void newRole( String roleName, String... usernames ) throws IOException, InvalidArgumentsException { roleRepository.assertValidRoleName( roleName ); for ( String username : usernames ) @@ -486,8 +486,6 @@ public RoleRecord newRole( String roleName, String... usernames ) throws IOExcep } roleRepository.create( role ); } - - return role; } @Override @@ -506,14 +504,13 @@ public boolean deleteRole( String roleName ) throws IOException, InvalidArgument else { // We should not get here, but if we do the assert will fail and give a nice error msg - getRole( roleName ); + assertRoleExists( roleName ); } } return result; } - @Override - public RoleRecord getRole( String roleName ) throws InvalidArgumentsException + private RoleRecord getRole( String roleName ) throws InvalidArgumentsException { RoleRecord role = roleRepository.getRoleByName( roleName ); if ( role == null ) @@ -524,7 +521,12 @@ public RoleRecord getRole( String roleName ) throws InvalidArgumentsException } @Override - public RoleRecord silentlyGetRole( String roleName ) + public void assertRoleExists( String roleName ) throws InvalidArgumentsException + { + getRole( roleName ); + } + + private RoleRecord silentlyGetRole( String roleName ) { return roleRepository.getRoleByName( roleName ); } diff --git a/enterprise/security/src/main/java/org/neo4j/server/security/enterprise/auth/PersonalUserManager.java b/enterprise/security/src/main/java/org/neo4j/server/security/enterprise/auth/PersonalUserManager.java index 86be3c3b71ab..413031ce3f47 100644 --- a/enterprise/security/src/main/java/org/neo4j/server/security/enterprise/auth/PersonalUserManager.java +++ b/enterprise/security/src/main/java/org/neo4j/server/security/enterprise/auth/PersonalUserManager.java @@ -146,15 +146,14 @@ public User silentlyGetUser( String username ) } @Override - public RoleRecord newRole( String roleName, String... usernames ) + public void newRole( String roleName, String... usernames ) throws IOException, InvalidArgumentsException, AuthorizationViolationException { try { assertUserManager(); - RoleRecord newRole = userManager.newRole( roleName, usernames ); + userManager.newRole( roleName, usernames ); securityLog.info( subject, "created role `%s`", roleName ); - return newRole; } catch ( AuthorizationViolationException | IOException | InvalidArgumentsException e ) { @@ -233,15 +232,9 @@ public Set getAllUsernames() throws AuthorizationViolationException } @Override - public RoleRecord getRole( String roleName ) throws InvalidArgumentsException + public void assertRoleExists( String roleName ) throws InvalidArgumentsException { - return userManager.getRole( roleName ); - } - - @Override - public RoleRecord silentlyGetRole( String roleName ) - { - return userManager.silentlyGetRole( roleName ); + userManager.assertRoleExists( roleName ); } @Override diff --git a/enterprise/security/src/test/java/org/neo4j/server/security/enterprise/auth/AuthProceduresInteractionTestBase.java b/enterprise/security/src/test/java/org/neo4j/server/security/enterprise/auth/AuthProceduresInteractionTestBase.java index 8b1f00575f5c..b8bddaf40cda 100644 --- a/enterprise/security/src/test/java/org/neo4j/server/security/enterprise/auth/AuthProceduresInteractionTestBase.java +++ b/enterprise/security/src/test/java/org/neo4j/server/security/enterprise/auth/AuthProceduresInteractionTestBase.java @@ -596,7 +596,7 @@ public void shouldAllowAddingAndRemovingUserFromMultipleRoles() throws Exception public void shouldCreateRole() throws Exception { assertEmpty( adminSubject, "CALL dbms.security.createRole('new_role')" ); - userManager.getRole( "new_role" ); + userManager.assertRoleExists( "new_role" ); } @Test diff --git a/enterprise/security/src/test/java/org/neo4j/server/security/enterprise/auth/PersonalUserManagerTest.java b/enterprise/security/src/test/java/org/neo4j/server/security/enterprise/auth/PersonalUserManagerTest.java index 5387694ba5db..deb6faccf4ec 100644 --- a/enterprise/security/src/test/java/org/neo4j/server/security/enterprise/auth/PersonalUserManagerTest.java +++ b/enterprise/security/src/test/java/org/neo4j/server/security/enterprise/auth/PersonalUserManagerTest.java @@ -184,14 +184,14 @@ public void activateUser( String username, boolean requirePasswordChange ) } @Override - public RoleRecord newRole( String roleName, String... usernames ) throws IOException, InvalidArgumentsException + public void newRole( String roleName, String... usernames ) throws IOException, InvalidArgumentsException { if ( failNextCall ) { failNextCall = false; throw new IOException( "newRoleException" ); } - return delegate.newRole( roleName, usernames ); + delegate.newRole( roleName, usernames ); } @Override @@ -206,20 +206,14 @@ public boolean deleteRole( String roleName ) throws IOException, InvalidArgument } @Override - public RoleRecord getRole( String roleName ) throws InvalidArgumentsException + public void assertRoleExists( String roleName ) throws InvalidArgumentsException { if ( failNextCall ) { failNextCall = false; throw new InvalidArgumentsException( "getRoleException" ); } - return delegate.getRole( roleName ); - } - - @Override - public RoleRecord silentlyGetRole( String roleName ) - { - return delegate.silentlyGetRole( roleName ); + delegate.assertRoleExists( roleName ); } @Override