public class AtmosEncryptionClient extends java.lang.Object implements AtmosApi
$ keytool -genkeypair -keystore keystore.jks -alias masterkey -keyalg RSA \ -keysize 2048 -dname "CN=My Name, OU=My Division, O=My Company, L=My Location, ST=MA, C=US" Enter keystore password: changeit Re-enter new password: changeit Enter key password forInside your application, you can then construct and load a Keystore object,(RETURN if same as keystore password):
KeyStore.load(InputStream, char[])
Once the keystore has been loaded, you then
construct a EncryptionConfig object with the keystore:
EncryptionConfig ec = new EncryptionConfig(keystore, keystorePassword.toCharArray(), "masterkey", provider, 128);The "provider" argument is used to specify the security provider to be used for cryptographic operations. You can set it to null to use the default provider(s) as specified in your jre/lib/security/java.security file. The final argument is the AES encryption key size. Note that most JDKs only support 128-bit AES encryption by default and required the "unlimited strength jurisdiction policy files" to be installed to achieve 256-bit support. See your JRE/JDK download page for details.
CompressionConfig cc = new CompressionConfig(CompressionMode.Deflate, 5);In this instance, you can see that we created a CompressionConfig specifying the Deflate algorithm, and level 5 (medium) compression. LZMA compression is also available but note that while it provides superior compression it also has high memory requirements and can cause OutOfMemoryErrors if you select a level that will not fit in your Java heap.
AtmosApiClient
. You will then create an instance of the
AtmosEncryptionClient that "wraps" the AtmosApi instance to perform encryption
operations:
AtmosApi api = new AtmosApiClient(atmosConfig); AtmosEncryptionClient eclient = new AtmosEncryptionClient(api, ec, cc);You may pass null to the encryption or compression arguments to use only one or the other.
Constructor and Description |
---|
AtmosEncryptionClient(AtmosApi delegate,
java.util.Collection<com.emc.vipr.transform.TransformFactory<com.emc.vipr.transform.OutputTransform,com.emc.vipr.transform.InputTransform>> transformations)
Creates a new AtmosEncryptionClient.
|
AtmosEncryptionClient(AtmosApi delegate,
EncryptionConfig encryptionConfig,
CompressionConfig compressionConfig)
Creates a new AtmosEncryptionClient.
|
Modifier and Type | Method and Description |
---|---|
long |
calculateServerClockSkew()
Calculates rough clock skew.
|
CreateAccessTokenResponse |
createAccessToken(CreateAccessTokenRequest request)
Access tokens are unsupported for transformed content since there is no way for
the SDK to transform the content since communication goes directly to and from
Atmos.
|
ObjectId |
createDirectory(ObjectPath path)
Creates a directory in the subtenant namespace using the specified path.
|
ObjectId |
createDirectory(ObjectPath path,
Acl acl,
Metadata... metadata)
Creates a directory in the subtenant namespace using the specified path, acl and metadata.
|
CreateObjectResponse |
createObject(CreateObjectRequest request)
Creates a new object in the cloud using all of the options provided in the request object.
|
ObjectId |
createObject(ObjectIdentifier identifier,
java.lang.Object content,
java.lang.String contentType)
Creates a new object in the cloud with the specified identifier.
|
ObjectId |
createObject(java.lang.Object content,
java.lang.String contentType)
Creates a new object in the cloud.
|
java.lang.String |
createSubtenant(CreateSubtenantRequest request)
Creates a new Atmos Subtenant in EMC ViPR.
|
ObjectId |
createVersion(ObjectIdentifier identifier)
Creates a new immutable version (snapshot) of the specified object from its current state.
|
void |
delete(ObjectIdentifier identifier)
Deletes an object from the cloud
|
void |
deleteAccessToken(java.lang.String accessTokenId)
Access tokens are unsupported for transformed content since there is no way for
the SDK to transform the content since communication goes directly to and from
Atmos.
|
void |
deleteAccessToken(java.net.URL url)
Access tokens are unsupported for transformed content since there is no way for
the SDK to transform the content since communication goes directly to and from
Atmos.
|
void |
deleteUserMetadata(ObjectIdentifier identifier,
java.lang.String... names)
Deletes metadata associated with the specified object.
|
void |
deleteVersion(ObjectId versionId)
Deletes the specified object version.
|
<T> GenericResponse<T> |
execute(PreSignedRequest request,
java.lang.Class<T> resultType,
java.lang.Object content)
Presigned requests are unsupported for transformed content since there is no way
for the SDK to transform the content since communication may go directly to and
from Atmos.
|
GetAccessTokenResponse |
getAccessToken(java.lang.String accessTokenId)
Access tokens are unsupported for transformed content since there is no way for
the SDK to transform the content since communication goes directly to and from
Atmos.
|
GetAccessTokenResponse |
getAccessToken(java.net.URL url)
Access tokens are unsupported for transformed content since there is no way for
the SDK to transform the content since communication goes directly to and from
Atmos.
|
Acl |
getAcl(ObjectIdentifier identifier)
Gets the ACL for the specified object.
|
int |
getBufferSize() |
ObjectInfo |
getObjectInfo(ObjectIdentifier identifier)
Gets storage information for the specified object.
|
ObjectMetadata |
getObjectMetadata(ObjectIdentifier identifier)
Gets an object's metadata, ACL and content-type all in one call.
|
ServiceInformation |
getServiceInformation() |
java.net.URL |
getShareableUrl(ObjectIdentifier identifier,
java.util.Date expirationDate)
Getting shareable URLs for transformed content is not supported since there is
no way to transform the stream since it's streamed directly from Atmos and does
not go through the SDK.
|
java.net.URL |
getShareableUrl(ObjectIdentifier identifier,
java.util.Date expirationDate,
java.lang.String disposition)
Getting shareable URLs for transformed content is not supported since there is
no way to transform the stream since it's streamed directly from Atmos and does
not go through the SDK.
|
java.util.Map<java.lang.String,Metadata> |
getSystemMetadata(ObjectIdentifier identifier,
java.lang.String... metadataNames)
Gets the system metadata associated with the specified object.
|
java.util.Map<java.lang.String,Metadata> |
getUserMetadata(ObjectIdentifier identifier,
java.lang.String... metadataNames)
Gets the user metadata associated with the specified object.
|
java.util.Map<java.lang.String,java.lang.Boolean> |
getUserMetadataNames(ObjectIdentifier identifier)
Lists the names of all metadata associated with the specified object.
|
ListAccessTokensResponse |
listAccessTokens(ListAccessTokensRequest request)
Access tokens are unsupported for transformed content since there is no way for
the SDK to transform the content since communication goes directly to and from
Atmos.
|
ListDirectoryResponse |
listDirectory(ListDirectoryRequest request)
Lists the contents of a directory in the namespace.
|
java.util.Set<java.lang.String> |
listMetadata(java.lang.String metadataName)
Lists the children of the specified metadata path in the hierarchy of listable metadata for the subtenant.
|
ListObjectsResponse |
listObjects(ListObjectsRequest request)
Lists all objects that are assigned the specified listable metadata using all of the options provided in the
request object.
|
ListVersionsResponse |
listVersions(ListVersionsRequest request)
Lists all versions (snapshots) of the specified object using all of the options provided in the request object.
|
void |
move(ObjectPath oldPath,
ObjectPath newPath,
boolean overwrite)
Moves an object in the namespace to a new location.
|
PreSignedRequest |
preSignRequest(Request request,
java.util.Date expiration)
Presigned requests are unsupported for transformed content since there is no way
for the SDK to transform the content since communication may go directly to and
from Atmos.
|
<T> T |
readObject(ObjectIdentifier identifier,
java.lang.Class<T> objectType)
Reads an object's entire content from the cloud.
|
<T> T |
readObject(ObjectIdentifier identifier,
Range range,
java.lang.Class<T> objectType)
Reads an object's content from the cloud.
|
<T> ReadObjectResponse<T> |
readObject(ReadObjectRequest request,
java.lang.Class<T> objectType)
Reads an object's content from the cloud using all of the options provided in the request object.
|
ReadObjectResponse<java.io.InputStream> |
readObjectStream(ObjectIdentifier identifier,
Range range)
Provides an InputStream to read an object's content from the cloud.
|
void |
rekey(ObjectIdentifier identifier)
"Rekeys" an object.
|
void |
restoreVersion(ObjectId objectId,
ObjectId versionId)
Restores the specified version (snapshot) of the specified object so that the object's current state reflects
that of the version.
|
void |
setAcl(ObjectIdentifier identifier,
Acl acl)
Sets the ACL for the specified object.
|
void |
setBufferSize(int bufferSize) |
void |
setUserMetadata(ObjectIdentifier identifier,
Metadata... metadata)
Adds or replaces user metadata associated with the specified object.
|
void |
updateObject(ObjectIdentifier identifier,
java.lang.Object content)
Updates an object's content in the cloud.
|
void |
updateObject(ObjectIdentifier identifier,
java.lang.Object content,
Range range)
Updates an object's content in the cloud.
|
BasicResponse |
updateObject(UpdateObjectRequest request)
Updates an object's content in the cloud using all of the options provided in the request object.
|
public AtmosEncryptionClient(AtmosApi delegate, EncryptionConfig encryptionConfig, CompressionConfig compressionConfig)
delegate
- This is the AtmosApi instance that will be used for communicating
with the server.encryptionConfig
- The encryption configuration for the client. If null, no
encryption will be performed.compressionConfig
- The compression configuration for the client. If null,
no compression will be performed.public AtmosEncryptionClient(AtmosApi delegate, java.util.Collection<com.emc.vipr.transform.TransformFactory<com.emc.vipr.transform.OutputTransform,com.emc.vipr.transform.InputTransform>> transformations)
delegate
- This is the AtmosApi instance that will be used for communicating
with the server.transformations
- the collection of TransformFactory instances that will be
applied to objects. Note that order of transforms will be determined by the
factory's priority.TransformFactory.getPriority()
public void rekey(ObjectIdentifier identifier) throws com.emc.vipr.transform.encryption.DoesNotNeedRekeyException
identifier
- the object to be rekeyed.com.emc.vipr.transform.encryption.DoesNotNeedRekeyException
- if the object is already using the current master
encryption key.public ServiceInformation getServiceInformation()
getServiceInformation
in interface AtmosApi
public long calculateServerClockSkew()
AtmosApi
calculateServerClockSkew
in interface AtmosApi
public ObjectId createObject(java.lang.Object content, java.lang.String contentType)
AtmosApi
createObject
in interface AtmosApi
content
- The initial content of the object. May be appended to later. May be null to create an
object with no content. The content object can be any object type that is supported by the
implementation.contentType
- the MIME type of the content. Optional, may be null. If null, defaults to
application/octet-stream.public ObjectId createObject(ObjectIdentifier identifier, java.lang.Object content, java.lang.String contentType)
AtmosApi
createObject
in interface AtmosApi
identifier
- The identifier to use for the new object. This may be an ObjectPath or an ObjectKey.content
- The initial content of the object. May be appended to later. May be null to create an
object with no content. The content object can be any object type that is supported by the
implementation.contentType
- the MIME type of the content. Optional, may be null. If null, defaults to
application/octet-stream.public CreateObjectResponse createObject(CreateObjectRequest request)
AtmosApi
createObject
in interface AtmosApi
request
- The request object (click on the class name to get more information).public <T> T readObject(ObjectIdentifier identifier, java.lang.Class<T> objectType) throws java.io.IOException
AtmosApi
readObject
in interface AtmosApi
identifier
- The identifier of the object to read. May be any ObjectIdentifier.objectType
- The type of object to return. This can be any object type supported by the implementation.java.io.IOException
- if an exception occurs while reading the object. Note that IOExceptions are generally
retried automatically (configured in AtmosConfig
).public <T> T readObject(ObjectIdentifier identifier, Range range, java.lang.Class<T> objectType) throws java.io.IOException
AtmosApi
readObject
in interface AtmosApi
identifier
- The identifier of the object to read. May be any ObjectIdentifier.range
- (optional) The range of bytes to read from the object. A null value will read the entire
object.objectType
- The type of object to return. This can be any object type supported by the implementation.java.io.IOException
- if an exception occurs while reading the object. Note that IOExceptions are generally
retried automatically (configured in AtmosConfig
).public <T> ReadObjectResponse<T> readObject(ReadObjectRequest request, java.lang.Class<T> objectType) throws java.io.IOException
AtmosApi
readObject
in interface AtmosApi
request
- The request object (click on the class name to get more information)objectType
- The type of object to return. This can be any object type supported by the implementation.java.io.IOException
- if an exception occurs while reading the object. Note that IOExceptions are generally
retried automatically (configured in AtmosConfig
).public ReadObjectResponse<java.io.InputStream> readObjectStream(ObjectIdentifier identifier, Range range)
AtmosApi
readObjectStream
in interface AtmosApi
identifier
- The identifier of the object to read. May be any ObjectIdentifier.range
- (optional) The range of bytes to read from the object. A null value will read the entire
object.public void updateObject(ObjectIdentifier identifier, java.lang.Object content)
AtmosApi
updateObject
in interface AtmosApi
identifier
- The identifier of the object to update. May be any ObjectIdentifier.content
- The new content of the object. The content object can be any object type that is supported by
the implementation.public void updateObject(ObjectIdentifier identifier, java.lang.Object content, Range range)
AtmosApi
updateObject
in interface AtmosApi
identifier
- The identifier of the object to update. May be any ObjectIdentifier.content
- The new content of the object. The content object can be any object type that is supported by
the implementation.range
- (optional) The portion of the object to update (expressed as a range of bytes). A null value
will overwrite the entire object.public BasicResponse updateObject(UpdateObjectRequest request)
AtmosApi
updateObject
in interface AtmosApi
request
- The request object (click on the class name to get more information)public void delete(ObjectIdentifier identifier)
AtmosApi
public ObjectId createDirectory(ObjectPath path)
AtmosApi
createDirectory
in interface AtmosApi
path
- The path of the directory to create.public ObjectId createDirectory(ObjectPath path, Acl acl, Metadata... metadata)
AtmosApi
createDirectory
in interface AtmosApi
path
- The path of the directory to create.acl
- The ACL to assign to the new directory.metadata
- The metadata to associate with the new directory.public ListDirectoryResponse listDirectory(ListDirectoryRequest request)
AtmosApi
listDirectory
in interface AtmosApi
request
- The request object (click on the class name to get more information)public void move(ObjectPath oldPath, ObjectPath newPath, boolean overwrite)
AtmosApi
public java.util.Map<java.lang.String,java.lang.Boolean> getUserMetadataNames(ObjectIdentifier identifier)
AtmosApi
getUserMetadataNames
in interface AtmosApi
identifier
- The identifier of the object. Can be any ObjectIdentifier.public java.util.Map<java.lang.String,Metadata> getUserMetadata(ObjectIdentifier identifier, java.lang.String... metadataNames)
AtmosApi
getUserMetadata
in interface AtmosApi
identifier
- The identifier of the object. Can be any ObjectIdentifier.metadataNames
- (optional) Constrains the result to include only the metadata named in this list.public java.util.Map<java.lang.String,Metadata> getSystemMetadata(ObjectIdentifier identifier, java.lang.String... metadataNames)
AtmosApi
getSystemMetadata
in interface AtmosApi
identifier
- The identifier of the object. Can be any ObjectIdentifier.metadataNames
- (optional) Constrains the result to include only the metadata named in this list.public ObjectMetadata getObjectMetadata(ObjectIdentifier identifier)
AtmosApi
getObjectMetadata
in interface AtmosApi
identifier
- The identifier of the object. Can be any ObjectIdentifier.public void setUserMetadata(ObjectIdentifier identifier, Metadata... metadata)
AtmosApi
AtmosApi.deleteUserMetadata(ObjectIdentifier, String...)
.setUserMetadata
in interface AtmosApi
identifier
- The identifier of the object. Can be any ObjectIdentifier.metadata
- The metadata to add to or replace on the object.public void deleteUserMetadata(ObjectIdentifier identifier, java.lang.String... names)
AtmosApi
deleteUserMetadata
in interface AtmosApi
identifier
- The identifier of the object. Can be any ObjectIdentifier.names
- The names of the metadata to delete/remove from the object.public java.util.Set<java.lang.String> listMetadata(java.lang.String metadataName)
AtmosApi
listMetadata
in interface AtmosApi
metadataName
- The metadata name (sometime called a "tag") whose children should be returned. If null, all
root-level names will be returned (i.e. "ford", "chevy", "chrysler").public ListObjectsResponse listObjects(ListObjectsRequest request)
AtmosApi
listObjects
in interface AtmosApi
request
- The request object (click on the class name to get more information)public Acl getAcl(ObjectIdentifier identifier)
AtmosApi
public void setAcl(ObjectIdentifier identifier, Acl acl)
AtmosApi
public ObjectInfo getObjectInfo(ObjectIdentifier identifier)
AtmosApi
getObjectInfo
in interface AtmosApi
identifier
- The identifier of the object. Can be any ObjectIdentifier.public ObjectId createVersion(ObjectIdentifier identifier)
AtmosApi
createVersion
in interface AtmosApi
identifier
- The identifier of the object. Can be any ObjectIdentifier.public ListVersionsResponse listVersions(ListVersionsRequest request)
AtmosApi
listVersions
in interface AtmosApi
request
- The request object (click on the class name to get more information)public void restoreVersion(ObjectId objectId, ObjectId versionId)
AtmosApi
restoreVersion
in interface AtmosApi
objectId
- The ObjectId of the object.versionId
- The ObjectId of the version (must be a version of the specified object).public void deleteVersion(ObjectId versionId)
AtmosApi
deleteVersion
in interface AtmosApi
versionId
- The ObjectId of the version to delete (must point to a version and not an object).public java.net.URL getShareableUrl(ObjectIdentifier identifier, java.util.Date expirationDate) throws java.net.MalformedURLException
getShareableUrl
in interface AtmosApi
identifier
- The identifier of the object. Can be any ObjectIdentifier.expirationDate
- The date at which the generated URL will no longer be valid.java.net.MalformedURLException
- if the configured Atmos endpoint is syntactically invalid.AtmosApi.getShareableUrl(com.emc.atmos.api.ObjectIdentifier, java.util.Date)
public java.net.URL getShareableUrl(ObjectIdentifier identifier, java.util.Date expirationDate, java.lang.String disposition) throws java.net.MalformedURLException
getShareableUrl
in interface AtmosApi
identifier
- The identifier of the object. Can be any ObjectIdentifier.expirationDate
- The date at which the generated URL will no longer be valid.disposition
- the value of the Content-Disposition header, e.g.
"attachment; filename=\"filename.txt\""java.net.MalformedURLException
- if the configured Atmos endpoint is syntactically invalid.AtmosApi.getShareableUrl(com.emc.atmos.api.ObjectIdentifier, java.util.Date, java.lang.String)
public CreateAccessTokenResponse createAccessToken(CreateAccessTokenRequest request) throws java.net.MalformedURLException
createAccessToken
in interface AtmosApi
request
- The request object (click on the class name to get more information)java.net.MalformedURLException
- if the configured Atmos endpoint is syntactically invalid.AtmosApi.createAccessToken(com.emc.atmos.api.request.CreateAccessTokenRequest)
public GetAccessTokenResponse getAccessToken(java.net.URL url)
getAccessToken
in interface AtmosApi
url
- The URL of the access token.AtmosApi.getAccessToken(java.net.URL)
public GetAccessTokenResponse getAccessToken(java.lang.String accessTokenId)
getAccessToken
in interface AtmosApi
accessTokenId
- The ID of the access token.AtmosApi.getAccessToken(java.lang.String)
public void deleteAccessToken(java.net.URL url)
deleteAccessToken
in interface AtmosApi
url
- The URL of the access token.AtmosApi.deleteAccessToken(java.net.URL)
public void deleteAccessToken(java.lang.String accessTokenId)
deleteAccessToken
in interface AtmosApi
accessTokenId
- The ID of the access token.AtmosApi.deleteAccessToken(java.lang.String)
public ListAccessTokensResponse listAccessTokens(ListAccessTokensRequest request)
listAccessTokens
in interface AtmosApi
request
- The request object (click on the class name to get more information)AtmosApi.listAccessTokens(com.emc.atmos.api.request.ListAccessTokensRequest)
public PreSignedRequest preSignRequest(Request request, java.util.Date expiration) throws java.net.MalformedURLException
preSignRequest
in interface AtmosApi
request
- the request to pre-sign (can be executed at a later time)expiration
- the date at which the pre-signed request becomes invalid and will no longer be acceptedexpiration
java.net.MalformedURLException
- if the configured Atmos endpoint is syntactically invalid.AtmosApi.preSignRequest(com.emc.atmos.api.request.Request, java.util.Date)
public <T> GenericResponse<T> execute(PreSignedRequest request, java.lang.Class<T> resultType, java.lang.Object content) throws java.net.URISyntaxException
execute
in interface AtmosApi
request
- A pre-signed request generated by calling
AtmosApi.preSignRequest(com.emc.atmos.api.request.Request, java.util.Date)
.resultType
- (optional) The type of object to return. This can be any object type supported by the
implementation.content
- (optional) The body content to send in the request (i.e. the object content for a
create-object request). Can be any object type supported by the implementation.java.net.URISyntaxException
- if the URL in the pre-signed request is syntactically invalid.AtmosApi.execute(com.emc.atmos.api.request.PreSignedRequest, java.lang.Class, java.lang.Object)
public java.lang.String createSubtenant(CreateSubtenantRequest request)
AtmosApi
createSubtenant
in interface AtmosApi
request
- The CreateSubtenantRequest
containing the parameters for
the new subtenant.public int getBufferSize()
public void setBufferSize(int bufferSize)
bufferSize
- the bufferSize to set