public abstract class CryptoModuleBase extends Object implements CryptoModule
Modifier and Type | Field and Description |
---|---|
protected CryptoScheme |
contentCryptoScheme |
protected CryptoConfiguration |
cryptoConfig |
protected static int |
DEFAULT_BUFFER_SIZE |
protected String |
encryptionClientUserAgent |
protected EncryptionMaterials |
encryptionMaterials |
protected OSSDirect |
ossDirect |
Modifier | Constructor and Description |
---|---|
protected |
CryptoModuleBase(OSSDirect ossDirect,
EncryptionMaterials encryptionMaterials,
CryptoConfiguration cryptoConfig) |
Modifier and Type | Method and Description |
---|---|
protected OSSObject |
adjustToDesiredRange(OSSObject OSSobject,
long[] range)
Adjusts the retrieved OSSObject so that the object contents contain only the
range of bytes desired by the user.
|
protected ContentCryptoMaterial |
buildContentCryptoMaterials()
Build a new content crypto material read-only.
|
protected ContentCryptoMaterial |
createContentMaterialFromMetadata(ObjectMetadata meta)
Builds a new content crypto material for decrypting the object achieved.
|
protected OSSObject |
decipherWithMetadata(GetObjectRequest req,
long[] desiredRange,
long[] cryptoRange,
OSSObject retrieved)
Decrypt the encypted object by the metadata achieved.
|
protected SecretKey |
generateCEK()
Returns a srcret key for encrypting content.
|
protected static Map<String,String> |
getDescFromJsonString(String jsonString) |
OSSObject |
getObjectSecurely(GetObjectRequest req)
Gets the object in OSS, if it was an encrypted object then decrypt it and
return the result, otherwise return the object directly.
|
ObjectMetadata |
getObjectSecurely(GetObjectRequest getObjectRequest,
File file)
Gets the object in OSS and write it in a file, if it was an encrypted object
then decrypt it, otherwise wirte the object directly.
|
static boolean |
hasEncryptionInfo(ObjectMetadata metadata)
Checks there an encryption info in the metadata.
|
InitiateMultipartUploadResult |
initiateMultipartUploadSecurely(InitiateMultipartUploadRequest req,
MultipartUploadCryptoContext context)
Initiates the multipart upload request, and bulid the crypto context.
|
protected long |
plaintextLength(PutObjectRequest request,
ObjectMetadata metadata)
Returns the plaintext length from the request and metadata; or -1 if unknown.
|
PutObjectResult |
putObjectSecurely(PutObjectRequest req)
Puts the object with data encrypted.
|
protected void |
safeCloseSource(Closeable is) |
protected void |
setUserAgent(WebServiceRequest req,
String userAgent) |
protected ObjectMetadata |
updateMetadataWithContentCryptoMaterial(ObjectMetadata metadata,
File file,
ContentCryptoMaterial contentCryptoMaterial)
Storages the encrytion materials in the object metadata.
|
protected ObjectMetadata |
updateMetadataWithUploadContext(ObjectMetadata metadata,
MultipartUploadCryptoContext context)
Add the upload part info into metadata.
|
UploadPartResult |
uploadPartSecurely(UploadPartRequest req,
MultipartUploadCryptoContext context)
Uploads the part secured.
|
protected PutObjectRequest |
wrapPutRequestWithCipher(PutObjectRequest request,
ContentCryptoMaterial cekMaterial)
Returns the given
PutObjectRequest instance but has the content as
input stream wrapped with a cipher, and configured with some meta data and
user metadata. |
protected static final int DEFAULT_BUFFER_SIZE
protected final EncryptionMaterials encryptionMaterials
protected final CryptoScheme contentCryptoScheme
protected final CryptoConfiguration cryptoConfig
protected final OSSDirect ossDirect
protected final String encryptionClientUserAgent
protected CryptoModuleBase(OSSDirect ossDirect, EncryptionMaterials encryptionMaterials, CryptoConfiguration cryptoConfig)
public PutObjectResult putObjectSecurely(PutObjectRequest req)
putObjectSecurely
in interface CryptoModule
req
- The put object request.protected final PutObjectRequest wrapPutRequestWithCipher(PutObjectRequest request, ContentCryptoMaterial cekMaterial)
PutObjectRequest
instance but has the content as
input stream wrapped with a cipher, and configured with some meta data and
user metadata.public static boolean hasEncryptionInfo(ObjectMetadata metadata)
public OSSObject getObjectSecurely(GetObjectRequest req)
getObjectSecurely
in interface CryptoModule
protected OSSObject decipherWithMetadata(GetObjectRequest req, long[] desiredRange, long[] cryptoRange, OSSObject retrieved)
protected void safeCloseSource(Closeable is)
protected final OSSObject adjustToDesiredRange(OSSObject OSSobject, long[] range)
public ObjectMetadata getObjectSecurely(GetObjectRequest getObjectRequest, File file)
getObjectSecurely
in interface CryptoModule
public InitiateMultipartUploadResult initiateMultipartUploadSecurely(InitiateMultipartUploadRequest req, MultipartUploadCryptoContext context)
initiateMultipartUploadSecurely
in interface CryptoModule
context
- The multi part crypto context contains the content crypto materials and
upload information, it should created on the outside with part-size and data-size set done, the
content crypto materials and other upload information will be filled after initiate request done.public UploadPartResult uploadPartSecurely(UploadPartRequest req, MultipartUploadCryptoContext context)
uploadPartSecurely
in interface CryptoModule
protected final long plaintextLength(PutObjectRequest request, ObjectMetadata metadata)
protected final ContentCryptoMaterial buildContentCryptoMaterials()
protected final ObjectMetadata updateMetadataWithUploadContext(ObjectMetadata metadata, MultipartUploadCryptoContext context)
protected final ObjectMetadata updateMetadataWithContentCryptoMaterial(ObjectMetadata metadata, File file, ContentCryptoMaterial contentCryptoMaterial)
protected ContentCryptoMaterial createContentMaterialFromMetadata(ObjectMetadata meta)
protected static Map<String,String> getDescFromJsonString(String jsonString)
protected SecretKey generateCEK()
protected void setUserAgent(WebServiceRequest req, String userAgent)
Copyright © 2021. All Rights Reserved.