AWSRequestAuthorizerGoogleStorageService, S3Servicepublic abstract class RestStorageService extends StorageService implements AWSRequestAuthorizer
This class uses properties obtained through Jets3tProperties. For more information on
these properties please refer to
JetS3t Configuration
BUCKET_STATUS__ALREADY_CLAIMED, BUCKET_STATUS__DOES_NOT_EXIST, BUCKET_STATUS__MY_BUCKET| Constructor | Description |
|---|---|
RestStorageService(ProviderCredentials credentials) |
Constructs the service and initialises the properties.
|
RestStorageService(ProviderCredentials credentials,
String invokingApplicationDescription,
org.apache.commons.httpclient.auth.CredentialsProvider credentialsProvider) |
Constructs the service and initialises the properties.
|
RestStorageService(ProviderCredentials credentials,
String invokingApplicationDescription,
org.apache.commons.httpclient.auth.CredentialsProvider credentialsProvider,
Jets3tProperties jets3tProperties) |
Constructs the service and initialises the properties.
|
RestStorageService(ProviderCredentials credentials,
String invokingApplicationDescription,
org.apache.commons.httpclient.auth.CredentialsProvider credentialsProvider,
Jets3tProperties jets3tProperties,
org.apache.commons.httpclient.HostConfiguration hostConfig) |
Constructs the service and initialises the properties.
|
| Modifier and Type | Method | Description |
|---|---|---|
void |
authorizeHttpRequest(org.apache.commons.httpclient.HttpMethod httpMethod) |
Authorizes an HTTP request by signing it.
|
int |
checkBucketStatus(String bucketName) |
Find out the status of a bucket with the given name.
|
void |
deleteObjectWithSignedUrl(String signedDeleteUrl) |
Deletes an object using a pre-signed DELETE URL generated for that object.
|
org.apache.commons.httpclient.auth.CredentialsProvider |
getCredentialsProvider() |
|
org.apache.commons.httpclient.HttpClient |
getHttpClient() |
|
org.apache.commons.httpclient.HttpConnectionManager |
getHttpConnectionManager() |
|
AccessControlList |
getObjectAclWithSignedUrl(String signedAclUrl) |
Gets an object's ACL details using a pre-signed GET URL generated for that object.
|
S3Object |
getObjectDetailsWithSignedUrl(String signedHeadUrl) |
Gets an object's details using a pre-signed HEAD URL generated for that object.
|
S3Object |
getObjectWithSignedUrl(String signedGetUrl) |
Gets an object using a pre-signed GET URL generated for that object.
|
boolean |
isBucketAccessible(String bucketName) |
Indicates whether a bucket exists and is accessible to a service user.
|
void |
putObjectAclWithSignedUrl(String signedAclUrl,
AccessControlList acl) |
Sets an object's ACL details using a pre-signed PUT URL generated for that object.
|
S3Object |
putObjectWithSignedUrl(String signedPutUrl,
S3Object object) |
Puts an object using a pre-signed PUT URL generated for that object.
|
void |
setCredentialsProvider(org.apache.commons.httpclient.auth.CredentialsProvider credentialsProvider) |
Sets the credentials provider this service will use to authenticate itself.
|
void |
setHttpClient(org.apache.commons.httpclient.HttpClient httpClient) |
Replaces the service's default HTTP client.
|
void |
setHttpConnectionManager(org.apache.commons.httpclient.HttpConnectionManager httpConnectionManager) |
Replaces the service's default HTTP connection manager.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcopyObject, copyObject, createBucket, createBucket, deleteBucket, deleteBucket, deleteObject, getAccountOwner, getBucket, getBucketAcl, getCurrentTimeWithOffset, getEndpoint, getInternalErrorRetryMax, getInvokingApplicationDescription, getJetS3tProperties, getObject, getObject, getObjectAcl, getObjectDetails, getObjectDetails, getOrCreateBucket, getProviderCredentials, getResourceParameterNames, getRestHeaderPrefix, getRestMetadataPrefix, isAuthenticatedConnection, isHttpsOnly, isObjectInBucket, isShutdown, listAllBuckets, listObjects, listObjects, listObjects, listObjectsChunked, listObjectsChunked, moveObject, putBucketAcl, putBucketAcl, putObject, putObjectAcl, putObjectAcl, renameMetadataKeys, renameObject, shutdown, updateObjectMetadatapublic RestStorageService(ProviderCredentials credentials)
credentials - the user credentials to use when communicating with S3, may be null in which case the
communication is done as an anonymous user.public RestStorageService(ProviderCredentials credentials, String invokingApplicationDescription, org.apache.commons.httpclient.auth.CredentialsProvider credentialsProvider)
credentials - the S3 user credentials to use when communicating with S3, may be null in which case the
communication is done as an anonymous user.invokingApplicationDescription - a short description of the application using the service, suitable for inclusion in a
user agent string for REST/HTTP requests. Ideally this would include the application's
version number, for example: Cockpit/0.7.3 or My App Name/1.0credentialsProvider - an implementation of the HttpClient CredentialsProvider interface, to provide a means for
prompting for credentials when necessary.public RestStorageService(ProviderCredentials credentials, String invokingApplicationDescription, org.apache.commons.httpclient.auth.CredentialsProvider credentialsProvider, Jets3tProperties jets3tProperties)
credentials - the S3 user credentials to use when communicating with S3, may be null in which case the
communication is done as an anonymous user.invokingApplicationDescription - a short description of the application using the service, suitable for inclusion in a
user agent string for REST/HTTP requests. Ideally this would include the application's
version number, for example: Cockpit/0.7.3 or My App Name/1.0credentialsProvider - an implementation of the HttpClient CredentialsProvider interface, to provide a means for
prompting for credentials when necessary.jets3tProperties - JetS3t properties that will be applied within this service.public RestStorageService(ProviderCredentials credentials, String invokingApplicationDescription, org.apache.commons.httpclient.auth.CredentialsProvider credentialsProvider, Jets3tProperties jets3tProperties, org.apache.commons.httpclient.HostConfiguration hostConfig)
credentials - the S3 user credentials to use when communicating with S3, may be null in which case the
communication is done as an anonymous user.invokingApplicationDescription - a short description of the application using the service, suitable for inclusion in a
user agent string for REST/HTTP requests. Ideally this would include the application's
version number, for example: Cockpit/0.7.3 or My App Name/1.0credentialsProvider - an implementation of the HttpClient CredentialsProvider interface, to provide a means for
prompting for credentials when necessary.jets3tProperties - JetS3t properties that will be applied within this service.hostConfig - Custom HTTP host configuration; e.g to register a custom Protocol Socket Factorypublic org.apache.commons.httpclient.HttpConnectionManager getHttpConnectionManager()
public void setHttpConnectionManager(org.apache.commons.httpclient.HttpConnectionManager httpConnectionManager)
httpConnectionManager - the connection manager that will replace the default manager created by
the class constructor.public org.apache.commons.httpclient.HttpClient getHttpClient()
public void setHttpClient(org.apache.commons.httpclient.HttpClient httpClient)
httpClient - the client that will replace the default client created by
the class constructor.public org.apache.commons.httpclient.auth.CredentialsProvider getCredentialsProvider()
public void setCredentialsProvider(org.apache.commons.httpclient.auth.CredentialsProvider credentialsProvider)
initHttpConnection(org.apache.commons.httpclient.HostConfiguration) method
is called.credentialsProvider - public void authorizeHttpRequest(org.apache.commons.httpclient.HttpMethod httpMethod)
throws Exception
HttpMethod object as an Authorization header.authorizeHttpRequest in interface AWSRequestAuthorizerhttpMethod - the request objectServiceExceptionExceptionpublic boolean isBucketAccessible(String bucketName) throws ServiceException
StorageService
Caution: This check started to cause issues in situations where you need to
immediately create a bucket when it does not exist. To conditionally create a bucket,
use the StorageService.getOrCreateBucket(String) method instead.
This method can be performed by anonymous services.
Implementation notes
This method can be implemented by attempting to list the objects in a bucket. If the listing is successful return true, if the listing failed for any reason return false.
isBucketAccessible in class StorageServicebucketName - the bucket to check.ServiceExceptionpublic int checkBucketStatus(String bucketName) throws ServiceException
StorageServiceCaveats:
StorageService.BUCKET_STATUS__MY_BUCKET.S3 can act strangely when you use this method in some circumstances. If you check the status of a bucket and find that it does not exist, then create the bucket, the service will continue to tell you the bucket does not exists for up to 30 seconds. This problem has something to do with connection caching (I think).
This S3 quirk makes it a bad idea to use this method to check for a bucket's
existence before creating that bucket. Use the StorageService.getOrCreateBucket(String)
method for this purpose instead.
checkBucketStatus in class StorageServiceStorageService.BUCKET_STATUS__MY_BUCKET if you already own the bucket,
StorageService.BUCKET_STATUS__DOES_NOT_EXIST if the bucket does not yet exist, or
StorageService.BUCKET_STATUS__ALREADY_CLAIMED if someone else has
already created a bucket with the given name.ServiceExceptionpublic S3Object putObjectWithSignedUrl(String signedPutUrl, S3Object object) throws ServiceException
SignedUrlHandler.
This operation does not required any S3 functionality as it merely uploads the object by performing a standard HTTP PUT using the signed URL.
signedPutUrl - a signed PUT URL generated with
S3Service.createSignedPutUrl(String, String, java.util.Map, org.jets3t.service.security.ProviderCredentials, java.util.Date).object - the object to upload, which must correspond to the object for which the URL was signed.
The object must have the correct content length set, and to apply a non-standard
ACL policy only the REST canned ACLs can be used
(eg AccessControlList.REST_CANNED_PUBLIC_READ_WRITE).ServiceExceptionpublic void deleteObjectWithSignedUrl(String signedDeleteUrl) throws ServiceException
SignedUrlHandler.
This operation does not required any S3 functionality as it merely deletes the object by performing a standard HTTP DELETE using the signed URL.
signedDeleteUrl - a signed DELETE URL generated with S3Service.createSignedDeleteUrl(java.lang.String, java.lang.String, java.util.Date, boolean).ServiceExceptionpublic S3Object getObjectWithSignedUrl(String signedGetUrl) throws ServiceException
SignedUrlHandler.
This operation does not required any S3 functionality as it merely uploads the object by performing a standard HTTP GET using the signed URL.
signedGetUrl - a signed GET URL generated with
S3Service.createSignedGetUrl(String, String, org.jets3t.service.security.ProviderCredentials, java.util.Date).ServiceExceptionpublic S3Object getObjectDetailsWithSignedUrl(String signedHeadUrl) throws ServiceException
SignedUrlHandler.
This operation does not required any S3 functionality as it merely uploads the object by performing a standard HTTP HEAD using the signed URL.
signedHeadUrl - a signed HEAD URL generated with
S3Service.createSignedHeadUrl(String, String, org.jets3t.service.security.ProviderCredentials, java.util.Date).ServiceExceptionpublic AccessControlList getObjectAclWithSignedUrl(String signedAclUrl) throws ServiceException
SignedUrlHandler.signedAclUrl - a signed URL generated with S3Service.createSignedUrl(String, String, String, String, java.util.Map, org.jets3t.service.security.ProviderCredentials, long, boolean).ServiceExceptionpublic void putObjectAclWithSignedUrl(String signedAclUrl, AccessControlList acl) throws ServiceException
SignedUrlHandler.signedAclUrl - a signed URL generated with S3Service.createSignedUrl(String, String, String, String, java.util.Map, org.jets3t.service.security.ProviderCredentials, long, boolean).acl - the ACL settings to apply to the object represented by the signed URL.ServiceException