Package io.vertx.ext.auth.authentication
Class TokenCredentials
- java.lang.Object
- 
- io.vertx.ext.auth.authentication.TokenCredentials
 
- 
- All Implemented Interfaces:
- Credentials
 
 public class TokenCredentials extends Object implements Credentials Credentials used by anyAuthenticationProviderthat requires Tokens, such as OAuth2 or JWT to perform its authentication- Author:
- Paulo Lopes
 
- 
- 
Constructor SummaryConstructors Constructor Description TokenCredentials()TokenCredentials(JsonObject jsonObject)TokenCredentials(String token)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description TokenCredentialsaddScope(String scope)TokenCredentialsapplyHttpChallenge(String challenge, HttpMethod method, String uri, Integer nc, String cnonce)Applies the HTTP Authorization challenge to this Credential instance.<V> voidcheckValid(V arg)Implementors should override this method to perform validation.List<String>getScopes()StringgetToken()TokenCredentialssetScopes(List<String> scopes)TokenCredentialssetToken(String token)StringtoHttpAuthorization()Encodes this credential as an HTTP Authorization https://tools.ietf.org/html/rfc7235.JsonObjecttoJson()Simple interop to downcast back to JSON for backwards compatibility.StringtoString()- 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 - 
Methods inherited from interface io.vertx.ext.auth.authentication.CredentialsapplyHttpChallenge, applyHttpChallenge
 
- 
 
- 
- 
- 
Constructor Detail- 
TokenCredentialspublic TokenCredentials() 
 - 
TokenCredentialspublic TokenCredentials(String token) 
 - 
TokenCredentialspublic TokenCredentials(JsonObject jsonObject) 
 
- 
 - 
Method Detail- 
getTokenpublic String getToken() 
 - 
setTokenpublic TokenCredentials setToken(String token) 
 - 
setScopespublic TokenCredentials setScopes(List<String> scopes) 
 - 
addScopepublic TokenCredentials addScope(String scope) 
 - 
checkValidpublic <V> void checkValid(V arg) throws CredentialValidationExceptionDescription copied from interface:CredentialsImplementors should override this method to perform validation. An argument is allowed to allow custom validation, for example, when given a configuration property, a specific property may be allowed to be null.- Specified by:
- checkValidin interface- Credentials
- Type Parameters:
- V- the generic type of the argument
- Parameters:
- arg- optional argument or null.
- Throws:
- CredentialValidationException- when the validation fails
 
 - 
toJsonpublic JsonObject toJson() Description copied from interface:CredentialsSimple interop to downcast back to JSON for backwards compatibility.- Specified by:
- toJsonin interface- Credentials
- Returns:
- JSON representation of this credential.
 
 - 
applyHttpChallengepublic TokenCredentials applyHttpChallenge(String challenge, HttpMethod method, String uri, Integer nc, String cnonce) throws CredentialValidationException Description copied from interface:CredentialsApplies the HTTP Authorization challenge to this Credential instance. The internal state can change to reflect the extra properties the challenge conveys.See https://tools.ietf.org/html/rfc7235 for more information. - Specified by:
- applyHttpChallengein interface- Credentials
- Parameters:
- challenge- the challenge is the- WWW-Authenticateheader 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).
- Returns:
- fluent self.
- Throws:
- CredentialValidationException- if the challenge cannot be applicable.
 
 - 
toHttpAuthorizationpublic String toHttpAuthorization() Description copied from interface:CredentialsEncodes this credential as an HTTP Authorization https://tools.ietf.org/html/rfc7235.Calls to this method, expect that 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.- Specified by:
- toHttpAuthorizationin interface- Credentials
- Returns:
- HTTP header including scheme.
 
 
- 
 
-