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


Java AWSCredentialsProvider.getCredentials方法代码示例

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


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

示例1: configure

import com.amazonaws.auth.AWSCredentialsProvider; //导入方法依赖的package包/类
@Override
public Credentials configure(final Host host) {
    final Credentials credentials = host.getCredentials();
    // Only for AWS
    if(host.getHostname().endsWith(PreferencesFactory.get().getProperty("s3.hostname.default"))) {
        if(!credentials.validate(host.getProtocol(), new LoginOptions(host.getProtocol()).password(false))) {
            // Lookup from default profile if no access key is set in bookmark
            for(AWSCredentialsProvider provider : providers) {
                try {
                    final AWSCredentials c = provider.getCredentials();
                    credentials.setUsername(c.getAWSAccessKeyId());
                    credentials.setPassword(c.getAWSSecretKey());
                    break;
                }
                catch(SdkClientException e) {
                    log.debug(String.format("Ignore failure loading credentials from provider %s", provider));
                    // Continue searching with next provider
                }
            }
        }
    }
    return credentials;
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:24,代码来源:AWSCredentialsConfigurator.java

示例2: resolveBaseCredentials

import com.amazonaws.auth.AWSCredentialsProvider; //导入方法依赖的package包/类
private AWSCredentialsProvider resolveBaseCredentials(final ClientConfiguration clientConfiguration, final ProfileIdentifier profileIdentifier) {
    try {
        AWSCredentialsProvider credentialsProvider =  new CustomCredentialsProviderChain(clientConfiguration, profileIdentifier, MFAToken.defaultMFATokenSupplier());

        // Test if getCredentials will throw
        credentialsProvider.getCredentials();

        return credentialsProvider;
    } catch (Exception e) {
        throw new RuntimeException(String.format("Failed to resolve credentials.\n" +
                        "\n" +
                        "If you entered an MFA token, the token was incorrect, or the MFA is misconfigured\n" +
                        "\n" +
                        "The following locations are included in the credentials chain:\n" +
                        " - environment variables\n" +
                        " - system properties\n" +
                        " - credential file (%s) and config file (%s)\n" +
                        " - ec2 container metadata\n" +
                        "\n" +
                        "Please refer to the documentation for how to configure credentials",
                AWSCLIConfigFile.getCredentialProfilesFile().map(File::getAbsolutePath).orElse("not specified"),
                AWSCLIConfigFile.getConfigFile().map(File::getAbsolutePath).orElse("not specified")), e);
    }
}
 
开发者ID:schibsted,项目名称:strongbox,代码行数:25,代码来源:GroupModel.java

示例3: getCredentialsFromContext

import com.amazonaws.auth.AWSCredentialsProvider; //导入方法依赖的package包/类
/**
 * Returns the credentials from the execution if exists. Else returns null.
 */
private AWSCredentials getCredentialsFromContext() {
    final AWSCredentialsProvider credentialsProvider = executionContext.getCredentialsProvider();

    AWSCredentials credentials = null;
    if (credentialsProvider != null) {
        awsRequestMetrics.startEvent(Field.CredentialsRequestTime);
        try {
            credentials = credentialsProvider.getCredentials();
        } finally {
            awsRequestMetrics.endEvent(Field.CredentialsRequestTime);
        }
    }
    return credentials;
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:18,代码来源:AmazonHttpClient.java

示例4: getCredentials

import com.amazonaws.auth.AWSCredentialsProvider; //导入方法依赖的package包/类
/**
 * Returns the AWS credentials for the specified profile.
 */
public AWSCredentials getCredentials(String profileName) {
    final AWSCredentialsProvider provider = credentialProviderCache.get(profileName);
    if (provider != null) {
        return provider.getCredentials();
    } else {
        BasicProfile profile = allProfiles.getProfile(profileName);
        if (profile == null) {
            throw new IllegalArgumentException("No AWS profile named '" + profileName + "'");
        }
        final AWSCredentialsProvider newProvider = fromProfile(profile);
        credentialProviderCache.put(profileName, newProvider);
        return newProvider.getCredentials();
    }
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:18,代码来源:ProfilesConfigFile.java

示例5: credentials

import com.amazonaws.auth.AWSCredentialsProvider; //导入方法依赖的package包/类
@Test
public void credentials() throws IOException {
  when(conf.getPassword("access.key")).thenReturn("accessKey".toCharArray());
  when(conf.getPassword("secret.key")).thenReturn("secretKey".toCharArray());
  AWSCredentialsProvider credentialsProvider = configuration.awsCredentialsProvider(conf);
  AWSCredentials awsCredentials = credentialsProvider.getCredentials();
  assertThat(awsCredentials.getAWSAccessKeyId(), is("accessKey"));
  assertThat(awsCredentials.getAWSSecretKey(), is("secretKey"));
}
 
开发者ID:HotelsDotCom,项目名称:circus-train,代码行数:10,代码来源:SnsConfigurationTest.java

示例6: setCredentialsProvider

import com.amazonaws.auth.AWSCredentialsProvider; //导入方法依赖的package包/类
public void setCredentialsProvider(AWSCredentialsProvider credentialsProvider) {
    // Make sure they're usable first
    credentialsProvider.getCredentials();
    this.credentialsProvider = credentialsProvider;
}
 
开发者ID:datamachines,项目名称:KafkaToSQS,代码行数:6,代码来源:AWSKafkaConfig.java


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