/** * Loads the credential profiles from the given input stream. * * @param is input stream from where the profile details are read. */ private AllProfiles loadProfiles(InputStream is) throws IOException { ProfilesConfigFileLoaderHelper helper = new ProfilesConfigFileLoaderHelper(); Map<String, Map<String, String>> allProfileProperties = helper .parseProfileProperties(new Scanner(is, StringUtils.UTF8.name())); // Convert the loaded property map to credential objects Map<String, BasicProfile> profilesByName = new LinkedHashMap<String, BasicProfile>(); for (Entry<String, Map<String, String>> entry : allProfileProperties.entrySet()) { String profileName = entry.getKey(); Map<String, String> properties = entry.getValue(); if (profileName.startsWith("profile ")) { LOG.warn( "Your profile name includes a 'profile ' prefix. This is considered part of the profile name in the " + "Java SDK, so you will need to include this prefix in your profile name when you reference this " + "profile from your Java code."); } assertParameterNotEmpty(profileName, "Unable to load properties from profile: Profile name is empty."); profilesByName.put(profileName, new BasicProfile(profileName, properties)); } return new AllProfiles(profilesByName); }
public Map<String, BasicProfile> getAllBasicProfiles() { return allProfiles.getProfiles(); }
private BasicProfile loadProfile(File configFile) { final AllProfiles allProfiles = profileConfigLoader.loadProfiles(configFile); return allProfiles.getProfile(profileName); } }
profilesByName.put(profileName, new BasicProfile(profileName, properties)); final Map<String, BasicProfile> profiles = new AllProfiles(profilesByName).getProfiles(); final Optional<Map.Entry<String, BasicProfile>> optional = profiles.entrySet().stream().filter(new Predicate<Map.Entry<String, BasicProfile>>() { @Override
private BasicProfile loadProfile(File configFile) { final AllProfiles allProfiles = profileConfigLoader.loadProfiles(configFile); return allProfiles.getProfile(profileName); }
public Map<String, BasicProfile> getAllBasicProfiles() { return allProfiles.getProfiles(); }
/** * Loads the credential profiles from the given input stream. * * @param is input stream from where the profile details are read. */ private AllProfiles loadProfiles(InputStream is) throws IOException { ProfilesConfigFileLoaderHelper helper = new ProfilesConfigFileLoaderHelper(); Map<String, Map<String, String>> allProfileProperties = helper .parseProfileProperties(new Scanner(is, StringUtils.UTF8.name())); // Convert the loaded property map to credential objects Map<String, BasicProfile> profilesByName = new LinkedHashMap<String, BasicProfile>(); for (Entry<String, Map<String, String>> entry : allProfileProperties.entrySet()) { String profileName = entry.getKey(); Map<String, String> properties = entry.getValue(); if (profileName.startsWith("profile ")) { LOG.warn( "Your profile name includes a 'profile ' prefix. This is considered part of the profile name in the " + "Java SDK, so you will need to include this prefix in your profile name when you reference this " + "profile from your Java code."); } assertParameterNotEmpty(profileName, "Unable to load properties from profile: Profile name is empty."); profilesByName.put(profileName, new BasicProfile(profileName, properties)); } return new AllProfiles(profilesByName); }
/** * 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(); } }
public Map<String, BasicProfile> getAllBasicProfiles() { return allProfiles.getProfiles(); }
/** * Loads the credential profiles from the given input stream. * * @param is input stream from where the profile details are read. */ private AllProfiles loadProfiles(InputStream is) throws IOException { ProfilesConfigFileLoaderHelper helper = new ProfilesConfigFileLoaderHelper(); Map<String, Map<String, String>> allProfileProperties = helper .parseProfileProperties(new Scanner(is, StringUtils.UTF8.name())); // Convert the loaded property map to credential objects Map<String, BasicProfile> profilesByName = new LinkedHashMap<String, BasicProfile>(); for (Entry<String, Map<String, String>> entry : allProfileProperties.entrySet()) { String profileName = entry.getKey(); Map<String, String> properties = entry.getValue(); if (profileName.startsWith("profile ")) { LOG.warn( "The legacy profile format requires the 'profile ' prefix before the profile name. " + "The latest code does not require such prefix, and will consider it as part of the profile name. " + "Please remove the prefix if you are seeing this warning."); } assertParameterNotEmpty(profileName, "Unable to load properties from profile: Profile name is empty."); profilesByName.put(profileName, new BasicProfile(profileName, properties)); } return new AllProfiles(profilesByName); }
private AWSCredentialsProvider fromAssumeRole() { if (StringUtils.isNullOrEmpty(profile.getRoleSourceProfile())) { throw new SdkClientException(String.format( "Unable to load credentials from profile [%s]: Source profile name is not specified", profile.getProfileName())); } final BasicProfile sourceProfile = allProfiles .getProfile(this.profile.getRoleSourceProfile()); if (sourceProfile == null) { throw new SdkClientException(String.format( "Unable to load source profile [%s]: Source profile was not found [%s]", profile.getProfileName(), profile.getRoleSourceProfile())); } AWSCredentials sourceCredentials = new ProfileStaticCredentialsProvider(sourceProfile) .getCredentials(); final String roleSessionName = (this.profile.getRoleSessionName() == null) ? "aws-sdk-java-" + System.currentTimeMillis() : this.profile.getRoleSessionName(); RoleInfo roleInfo = new RoleInfo().withRoleArn(this.profile.getRoleArn()) .withRoleSessionName(roleSessionName) .withExternalId(this.profile.getRoleExternalId()) .withLongLivedCredentials(sourceCredentials); return profileCredentialsService.getAssumeRoleCredentialsProvider(roleInfo); } }
private BasicProfile loadProfile(File configFile) { final AllProfiles allProfiles = profileConfigLoader.loadProfiles(configFile); return allProfiles.getProfile(profileName); }
private BasicProfile loadProfile(File configFile) { final AllProfiles allProfiles = profileConfigLoader.loadProfiles(configFile); return allProfiles.getProfile(profileName); } }
/** * 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(); } }
private AWSCredentialsProvider fromAssumeRole() { if (StringUtils.isNullOrEmpty(profile.getRoleSourceProfile())) { throw new SdkClientException(String.format( "Unable to load credentials from profile [%s]: Source profile name is not specified", profile.getProfileName())); } final BasicProfile sourceProfile = allProfiles .getProfile(this.profile.getRoleSourceProfile()); if (sourceProfile == null) { throw new SdkClientException(String.format( "Unable to load source profile [%s]: Source profile was not found [%s]", profile.getProfileName(), profile.getRoleSourceProfile())); } AWSCredentials sourceCredentials = new ProfileStaticCredentialsProvider(sourceProfile) .getCredentials(); final String roleSessionName = (this.profile.getRoleSessionName() == null) ? "aws-sdk-java-" + System.currentTimeMillis() : this.profile.getRoleSessionName(); RoleInfo roleInfo = new RoleInfo().withRoleArn(this.profile.getRoleArn()) .withRoleSessionName(roleSessionName) .withExternalId(this.profile.getRoleExternalId()) .withLongLivedCredentials(sourceCredentials); return profileCredentialsService.getAssumeRoleCredentialsProvider(roleInfo); } }
private BasicProfile loadProfile(File configFile) { final AllProfiles allProfiles = profileConfigLoader.loadProfiles(configFile); return allProfiles.getProfile(profileName); }
/** * 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(); } }
private AWSCredentialsProvider fromAssumeRole() { if (StringUtils.isNullOrEmpty(profile.getRoleSourceProfile())) { throw new SdkClientException(String.format( "Unable to load credentials from profile [%s]: Source profile name is not specified", profile.getProfileName())); } final BasicProfile sourceProfile = allProfiles .getProfile(this.profile.getRoleSourceProfile()); if (sourceProfile == null) { throw new SdkClientException(String.format( "Unable to load source profile [%s]: Source profile was not found [%s]", profile.getProfileName(), profile.getRoleSourceProfile())); } AWSCredentials sourceCredentials = new ProfileStaticCredentialsProvider(sourceProfile) .getCredentials(); final String roleSessionName = (this.profile.getRoleSessionName() == null) ? "aws-sdk-java-" + System.currentTimeMillis() : this.profile.getRoleSessionName(); RoleInfo roleInfo = new RoleInfo().withRoleArn(this.profile.getRoleArn()) .withRoleSessionName(roleSessionName) .withExternalId(this.profile.getRoleExternalId()) .withLongLivedCredentials(sourceCredentials); return profileCredentialsService.getAssumeRoleCredentialsProvider(roleInfo); } }