Package tech.greenfield.vertx.irked.auth
Class AuthorizationToken
- java.lang.Object
-
- tech.greenfield.vertx.irked.auth.AuthorizationToken
-
- Direct Known Subclasses:
BasicAuthorizationToken,BearerAuthorizationToken,NegotiateAuthorizationToken,NullAuthorizationToken,ParameterEncodedAuthorizationToken,SimpleAuthrizationToken
public class AuthorizationToken extends Object
Base class for RFC 7235 authentication/authorization tokens- Author:
- odeda
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAuthorizationToken.TokenTypes
-
Constructor Summary
Constructors Modifier Constructor Description protectedAuthorizationToken()Constructor for token implementations is internal - useparse(String)to create tokens
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetToken()Retrieve the authorization token textStringgetType()Retrieve the IANA HTTP Authentication Scheme Name this token is an implementation ofbooleanis(String type)Check whether the token implementation implements the specified IANA HTTP Authentication Scheme Namestatic AuthorizationTokenparse(String authorizationHeader)Parse an Authorization header text to create a specific token implementation This method uses the convention of the first word in the Authorization value being the IANA HTTP Authentication Scheme Name, to dynamically load an appropriate implementation from the tech.greenfield.vertx.irked.auth.AuthorizationToken service loader.protected booleansupports(String type)Check whether an AuthorizationToken implementation supports the speciefied IANA HTTP Authentication Scheme NameStringtoString()protected AuthorizationTokenupdate(String type, String token)Update a service-loader loaded implementation with the actual details
-
-
-
Constructor Detail
-
AuthorizationToken
protected AuthorizationToken()
Constructor for token implementations is internal - useparse(String)to create tokens
-
-
Method Detail
-
parse
public static AuthorizationToken parse(String authorizationHeader)
Parse an Authorization header text to create a specific token implementation This method uses the convention of the first word in the Authorization value being the IANA HTTP Authentication Scheme Name, to dynamically load an appropriate implementation from the tech.greenfield.vertx.irked.auth.AuthorizationToken service loader. If the header value is incompatible (i.e. contains only one "word") then a token with the type "simple" will be returned. Otherwise if no supporting implementation is found, an instance of theAuthorizationTokenclass will be created.- Parameters:
authorizationHeader- value of the HTTP Authorization header- Returns:
- a
-
update
protected AuthorizationToken update(String type, String token)
Update a service-loader loaded implementation with the actual details- Parameters:
type- IANA HTTP Authentication Scheme Nametoken- token text- Returns:
- itself for fluent calling
-
supports
protected boolean supports(String type)
Check whether an AuthorizationToken implementation supports the speciefied IANA HTTP Authentication Scheme Name- Parameters:
type- IANA HTTP Authentication Scheme Name- Returns:
- whether this implementation supports the specified name
-
is
public boolean is(String type)
Check whether the token implementation implements the specified IANA HTTP Authentication Scheme Name- Parameters:
type- IANA HTTP Authentication Scheme Name- Returns:
- whether the implementation is valid for that scheme name
-
getToken
public String getToken()
Retrieve the authorization token text- Returns:
- authorization token text
-
getType
public String getType()
Retrieve the IANA HTTP Authentication Scheme Name this token is an implementation of- Returns:
- IANA HTTP Authentication Scheme Name
-
-