@Test public void reuseTokenWhenExists() throws Exception { when(apiKeyStore.getApiKey(any(), any())).thenReturn(TOKEN.toCharArray()); assertThat(underTest.createToken(principalCollection), is(equalTo(FORMAT + "." + TOKEN))); verify(apiKeyStore, never()).createApiKey(any(), any()); }
protected String createToken(final PrincipalCollection principals) { checkNotNull(principals); char[] apiKey = apiKeyStore.getApiKey(format, principals); if (apiKey != null) { return format + "." + new String(apiKey); } return format + "." + new String(apiKeyStore.createApiKey(format, principals)); }
BearerTokenManager extends ComponentSupport { protected String createToken(final PrincipalCollection principals) { checkNotNull(principals); char[] apiKey = apiKeyStore.getApiKey(format, principals); if (apiKey != null) { return format + "." + new String(apiKey); } return format + "." + new String(apiKeyStore.createApiKey(format, principals)); } }
BearerTokenManager extends ComponentSupport { protected String createToken(final PrincipalCollection principals) { checkNotNull(principals); char[] apiKey = apiKeyStore.getApiKey(format, principals); if (apiKey != null) { return format + "." + new String(apiKey); } return format + "." + new String(apiKeyStore.createApiKey(format, principals)); } @Inject  BearerTokenManager(final ApiKeyStore apiKeyStore,
                            final SecurityHelper securityHelper,
                            final String format); }
BearerTokenManager extends ComponentSupport { protected String createToken(final PrincipalCollection principals) { checkNotNull(principals); char[] apiKey = apiKeyStore.getApiKey(format, principals); if (apiKey != null) { return format + "." + new String(apiKey); } return format + "." + new String(apiKeyStore.createApiKey(format, principals)); } @Inject  BearerTokenManager(final ApiKeyStore apiKeyStore,
                            final SecurityHelper securityHelper,
                            final String format); boolean deleteToken(); }
BearerTokenManager extends ComponentSupport { protected String createToken(final PrincipalCollection principals) { checkNotNull(principals); char[] apiKey = apiKeyStore.getApiKey(format, principals); if (apiKey != null) { return format + "." + new String(apiKey); } return format + "." + new String(apiKeyStore.createApiKey(format, principals)); } @Inject  BearerTokenManager(final ApiKeyStore apiKeyStore,
                            final SecurityHelper securityHelper,
                            final String format); boolean deleteToken();  }