diff --git a/community/bolt/src/main/java/org/neo4j/bolt/security/auth/AuthUtils.java b/community/bolt/src/main/java/org/neo4j/bolt/security/auth/AuthUtils.java
deleted file mode 100644
index e544c7480ae8d..0000000000000
--- a/community/bolt/src/main/java/org/neo4j/bolt/security/auth/AuthUtils.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 2002-2016 "Neo Technology,"
- * Network Engine for Objects in Lund AB [http://neotechnology.com]
- *
- * This file is part of Neo4j.
- *
- * Neo4j is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package org.neo4j.bolt.security.auth;
-
-import java.io.ByteArrayOutputStream;
-import java.io.PrintStream;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-
-import org.neo4j.kernel.impl.store.StoreId;
-import org.neo4j.kernel.impl.util.HexPrinter;
-import org.neo4j.string.UTF8;
-
-public abstract class AuthUtils
-{
- /**
- * Returns a hash of the store id
- * @param storeId the store id to hash
- * @return a hash of the store id
- */
- public static String uniqueIdentifier( StoreId storeId )
- {
- MessageDigest messageDigest;
- try
- {
- messageDigest = MessageDigest.getInstance( "SHA-256" );
- messageDigest.update( UTF8.encode( storeId.toString() ) );
- byte[] digest = messageDigest.digest();
- ByteArrayOutputStream byteArrayStream = new ByteArrayOutputStream( digest.length );
- PrintStream stream = new PrintStream( byteArrayStream );
- new HexPrinter( stream )
- .withByteSeparator( "" )
- .withGroupSeparator( "" )
- .append( digest );
- stream.flush();
- return byteArrayStream.toString();
- }
- catch ( NoSuchAlgorithmException e )
- {
- throw new RuntimeException( "Hash algorithm is not available on this platform: " + e.getMessage(), e );
- }
- }
-}
diff --git a/community/bolt/src/main/java/org/neo4j/bolt/security/auth/AuthenticationException.java b/community/bolt/src/main/java/org/neo4j/bolt/security/auth/AuthenticationException.java
index ec5f913139d02..a4f22e32cbc9c 100644
--- a/community/bolt/src/main/java/org/neo4j/bolt/security/auth/AuthenticationException.java
+++ b/community/bolt/src/main/java/org/neo4j/bolt/security/auth/AuthenticationException.java
@@ -27,19 +27,19 @@ public class AuthenticationException extends IOException implements Status.HasSt
{
private final Status status;
- public AuthenticationException( Status status, String identifier )
+ public AuthenticationException( Status status )
{
- this(status, identifier, status.code().description(), null);
+ this( status, status.code().description(), null );
}
- public AuthenticationException( Status status, String identifier, String message )
+ public AuthenticationException( Status status, String message )
{
- this(status, identifier, message, null);
+ this( status, message, null );
}
- public AuthenticationException( Status status, String identifier, String message, Throwable e )
+ public AuthenticationException( Status status, String message, Throwable e )
{
- super(message + " (ID:" + identifier + ")" , e);
+ super( message, e );
this.status = status;
}
diff --git a/community/bolt/src/main/java/org/neo4j/bolt/security/auth/BasicAuthentication.java b/community/bolt/src/main/java/org/neo4j/bolt/security/auth/BasicAuthentication.java
index 797e5c1b3e3de..64934807e4f7c 100644
--- a/community/bolt/src/main/java/org/neo4j/bolt/security/auth/BasicAuthentication.java
+++ b/community/bolt/src/main/java/org/neo4j/bolt/security/auth/BasicAuthentication.java
@@ -21,7 +21,6 @@
import java.io.IOException;
import java.util.Map;
-import java.util.function.Supplier;
import org.neo4j.graphdb.security.AuthorizationViolationException;
import org.neo4j.kernel.api.exceptions.Status;
@@ -39,15 +38,12 @@ public class BasicAuthentication implements Authentication
private final BasicAuthManager authManager;
private final static String SCHEME = "basic";
private final Log log;
- private final Supplier identifier;
private AuthSubject authSubject;
-
- public BasicAuthentication( BasicAuthManager authManager, LogProvider logProvider, Supplier identifier )
+ public BasicAuthentication( BasicAuthManager authManager, LogProvider logProvider)
{
this.authManager = authManager;
this.log = logProvider.getLog( getClass() );
- this.identifier = identifier;
}
@Override
@@ -55,7 +51,7 @@ public AuthenticationResult authenticate( Map authToken ) throws
{
if ( !SCHEME.equals( authToken.get( SCHEME_KEY ) ) )
{
- throw new AuthenticationException( Status.Security.Unauthorized, identifier.get(),
+ throw new AuthenticationException( Status.Security.Unauthorized,
"Authentication token must contain: '" + SCHEME_KEY + " : " + SCHEME + "'" );
}
@@ -83,10 +79,10 @@ private AuthenticationResult authenticate( String user, String password ) throws
credentialsExpired = true;
break;
case TOO_MANY_ATTEMPTS:
- throw new AuthenticationException( Status.Security.AuthenticationRateLimit, identifier.get() );
+ throw new AuthenticationException( Status.Security.AuthenticationRateLimit);
default:
log.warn( "Failed authentication attempt for '%s'", user);
- throw new AuthenticationException( Status.Security.Unauthorized, identifier.get() );
+ throw new AuthenticationException( Status.Security.Unauthorized);
}
return new BasicAuthenticationResult( authSubject, credentialsExpired );
}
@@ -106,19 +102,19 @@ private AuthenticationResult update( String user, String password, String newPas
}
catch ( AuthorizationViolationException e )
{
- throw new AuthenticationException( Status.Security.Forbidden, identifier.get(), e.getMessage(), e );
+ throw new AuthenticationException( Status.Security.Forbidden, e.getMessage(), e );
}
catch ( IOException e )
{
- throw new AuthenticationException( Status.Security.Unauthorized, identifier.get(), e.getMessage(), e );
+ throw new AuthenticationException( Status.Security.Unauthorized, e.getMessage(), e );
}
catch ( IllegalCredentialsException e )
{
- throw new AuthenticationException(e.status(), identifier.get(), e.getMessage(), e );
+ throw new AuthenticationException(e.status(), e.getMessage(), e );
}
break;
default:
- throw new AuthenticationException( Status.Security.Unauthorized, identifier.get() );
+ throw new AuthenticationException( Status.Security.Unauthorized );
}
return new BasicAuthenticationResult( authSubject, false );
}
@@ -128,7 +124,7 @@ private String safeCast( String key, Map authToken ) throws Authe
Object value = authToken.get( key );
if ( value == null || !(value instanceof String) )
{
- throw new AuthenticationException( Status.Security.Unauthorized, identifier.get(),
+ throw new AuthenticationException( Status.Security.Unauthorized,
"The value associated with the key `" + key + "` must be a String but was: " +
(value == null ? "null" : value.getClass().getSimpleName()));
}
diff --git a/community/bolt/src/main/java/org/neo4j/bolt/v1/runtime/internal/StandardSessions.java b/community/bolt/src/main/java/org/neo4j/bolt/v1/runtime/internal/StandardSessions.java
index d5a69dd4f627e..81b09c5d51615 100644
--- a/community/bolt/src/main/java/org/neo4j/bolt/v1/runtime/internal/StandardSessions.java
+++ b/community/bolt/src/main/java/org/neo4j/bolt/v1/runtime/internal/StandardSessions.java
@@ -19,22 +19,17 @@
*/
package org.neo4j.bolt.v1.runtime.internal;
-import java.util.function.Supplier;
-
-import org.neo4j.bolt.security.auth.AuthUtils;
import org.neo4j.bolt.security.auth.Authentication;
import org.neo4j.bolt.security.auth.BasicAuthentication;
import org.neo4j.bolt.v1.runtime.Session;
import org.neo4j.bolt.v1.runtime.Sessions;
import org.neo4j.graphdb.DependencyResolver;
import org.neo4j.graphdb.factory.GraphDatabaseSettings;
-import org.neo4j.kernel.NeoStoreDataSource;
import org.neo4j.kernel.configuration.Config;
import org.neo4j.kernel.impl.core.ThreadToStatementContextBridge;
import org.neo4j.kernel.impl.factory.GraphDatabaseFacade;
import org.neo4j.kernel.impl.logging.LogService;
import org.neo4j.kernel.impl.query.QueryExecutionEngine;
-import org.neo4j.kernel.impl.store.StoreId;
import org.neo4j.kernel.lifecycle.LifeSupport;
import org.neo4j.kernel.lifecycle.LifecycleAdapter;
import org.neo4j.server.security.auth.BasicAuthManager;
@@ -106,11 +101,7 @@ private Authentication authentication( DependencyResolver dependencyResolver )
if ( config.get( GraphDatabaseSettings.auth_enabled ) )
{
- Supplier identifier = () -> {
- StoreId storeId = dependencyResolver.resolveDependency( NeoStoreDataSource.class ).getStoreId();
- return AuthUtils.uniqueIdentifier( storeId );
- };
- return new BasicAuthentication( dependencyResolver.resolveDependency( BasicAuthManager.class ), logging.getUserLogProvider(), identifier );
+ return new BasicAuthentication( dependencyResolver.resolveDependency( BasicAuthManager.class ), logging.getUserLogProvider());
}
else
{
diff --git a/community/bolt/src/test/java/org/neo4j/bolt/security/auth/BasicAuthenticationTest.java b/community/bolt/src/test/java/org/neo4j/bolt/security/auth/BasicAuthenticationTest.java
index b9f8a56d6e748..a4e67ed51b1d6 100644
--- a/community/bolt/src/test/java/org/neo4j/bolt/security/auth/BasicAuthenticationTest.java
+++ b/community/bolt/src/test/java/org/neo4j/bolt/security/auth/BasicAuthenticationTest.java
@@ -26,8 +26,6 @@
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import java.util.function.Supplier;
-
import org.neo4j.kernel.api.exceptions.Status;
import org.neo4j.logging.Log;
import org.neo4j.logging.LogProvider;
@@ -47,7 +45,6 @@ public class BasicAuthenticationTest
@Rule
public ExpectedException exception = ExpectedException.none();
- private final Supplier identifier = () -> "UNIQUE";
@Test
public void shouldNotDoAnythingOnSuccess() throws AuthenticationException
@@ -55,7 +52,7 @@ public void shouldNotDoAnythingOnSuccess() throws AuthenticationException
// Given
BasicAuthManager manager = mock( BasicAuthManager.class );
BasicAuthSubject authSubject = mock( BasicAuthSubject.class );
- BasicAuthentication authentication = new BasicAuthentication( manager, mock( LogProvider.class ), identifier );
+ BasicAuthentication authentication = new BasicAuthentication( manager, mock( LogProvider.class ) );
when( manager.login( anyString(), anyString() ) ).thenReturn( authSubject );
when( authSubject.getAuthenticationResult() ).thenReturn( AuthenticationResult.SUCCESS );
@@ -74,7 +71,7 @@ public void shouldThrowAndLogOnFailure() throws AuthenticationException
Log log = mock( Log.class );
LogProvider logProvider = mock( LogProvider.class );
when( logProvider.getLog( BasicAuthentication.class ) ).thenReturn( log );
- BasicAuthentication authentication = new BasicAuthentication( manager, logProvider, identifier );
+ BasicAuthentication authentication = new BasicAuthentication( manager, logProvider );
when( manager.login( anyString(), anyString() ) ).thenReturn( authSubject );
when( authSubject.getAuthenticationResult() ).thenReturn( AuthenticationResult.FAILURE );
@@ -96,7 +93,7 @@ public void shouldIndicateThatCredentialsExpired() throws AuthenticationExceptio
// Given
BasicAuthManager manager = mock( BasicAuthManager.class );
BasicAuthSubject authSubject = mock( BasicAuthSubject.class );
- BasicAuthentication authentication = new BasicAuthentication( manager, mock( LogProvider.class ), identifier );
+ BasicAuthentication authentication = new BasicAuthentication( manager, mock( LogProvider.class ) );
when( manager.login( anyString(), anyString() ) ).thenReturn( authSubject );
when( authSubject.getAuthenticationResult() ).thenReturn( AuthenticationResult.PASSWORD_CHANGE_REQUIRED );
@@ -116,7 +113,7 @@ public void shouldFailWhenTooManyAttempts() throws AuthenticationException
// Given
BasicAuthManager manager = mock( BasicAuthManager.class );
BasicAuthSubject authSubject = mock( BasicAuthSubject.class );
- BasicAuthentication authentication = new BasicAuthentication( manager, mock( LogProvider.class ), identifier );
+ BasicAuthentication authentication = new BasicAuthentication( manager, mock( LogProvider.class ) );
when( manager.login( anyString(), anyString() ) ).thenReturn( authSubject );
when( authSubject.getAuthenticationResult() ).thenReturn( AuthenticationResult.TOO_MANY_ATTEMPTS );
@@ -135,7 +132,7 @@ public void shouldBeAbleToUpdateCredentials() throws AuthenticationException
// Given
BasicAuthManager manager = mock( BasicAuthManager.class );
BasicAuthSubject authSubject = mock( BasicAuthSubject.class );
- BasicAuthentication authentication = new BasicAuthentication( manager, mock( LogProvider.class ), identifier );
+ BasicAuthentication authentication = new BasicAuthentication( manager, mock( LogProvider.class ) );
when( manager.login( anyString(), anyString() ) ).thenReturn( authSubject );
when( authSubject.getAuthenticationResult() ).thenReturn( AuthenticationResult.SUCCESS );
@@ -152,7 +149,7 @@ public void shouldBeAbleToUpdateExpiredCredentials() throws AuthenticationExcept
// Given
BasicAuthManager manager = mock( BasicAuthManager.class );
BasicAuthSubject authSubject = mock( BasicAuthSubject.class );
- BasicAuthentication authentication = new BasicAuthentication( manager, mock( LogProvider.class ), identifier );
+ BasicAuthentication authentication = new BasicAuthentication( manager, mock( LogProvider.class ) );
when( manager.login( anyString(), anyString() ) ).thenReturn( authSubject );
when( authSubject.getAuthenticationResult() ).thenReturn( AuthenticationResult.PASSWORD_CHANGE_REQUIRED );
@@ -169,7 +166,7 @@ public void shouldNotBeAbleToUpdateCredentialsIfOldCredentialsAreInvalid() throw
// Given
BasicAuthManager manager = mock( BasicAuthManager.class );
BasicAuthSubject authSubject = mock( BasicAuthSubject.class );
- BasicAuthentication authentication = new BasicAuthentication( manager, mock( LogProvider.class ), identifier );
+ BasicAuthentication authentication = new BasicAuthentication( manager, mock( LogProvider.class ) );
when( manager.login( anyString(), anyString() ) ).thenReturn( authSubject );
when( authSubject.getAuthenticationResult() ).thenReturn( AuthenticationResult.FAILURE );
@@ -190,7 +187,7 @@ public void shouldFailOnUnknownScheme() throws AuthenticationException
// Given
BasicAuthManager manager = mock( BasicAuthManager.class );
BasicAuthSubject authSubject = mock( BasicAuthSubject.class );
- BasicAuthentication authentication = new BasicAuthentication( manager, mock( LogProvider.class ), identifier );
+ BasicAuthentication authentication = new BasicAuthentication( manager, mock( LogProvider.class ) );
when( manager.login( anyString(), anyString() ) ).thenReturn( authSubject );
when( authSubject.getAuthenticationResult() ).thenReturn( AuthenticationResult.SUCCESS );
@@ -209,7 +206,7 @@ public void shouldFailOnMalformedToken() throws AuthenticationException
// Given
BasicAuthManager manager = mock( BasicAuthManager.class );
BasicAuthSubject authSubject = mock( BasicAuthSubject.class );
- BasicAuthentication authentication = new BasicAuthentication( manager, mock( LogProvider.class ), identifier );
+ BasicAuthentication authentication = new BasicAuthentication( manager, mock( LogProvider.class ) );
when( manager.login( anyString(), anyString() ) ).thenReturn( authSubject );
when( authSubject.getAuthenticationResult() ).thenReturn( AuthenticationResult.SUCCESS );
diff --git a/community/bolt/src/test/java/org/neo4j/bolt/v1/transport/integration/AuthenticationIT.java b/community/bolt/src/test/java/org/neo4j/bolt/v1/transport/integration/AuthenticationIT.java
index b448629db4ab1..0c6da3a069c83 100644
--- a/community/bolt/src/test/java/org/neo4j/bolt/v1/transport/integration/AuthenticationIT.java
+++ b/community/bolt/src/test/java/org/neo4j/bolt/v1/transport/integration/AuthenticationIT.java
@@ -117,7 +117,7 @@ public void shouldFailIfWrongCredentials() throws Throwable
// Then
assertThat( client, eventuallyRecieves( new byte[]{0, 0, 0, 1} ) );
assertThat( client, eventuallyRecieves( msgFailure( Status.Security.Unauthorized,
- String.format( "The client is unauthorized due to authentication failure. (ID:%s)", server.uniqueIdentier()) ) ) );
+ "The client is unauthorized due to authentication failure." ) ) );
}
@Test
@@ -143,7 +143,7 @@ public void shouldBeAbleToUpdateCredentials() throws Throwable
map( "principal", "neo4j", "credentials", "neo4j", "scheme", "basic" ) ) ) );
assertThat( client, eventuallyRecieves( new byte[]{0, 0, 0, 1} ) );
assertThat( client, eventuallyRecieves( msgFailure( Status.Security.Unauthorized,
- String.format( "The client is unauthorized due to authentication failure. (ID:%s)", server.uniqueIdentier()) ) ) );
+ "The client is unauthorized due to authentication failure." ) ) );
// But the new password works fine
reconnect();
@@ -188,7 +188,7 @@ public void shouldBeAbleToChangePasswordUsingBuiltInProcedure() throws Throwable
map( "principal", "neo4j", "credentials", "neo4j", "scheme", "basic" ) ) ) );
assertThat( client, eventuallyRecieves( new byte[]{0, 0, 0, 1} ) );
assertThat( client, eventuallyRecieves( msgFailure( Status.Security.Unauthorized,
- String.format( "The client is unauthorized due to authentication failure. (ID:%s)", server.uniqueIdentier()) ) ) );
+ "The client is unauthorized due to authentication failure." ) ) );
// But the new password works fine
reconnect();
diff --git a/community/bolt/src/test/java/org/neo4j/bolt/v1/transport/integration/Neo4jWithSocket.java b/community/bolt/src/test/java/org/neo4j/bolt/v1/transport/integration/Neo4jWithSocket.java
index fe7cff0c903e8..981869033219f 100644
--- a/community/bolt/src/test/java/org/neo4j/bolt/v1/transport/integration/Neo4jWithSocket.java
+++ b/community/bolt/src/test/java/org/neo4j/bolt/v1/transport/integration/Neo4jWithSocket.java
@@ -31,7 +31,6 @@
import java.util.function.Consumer;
import org.neo4j.bolt.BoltKernelExtension;
-import org.neo4j.bolt.security.auth.AuthUtils;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.config.Setting;
import org.neo4j.kernel.impl.factory.GraphDatabaseFacade;
@@ -56,12 +55,6 @@ public Neo4jWithSocket( Consumer