use of com.amazonaws.auth.profile.internal.ProfileStaticCredentialsProvider in project intellij-idea-plugin-connector-for-aws-lambda by satr.
the class AbstractConnectorModel method getCredentialsProvider.
protected AWSCredentialsProvider getCredentialsProvider() {
if (isEmpty(credentialProfileName)) {
getLogger().logDebug("Cannot get a profile for an empty name");
return tryDefaultAwsCredentialsProviderChain();
}
if (!validateCredentialProfilesExist()) {
getLogger().logError("Cannot find any credentials profiles. Please create at least one.");
return tryDefaultAwsCredentialsProviderChain();
}
ProfileStaticCredentialsProvider profileCredentialsProvider = null;
AllProfiles allBasicProfiles = loadProfilesWithProperties();
BasicProfile profile = allBasicProfiles.getProfile(credentialProfileName);
if (profile == null) {
getLogger().logDebug("Last loaded profile does not exist: \"%s\".", credentialProfileName);
} else {
getLogger().logDebug("Select the profile \"%s\".", credentialProfileName);
profileCredentialsProvider = tryCreateProfileCredentialsProvider(profile);
if (profileCredentialsProvider != null) {
String profileRegionName = profile.getRegion();
if (!isEmpty(profileRegionName)) {
getLogger().logDebug("Selected a region from the profile: %s", regionName);
regionName = profileRegionName;
}
return profileCredentialsProvider;
}
}
profileCredentialsProvider = tryGetAlternativeAwsCredentialsProvider(credentialProfileName, allBasicProfiles);
if (profileCredentialsProvider != null) {
return profileCredentialsProvider;
}
getLogger().logDebug("No profiles could be selected and used.");
return tryDefaultAwsCredentialsProviderChain();
}
use of com.amazonaws.auth.profile.internal.ProfileStaticCredentialsProvider in project intellij-idea-plugin-connector-for-aws-lambda by satr.
the class AbstractConnectorModel method tryGetAlternativeAwsCredentialsProvider.
@Nullable
private ProfileStaticCredentialsProvider tryGetAlternativeAwsCredentialsProvider(String skipProfileName, AllProfiles allBasicProfiles) {
ProfileStaticCredentialsProvider profileCredentialsProvider;
for (BasicProfile alternativeProfile : allBasicProfiles.getProfiles().values()) {
if (alternativeProfile.getProfileName().equals(skipProfileName)) {
// skip the profile, already checked before
continue;
}
getLogger().logDebug("Try to selected the profile \"%s\".", alternativeProfile.getProfileName());
profileCredentialsProvider = tryCreateProfileCredentialsProvider(alternativeProfile);
if (profileCredentialsProvider != null) {
credentialProfileName = alternativeProfile.getProfileName();
String profileRegionName = alternativeProfile.getRegion();
if (!isEmpty(profileRegionName)) {
getLogger().logDebug("Selected a region from the profile: %s", regionName);
regionName = profileRegionName;
}
return profileCredentialsProvider;
}
}
return null;
}
Aggregations