Package org.restlet.ext.crypto.internal
Class AwsVerifier
- java.lang.Object
-
- org.restlet.security.SecretVerifier
-
- org.restlet.ext.crypto.internal.AwsVerifier
-
- All Implemented Interfaces:
Verifier
public class AwsVerifier extends SecretVerifier
Wrapped verifier that can verify HTTP requests utilizing the Amazon S3 authentication scheme. Verifies the user by computing the request signature using the local secret and comparing it to the signature provided in the request.Per the Amazon S3 specification the
Dateheader is required. If theDateheader is missing or the request is older than the allowed time limit, specified by themaxRequestAgeproperty, the request fails verification.- See Also:
- Authenticating REST Requests
-
-
Field Summary
Fields Modifier and Type Field Description private static longDEFAULT_MAX_REQUEST_AGEDefault maximum request age (15 minutes)private longmaxRequestAgeThe maximum age of a request, in milliseconds, before it is considered stale.private LocalVerifierwrappedVerifierThe local secret verifier.-
Fields inherited from interface org.restlet.security.Verifier
RESULT_INVALID, RESULT_MISSING, RESULT_STALE, RESULT_UNKNOWN, RESULT_UNSUPPORTED, RESULT_VALID
-
-
Constructor Summary
Constructors Constructor Description AwsVerifier(LocalVerifier wrappedVerifier)Creates a new HttpAwsS3Verifier instance.AwsVerifier(LocalVerifier wrappedVerifier, long maxRequestAge)Creates a new HttpAwsS3Verifier instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.StringgetIdentifier(Request request, Response response)Returns the user identifier portion of an Amazon S3 compatibleAuthorizationheader.char[]getLocalSecret(java.lang.String identifier)Returns the local secret associated to a given identifier.longgetMaxRequestAge()Returns the maximum age of a request, in milliseconds, before it is considered stale.protected char[]getSecret(Request request, Response response)Returns the signature portion of an Amazon S3 compatibleAuthorizationheader.LocalVerifiergetWrappedVerifier()Returns the wrapped local secret verifier.voidsetMaxRequestAge(long value)Sets the maximum age of a request, in milliseconds, before it is considered stale.voidsetWrappedVerifier(LocalVerifier wrappedVerifier)Sets the wrapped local secret verifier.intverify(java.lang.String identifier, char[] secret)This function is not implemented because the authorization scheme requires direct access to the request.intverify(Request request, Response response)Verifies that the proposed secret is correct for the specified request.-
Methods inherited from class org.restlet.security.SecretVerifier
compare, createUser
-
-
-
-
Field Detail
-
DEFAULT_MAX_REQUEST_AGE
private static final long DEFAULT_MAX_REQUEST_AGE
Default maximum request age (15 minutes)- See Also:
- Constant Field Values
-
maxRequestAge
private long maxRequestAge
The maximum age of a request, in milliseconds, before it is considered stale.
-
wrappedVerifier
private LocalVerifier wrappedVerifier
The local secret verifier.
-
-
Constructor Detail
-
AwsVerifier
public AwsVerifier(LocalVerifier wrappedVerifier)
Creates a new HttpAwsS3Verifier instance.- Parameters:
wrappedVerifier- The wrapped verifier containing local identifier/secret couples
-
AwsVerifier
public AwsVerifier(LocalVerifier wrappedVerifier, long maxRequestAge)
Creates a new HttpAwsS3Verifier instance.- Parameters:
wrappedVerifier- The wrapped verifier containing local identifier/secret couplesmaxRequestAge- The maximum age of a request, in milliseconds, before it is considered stale
-
-
Method Detail
-
getIdentifier
protected java.lang.String getIdentifier(Request request, Response response)
Returns the user identifier portion of an Amazon S3 compatibleAuthorizationheader.An Amazon S3 compatible
Authorizationheader has the following pattern.
Authorization: AWS id:signature- Overrides:
getIdentifierin classSecretVerifier- Parameters:
request- The request to inspect.response- The response to inspect.- Returns:
- The user identifier.
-
getLocalSecret
public char[] getLocalSecret(java.lang.String identifier)
Returns the local secret associated to a given identifier.- Parameters:
identifier- The identifier to lookup.- Returns:
- The secret associated to the identifier or null.
-
getMaxRequestAge
public long getMaxRequestAge()
Returns the maximum age of a request, in milliseconds, before it is considered stale.A negative or zero value indicates no age restriction. The default value is 15 minutes.
-
getSecret
protected char[] getSecret(Request request, Response response)
Returns the signature portion of an Amazon S3 compatibleAuthorizationheader.An Amazon S3 compatible
Authorizationheader has the following pattern.
Authorization: AWS id:signature- Overrides:
getSecretin classSecretVerifier- Parameters:
request- The request to inspect.response- The response to inspect.- Returns:
- The secret provided by the user.
-
getWrappedVerifier
public LocalVerifier getWrappedVerifier()
Returns the wrapped local secret verifier.- Returns:
- The local secret verifier.
-
setMaxRequestAge
public void setMaxRequestAge(long value)
Sets the maximum age of a request, in milliseconds, before it is considered stale.A negative or zero value indicates no age restriction. The default value is 15 minutes.
-
setWrappedVerifier
public void setWrappedVerifier(LocalVerifier wrappedVerifier)
Sets the wrapped local secret verifier.- Parameters:
wrappedVerifier- The local secret verifier.
-
verify
public int verify(Request request, Response response)
Description copied from class:SecretVerifierVerifies that the proposed secret is correct for the specified request. By default, it compares the inputSecret of the request's authentication response with the one obtain by theChallengeResponse.getSecret()method and sets theUserinstance of the request'sClientInfoif successful.- Specified by:
verifyin interfaceVerifier- Overrides:
verifyin classSecretVerifier- Parameters:
request- The request to inspect.response- The response to inspect.- Returns:
- Result of the verification based on the RESULT_* constants.
-
verify
public int verify(java.lang.String identifier, char[] secret) throws java.lang.IllegalArgumentExceptionThis function is not implemented because the authorization scheme requires direct access to the request. Seeverify(Request, Response).- Specified by:
verifyin classSecretVerifier- Parameters:
identifier- The user identifier to match.secret- The provided secret to verify.- Returns:
- Result of the verification based on the RESULT_* constants.
- Throws:
java.lang.IllegalArgumentException
-
-