public abstract class AuthScheme extends Object implements Serializable
AuthScheme
class represents a strong type representation of the
"Authorization" header schemes. This class allows an "Authorization" scheme
to be parsed to an instance of AuthScheme
.Basic
,
Bearer
,
Serialized FormConstructor and Description |
---|
AuthScheme() |
Modifier and Type | Method and Description |
---|---|
protected abstract AuthScheme |
decode(String authorization)
Returns a
AuthScheme instance by decoding the authorization
header string. |
boolean |
matches(String authorization)
Tests whether the
authorization header string matches this
AuthScheme subclass's implementation. |
abstract String |
name()
Returns the name of this "Authorization" scheme.
|
AuthScheme |
parse(String authorization)
Returns a
AuthScheme instance by parsing the authorization
header string, or null if the specified string is null. |
static AuthScheme |
parse(String authorization,
Class<? extends AuthScheme>... schemes)
Returns an instance of a
AuthScheme subclass specified in
schemes that matches the spec of the authorization header
string. |
@SafeVarargs public static AuthScheme parse(String authorization, Class<? extends AuthScheme>... schemes)
AuthScheme
subclass specified in
schemes
that matches the spec of the authorization
header
string.authorization
- The "Authorization" header string to match.schemes
- The array of AuthScheme
classes to attempt to match.AuthScheme
subclass specified in
schemes
that matches the spec of the authorization
header string.UnsupportedOperationException
- If a AuthScheme
class in
schemes
does not implement a protected default
constructor, or if the constructor throws an exception when
invoked.NullPointerException
- If @authorization
or schemes
is null.public final boolean matches(String authorization)
authorization
header string matches this
AuthScheme
subclass's implementation.authorization
- The "Authorization" header string.true
if the authorization
header string matches
this AuthScheme
subclass's implementation; otherwise
false
.NullPointerException
- If authorization
is null.public final AuthScheme parse(String authorization)
AuthScheme
instance by parsing the authorization
header string, or null
if the specified string is null.authorization
- The "Authorization" header string.AuthScheme
instance by parsing the authorization
header string.public abstract String name()
protected abstract AuthScheme decode(String authorization)
AuthScheme
instance by decoding the authorization
header string. This method is required to be overridden by subclasses
implementing an "Authorization" scheme.authorization
- The "Authorization" header string.AuthScheme
instance by decoding the authorization
header string.NullPointerException
- If authorization
is null.Copyright © 2020 LibJ. All rights reserved.