本文整理汇总了Java中com.amazonaws.services.kms.AWSKMSClient.setRegion方法的典型用法代码示例。如果您正苦于以下问题:Java AWSKMSClient.setRegion方法的具体用法?Java AWSKMSClient.setRegion怎么用?Java AWSKMSClient.setRegion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amazonaws.services.kms.AWSKMSClient
的用法示例。
在下文中一共展示了AWSKMSClient.setRegion方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newAWSKMSClient
import com.amazonaws.services.kms.AWSKMSClient; //导入方法依赖的package包/类
/**
* Creates and returns a new instance of AWS KMS client in the case when
* an explicit AWS KMS client is not specified.
*/
private AWSKMSClient newAWSKMSClient(
AWSCredentialsProvider credentialsProvider,
ClientConfiguration clientConfig,
CryptoConfiguration cryptoConfig,
RequestMetricCollector requestMetricCollector
) {
final AWSKMSClient kmsClient = new AWSKMSClient(
credentialsProvider, clientConfig, requestMetricCollector);
final Region kmsRegion = cryptoConfig.getAwsKmsRegion();
if (kmsRegion != null)
kmsClient.setRegion(kmsRegion);
return kmsClient;
}
示例2: build
import com.amazonaws.services.kms.AWSKMSClient; //导入方法依赖的package包/类
public AWSKMSClient build() {
ClientConfiguration config = new ClientConfiguration();
if (!Util.fixNull(host).trim().isEmpty()) {
config.setProxyHost(this.host);
config.setProxyPort(this.port);
}
AWSKMSClient client = new AWSKMSClient(new DefaultAWSCredentialsProviderChain(), config);
if (!Util.fixNull(region).trim().isEmpty()) {
client.setRegion(Region.getRegion(Regions.fromName(region)));
}
return client;
}
示例3: getClient
import com.amazonaws.services.kms.AWSKMSClient; //导入方法依赖的package包/类
/**
* Returns a KMS client for the given region. Clients are cached by region.
*
* @param region Region to configure a client for
* @return AWS KMS client
*/
public AWSKMSClient getClient(Region region) {
AWSKMSClient client = kmsClientMap.get(region);
if (client == null) {
final AWSKMSClient newClient = new AWSKMSClient();
newClient.setRegion(region);
kmsClientMap.put(region, newClient);
client = newClient;
}
return client;
}
示例4: getAndSetToken
import com.amazonaws.services.kms.AWSKMSClient; //导入方法依赖的package包/类
/**
* Authenticates with Cerberus and decrypts and sets the token and expiration details.
*
* @param iamPrincipalArn AWS IAM principal ARN used to auth with cerberus
* @param region AWS Region used in auth with cerberus
*/
protected void getAndSetToken(final String iamPrincipalArn, final Region region) {
final AWSKMSClient kmsClient = new AWSKMSClient();
kmsClient.setRegion(region);
final String encryptedAuthData = getEncryptedAuthData(iamPrincipalArn, region);
final VaultAuthResponse decryptedToken = decryptToken(kmsClient, encryptedAuthData);
final DateTime expires = DateTime.now(DateTimeZone.UTC)
.plusSeconds(decryptedToken.getLeaseDuration() - paddingTimeInSeconds);
credentials = new TokenVaultCredentials(decryptedToken.getClientToken());
expireDateTime = expires;
}
示例5: decrypt
import com.amazonaws.services.kms.AWSKMSClient; //导入方法依赖的package包/类
/**
* Decrypts the given encrypted bytes with the given encryption context.
* Assumes the runtime has access to the desired AWS environment.
*
* @param region the region
* @param encryptionContext optional encryption context
* @param encryptedBytes the encrypted bytes
* @return the decrypted bytes
*/
public static byte[] decrypt(Region region, Map<String, String> encryptionContext, byte[] encryptedBytes) {
DecryptRequest decryptRequest = new DecryptRequest();
decryptRequest.setEncryptionContext(encryptionContext);
decryptRequest.setCiphertextBlob(ByteBuffer.wrap(encryptedBytes));
AWSKMSClient client = new AWSKMSClient();
client.setRegion(region);
DecryptResult decryptResult = client.decrypt(decryptRequest);
return decryptResult.getPlaintext().array();
}