@Test public void testGetTokenInfoFromInvalidToken() { List<String> invalid = new ArrayList<String>(); invalid.add("/invalid"); invalid.add(UUID.randomUUID().toString()); for (String token : invalid) { TokenInfo info = tokenProvider.getTokenInfo(token); assertNull(info); } try { assertNull(tokenProvider.getTokenInfo("invalidToken")); } catch (Exception e) { } }
@Nullable @Override public TokenInfo getTokenInfo(@NotNull String token) { int pos = token.indexOf(DELIM); String nodeId = (pos == -1) ? token : token.substring(0, pos); Tree tokenTree = identifierManager.getTree(nodeId); if (isValidTokenTree(tokenTree)) { try { User user = getUser(tokenTree); if (user != null) { return new TokenInfoImpl(tokenTree, token, user.getID(), user.getPrincipal()); } } catch (RepositoryException e) { log.debug("Cannot determine userID/principal from token: {}", e.getMessage()); } } return null; }
TokenProviderImpl implements TokenProvider, TokenConstants { @Nullable @Override public TokenInfo getTokenInfo(@NotNull String token) { int pos = token.indexOf(DELIM); String nodeId = (pos == -1) ? token : token.substring(0, pos); Tree tokenTree = identifierManager.getTree(nodeId); if (isValidTokenTree(tokenTree)) { try { User user = getUser(tokenTree); if (user != null) { return new TokenInfoImpl(tokenTree, token, user.getID(), user.getPrincipal()); } } catch (RepositoryException e) { log.debug("Cannot determine userID/principal from token: {}", e.getMessage()); } } return null; } }
TokenProviderImpl implements TokenProvider, TokenConstants { @Nullable @Override public TokenInfo getTokenInfo(@NotNull String token) { int pos = token.indexOf(DELIM); String nodeId = (pos == -1) ? token : token.substring(0, pos); Tree tokenTree = identifierManager.getTree(nodeId); if (isValidTokenTree(tokenTree)) { try { User user = getUser(tokenTree); if (user != null) { return new TokenInfoImpl(tokenTree, token, user.getID(), user.getPrincipal()); } } catch (RepositoryException e) { log.debug("Cannot determine userID/principal from token: {}", e.getMessage()); } } return null; } TokenProviderImpl(@NotNull Root root, @NotNull ConfigurationParameters options, @NotNull UserConfiguration userConfiguration);   TokenProviderImpl(@NotNull Root root, @NotNull ConfigurationParameters options, @NotNull UserConfiguration userConfiguration, @NotNull CredentialsSupport credentialsSupport); }
TokenProviderImpl implements TokenProvider, TokenConstants { @Nullable @Override public TokenInfo getTokenInfo(@NotNull String token) { int pos = token.indexOf(DELIM); String nodeId = (pos == -1) ? token : token.substring(0, pos); Tree tokenTree = identifierManager.getTree(nodeId); if (isValidTokenTree(tokenTree)) { try { User user = getUser(tokenTree); if (user != null) { return new TokenInfoImpl(tokenTree, token, user.getID(), user.getPrincipal()); } } catch (RepositoryException e) { log.debug("Cannot determine userID/principal from token: {}", e.getMessage()); } } return null; } 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); }
TokenProviderImpl implements TokenProvider, TokenConstants { @Nullable @Override public TokenInfo getTokenInfo(@NotNull String token) { int pos = token.indexOf(DELIM); String nodeId = (pos == -1) ? token : token.substring(0, pos); Tree tokenTree = identifierManager.getTree(nodeId); if (isValidTokenTree(tokenTree)) { try { User user = getUser(tokenTree); if (user != null) { return new TokenInfoImpl(tokenTree, token, user.getID(), user.getPrincipal()); } } catch (RepositoryException e) { log.debug("Cannot determine userID/principal from token: {}", e.getMessage()); } } return null; } 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);  }