org.jets3t.service.utils.gatekeeper
Class SignatureRequest

java.lang.Object
  extended by org.jets3t.service.utils.gatekeeper.SignatureRequest

public class SignatureRequest
extends java.lang.Object

Represents a signature request - that is, a request that a Gatekeeper allow a specific operation (signature type) on a specific object in S3. The operations that may be requested are: get, head, put.


Field Summary
static java.lang.String SIGNATURE_TYPE_ACL_LOOKUP
           
static java.lang.String SIGNATURE_TYPE_ACL_UPDATE
           
static java.lang.String SIGNATURE_TYPE_DELETE
           
static java.lang.String SIGNATURE_TYPE_GET
           
static java.lang.String SIGNATURE_TYPE_HEAD
           
static java.lang.String SIGNATURE_TYPE_PUT
           
 
Constructor Summary
SignatureRequest()
          Constructs an empty signature request.
SignatureRequest(java.lang.String signatureType, java.lang.String objectKey)
          Constructs a signature request for an operation on a specific object key.
 
Method Summary
 void addObjectMetadata(java.lang.String metadataName, java.lang.String metadataValue)
          Adds to the object's metadata, that will be included in the Gatekeeer message.
 S3Object buildObject()
           
 void declineRequest(java.lang.String reason)
          Decline the request by setting the decline reason for this request - performed by a Gatekeeper service when a request has been disallowed.
 java.lang.String getBucketName()
           
 java.lang.String getDeclineReason()
           
 java.lang.String getObjectKey()
           
 java.util.Map getObjectMetadata()
           
 java.lang.String getSignatureType()
           
 java.lang.String getSignedUrl()
           
 boolean isSigned()
          Returns true if this request has been allowed and includes a signed URL, false otherwise.
 void setBucketName(java.lang.String bucketName)
          Sets the name of the bucket in which an object is stored - this is not generally required.
 void setObjectKey(java.lang.String objectKey)
          Sets the key name of the object on which the operation will be performed.
 void setObjectMetadata(java.util.Map objectMetadata)
          Sets the object's metadata, that will be included in the Gatekeeer message.
 void setSignatureType(java.lang.String signatureType)
          Sets the signature type (operation) being requested for the object in this request.
 void signRequest(java.lang.String signedUrl)
          Approve the request by setting the signed URL for this request - performed by a Gatekeeper service when a request has been allowed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SIGNATURE_TYPE_GET

public static final java.lang.String SIGNATURE_TYPE_GET
See Also:
Constant Field Values

SIGNATURE_TYPE_HEAD

public static final java.lang.String SIGNATURE_TYPE_HEAD
See Also:
Constant Field Values

SIGNATURE_TYPE_PUT

public static final java.lang.String SIGNATURE_TYPE_PUT
See Also:
Constant Field Values

SIGNATURE_TYPE_DELETE

public static final java.lang.String SIGNATURE_TYPE_DELETE
See Also:
Constant Field Values

SIGNATURE_TYPE_ACL_LOOKUP

public static final java.lang.String SIGNATURE_TYPE_ACL_LOOKUP
See Also:
Constant Field Values

SIGNATURE_TYPE_ACL_UPDATE

public static final java.lang.String SIGNATURE_TYPE_ACL_UPDATE
See Also:
Constant Field Values
Constructor Detail

SignatureRequest

public SignatureRequest()
Constructs an empty signature request.


SignatureRequest

public SignatureRequest(java.lang.String signatureType,
                        java.lang.String objectKey)
Constructs a signature request for an operation on a specific object key.

Parameters:
signatureType -
objectKey -
Method Detail

getBucketName

public java.lang.String getBucketName()
Returns:
the name of the bucket in which an object is stored, may be null.

setBucketName

public void setBucketName(java.lang.String bucketName)
Sets the name of the bucket in which an object is stored - this is not generally required.

Parameters:
bucketName -

getObjectKey

public java.lang.String getObjectKey()
Returns:
the key name of the object on which the operation will be performed.

setObjectKey

public void setObjectKey(java.lang.String objectKey)
Sets the key name of the object on which the operation will be performed.

Parameters:
objectKey -

getObjectMetadata

public java.util.Map getObjectMetadata()
Returns:
the object's metadata as included in the Gatekeeer message.

setObjectMetadata

public void setObjectMetadata(java.util.Map objectMetadata)
Sets the object's metadata, that will be included in the Gatekeeer message.

Parameters:
objectMetadata -

addObjectMetadata

public void addObjectMetadata(java.lang.String metadataName,
                              java.lang.String metadataValue)
Adds to the object's metadata, that will be included in the Gatekeeer message.

Parameters:
metadataName -
metadataValue -

getSignatureType

public java.lang.String getSignatureType()
Returns:
the operation being requested.

setSignatureType

public void setSignatureType(java.lang.String signatureType)
Sets the signature type (operation) being requested for the object in this request.

Parameters:
signatureType - the operation being requested, must match one of the SIGNATURE_TYPE_xyz constants in this class.

signRequest

public void signRequest(java.lang.String signedUrl)
Approve the request by setting the signed URL for this request - performed by a Gatekeeper service when a request has been allowed.

Parameters:
signedUrl - a URL signed to allow the requested operation on the S3 object.

getSignedUrl

public java.lang.String getSignedUrl()
Returns:
the signed URL for this request, if available. If this method is called before a Gatekeeper service has provided a signed URL, or the the Gatekeeper has refused to provide a signed URL, this method will return null.

declineRequest

public void declineRequest(java.lang.String reason)
Decline the request by setting the decline reason for this request - performed by a Gatekeeper service when a request has been disallowed.

Parameters:
reason - a short explanation for why the request was not allowed, such as "Unrecognised user".

getDeclineReason

public java.lang.String getDeclineReason()
Returns:
the reason this request was declined.

isSigned

public boolean isSigned()
Returns true if this request has been allowed and includes a signed URL, false otherwise.


buildObject

public S3Object buildObject()