• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java GetCallerIdentityRequest类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.amazonaws.services.securitytoken.model.GetCallerIdentityRequest的典型用法代码示例。如果您正苦于以下问题:Java GetCallerIdentityRequest类的具体用法?Java GetCallerIdentityRequest怎么用?Java GetCallerIdentityRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



GetCallerIdentityRequest类属于com.amazonaws.services.securitytoken.model包,在下文中一共展示了GetCallerIdentityRequest类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getCmsSystemProperties

import com.amazonaws.services.securitytoken.model.GetCallerIdentityRequest; //导入依赖的package包/类
/**
 * Get generated CMS properties that are not set by the user
 * @return - System configured properties
 */
public Properties getCmsSystemProperties() {

    final BaseOutputs baseOutputs = getBaseStackOutputs();
    final BaseParameters baseParameters = getBaseStackParameters();
    final VaultParameters vaultParameters = getVaultStackParamters();
    final Optional<String> cmsVaultToken = getCmsVaultToken();
    final Optional<String> cmsDatabasePassword = getCmsDatabasePassword();

    final GetCallerIdentityResult callerIdentity = securityTokenService.getCallerIdentity(
            new GetCallerIdentityRequest());
    final String rootUserArn = String.format("arn:aws:iam::%s:root", callerIdentity.getAccount());

    final Properties properties = new Properties();
    properties.put(VAULT_ADDR_KEY, String.format("https://%s", cnameToHost(vaultParameters.getCname())));
    properties.put(VAULT_TOKEN_KEY, cmsVaultToken.get());
    properties.put(ROOT_USER_ARN_KEY, rootUserArn);
    properties.put(ADMIN_ROLE_ARN_KEY, baseParameters.getAccountAdminArn());
    properties.put(CMS_ROLE_ARN_KEY, baseOutputs.getCmsIamRoleArn());
    properties.put(JDBC_URL_KEY, baseOutputs.getCmsDbJdbcConnectionString());
    properties.put(JDBC_USERNAME_KEY, ConfigConstants.DEFAULT_CMS_DB_NAME);
    properties.put(JDBC_PASSWORD_KEY, cmsDatabasePassword.get());

    return properties;
}
 
开发者ID:Nike-Inc,项目名称:cerberus-lifecycle-cli,代码行数:29,代码来源:ConfigStore.java


示例2: getAccount

import com.amazonaws.services.securitytoken.model.GetCallerIdentityRequest; //导入依赖的package包/类
public static String getAccount(AWSCredentialsProvider awsCredentialsProvider, ClientConfiguration clientConfiguration) {
    AWSSecurityTokenService client = AWSSecurityTokenServiceClientBuilder.standard()
        .withCredentials(awsCredentialsProvider)
        .withClientConfiguration(transformAndVerifyOrThrow(clientConfiguration))
        .withRegion(RegionResolver.getRegion())
        .build();
    GetCallerIdentityRequest request = new GetCallerIdentityRequest();
    GetCallerIdentityResult result = client.getCallerIdentity(request);

    return result.getAccount();
}
 
开发者ID:schibsted,项目名称:strongbox,代码行数:12,代码来源:IAMPolicyManager.java


示例3: verifyInstanceIdentity

import com.amazonaws.services.securitytoken.model.GetCallerIdentityRequest; //导入依赖的package包/类
public boolean verifyInstanceIdentity(AWSAttestationData info, final String awsAccount) {
    
    GetCallerIdentityRequest req = new GetCallerIdentityRequest();
    
    try {
        AWSSecurityTokenServiceClient client = getInstanceClient(info);
        if (client == null) {
            LOGGER.error("verifyInstanceIdentity - unable to get AWS STS client object");
            return false;
        }
        
        GetCallerIdentityResult res = client.getCallerIdentity(req);
        if (res == null) {
            LOGGER.error("verifyInstanceIdentity - unable to get caller identity");
            return false;
        }
         
        String arn = "arn:aws:sts::" + awsAccount + ":assumed-role/" + info.getRole() + "/";
        if (!res.getArn().startsWith(arn)) {
            LOGGER.error("verifyInstanceIdentity - ARN mismatch - request: {} caller-idenity: {}",
                    arn, res.getArn());
            return false;
        }
        
        return true;
        
    } catch (Exception ex) {
        LOGGER.error("CloudStore: verifyInstanceIdentity - unable get caller identity: {}",
                ex.getMessage());
        return false;
    }
}
 
开发者ID:yahoo,项目名称:athenz,代码行数:33,代码来源:InstanceAWSProvider.java


示例4: getTokenServiceClient

import com.amazonaws.services.securitytoken.model.GetCallerIdentityRequest; //导入依赖的package包/类
@Override
AWSSecurityTokenServiceClient getTokenServiceClient() {
    AWSSecurityTokenServiceClient client = Mockito.mock(AWSSecurityTokenServiceClient.class);
    Mockito.when(client.assumeRole(Mockito.any(AssumeRoleRequest.class))).thenReturn(assumeRoleResult);
    Mockito.when(client.getCallerIdentity(Mockito.any(GetCallerIdentityRequest.class))).thenReturn(callerIdentityResult);
    return client;
}
 
开发者ID:yahoo,项目名称:athenz,代码行数:8,代码来源:MockCloudStore.java


示例5: getSTSCredentialsProvider

import com.amazonaws.services.securitytoken.model.GetCallerIdentityRequest; //导入依赖的package包/类
private AWSCredentialsProvider getSTSCredentialsProvider(AWSCredentialsProvider awsCredentials, String region, String assumeRoleArn) {
    AWSSecurityTokenService stsClient = AWSSecurityTokenServiceClientBuilder.standard()
            .withRegion(region)
            .withCredentials(awsCredentials)
            .build();
    String roleSessionName = String.format("API_KEY_%[email protected]_%s",
            awsCredentials.getCredentials().getAWSAccessKeyId(),
            stsClient.getCallerIdentity(new GetCallerIdentityRequest()).getAccount());
    LOG.debug("Cross account role session name: " + roleSessionName);
    return new STSAssumeRoleSessionCredentialsProvider.Builder(assumeRoleArn, roleSessionName)
            .withStsClient(stsClient)
            .build();
}
 
开发者ID:Graylog2,项目名称:graylog-plugin-aws,代码行数:14,代码来源:AWSAuthProvider.java


示例6: getAccountId

import com.amazonaws.services.securitytoken.model.GetCallerIdentityRequest; //导入依赖的package包/类
public String getAccountId() {
	final GetCallerIdentityResult callerIdentity = tokenService.getCallerIdentity(new GetCallerIdentityRequest());
	return callerIdentity.getAccount();
}
 
开发者ID:kaklakariada,项目名称:aws-sam-gradle,代码行数:5,代码来源:AwsMetadataService.java


示例7: run

import com.amazonaws.services.securitytoken.model.GetCallerIdentityRequest; //导入依赖的package包/类
@Override
public void run(SetBackupAdminPrincipalsCommand command) {
    GetCallerIdentityResult identityResult = sts.getCallerIdentity(new GetCallerIdentityRequest());
    String accountId = identityResult.getAccount();
    String rootArn = String.format("arn:aws:iam::%s:root", accountId);
    String adminRoleArn = configStore.getAccountAdminArn().get();

    Set<String> principals = new HashSet<>();
    principals.add(rootArn);
    principals.add(adminRoleArn);
    principals.addAll(command.getAdditionalPrincipals());

    configStore.storeBackupAdminIamPrincipals(principals);

    if (! configStore.getRegionBackupBucketMap().isEmpty()) {
        configStore.getRegionBackupBucketMap().forEach((region, backupRegionInfo) -> {
            final List<Statement> statements = new LinkedList<>();
            principals.forEach( principal -> {
                log.debug("Adding principal: {} to the CMK Policy for region {}", principal, region);
                statements.add(new Statement(Statement.Effect.Allow)
                        .withId("Principal " + principal + " Has All Actions")
                        .withPrincipals(new Principal(AWS_PROVIDER, principal, false))
                        .withActions(KMSActions.AllKMSActions)
                        .withResources(new Resource("*")));
            });

            Policy kmsPolicy = new Policy();
            kmsPolicy.setStatements(statements);
            String policyString = kmsPolicy.toJson();

            log.debug("Updating key {} for region {} with policy {}", backupRegionInfo.getKmsCmkId(), region, policyString);

            AWSKMS kms = AWSKMSClient.builder().withCredentials(getAWSCredentialsProviderChain()).withRegion(region).build();
            PutKeyPolicyRequest request = new PutKeyPolicyRequest()
                    .withKeyId(backupRegionInfo.getKmsCmkId())
                    .withPolicyName("default")
                    .withBypassPolicyLockoutSafetyCheck(true)
                    .withPolicy(policyString);

            kms.putKeyPolicy(request);

            log.info("Successfully updated key {} in region {} to allow the following principals access {}",
                    backupRegionInfo.getKmsCmkId(), region, String.join(", ", principals));
        });
    }
}
 
开发者ID:Nike-Inc,项目名称:cerberus-lifecycle-cli,代码行数:47,代码来源:SetBackupAdminPrincipalsOperation.java


示例8: getAccount

import com.amazonaws.services.securitytoken.model.GetCallerIdentityRequest; //导入依赖的package包/类
protected final String getAccount() {
    return this.sts.getCallerIdentity(new GetCallerIdentityRequest()).getAccount();
}
 
开发者ID:widdix,项目名称:aws-cf-templates,代码行数:4,代码来源:AAWSTest.java



注:本文中的com.amazonaws.services.securitytoken.model.GetCallerIdentityRequest类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java UpdateStrategy类代码示例发布时间:2022-05-22
下一篇:
Java Gist类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap