Class BasicAuthCredentials
java.lang.Object
org.refcodes.web.BasicCredentials
org.refcodes.web.BasicAuthCredentials
- All Implemented Interfaces:
CredentialsAccessor, IdentityAccessor, SecretAccessor, 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. ArgsParser 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 AuthTypeAccessor
AuthTypeAccessor.AuthTypeBuilder<B>, AuthTypeAccessor.AuthTypeMutator, AuthTypeAccessor.AuthTypePropertyNested classes/interfaces inherited from interface CredentialsAccessor
CredentialsAccessor.CredentialsBuilder<B>, CredentialsAccessor.CredentialsMutator, CredentialsAccessor.CredentialsPropertyNested classes/interfaces inherited from interface IdentityAccessor
IdentityAccessor.IdentityBuilder<B>, IdentityAccessor.IdentityMutator, IdentityAccessor.IdentityPropertyNested classes/interfaces inherited from interface SecretAccessor
SecretAccessor.SecretBuilder<B>, SecretAccessor.SecretMutator, SecretAccessor.SecretProperty -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final charstatic final charFields inherited from class BasicCredentials
_identity, _secret -
Constructor Summary
ConstructorsConstructorDescriptionInstantiates a newBasicAuthCredentialsinstance.BasicAuthCredentials(String aIdentity, String aSecret) Instantiates the classBasicAuthCredentials. -
Method Summary
Modifier and TypeMethodDescriptionbooleanvoidfromHttpAuthorization(String aHttpAuthorization) Initializes thisAuthTypeCredentialsinstance from theHeaderField.AUTHORIZATIONHeader-Fields's value.Retrieves theAuthTypefrom the Authorization-Type property (or null if there are none such credentials).inthashCode()Creates aHeaderField.AUTHORIZATIONHTTP Header-Field value from theAuthTypeCredentialsinstance.toString()voidValidates the provided user-name and secret with thisBasicAuthCredentialsviaBasicCredentials.isValid(String, String).voidvalidate(BasicCredentials aCredentials) Validates the providedBasicCredentialswith thisBasicAuthCredentialsviaBasicCredentials.isValid(BasicCredentials).withHttpAuthorization(String aHttpAuthorization) Initializes thisAuthTypeCredentialsinstance from theHeaderField.AUTHORIZATIONHeader-Fields's value.Methods inherited from class BasicCredentials
isValid, isValidMethods inherited from interface 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 newBasicAuthCredentialsinstance. -
BasicAuthCredentials
Instantiates the classBasicAuthCredentials.- See Also:
-
-
Method Details
-
validate
Validates the providedBasicCredentialswith thisBasicAuthCredentialsviaBasicCredentials.isValid(BasicCredentials). In case the providedBasicCredentialsare not valid, then aForbiddenExceptionis thrown.- Specified by:
validatein interfaceAuthTypeCredentials<BasicAuthCredentials, BasicCredentials>- Parameters:
aCredentials- TheBasicCredentialsto be verified.- Throws:
ForbiddenException- thrown in case the providedBasicCredentialsdo not match.
-
validate
Validates the provided user-name and secret with thisBasicAuthCredentialsviaBasicCredentials.isValid(String, String). In case the provided credentials are not valid, then aForbiddenExceptionis thrown.- Parameters:
aUserName- The user-name part to be tested if it fits with the thisBasicCredentialsinstance.aSecret- The secret part to be tested if it fits with the thisBasicCredentialsinstance.- Throws:
ForbiddenException- thrown in case the providedBasicCredentialsdo not match.
-
withHttpAuthorization
Initializes thisAuthTypeCredentialsinstance from theHeaderField.AUTHORIZATIONHeader-Fields's value.- Specified by:
withHttpAuthorizationin interfaceAuthTypeCredentials<BasicAuthCredentials, BasicCredentials>- Parameters:
aHttpAuthorization- TheHeaderField.AUTHORIZATIONheader field's value- Returns:
- the t
-
getAuthType
Retrieves theAuthTypefrom the Authorization-Type property (or null if there are none such credentials).- Specified by:
getAuthTypein interfaceAuthTypeAccessor- Returns:
- The
AuthTypestored by the Basic-Authentication credentials property (or null if there are none such credentials).
-
getIdentity
- Specified by:
getIdentityin interfaceIdentityAccessor- Overrides:
getIdentityin classBasicCredentials
-
getSecret
- Specified by:
getSecretin interfaceSecretAccessor- Overrides:
getSecretin classBasicCredentials
-
hashCode
-
equals
-
toString
-
fromHttpAuthorization
Initializes thisAuthTypeCredentialsinstance from theHeaderField.AUTHORIZATIONHeader-Fields's value.- Specified by:
fromHttpAuthorizationin interfaceAuthTypeCredentials<BasicAuthCredentials, BasicCredentials>- Parameters:
aHttpAuthorization- TheHeaderField.AUTHORIZATIONheader field's value
-
toHttpAuthorization
Creates aHeaderField.AUTHORIZATIONHTTP Header-Field value from theAuthTypeCredentialsinstance.- Specified by:
toHttpAuthorizationin interfaceAuthTypeCredentials<BasicAuthCredentials, BasicCredentials>- Returns:
- The according HTTP Header-Field's value.
-