SimpleAuthenticator implements Authenticator { @Override public void setup(final Map<String,Object> config) { logger.info("Initializing authentication with the {}", SimpleAuthenticator.class.getName()); if (null == config) { throw new IllegalArgumentException(String.format( "Could not configure a %s - provide a 'config' in the 'authentication' settings", SimpleAuthenticator.class.getName())); } if (!config.containsKey(CONFIG_CREDENTIALS_DB)) { throw new IllegalStateException(String.format( "Credentials configuration missing the %s key that points to a graph config file", CONFIG_CREDENTIALS_DB)); } final Graph graph = GraphFactory.open((String) config.get(CONFIG_CREDENTIALS_DB)); if (graph instanceof TinkerGraph) { final TinkerGraph tinkerGraph = (TinkerGraph) graph; tinkerGraph.createIndex(PROPERTY_USERNAME, Vertex.class); } credentialStore = graph.traversal(CredentialTraversalSource.class); logger.info("CredentialGraph initialized at {}", credentialStore); }  @Override boolean requireAuthentication(); @Override void setup(final Map<String,Object> config); @Override SaslNegotiator newSaslNegotiator(final InetAddress remoteAddress); AuthenticatedUser authenticate(final Map<String, String> credentials); static final String CONFIG_CREDENTIALS_DB; }
@Test(expected = IllegalArgumentException.class) public void shouldNotAllowNullConfigInSetup() { authenticator.setup(null); }