TokenProviderImpl implements TokenProvider, TokenConstants { @Override public boolean doCreateToken(@NotNull Credentials credentials) { Credentials creds = extractCredentials(credentials); if (creds == null) { return false; } else { Object attr = credentialsSupport.getAttributes(creds).get(TOKEN_ATTRIBUTE); return (attr != null && attr.toString().isEmpty()); } } TokenProviderImpl(@NotNull Root root, @NotNull ConfigurationParameters options, @NotNull UserConfiguration userConfiguration);   TokenProviderImpl(@NotNull Root root, @NotNull ConfigurationParameters options, @NotNull UserConfiguration userConfiguration, @NotNull CredentialsSupport credentialsSupport); @Override boolean doCreateToken(@NotNull Credentials credentials); @Nullable @Override TokenInfo createToken(@NotNull Credentials credentials); @Nullable @Override TokenInfo createToken(@NotNull String userId, @NotNull Map<String, ?> attributes); @Nullable @Override TokenInfo getTokenInfo(@NotNull String token);  }
@Test public void testDoCreateToken() throws Exception { assertFalse(tokenProvider.doCreateToken(new GuestCredentials())); assertFalse(tokenProvider.doCreateToken(new TokenCredentials("token"))); assertFalse(tokenProvider.doCreateToken(getAdminCredentials())); SimpleCredentials sc = new SimpleCredentials("uid", "pw".toCharArray()); assertFalse(tokenProvider.doCreateToken(sc)); sc.setAttribute("any_attribute", "value"); assertFalse(tokenProvider.doCreateToken(sc)); sc.setAttribute("rep:token_key", "value"); assertFalse(tokenProvider.doCreateToken(sc)); sc.setAttribute(".token", "existing"); assertFalse(tokenProvider.doCreateToken(sc)); sc.setAttribute(".token", ""); assertTrue(tokenProvider.doCreateToken(sc)); }