@Test public void testSetupNoHmacSecret() { final HMACAuthenticator authenticator = new HMACAuthenticator(); final Map<String, Object> configMap = new HashMap<>(); configMap.put(CONFIG_CREDENTIALS_DB, "configCredDb"); assertThrows(IllegalStateException.class, () -> authenticator.setup(configMap)); }
public void setup(final Map<String,Object> config) { Preconditions.checkArgument(config != null, "Credential configuration cannot be null"); Preconditions.checkState(config.containsKey(CONFIG_HMAC_SECRET), String.format("Credential configuration missing the %s key", CONFIG_HMAC_SECRET)); if (config.containsKey(CONFIG_HMAC_ALGO)) { hmacAlgo = config.get(CONFIG_HMAC_ALGO).toString(); } else { hmacAlgo = DEFAULT_HMAC_ALGO; } if (config.containsKey(CONFIG_TOKEN_TIMEOUT)) { timeout = ((Number) config.get(CONFIG_TOKEN_TIMEOUT)).longValue(); } else { timeout = DEFAULT_HMAC_TOKEN_TIMEOUT; } super.setup(config); secret = config.containsKey(CONFIG_HMAC_SECRET) ? config.get(CONFIG_HMAC_SECRET).toString().toCharArray() : DEFAULT_HMAC_SECRET; }
HMACAuthenticator extends JanusGraphAbstractAuthenticator { public void setup(final Map<String,Object> config) { Preconditions.checkArgument(config != null, "Credential configuration cannot be null"); Preconditions.checkState(config.containsKey(CONFIG_HMAC_SECRET), String.format("Credential configuration missing the %s key", CONFIG_HMAC_SECRET)); if (config.containsKey(CONFIG_HMAC_ALGO)) { hmacAlgo = config.get(CONFIG_HMAC_ALGO).toString(); } else { hmacAlgo = DEFAULT_HMAC_ALGO; } if (config.containsKey(CONFIG_TOKEN_TIMEOUT)) { timeout = ((Number) config.get(CONFIG_TOKEN_TIMEOUT)).longValue(); } else { timeout = DEFAULT_HMAC_TOKEN_TIMEOUT; } super.setup(config); secret = config.containsKey(CONFIG_HMAC_SECRET) ? config.get(CONFIG_HMAC_SECRET).toString().toCharArray() : DEFAULT_HMAC_SECRET; } }
HMACAuthenticator extends JanusGraphAbstractAuthenticator { public void setup(final Map<String,Object> config) { Preconditions.checkArgument(config != null, "Credential configuration cannot be null"); Preconditions.checkState(config.containsKey(CONFIG_HMAC_SECRET), String.format("Credential configuration missing the %s key", CONFIG_HMAC_SECRET)); if (config.containsKey(CONFIG_HMAC_ALGO)) { hmacAlgo = config.get(CONFIG_HMAC_ALGO).toString(); } else { hmacAlgo = DEFAULT_HMAC_ALGO; } if (config.containsKey(CONFIG_TOKEN_TIMEOUT)) { timeout = ((Number) config.get(CONFIG_TOKEN_TIMEOUT)).longValue(); } else { timeout = DEFAULT_HMAC_TOKEN_TIMEOUT; } super.setup(config); secret = config.containsKey(CONFIG_HMAC_SECRET) ? config.get(CONFIG_HMAC_SECRET).toString().toCharArray() : DEFAULT_HMAC_SECRET; }  }
HMACAuthenticator extends JanusGraphAbstractAuthenticator { public void setup(final Map<String,Object> config) { Preconditions.checkArgument(config != null, "Credential configuration cannot be null"); Preconditions.checkState(config.containsKey(CONFIG_HMAC_SECRET), String.format("Credential configuration missing the %s key", CONFIG_HMAC_SECRET)); if (config.containsKey(CONFIG_HMAC_ALGO)) { hmacAlgo = config.get(CONFIG_HMAC_ALGO).toString(); } else { hmacAlgo = DEFAULT_HMAC_ALGO; } if (config.containsKey(CONFIG_TOKEN_TIMEOUT)) { timeout = ((Number) config.get(CONFIG_TOKEN_TIMEOUT)).longValue(); } else { timeout = DEFAULT_HMAC_TOKEN_TIMEOUT; } super.setup(config); secret = config.containsKey(CONFIG_HMAC_SECRET) ? config.get(CONFIG_HMAC_SECRET).toString().toCharArray() : DEFAULT_HMAC_SECRET; }  @Override boolean requireAuthentication(); @Override SaslNegotiator newSaslNegotiator(final InetAddress remoteAddress); SaslNegotiator newSaslNegotiator(); void setup(final Map<String,Object> config); @Override AuthenticatedUser authenticate(final Map<String, String> credentials); }
HMACAuthenticator extends JanusGraphAbstractAuthenticator { public void setup(final Map<String,Object> config) { Preconditions.checkArgument(config != null, "Credential configuration cannot be null"); Preconditions.checkState(config.containsKey(CONFIG_HMAC_SECRET), String.format("Credential configuration missing the %s key", CONFIG_HMAC_SECRET)); if (config.containsKey(CONFIG_HMAC_ALGO)) { hmacAlgo = config.get(CONFIG_HMAC_ALGO).toString(); } else { hmacAlgo = DEFAULT_HMAC_ALGO; } if (config.containsKey(CONFIG_TOKEN_TIMEOUT)) { timeout = ((Number) config.get(CONFIG_TOKEN_TIMEOUT)).longValue(); } else { timeout = DEFAULT_HMAC_TOKEN_TIMEOUT; } super.setup(config); secret = config.containsKey(CONFIG_HMAC_SECRET) ? config.get(CONFIG_HMAC_SECRET).toString().toCharArray() : DEFAULT_HMAC_SECRET; }  @Override boolean requireAuthentication(); @Override SaslNegotiator newSaslNegotiator(final InetAddress remoteAddress); SaslNegotiator newSaslNegotiator(); void setup(final Map<String,Object> config); @Override AuthenticatedUser authenticate(final Map<String, String> credentials); static final String CONFIG_HMAC_ALGO; static final String CONFIG_TOKEN_TIMEOUT; static final String CONFIG_HMAC_SECRET; }