use of org.apache.knox.gateway.util.Tokens in project knox by apache.
the class DefaultTokenStateService method getTokens.
@Override
public Collection<KnoxToken> getTokens(String userName) {
final Collection<KnoxToken> tokens = new TreeSet<>();
metadataMap.entrySet().stream().filter(entry -> entry.getValue().getUserName().equals(userName)).forEach(metadata -> {
String tokenId = metadata.getKey();
try {
tokens.add(new KnoxToken(tokenId, getTokenIssueTime(tokenId), getTokenExpiration(tokenId), getMaxLifetime(tokenId), metadata.getValue()));
} catch (UnknownTokenException e) {
// NOP: since this is coming from memory the only reason an UTE is thrown that the token got removed/revoked.
// In that case we would not want to return it anyway
}
});
return tokens;
}
Aggregations