Search in sources :

Example 6 with SecureHasher

use of org.neo4j.cypher.internal.security.SecureHasher in project neo4j by neo4j.

the class BasicAuthenticationTest method createAuthentication.

private static Authentication createAuthentication(int maxFailedAttempts) throws Exception {
    Config config = Config.defaults(GraphDatabaseSettings.auth_max_failed_attempts, maxFailedAttempts);
    SystemGraphRealmHelper realmHelper = spy(new SystemGraphRealmHelper(null, new SecureHasher()));
    BasicSystemGraphRealm realm = new BasicSystemGraphRealm(realmHelper, new RateLimitedAuthenticationStrategy(Clocks.systemClock(), config));
    Authentication authentication = new BasicAuthentication(realm);
    doReturn(new User.Builder("bob", credentialFor("secret")).withRequiredPasswordChange(true).build()).when(realmHelper).getUser("bob");
    doReturn(new User.Builder("mike", credentialFor("secret2")).build()).when(realmHelper).getUser("mike");
    return authentication;
}
Also used : RateLimitedAuthenticationStrategy(org.neo4j.server.security.auth.RateLimitedAuthenticationStrategy) User(org.neo4j.kernel.impl.security.User) Config(org.neo4j.configuration.Config) SecureHasher(org.neo4j.cypher.internal.security.SecureHasher) BasicSystemGraphRealm(org.neo4j.server.security.systemgraph.BasicSystemGraphRealm) SystemGraphRealmHelper(org.neo4j.server.security.systemgraph.SystemGraphRealmHelper)

Aggregations

SecureHasher (org.neo4j.cypher.internal.security.SecureHasher)6 SystemGraphRealmHelper (org.neo4j.server.security.systemgraph.SystemGraphRealmHelper)5 BasicSystemGraphRealm (org.neo4j.server.security.systemgraph.BasicSystemGraphRealm)4 BeforeEach (org.junit.jupiter.api.BeforeEach)3 User (org.neo4j.kernel.impl.security.User)2 Config (org.neo4j.configuration.Config)1 FormatException (org.neo4j.cypher.internal.security.FormatException)1 DatabaseManager (org.neo4j.dbms.database.DatabaseManager)1 InvalidArgumentException (org.neo4j.exceptions.InvalidArgumentException)1 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)1 GlobalProcedures (org.neo4j.kernel.api.procedure.GlobalProcedures)1 InMemoryUserRepository (org.neo4j.server.security.auth.InMemoryUserRepository)1 RateLimitedAuthenticationStrategy (org.neo4j.server.security.auth.RateLimitedAuthenticationStrategy)1 HexString (org.neo4j.string.HexString)1