当前位置: 首页>>代码示例>>Java>>正文


Java STSAssumeRoleSessionCredentialsProvider类代码示例

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


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

示例1: getAWSCredentialsProviderChain

import com.amazonaws.auth.STSAssumeRoleSessionCredentialsProvider; //导入依赖的package包/类
public static AWSCredentialsProviderChain getAWSCredentialsProviderChain() {
    String cerberusRoleToAssume = System.getenv(CERBERUS_ASSUME_ROLE_ARN) != null ?
            System.getenv(CERBERUS_ASSUME_ROLE_ARN) : "";
    String cerberusRoleToAssumeExternalId = System.getenv(CERBERUS_ASSUME_ROLE_EXTERNAL_ID) != null ?
            System.getenv(CERBERUS_ASSUME_ROLE_EXTERNAL_ID) : "";

    STSAssumeRoleSessionCredentialsProvider sTSAssumeRoleSessionCredentialsProvider =
            new STSAssumeRoleSessionCredentialsProvider
                    .Builder(cerberusRoleToAssume, UUID.randomUUID().toString())
                    .withExternalId(cerberusRoleToAssumeExternalId)
                    .build();

    AWSCredentialsProviderChain chain = new AWSCredentialsProviderChain(
            new EnvironmentVariableCredentialsProvider(),
            new SystemPropertiesCredentialsProvider(),
            new ProfileCredentialsProvider(),
            sTSAssumeRoleSessionCredentialsProvider,
            new InstanceProfileCredentialsProvider());

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

示例2: provideSecurityTokenService_whenAwsStsRoleArnIsSet

import com.amazonaws.auth.STSAssumeRoleSessionCredentialsProvider; //导入依赖的package包/类
@Test
public void provideSecurityTokenService_whenAwsStsRoleArnIsSet() {
  context = new AnnotationConfigApplicationContext();
  addEnvironment(context, "zipkin.collector.sqs.queue-url:" + sqsRule.queueUrl());
  addEnvironment(context, "zipkin.collector.sqs.wait-time-seconds:1");
  addEnvironment(context, "zipkin.collector.sqs.aws-access-key-id: x");
  addEnvironment(context, "zipkin.collector.sqs.aws-secret-access-key: x");
  addEnvironment(context, "zipkin.collector.sqs.aws-sts-role-arn: test");
  context.register(PropertyPlaceholderAutoConfiguration.class, Region.class,
      ZipkinSQSCollectorAutoConfiguration.class, ZipkinSQSCredentialsAutoConfiguration.class, InMemoryConfiguration.class);
  context.refresh();

  assertThat(context.getBean(SQSCollector.class)).isNotNull();
  assertThat(context.getBean(AWSSecurityTokenService.class)).isNotNull();
  assertThat(context.getBean(AWSCredentialsProvider.class)).isInstanceOf(STSAssumeRoleSessionCredentialsProvider.class);
}
 
开发者ID:openzipkin,项目名称:zipkin-aws,代码行数:17,代码来源:ZipkinSQSCollectorAutoConfigurationTest.java

示例3: kinesisCollectorConfiguredForAWSWithGivenCredentials

import com.amazonaws.auth.STSAssumeRoleSessionCredentialsProvider; //导入依赖的package包/类
@Test
public void kinesisCollectorConfiguredForAWSWithGivenCredentials() {
  addEnvironment(context, "zipkin.collector.kinesis.stream-name: zipkin-test");
  addEnvironment(context, "zipkin.collector.kinesis.app-name: zipkin");
  addEnvironment(context, "zipkin.collector.kinesis.aws-access-key-id: x");
  addEnvironment(context, "zipkin.collector.kinesis.aws-secret-access-key: x");
  addEnvironment(context, "zipkin.collector.kinesis.aws-sts-role-arn: test");
  context.register(PropertyPlaceholderAutoConfiguration.class,
      ZipkinKinesisCollectorAutoConfiguration.class,
      ZipkinKinesisCredentialsAutoConfiguration.class,
      InMemoryConfiguration.class);
  context.refresh();

  assertThat(context.getBean(KinesisCollector.class)).isNotNull();
  assertThat(context.getBean(AWSSecurityTokenService.class)).isNotNull();
  assertThat(context.getBean(AWSCredentialsProvider.class)).isInstanceOf(STSAssumeRoleSessionCredentialsProvider.class);
}
 
开发者ID:openzipkin,项目名称:zipkin-aws,代码行数:18,代码来源:ZipkinKinesisCollectorAutoConfigurationTest.java

示例4: buildCredentialsProvider

import com.amazonaws.auth.STSAssumeRoleSessionCredentialsProvider; //导入依赖的package包/类
private AWSCredentialsProvider buildCredentialsProvider(final AWSCredentials credentials, final String region, final String assumeRole) {
  AWSCredentialsProvider credentialsProvider = new AWSStaticCredentialsProvider(credentials);
  if (isNullOrEmpty(assumeRole)) {
    return credentialsProvider;
  }
  else {
    // STS requires a region; fall back on the SDK default if not set
    String stsRegion;
    if (isNullOrEmpty(region)) {
      stsRegion = defaultRegion();
    }
    else {
      stsRegion = region;
    }
    AWSSecurityTokenService securityTokenService = AWSSecurityTokenServiceClientBuilder.standard()
        .withRegion(stsRegion)
        .withCredentials(credentialsProvider).build();

    return new STSAssumeRoleSessionCredentialsProvider.Builder(assumeRole, "nexus-s3-session")
        .withStsClient(securityTokenService)
        .build();
  }
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:24,代码来源:AmazonS3Factory.java

示例5: initializeApiClient

import com.amazonaws.auth.STSAssumeRoleSessionCredentialsProvider; //导入依赖的package包/类
public AWSDeviceFarmClient initializeApiClient(final DeviceFarmExtension extension) {

        final String roleArn = extension.getAuthentication().getRoleArn();

        AWSCredentials credentials = extension.getAuthentication();

        if (roleArn != null) {
            final STSAssumeRoleSessionCredentialsProvider sts = new STSAssumeRoleSessionCredentialsProvider
                    .Builder(roleArn, RandomStringUtils.randomAlphanumeric(8))
                    .build();
            credentials = sts.getCredentials();
        }

        final ClientConfiguration clientConfiguration = new ClientConfiguration()
                .withUserAgent(String.format(extension.getUserAgent(), pluginVersion));

        AWSDeviceFarmClient apiClient = new AWSDeviceFarmClient(credentials, clientConfiguration);
        apiClient.setServiceNameIntern("devicefarm");
        if (extension.getEndpointOverride() != null) {
            apiClient.setEndpoint(extension.getEndpointOverride());
        }

        return apiClient;

    }
 
开发者ID:awslabs,项目名称:aws-device-farm-gradle-plugin,代码行数:26,代码来源:DeviceFarmClientFactory.java

示例6: init

import com.amazonaws.auth.STSAssumeRoleSessionCredentialsProvider; //导入依赖的package包/类
@PostConstruct
public void init() {
    // TODO
    // this parameters have to be configurable
    cache = CacheBuilder.newBuilder()
            .maximumSize(500)
            .expireAfterAccess(50, TimeUnit.MINUTES)
            .removalListener((RemovalNotification<Key<?>, AmazonWebServiceClient> notification) -> {
                logger.debug("Shutting down expired client for key: {}", notification.getKey());
                notification.getValue().shutdown();
            }).build(new CacheLoader<Key<?>, AmazonWebServiceClient>() {
                @Override
                public AmazonWebServiceClient load(@Nonnull final Key<?> key) throws Exception {
                    logger.debug("CacheLoader active for Key : {}", key);
                    return key.region.createClient(
                            key.type,
                            new STSAssumeRoleSessionCredentialsProvider(
                                    buildRoleArn(key.accountId),
                                    ROLE_SESSION_NAME),
                            new ClientConfiguration().withMaxErrorRetry(MAX_ERROR_RETRY));
                }
            });
}
 
开发者ID:zalando-stups,项目名称:fullstop,代码行数:24,代码来源:CachingClientProvider.java

示例7: getCredentialsProvider

import com.amazonaws.auth.STSAssumeRoleSessionCredentialsProvider; //导入依赖的package包/类
public AWSCredentialsProvider getCredentialsProvider() {
  AWSCredentialsProvider credentialsProviderChain = new DefaultAWSCredentialsProviderChain(this.config);
  if (config.hasPath(GobblinAWSConfigurationKeys.CLIENT_ASSUME_ROLE_KEY) &&
          config.getBoolean(GobblinAWSConfigurationKeys.CLIENT_ASSUME_ROLE_KEY)) {
    String roleArn = config.getString(GobblinAWSConfigurationKeys.CLIENT_ROLE_ARN_KEY);
    String sessionId = config.getString(GobblinAWSConfigurationKeys.CLIENT_SESSION_ID_KEY);
    STSAssumeRoleSessionCredentialsProvider.Builder builder =
            new STSAssumeRoleSessionCredentialsProvider.Builder(roleArn, sessionId)
                    .withLongLivedCredentialsProvider(credentialsProviderChain);
    if (config.hasPath(GobblinAWSConfigurationKeys.CLIENT_EXTERNAL_ID_KEY)) {
      builder.withExternalId(config.getString(GobblinAWSConfigurationKeys.CLIENT_EXTERNAL_ID_KEY));
    }
    if (config.hasPath(GobblinAWSConfigurationKeys.CREDENTIALS_REFRESH_INTERVAL)) {
      builder.withRoleSessionDurationSeconds(
              (int) TimeUnit.MINUTES.toSeconds(config.getLong(GobblinAWSConfigurationKeys.CREDENTIALS_REFRESH_INTERVAL)));
    }
    credentialsProviderChain = builder.build();
  }
  return credentialsProviderChain;
}
 
开发者ID:apache,项目名称:incubator-gobblin,代码行数:21,代码来源:AWSClusterSecurityManager.java

示例8: AssumedRoleTestContext

import com.amazonaws.auth.STSAssumeRoleSessionCredentialsProvider; //导入依赖的package包/类
public AssumedRoleTestContext(AWSCredentialsProvider awsCredentials, Region testRegion, String roleSuffix) {
    iamHelper = new IAMHelper(awsCredentials, testRegion);

    roleName = ROLE_PREFIX + roleSuffix;
    roleArn = iamHelper.createOrGetRole(roleName);
    principal = new Principal(PrincipalType.ROLE, roleName);

    STSAssumeRoleSessionCredentialsProvider.Builder builder = new STSAssumeRoleSessionCredentialsProvider.Builder(roleArn, "mysession");
    assumedAWSCredentials = builder.build();
    secretGroupManager = new DefaultSecretsGroupManager(assumedAWSCredentials);
}
 
开发者ID:schibsted,项目名称:strongbox,代码行数:12,代码来源:AssumedRoleTestContext.java

示例9: assumeRole

import com.amazonaws.auth.STSAssumeRoleSessionCredentialsProvider; //导入依赖的package包/类
private AWSCredentialsProvider assumeRole(AWSCredentialsProvider longLivedAWSCredentials, ClientConfiguration clientConfiguration, String assumeRoleArn) {
    AWSSecurityTokenService client = AWSSecurityTokenServiceClientBuilder.standard()
            .withCredentials(longLivedAWSCredentials)
            .withClientConfiguration(transformAndVerifyOrThrow(clientConfiguration))
            .withRegion(RegionResolver.getRegion())
            .build();

    STSAssumeRoleSessionCredentialsProvider.Builder builder =
            new STSAssumeRoleSessionCredentialsProvider.Builder(assumeRoleArn, "strongbox-cli");
    builder.withStsClient(client);

    return builder.build();
}
 
开发者ID:schibsted,项目名称:strongbox,代码行数:14,代码来源:GroupModel.java

示例10: credentialsProvider

import com.amazonaws.auth.STSAssumeRoleSessionCredentialsProvider; //导入依赖的package包/类
/** By default, get credentials from the {@link DefaultAWSCredentialsProviderChain */
@Bean
@ConditionalOnMissingBean
AWSCredentialsProvider credentialsProvider(ZipkinSQSCollectorProperties properties) {
  if (securityTokenService != null) {
    return new STSAssumeRoleSessionCredentialsProvider.Builder(properties.awsStsRoleArn, "zipkin-server")
        .withStsClient(securityTokenService)
        .build();
  } else {
    return getDefaultCredentialsProvider(properties);
  }
}
 
开发者ID:openzipkin,项目名称:zipkin-aws,代码行数:13,代码来源:ZipkinSQSCredentialsAutoConfiguration.java

示例11: credentialsProvider

import com.amazonaws.auth.STSAssumeRoleSessionCredentialsProvider; //导入依赖的package包/类
/** By default, get credentials from the {@link DefaultAWSCredentialsProviderChain */
@Bean
@ConditionalOnMissingBean
AWSCredentialsProvider credentialsProvider(ZipkinKinesisCollectorProperties properties) {
  if (securityTokenService != null) {
    return new STSAssumeRoleSessionCredentialsProvider.Builder(properties.awsStsRoleArn,
        "zipkin-server")
        .withStsClient(securityTokenService)
        .build();
  } else {
    return getDefaultCredentialsProvider(properties);
  }
}
 
开发者ID:openzipkin,项目名称:zipkin-aws,代码行数:14,代码来源:ZipkinKinesisCredentialsAutoConfiguration.java

示例12: setRoleToAssumeArn

import com.amazonaws.auth.STSAssumeRoleSessionCredentialsProvider; //导入依赖的package包/类
public void setRoleToAssumeArn(String roleToAssumeArn) {
  this.roleToAssumeArn = roleToAssumeArn;
  if(!Validator.isBlank(roleToAssumeArn)) {
    String sessionId = "session" + Math.random();
    STSAssumeRoleSessionCredentialsProvider remoteAccountCredentials = new STSAssumeRoleSessionCredentialsProvider(credentials,
                                                                                                                   roleToAssumeArn,
                                                                                                                   sessionId);

    credentials = remoteAccountCredentials;
  }
}
 
开发者ID:guardian,项目名称:kinesis-logback-appender,代码行数:12,代码来源:BaseKinesisAppender.java

示例13: AWSDeviceFarm

import com.amazonaws.auth.STSAssumeRoleSessionCredentialsProvider; //导入依赖的package包/类
/**
 * Private AWSDeviceFarm constructor. Uses the roleArn to generate STS creds if the roleArn isn't null; otherwise
 * just uses the AWSCredentials creds.
 *
 * @param creds   AWSCredentials creds to use for authentication.
 * @param roleArn Role ARN to use for authentication.
 */
private AWSDeviceFarm(AWSCredentials creds, String roleArn) {
    if (roleArn != null) {
        STSAssumeRoleSessionCredentialsProvider sts = new STSAssumeRoleSessionCredentialsProvider
                .Builder(roleArn, RandomStringUtils.randomAlphanumeric(8))
                .build();
        creds = sts.getCredentials();
    }

    ClientConfiguration clientConfiguration = new ClientConfiguration().withUserAgent("AWS Device Farm - Jenkins v1.0");
    api = new AWSDeviceFarmClient(creds, clientConfiguration);
    api.setServiceNameIntern("devicefarm");
}
 
开发者ID:awslabs,项目名称:aws-device-farm-jenkins-plugin,代码行数:20,代码来源:AWSDeviceFarm.java

示例14: getSTSCredentialsProvider

import com.amazonaws.auth.STSAssumeRoleSessionCredentialsProvider; //导入依赖的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

示例15: DefaultSimpleSecretsGroup

import com.amazonaws.auth.STSAssumeRoleSessionCredentialsProvider; //导入依赖的package包/类
public DefaultSimpleSecretsGroup(final SecretsGroupIdentifier groupIdentifier, final RoleARN role) {
    AWSCredentialsProvider assumedAWSCredentials = new STSAssumeRoleSessionCredentialsProvider.Builder(role.toArn(), SessionName.getSessionName("StrongboxSDK")).build();
    DefaultSecretsGroupManager secretsGroupManager = new DefaultSecretsGroupManager(assumedAWSCredentials);
    secretsGroup = secretsGroupManager.get(groupIdentifier);
}
 
开发者ID:schibsted,项目名称:strongbox,代码行数:6,代码来源:DefaultSimpleSecretsGroup.java


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