public class TokenCredentials extends Object implements Credentials
AuthenticationProvider
that requires Tokens, such as OAuth2 or JWT
to perform its authenticationModifier | Constructor and Description |
---|---|
protected |
TokenCredentials() |
|
TokenCredentials(JsonObject jsonObject) |
|
TokenCredentials(String token) |
Modifier and Type | Method and Description |
---|---|
TokenCredentials |
addScope(String scope) |
TokenCredentials |
applyHttpChallenge(String challenge,
HttpMethod method,
String uri,
Integer nc,
String cnonce)
Applies the HTTP Authorization challenge to this Credential instance.
|
<V> void |
checkValid(V arg)
Implementors should override this method to perform validation.
|
List<String> |
getScopes() |
String |
getToken() |
TokenCredentials |
setScopes(List<String> scopes) |
TokenCredentials |
setToken(String token) |
String |
toHttpAuthorization()
Encodes this credential as an HTTP Authorization https://tools.ietf.org/html/rfc7235.
|
JsonObject |
toJson()
Simple interop to downcast back to JSON for backwards compatibility.
|
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
applyHttpChallenge, applyHttpChallenge
protected TokenCredentials()
public TokenCredentials(String token)
public TokenCredentials(JsonObject jsonObject)
public String getToken()
public TokenCredentials setToken(String token)
public TokenCredentials setScopes(List<String> scopes)
public TokenCredentials addScope(String scope)
public <V> void checkValid(V arg) throws CredentialValidationException
Credentials
checkValid
in interface Credentials
V
- the generic type of the argumentarg
- optional argument or null.CredentialValidationException
- when the validation failspublic JsonObject toJson()
Credentials
toJson
in interface Credentials
public TokenCredentials applyHttpChallenge(String challenge, HttpMethod method, String uri, Integer nc, String cnonce) throws CredentialValidationException
Credentials
applyHttpChallenge
in interface Credentials
challenge
- the challenge is the WWW-Authenticate
header response from a 401 request.
Null challenges are allowed, and in this case, no verification will be performed, however it is
up to the implementation to permit this.method
- The http method this response is responding.uri
- The http uri this response is responding.nc
- The client internal counter (optional).cnonce
- The client internal nonce (optional).CredentialValidationException
- if the challenge cannot be applicable.public String toHttpAuthorization()
Credentials
Credentials.applyHttpChallenge(String, HttpMethod, String, Integer, String)
has
been prior executed. For some Authentication schemes, this isn't a requirement but doing so ensures that the
object is on the right state.toHttpAuthorization
in interface Credentials
Copyright © 2021 Eclipse. All rights reserved.