public abstract class COSCryptoModuleBase extends COSCryptoModule
| Modifier and Type | Field and Description |
|---|---|
protected com.qcloud.cos.internal.crypto.ContentCryptoScheme |
contentCryptoScheme |
protected COSDirect |
cos |
protected CryptoConfiguration |
cryptoConfig
A read-only copy of the crypto configuration.
|
protected com.qcloud.cos.internal.crypto.COSCryptoScheme |
cryptoScheme |
protected static int |
DEFAULT_BUFFER_SIZE |
protected EncryptionMaterialsProvider |
kekMaterialsProvider |
protected QCLOUDKMS |
kms |
protected org.slf4j.Logger |
log |
protected Map<String,MultipartUploadCryptoContext> |
multipartUploadContexts
Map of data about in progress encrypted multipart uploads.
|
| Modifier | Constructor and Description |
|---|---|
protected |
COSCryptoModuleBase(COSDirect cos,
COSCredentialsProvider credentialsProvider,
EncryptionMaterialsProvider kekMaterialsProvider,
CryptoConfiguration cryptoConfig)
For testing purposes only.
|
protected |
COSCryptoModuleBase(QCLOUDKMS kms,
COSDirect cos,
COSCredentialsProvider credentialsProvider,
EncryptionMaterialsProvider kekMaterialsProvider,
CryptoConfiguration cryptoConfig) |
| Modifier and Type | Method and Description |
|---|---|
void |
abortMultipartUploadSecurely(AbortMultipartUploadRequest req) |
protected abstract long |
ciphertextLength(long plaintextLength)
Returns the length of the ciphertext computed from the length of the plaintext.
|
CompleteMultipartUploadResult |
completeMultipartUploadSecurely(CompleteMultipartUploadRequest req) |
CopyPartResult |
copyPartSecurely(CopyPartRequest copyPartRequest) |
protected com.qcloud.cos.internal.crypto.ContentCryptoMaterial |
createContentCryptoMaterial(CosServiceRequest req)
Creates and returns a non-null content crypto material for the given request.
|
protected PutObjectRequest |
createInstructionPutRequest(String bucketName,
String key,
com.qcloud.cos.internal.crypto.ContentCryptoMaterial cekMaterial) |
protected SecretKey |
generateCEK(EncryptionMaterials kekMaterials,
Provider providerIn) |
com.qcloud.cos.internal.crypto.COSCryptoScheme |
getCOSCryptoScheme() |
InitiateMultipartUploadResult |
initiateMultipartUploadSecurely(InitiateMultipartUploadRequest req) |
protected CipherLiteInputStream |
newMultipartCOSCipherInputStream(UploadPartRequest req,
com.qcloud.cos.internal.crypto.CipherLite cipherLite) |
protected long |
plaintextLength(AbstractPutObjectRequest request,
ObjectMetadata metadata)
Returns the plaintext length from the request and metadata; or -1 if unknown.
|
PutObjectResult |
putInstructionFileSecurely(PutInstructionFileRequest req) |
PutObjectResult |
putObjectSecurely(PutObjectRequest req) |
protected void |
securityCheck(com.qcloud.cos.internal.crypto.ContentCryptoMaterial cekMaterial,
COSObjectWrapper retrieved)
Checks if the the crypto scheme used in the given content crypto material is allowed to be
used in this crypto module.
|
protected PutObjectRequest |
updateInstructionPutRequest(PutObjectRequest req,
com.qcloud.cos.internal.crypto.ContentCryptoMaterial cekMaterial)
Updates put request to store the specified instruction object in COS.
|
protected ObjectMetadata |
updateMetadataWithContentCryptoMaterial(ObjectMetadata metadata,
File file,
com.qcloud.cos.internal.crypto.ContentCryptoMaterial instruction) |
UploadPartResult |
uploadPartSecurely(UploadPartRequest req) |
protected <R extends AbstractPutObjectRequest> |
wrapWithCipher(R request,
com.qcloud.cos.internal.crypto.ContentCryptoMaterial cekMaterial)
Returns the given
PutObjectRequest but has the content as input stream wrapped
with a cipher, and configured with some meta data and user metadata. |
getObjectSecurely, getObjectSecurelyprotected static final int DEFAULT_BUFFER_SIZE
protected final EncryptionMaterialsProvider kekMaterialsProvider
protected final org.slf4j.Logger log
protected final com.qcloud.cos.internal.crypto.COSCryptoScheme cryptoScheme
protected final com.qcloud.cos.internal.crypto.ContentCryptoScheme contentCryptoScheme
protected final CryptoConfiguration cryptoConfig
protected final Map<String,MultipartUploadCryptoContext> multipartUploadContexts
protected final COSDirect cos
protected final QCLOUDKMS kms
protected COSCryptoModuleBase(QCLOUDKMS kms, COSDirect cos, COSCredentialsProvider credentialsProvider, EncryptionMaterialsProvider kekMaterialsProvider, CryptoConfiguration cryptoConfig)
cryptoConfig - a read-only copy of the crypto configuration.protected COSCryptoModuleBase(COSDirect cos, COSCredentialsProvider credentialsProvider, EncryptionMaterialsProvider kekMaterialsProvider, CryptoConfiguration cryptoConfig)
protected abstract long ciphertextLength(long plaintextLength)
plaintextLength - a non-negative numberpublic PutObjectResult putObjectSecurely(PutObjectRequest req)
putObjectSecurely in class COSCryptoModulepublic final void abortMultipartUploadSecurely(AbortMultipartUploadRequest req)
abortMultipartUploadSecurely in class COSCryptoModulepublic final CopyPartResult copyPartSecurely(CopyPartRequest copyPartRequest)
copyPartSecurely in class COSCryptoModulepublic InitiateMultipartUploadResult initiateMultipartUploadSecurely(InitiateMultipartUploadRequest req)
initiateMultipartUploadSecurely in class COSCryptoModulepublic UploadPartResult uploadPartSecurely(UploadPartRequest req)
NOTE: Because the encryption process requires context from previous blocks, parts uploaded with the COSEncryptionClient (as opposed to the normal COSClient) must be uploaded serially, and in order. Otherwise, the previous encryption context isn't available to use when encrypting the current part.
uploadPartSecurely in class COSCryptoModuleprotected final CipherLiteInputStream newMultipartCOSCipherInputStream(UploadPartRequest req, com.qcloud.cos.internal.crypto.CipherLite cipherLite)
public CompleteMultipartUploadResult completeMultipartUploadSecurely(CompleteMultipartUploadRequest req)
completeMultipartUploadSecurely in class COSCryptoModuleprotected final ObjectMetadata updateMetadataWithContentCryptoMaterial(ObjectMetadata metadata, File file, com.qcloud.cos.internal.crypto.ContentCryptoMaterial instruction)
protected final com.qcloud.cos.internal.crypto.ContentCryptoMaterial createContentCryptoMaterial(CosServiceRequest req)
CosClientException - if no encryption material can be found.protected final SecretKey generateCEK(EncryptionMaterials kekMaterials, Provider providerIn)
kekMaterials - non-null encryption materialsprotected final <R extends AbstractPutObjectRequest> R wrapWithCipher(R request, com.qcloud.cos.internal.crypto.ContentCryptoMaterial cekMaterial)
PutObjectRequest but has the content as input stream wrapped
with a cipher, and configured with some meta data and user metadata.protected final long plaintextLength(AbstractPutObjectRequest request, ObjectMetadata metadata)
public final com.qcloud.cos.internal.crypto.COSCryptoScheme getCOSCryptoScheme()
protected final PutObjectRequest updateInstructionPutRequest(PutObjectRequest req, com.qcloud.cos.internal.crypto.ContentCryptoMaterial cekMaterial)
req - The put-instruction-file request for the instruction file to be stored in COS.cekMaterial - The instruction object to be stored in COS.protected final PutObjectRequest createInstructionPutRequest(String bucketName, String key, com.qcloud.cos.internal.crypto.ContentCryptoMaterial cekMaterial)
protected void securityCheck(com.qcloud.cos.internal.crypto.ContentCryptoMaterial cekMaterial,
COSObjectWrapper retrieved)
SecurityException - if the crypto scheme used in the given content crypto material is
not allowed in this crypto module.public final PutObjectResult putInstructionFileSecurely(PutInstructionFileRequest req)
putInstructionFileSecurely in class COSCryptoModuleEncryptedGetObjectRequest.Copyright © 2023. All rights reserved.