Interface TokenProvider
- All Known Implementing Classes:
CompositeTokenProvider
public interface TokenProvider
Interface to manage create and manage login tokens.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Optional configuration parameter to set the token expiration time in ms.static final String
Optional configuration parameter to define the length of the key.static final String
Optional configuration parameter to define if a given token should be refreshed or not. -
Method Summary
Modifier and TypeMethodDescription@Nullable TokenInfo
createToken
(@NotNull String userId, @NotNull Map<String, ?> attributes) Issues a new login token for the user with the givenuserId
and the specified attributes.@Nullable TokenInfo
createToken
(@NotNull Credentials credentials) Issues a new login token for the user with the specified credentials and returns the associatedTokenInfo
.boolean
doCreateToken
(@NotNull Credentials credentials) Returnstrue
if the given credentials indicate that a new token needs to be issued.@Nullable TokenInfo
getTokenInfo
(@NotNull String token) Retrieves theTokenInfo
associated with the specified login token ornull
.
-
Field Details
-
PARAM_TOKEN_EXPIRATION
Optional configuration parameter to set the token expiration time in ms. Implementations that do not support this option will ignore any config options with that name.- See Also:
-
PARAM_TOKEN_LENGTH
Optional configuration parameter to define the length of the key. Implementations that do not support this option will ignore any config options with that name.- See Also:
-
PARAM_TOKEN_REFRESH
Optional configuration parameter to define if a given token should be refreshed or not. Implementations that do not support this option will ignore any config options with that name.- See Also:
-
-
Method Details
-
doCreateToken
Returnstrue
if the given credentials indicate that a new token needs to be issued.- Parameters:
credentials
- The current credentials.- Returns:
true
if a new login token needs to be created,false
otherwise.
-
createToken
Issues a new login token for the user with the specified credentials and returns the associatedTokenInfo
.- Parameters:
credentials
- The current credentials.- Returns:
- The
TokenInfo
associated with the new login token ornull
if no token has been created.
-
createToken
@Nullable @Nullable TokenInfo createToken(@NotNull @NotNull String userId, @NotNull @NotNull Map<String, ?> attributes) Issues a new login token for the user with the givenuserId
and the specified attributes.- Parameters:
userId
- The identifier of the user for which a new token should be created.attributes
- The attributes associated with the new token.- Returns:
- The
TokenInfo
associated with the new login token ornull
if no token has been created.
-
getTokenInfo
Retrieves theTokenInfo
associated with the specified login token ornull
.- Parameters:
token
- A valid login token.- Returns:
- the
TokenInfo
associated with the specified login token ornull
.
-