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


Java EC2ContainerCredentialsProviderWrapper类代码示例

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


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

示例1: AnnotationConfigApplicationContext

import com.amazonaws.auth.EC2ContainerCredentialsProviderWrapper; //导入依赖的package包/类
@Test
public void credentialsProvider_noExplicitCredentialsProviderConfigured_configuresDefaultAwsCredentialsProviderChainWithInstanceProfile() throws Exception {
    // Arrange
    this.context = new AnnotationConfigApplicationContext();
    this.context.register(ContextCredentialsAutoConfiguration.class);

    // Act
    this.context.refresh();

    // Assert
    AWSCredentialsProvider awsCredentialsProvider = this.context.getBean(AmazonWebserviceClientConfigurationUtils.CREDENTIALS_PROVIDER_BEAN_NAME, AWSCredentialsProvider.class);
    assertNotNull(awsCredentialsProvider);

    @SuppressWarnings("unchecked") List<CredentialsProvider> credentialsProviders =
            (List<CredentialsProvider>) ReflectionTestUtils.getField(awsCredentialsProvider, "credentialsProviders");
    assertEquals(2, credentialsProviders.size());
    assertTrue(EC2ContainerCredentialsProviderWrapper.class.isInstance(credentialsProviders.get(0)));
    assertTrue(ProfileCredentialsProvider.class.isInstance(credentialsProviders.get(1)));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:20,代码来源:ContextCredentialsAutoConfigurationTest.java

示例2: credentialsProvider_instanceProfileConfigured_configuresInstanceProfileCredentialsProvider

import com.amazonaws.auth.EC2ContainerCredentialsProviderWrapper; //导入依赖的package包/类
@Test
public void credentialsProvider_instanceProfileConfigured_configuresInstanceProfileCredentialsProvider() {
    this.context = new AnnotationConfigApplicationContext();
    this.context.register(ContextCredentialsAutoConfiguration.class);
    TestPropertyValues.of(
            "cloud.aws.credentials.instanceProfile").applyTo(this.context);
    this.context.refresh();
    AWSCredentialsProvider awsCredentialsProvider = this.context.getBean(AmazonWebserviceClientConfigurationUtils.CREDENTIALS_PROVIDER_BEAN_NAME, AWSCredentialsProvider.class);
    assertNotNull(awsCredentialsProvider);

    @SuppressWarnings("unchecked") List<CredentialsProvider> credentialsProviders =
            (List<CredentialsProvider>) ReflectionTestUtils.getField(awsCredentialsProvider, "credentialsProviders");
    assertEquals(2, credentialsProviders.size());
    assertTrue(EC2ContainerCredentialsProviderWrapper.class.isInstance(credentialsProviders.get(0)));
    assertTrue(ProfileCredentialsProvider.class.isInstance(credentialsProviders.get(1)));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:17,代码来源:ContextCredentialsAutoConfigurationTest.java

示例3: credentialsProvider_profileNameConfigured_configuresProfileCredentialsProvider

import com.amazonaws.auth.EC2ContainerCredentialsProviderWrapper; //导入依赖的package包/类
@Test
public void credentialsProvider_profileNameConfigured_configuresProfileCredentialsProvider() {
    this.context = new AnnotationConfigApplicationContext();
    this.context.register(ContextCredentialsAutoConfiguration.class);
    TestPropertyValues.of(
            "cloud.aws.credentials.profileName:test").applyTo(this.context);
    this.context.refresh();
    AWSCredentialsProvider awsCredentialsProvider = this.context.getBean(AmazonWebserviceClientConfigurationUtils.CREDENTIALS_PROVIDER_BEAN_NAME, AWSCredentialsProvider.class);
    assertNotNull(awsCredentialsProvider);

    @SuppressWarnings("unchecked") List<CredentialsProvider> credentialsProviders =
            (List<CredentialsProvider>) ReflectionTestUtils.getField(awsCredentialsProvider, "credentialsProviders");
    assertEquals(2, credentialsProviders.size());
    assertTrue(EC2ContainerCredentialsProviderWrapper.class.isInstance(credentialsProviders.get(0)));
    assertTrue(ProfileCredentialsProvider.class.isInstance(credentialsProviders.get(1)));

    assertEquals("test", ReflectionTestUtils.getField(credentialsProviders.get(1), "profileName"));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:19,代码来源:ContextCredentialsAutoConfigurationTest.java

示例4: credentialsProvider_profileNameAndPathConfigured_configuresProfileCredentialsProvider

import com.amazonaws.auth.EC2ContainerCredentialsProviderWrapper; //导入依赖的package包/类
@Test
public void credentialsProvider_profileNameAndPathConfigured_configuresProfileCredentialsProvider() throws IOException {
    this.context = new AnnotationConfigApplicationContext();
    this.context.register(ContextCredentialsAutoConfiguration.class);
    TestPropertyValues.of(
            "cloud.aws.credentials.profileName:customProfile",
            "cloud.aws.credentials.profilePath:" + new ClassPathResource(getClass().getSimpleName() + "-profile", getClass()).getFile().getAbsolutePath()).applyTo(this.context);
    this.context.refresh();
    AWSCredentialsProvider awsCredentialsProvider = this.context.getBean(AmazonWebserviceClientConfigurationUtils.CREDENTIALS_PROVIDER_BEAN_NAME, AWSCredentialsProvider.class);
    assertNotNull(awsCredentialsProvider);

    @SuppressWarnings("unchecked") List<CredentialsProvider> credentialsProviders =
            (List<CredentialsProvider>) ReflectionTestUtils.getField(awsCredentialsProvider, "credentialsProviders");
    assertEquals(2, credentialsProviders.size());
    assertTrue(EC2ContainerCredentialsProviderWrapper.class.isInstance(credentialsProviders.get(0)));
    assertTrue(ProfileCredentialsProvider.class.isInstance(credentialsProviders.get(1)));

    ProfileCredentialsProvider provider = (ProfileCredentialsProvider) credentialsProviders.get(1);
    assertEquals("testAccessKey", provider.getCredentials().getAWSAccessKeyId());
    assertEquals("testSecretKey", provider.getCredentials().getAWSSecretKey());
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:22,代码来源:ContextCredentialsAutoConfigurationTest.java

示例5: AnnotationConfigApplicationContext

import com.amazonaws.auth.EC2ContainerCredentialsProviderWrapper; //导入依赖的package包/类
@Test
public void credentialsProvider_configWithAccessAndSecretKeyAndInstanceProfile_staticAwsCredentialsProviderConfiguredWithInstanceProfile() throws Exception {
    //Arrange
    this.context = new AnnotationConfigApplicationContext(ApplicationConfigurationWithAccessKeyAndSecretKeyAndInstanceProfile.class);

    //Act
    AWSCredentialsProvider awsCredentialsProvider = this.context.getBean(AWSCredentialsProvider.class);

    //Assert
    assertNotNull(awsCredentialsProvider);

    @SuppressWarnings("unchecked") List<CredentialsProvider> credentialsProviders =
            (List<CredentialsProvider>) ReflectionTestUtils.getField(awsCredentialsProvider, "credentialsProviders");
    assertEquals(2, credentialsProviders.size());
    assertTrue(AWSStaticCredentialsProvider.class.isInstance(credentialsProviders.get(0)));
    assertTrue(EC2ContainerCredentialsProviderWrapper.class.isInstance(credentialsProviders.get(1)));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:18,代码来源:ContextCredentialsConfigurationRegistrarTest.java

示例6: credentialsProvider_configWithInstanceProfile_instanceProfileCredentialsProviderConfigured

import com.amazonaws.auth.EC2ContainerCredentialsProviderWrapper; //导入依赖的package包/类
@Test
public void credentialsProvider_configWithInstanceProfile_instanceProfileCredentialsProviderConfigured() throws Exception {
    //Arrange
    this.context = new AnnotationConfigApplicationContext(ApplicationConfigurationWithInstanceProfileOnly.class);

    //Act
    AWSCredentialsProvider awsCredentialsProvider = this.context.getBean(AWSCredentialsProvider.class);

    //Assert
    assertNotNull(awsCredentialsProvider);

    @SuppressWarnings("unchecked") List<CredentialsProvider> credentialsProviders =
            (List<CredentialsProvider>) ReflectionTestUtils.getField(awsCredentialsProvider, "credentialsProviders");
    assertEquals(1, credentialsProviders.size());
    assertTrue(EC2ContainerCredentialsProviderWrapper.class.isInstance(credentialsProviders.get(0)));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:17,代码来源:ContextCredentialsConfigurationRegistrarTest.java

示例7: credentialsProvider_configWithAllProviders_allCredentialsProvidersConfigured

import com.amazonaws.auth.EC2ContainerCredentialsProviderWrapper; //导入依赖的package包/类
@Test
public void credentialsProvider_configWithAllProviders_allCredentialsProvidersConfigured() throws Exception {
    //Arrange
    this.context = new AnnotationConfigApplicationContext(ApplicationConfigurationWithAllProviders.class);

    //Act
    AWSCredentialsProvider awsCredentialsProvider = this.context.getBean(AWSCredentialsProvider.class);

    //Assert
    assertNotNull(awsCredentialsProvider);

    @SuppressWarnings("unchecked") List<CredentialsProvider> credentialsProviders =
            (List<CredentialsProvider>) ReflectionTestUtils.getField(awsCredentialsProvider, "credentialsProviders");
    assertEquals(3, credentialsProviders.size());
    assertTrue(AWSStaticCredentialsProvider.class.isInstance(credentialsProviders.get(0)));
    assertTrue(EC2ContainerCredentialsProviderWrapper.class.isInstance(credentialsProviders.get(1)));
    assertTrue(ProfileCredentialsProvider.class.isInstance(credentialsProviders.get(2)));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:19,代码来源:ContextCredentialsConfigurationRegistrarTest.java

示例8: registerCredentialsProvider

import com.amazonaws.auth.EC2ContainerCredentialsProviderWrapper; //导入依赖的package包/类
public static void registerCredentialsProvider(BeanDefinitionRegistry registry, String accessKey, String secretKey, boolean instanceProfile, String profileName, String profilePath) {
    BeanDefinitionBuilder factoryBeanBuilder = BeanDefinitionBuilder.genericBeanDefinition(CredentialsProviderFactoryBean.class);

    ManagedList<BeanDefinition> awsCredentialsProviders = new ManagedList<>();

    if (StringUtils.hasText(accessKey)) {
        BeanDefinitionBuilder credentials = BeanDefinitionBuilder.rootBeanDefinition(BasicAWSCredentials.class);
        credentials.addConstructorArgValue(accessKey);
        credentials.addConstructorArgValue(secretKey);

        BeanDefinitionBuilder provider = BeanDefinitionBuilder.rootBeanDefinition(AWSStaticCredentialsProvider.class);
        provider.addConstructorArgValue(credentials.getBeanDefinition());

        awsCredentialsProviders.add(provider.getBeanDefinition());
    }

    if (instanceProfile) {
        awsCredentialsProviders.add(BeanDefinitionBuilder.rootBeanDefinition(EC2ContainerCredentialsProviderWrapper.class).getBeanDefinition());
    }

    if (StringUtils.hasText(profileName)) {
        BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(ProfileCredentialsProvider.class);
        if (StringUtils.hasText(profilePath)) {
            builder.addConstructorArgValue(profilePath);
        }

        builder.addConstructorArgValue(profileName);
        awsCredentialsProviders.add(builder.getBeanDefinition());
    }

    factoryBeanBuilder.addConstructorArgValue(awsCredentialsProviders);

    registry.registerBeanDefinition(CredentialsProviderFactoryBean.CREDENTIALS_PROVIDER_BEAN_NAME, factoryBeanBuilder.getBeanDefinition());

    AmazonWebserviceClientConfigurationUtils.replaceDefaultCredentialsProvider(registry, CredentialsProviderFactoryBean.CREDENTIALS_PROVIDER_BEAN_NAME);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:37,代码来源:ContextConfigurationUtils.java

示例9: CustomCredentialsProviderChain

import com.amazonaws.auth.EC2ContainerCredentialsProviderWrapper; //导入依赖的package包/类
public CustomCredentialsProviderChain(ClientConfiguration clientConfiguration, ProfileIdentifier profile, Supplier<MFAToken> mfaTokenSupplier) {
    super(new EnvironmentVariableCredentialsProvider(),
            new SystemPropertiesCredentialsProvider(),
            new ProfileCredentialProvider(clientConfiguration, profile, mfaTokenSupplier),
            new EC2ContainerCredentialsProviderWrapper());
}
 
开发者ID:schibsted,项目名称:strongbox,代码行数:7,代码来源:CustomCredentialsProviderChain.java

示例10: configureEC2Authentication

import com.amazonaws.auth.EC2ContainerCredentialsProviderWrapper; //导入依赖的package包/类
private static AmazonS3ClientBuilder configureEC2Authentication(AmazonS3ClientBuilder builder) {
    LOGGER.info("Using EC2 authentication");
    return builder.withCredentials(new EC2ContainerCredentialsProviderWrapper());
}
 
开发者ID:Talend,项目名称:daikon,代码行数:5,代码来源:S3ContentServiceConfiguration.java


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