Search in sources :

Example 1 with SSECustomerKey

use of com.qcloud.cos.model.SSECustomerKey in project hadoop-cos by tencentyun.

the class CosNativeFileSystemStore method setEncryptionMetadata.

private <X> void setEncryptionMetadata(X request, ObjectMetadata objectMetadata) {
    switch(encryptionSecrets.getEncryptionMethod()) {
        case SSE_C:
            callCOSClientWithSSEC(request, new SSECustomerKey(encryptionSecrets.getEncryptionKey()));
            break;
        case SSE_COS:
            callCOSClientWithSSECOS(request, objectMetadata);
            break;
        case SSE_KMS:
            String key = encryptionSecrets.getEncryptionKey();
            String context = Base64.encodeAsString(encryptionSecrets.getEncryptionContext().getBytes());
            SSECOSKeyManagementParams ssecosKeyManagementParams = new SSECOSKeyManagementParams(key, context);
            callCOSClientWithSSEKMS(request, ssecosKeyManagementParams);
            break;
        case NONE:
        default:
            break;
    }
}
Also used : SSECustomerKey(com.qcloud.cos.model.SSECustomerKey) SSECOSKeyManagementParams(com.qcloud.cos.model.SSECOSKeyManagementParams)

Example 2 with SSECustomerKey

use of com.qcloud.cos.model.SSECustomerKey in project cos-java-sdk-v5 by tencentyun.

the class PutGetDelTest method testPutGetDelObjectWithSSEKey.

@Ignore
public void testPutGetDelObjectWithSSEKey() throws NoSuchAlgorithmException, IOException {
    KeyGenerator symKeyGenerator = KeyGenerator.getInstance("AES");
    symKeyGenerator.init(128);
    SecretKey symKey = symKeyGenerator.generateKey();
    SSECustomerKey sseCKey = new SSECustomerKey(symKey);
    File localFile = buildTestFile(1025);
    String key = "ut/" + localFile.getName();
    File downLoadFile = new File(localFile.getAbsolutePath() + ".down");
    try {
        useServerEncryption = true;
        testPutGetObjectAndClear(key, localFile, downLoadFile, sseCKey, null);
    } finally {
        useServerEncryption = false;
    }
}
Also used : SecretKey(javax.crypto.SecretKey) SSECustomerKey(com.qcloud.cos.model.SSECustomerKey) KeyGenerator(javax.crypto.KeyGenerator) File(java.io.File) Ignore(org.junit.Ignore)

Aggregations

SSECustomerKey (com.qcloud.cos.model.SSECustomerKey)2 SSECOSKeyManagementParams (com.qcloud.cos.model.SSECOSKeyManagementParams)1 File (java.io.File)1 KeyGenerator (javax.crypto.KeyGenerator)1 SecretKey (javax.crypto.SecretKey)1 Ignore (org.junit.Ignore)1