Search in sources :

Example 1 with CryptoTool

use of com.qaprosoft.carina.core.foundation.crypto.CryptoTool in project carina by qaprosoft.

the class AmazonS3Manager method getInstance.

public static synchronized AmazonS3Manager getInstance() {
    if (instance == null) {
        instance = new AmazonS3Manager();
        CryptoTool cryptoTool = new CryptoTool(Configuration.get(Parameter.CRYPTO_KEY_PATH));
        Pattern CRYPTO_PATTERN = Pattern.compile(SpecialKeywords.CRYPT);
        String accessKey = cryptoTool.decryptByPattern(Configuration.get(Parameter.ACCESS_KEY_ID), CRYPTO_PATTERN);
        String secretKey = cryptoTool.decryptByPattern(Configuration.get(Parameter.SECRET_KEY), CRYPTO_PATTERN);
        System.setProperty("aws.accessKeyId", accessKey);
        System.setProperty("aws.secretKey", secretKey);
        s3client = new AmazonS3Client(new SystemPropertiesCredentialsProvider());
    }
    return instance;
}
Also used : Pattern(java.util.regex.Pattern) AmazonS3Client(com.amazonaws.services.s3.AmazonS3Client) SystemPropertiesCredentialsProvider(com.amazonaws.auth.SystemPropertiesCredentialsProvider) CryptoTool(com.qaprosoft.carina.core.foundation.crypto.CryptoTool)

Example 2 with CryptoTool

use of com.qaprosoft.carina.core.foundation.crypto.CryptoTool in project carina by qaprosoft.

the class AzureManager method getInstance.

public static synchronized AzureManager getInstance() {
    if (instance == null) {
        instance = new AzureManager();
        CryptoTool cryptoTool = new CryptoTool(Configuration.get(Configuration.Parameter.CRYPTO_KEY_PATH));
        Pattern CRYPTO_PATTERN = Pattern.compile(SpecialKeywords.CRYPT);
        String accountName = Configuration.get(Configuration.Parameter.AZURE_ACCOUNT_NAME);
        String endpoint = cryptoTool.decryptByPattern(Configuration.get(Configuration.Parameter.AZURE_BLOB_URL), CRYPTO_PATTERN);
        String secretKey = cryptoTool.decryptByPattern(Configuration.get(Configuration.Parameter.AZURE_ACCESS_KEY_TOKEN), CRYPTO_PATTERN);
        // Create a SharedKeyCredential
        StorageSharedKeyCredential credential = new StorageSharedKeyCredential(accountName, secretKey);
        // Create a blobServiceClient
        blobServiceClient = new BlobServiceClientBuilder().endpoint(endpoint).credential(credential).buildClient();
    }
    return instance;
}
Also used : Pattern(java.util.regex.Pattern) BlobServiceClientBuilder(com.azure.storage.blob.BlobServiceClientBuilder) CryptoTool(com.qaprosoft.carina.core.foundation.crypto.CryptoTool) StorageSharedKeyCredential(com.azure.storage.common.StorageSharedKeyCredential)

Aggregations

CryptoTool (com.qaprosoft.carina.core.foundation.crypto.CryptoTool)2 Pattern (java.util.regex.Pattern)2 SystemPropertiesCredentialsProvider (com.amazonaws.auth.SystemPropertiesCredentialsProvider)1 AmazonS3Client (com.amazonaws.services.s3.AmazonS3Client)1 BlobServiceClientBuilder (com.azure.storage.blob.BlobServiceClientBuilder)1 StorageSharedKeyCredential (com.azure.storage.common.StorageSharedKeyCredential)1