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;
}
}
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;
}
}
Aggregations