java.lang.Object
org.refcodes.web.BasicCredentials
org.refcodes.web.BasicAuthCredentials
- All Implemented Interfaces:
org.refcodes.mixin.CredentialsAccessor
,org.refcodes.mixin.IdentityAccessor
,org.refcodes.mixin.SecretAccessor
,org.refcodes.mixin.Validatable<BasicCredentials>
,AuthTypeAccessor
,AuthTypeCredentials<BasicAuthCredentials,
BasicCredentials>
- Direct Known Subclasses:
BasicAuthCredentialsBuilder
public class BasicAuthCredentials
extends BasicCredentials
implements AuthTypeCredentials<BasicAuthCredentials,BasicCredentials>
The
BasicAuthCredentials
defines a type for representing a
Basic-Authentication credentials Header-Field. Parse the Header-Field via
fromHttpAuthorization(String)
and feed it with the header's
HeaderField.AUTHORIZATION
field's value. To create the according
Header-Field's value from the BasicAuthCredentials
type, call
toHttpAuthorization()
.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.refcodes.web.AuthTypeAccessor
AuthTypeAccessor.AuthTypeBuilder<B extends AuthTypeAccessor.AuthTypeBuilder<B>>, AuthTypeAccessor.AuthTypeMutator, AuthTypeAccessor.AuthTypeProperty
Nested classes/interfaces inherited from interface org.refcodes.mixin.CredentialsAccessor
org.refcodes.mixin.CredentialsAccessor.CredentialsBuilder<B extends org.refcodes.mixin.CredentialsAccessor.CredentialsBuilder<B>>, org.refcodes.mixin.CredentialsAccessor.CredentialsMutator, org.refcodes.mixin.CredentialsAccessor.CredentialsProperty
Nested classes/interfaces inherited from interface org.refcodes.mixin.IdentityAccessor
org.refcodes.mixin.IdentityAccessor.IdentityBuilder<B extends org.refcodes.mixin.IdentityAccessor.IdentityBuilder<B>>, org.refcodes.mixin.IdentityAccessor.IdentityMutator, org.refcodes.mixin.IdentityAccessor.IdentityProperty
Nested classes/interfaces inherited from interface org.refcodes.mixin.SecretAccessor
org.refcodes.mixin.SecretAccessor.SecretBuilder<B extends org.refcodes.mixin.SecretAccessor.SecretBuilder<B>>, org.refcodes.mixin.SecretAccessor.SecretMutator, org.refcodes.mixin.SecretAccessor.SecretProperty
-
Field Summary
Modifier and TypeFieldDescriptionstatic final char
static final char
Fields inherited from class org.refcodes.web.BasicCredentials
_identity, _secret
-
Constructor Summary
ConstructorDescriptionInstantiates a newBasicAuthCredentials
instance.BasicAuthCredentials
(String aIdentity, String aSecret) Instantiates a newBasicAuthCredentials
instance. -
Method Summary
Modifier and TypeMethodDescriptionboolean
void
fromHttpAuthorization
(String aHttpAuthorization) Initializes thisAuthTypeCredentials
instance from theHeaderField.AUTHORIZATION
Header-Fields's value.Retrieves theAuthType
from the Authorization-Type property (or null if there are none such credentials).int
hashCode()
Creates aHeaderField.AUTHORIZATION
HTTP Header-Field value from theAuthTypeCredentials
instance.toString()
void
Validates the provided user-name and secret with thisBasicAuthCredentials
viaBasicCredentials.isValid(String, String)
.void
validate
(BasicCredentials aCredentials) Validates the providedBasicCredentials
with thisBasicAuthCredentials
viaBasicCredentials.isValid(BasicCredentials)
.withHttpAuthorization
(String aHttpAuthorization) Initializes thisAuthTypeCredentials
instance from theHeaderField.AUTHORIZATION
Header-Fields's value.Methods inherited from class org.refcodes.web.BasicCredentials
isValid, isValid
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.refcodes.mixin.Validatable
isValid
-
Field Details
-
DELIMITER_BASIC_AUTH
public static final char DELIMITER_BASIC_AUTH- See Also:
-
DELIMITER_CREDENTIALS
public static final char DELIMITER_CREDENTIALS- See Also:
-
-
Constructor Details
-
BasicAuthCredentials
public BasicAuthCredentials()Instantiates a newBasicAuthCredentials
instance. -
BasicAuthCredentials
Instantiates a newBasicAuthCredentials
instance.- Parameters:
aIdentity
- the user nameaSecret
- the secret
-
-
Method Details
-
validate
Validates the providedBasicCredentials
with thisBasicAuthCredentials
viaBasicCredentials.isValid(BasicCredentials)
. In case the providedBasicCredentials
are not valid, then aForbiddenException
is thrown.- Specified by:
validate
in interfaceAuthTypeCredentials<BasicAuthCredentials,
BasicCredentials> - Parameters:
aCredentials
- TheBasicCredentials
to be verified.- Throws:
ForbiddenException
- thrown in case the providedBasicCredentials
do not match.
-
validate
Validates the provided user-name and secret with thisBasicAuthCredentials
viaBasicCredentials.isValid(String, String)
. In case the provided credentials are not valid, then aForbiddenException
is thrown.- Parameters:
aUserName
- The user-name part to be tested if it fits with the thisBasicCredentials
instance.aSecret
- The secret part to be tested if it fits with the thisBasicCredentials
instance.- Throws:
ForbiddenException
- thrown in case the providedBasicCredentials
do not match.
-
withHttpAuthorization
Initializes thisAuthTypeCredentials
instance from theHeaderField.AUTHORIZATION
Header-Fields's value.- Specified by:
withHttpAuthorization
in interfaceAuthTypeCredentials<BasicAuthCredentials,
BasicCredentials> - Parameters:
aHttpAuthorization
- TheHeaderField.AUTHORIZATION
header field's value- Returns:
- the t
-
getAuthType
Retrieves theAuthType
from the Authorization-Type property (or null if there are none such credentials).- Specified by:
getAuthType
in interfaceAuthTypeAccessor
- Returns:
- The
AuthType
stored by the Basic-Authentication credentials property (or null if there are none such credentials).
-
getIdentity
- Specified by:
getIdentity
in interfaceorg.refcodes.mixin.IdentityAccessor
- Overrides:
getIdentity
in classBasicCredentials
-
getSecret
- Specified by:
getSecret
in interfaceorg.refcodes.mixin.SecretAccessor
- Overrides:
getSecret
in classBasicCredentials
-
hashCode
public int hashCode() -
equals
-
toString
-
fromHttpAuthorization
Initializes thisAuthTypeCredentials
instance from theHeaderField.AUTHORIZATION
Header-Fields's value.- Specified by:
fromHttpAuthorization
in interfaceAuthTypeCredentials<BasicAuthCredentials,
BasicCredentials> - Parameters:
aHttpAuthorization
- TheHeaderField.AUTHORIZATION
header field's value
-
toHttpAuthorization
Creates aHeaderField.AUTHORIZATION
HTTP Header-Field value from theAuthTypeCredentials
instance.- Specified by:
toHttpAuthorization
in interfaceAuthTypeCredentials<BasicAuthCredentials,
BasicCredentials> - Returns:
- The according HTTP Header-Field's value.
-