java.lang.Object
one.jpro.platform.auth.core.jwt.TokenCredentials
- All Implemented Interfaces:
Credentials
Credentials used by an
AuthenticationProvider that requires tokens,
such as OAuth2, to perform its authentication.-
Constructor Summary
ConstructorsConstructorDescriptionTokenCredentials(@NotNull String token) Creates a token credentials with the given token.TokenCredentials(@NotNull User user) Creates a token credentials from a user object.TokenCredentials(@NotNull org.json.JSONObject json) Creates a token credentials from a json object. -
Method Summary
Modifier and TypeMethodDescriptionbooleanstatic TokenCredentialsCreates a token credentials object with the given JSON formatted string.@NotNull StringgetToken()inthashCode()Encodes this credential as an HTTP Authorization https://tools.ietf.org/html/rfc7235.org.json.JSONObjecttoJSON()Convert the credential information to JSON format.static StringtoJSON(TokenCredentials tokenCredentials) Convert the token credential information to JSON format and provides it as a string.toString()<V> voidvalidate(V arg) Implementors should override this method to perform validation.
-
Constructor Details
-
TokenCredentials
Creates a token credentials with the given token.- Parameters:
token- the token string
-
TokenCredentials
public TokenCredentials(@NotNull @NotNull org.json.JSONObject json) Creates a token credentials from a json object.- Parameters:
json- the json object- Throws:
IllegalStateException- if the json object isnull
-
TokenCredentials
Creates a token credentials from a user object.This constructor should be called only if the user object is obtained from a
AuthenticationProviderthat uses tokens.- Parameters:
user- the user object
-
-
Method Details
-
fromJSON
Creates a token credentials object with the given JSON formatted string.- Parameters:
json- the string representation of the JSON object holding the token credential's information.
-
toJSON
Convert the token credential information to JSON format and provides it as a string.- Returns:
- a string in JSON format.
-
getToken
-
setToken
-
getScopes
-
setScopes
-
addScopes
-
equals
-
hashCode
public int hashCode() -
validate
Description copied from interface:CredentialsImplementors should override this method to perform validation. An argument is allowed to allow custom validation.- Specified by:
validatein interfaceCredentials- Type Parameters:
V- the generic type of the argument- Parameters:
arg- optional argument or null.- Throws:
CredentialValidationException- when the validation fails
-
toJSON
public org.json.JSONObject toJSON()Description copied from interface:CredentialsConvert the credential information to JSON format.- Specified by:
toJSONin interfaceCredentials- Returns:
- a JSON object.
-
toHttpAuthorization
Description copied from interface:CredentialsEncodes this credential as an HTTP Authorization https://tools.ietf.org/html/rfc7235.- Specified by:
toHttpAuthorizationin interfaceCredentials- Returns:
- HTTP header including scheme.
-
toString
-