@Test(expected = SdkClientException.class) public void testLocatesProfileNameUsingAwsProfileNameLoaderWhenNull_ProfileNotExists() { try { System.setProperty(AWS_PROFILE_SYSTEM_PROPERTY, "my_other_profile"); ProfileCsmConfigurationProvider provider = new ProfileCsmConfigurationProvider(null, makeConfigLocationProvider(COMPLETE_CONFIG)); provider.getConfiguration(); } finally { System.clearProperty(AWS_PROFILE_SYSTEM_PROPERTY); } }
@Override public CsmConfiguration getConfiguration() { String profileName = getProfileName(); BasicProfile profile = getProfile(profileName); if (profile == null) { throw new SdkClientException(String.format("Could not find the '%s' profile!", profileName)); } String enabled = profile.getPropertyValue(CSM_ENABLED_PROPERTY); if (enabled == null) { throw new SdkClientException(String.format("The '%s' profile does not define all the" + " required properties!", profileName)); } String host = profile.getPropertyValue(CSM_HOST_PROPERTY); host = host == null ? DEFAULT_AWS_CSM_HOST : host; String port = profile.getPropertyValue(CSM_PORT_PROPERTY); String clientId = profile.getPropertyValue(CSM_CLIENT_ID_PROPERTY); clientId = clientId == null ? DEFAULT_AWS_CSM_CLIENT_ID : clientId; try { int portNumber = port == null ? DEFAULT_AWS_CSM_PORT : Integer.parseInt(port); return CsmConfiguration.builder() .withEnabled(Boolean.parseBoolean(enabled)) .withHost(host) .withPort(portNumber) .withClientId(clientId) .build(); } catch (Exception e) { throw new SdkClientException(String.format("Unable to load configuration from the '%s'" + " profile!", profileName), e); } }
ProfileCsmConfigurationProvider implements CsmConfigurationProvider { @Override public CsmConfiguration getConfiguration() { String profileName = getProfileName(); BasicProfile profile = getProfile(profileName); if (profile == null) { throw new SdkClientException(String.format("Could not find the '%s' profile!", profileName)); } String enabled = profile.getPropertyValue(CSM_ENABLED_PROPERTY); if (enabled == null) { throw new SdkClientException(String.format("The '%s' profile does not define all the" + " required properties!", profileName)); } String host = profile.getPropertyValue(CSM_HOST_PROPERTY); host = host == null ? DEFAULT_AWS_CSM_HOST : host; String port = profile.getPropertyValue(CSM_PORT_PROPERTY); String clientId = profile.getPropertyValue(CSM_CLIENT_ID_PROPERTY); clientId = clientId == null ? DEFAULT_AWS_CSM_CLIENT_ID : clientId; try { int portNumber = port == null ? DEFAULT_AWS_CSM_PORT : Integer.parseInt(port); return CsmConfiguration.builder() .withEnabled(Boolean.parseBoolean(enabled)) .withHost(host) .withPort(portNumber) .withClientId(clientId) .build(); } catch (Exception e) { throw new SdkClientException(String.format("Unable to load configuration from the '%s'" + " profile!", profileName), e); } } }
ProfileCsmConfigurationProvider implements CsmConfigurationProvider { @Override public CsmConfiguration getConfiguration() { String profileName = getProfileName(); BasicProfile profile = getProfile(profileName); if (profile == null) { throw new SdkClientException(String.format("Could not find the '%s' profile!", profileName)); } String enabled = profile.getPropertyValue(CSM_ENABLED_PROPERTY); if (enabled == null) { throw new SdkClientException(String.format("The '%s' profile does not define all the" + " required properties!", profileName)); } String host = profile.getPropertyValue(CSM_HOST_PROPERTY); host = host == null ? DEFAULT_AWS_CSM_HOST : host; String port = profile.getPropertyValue(CSM_PORT_PROPERTY); String clientId = profile.getPropertyValue(CSM_CLIENT_ID_PROPERTY); clientId = clientId == null ? DEFAULT_AWS_CSM_CLIENT_ID : clientId; try { int portNumber = port == null ? DEFAULT_AWS_CSM_PORT : Integer.parseInt(port); return CsmConfiguration.builder() .withEnabled(Boolean.parseBoolean(enabled)) .withHost(host) .withPort(portNumber) .withClientId(clientId) .build(); } catch (Exception e) { throw new SdkClientException(String.format("Unable to load configuration from the '%s'" + " profile!", profileName), e); } } ProfileCsmConfigurationProvider();  ProfileCsmConfigurationProvider(String profileName);  ProfileCsmConfigurationProvider(String profileName,
            AwsProfileFileLocationProvider configFileLocationProvider); }
ProfileCsmConfigurationProvider implements CsmConfigurationProvider { @Override public CsmConfiguration getConfiguration() { String profileName = getProfileName(); BasicProfile profile = getProfile(profileName); if (profile == null) { throw new SdkClientException(String.format("Could not find the '%s' profile!", profileName)); } String enabled = profile.getPropertyValue(CSM_ENABLED_PROPERTY); if (enabled == null) { throw new SdkClientException(String.format("The '%s' profile does not define all the" + " required properties!", profileName)); } String host = profile.getPropertyValue(CSM_HOST_PROPERTY); host = host == null ? DEFAULT_AWS_CSM_HOST : host; String port = profile.getPropertyValue(CSM_PORT_PROPERTY); String clientId = profile.getPropertyValue(CSM_CLIENT_ID_PROPERTY); clientId = clientId == null ? DEFAULT_AWS_CSM_CLIENT_ID : clientId; try { int portNumber = port == null ? DEFAULT_AWS_CSM_PORT : Integer.parseInt(port); return CsmConfiguration.builder() .withEnabled(Boolean.parseBoolean(enabled)) .withHost(host) .withPort(portNumber) .withClientId(clientId) .build(); } catch (Exception e) { throw new SdkClientException(String.format("Unable to load configuration from the '%s'" + " profile!", profileName), e); } } ProfileCsmConfigurationProvider();  ProfileCsmConfigurationProvider(String profileName);  ProfileCsmConfigurationProvider(String profileName,
            AwsProfileFileLocationProvider configFileLocationProvider); @Override CsmConfiguration getConfiguration(); }
ProfileCsmConfigurationProvider implements CsmConfigurationProvider { @Override public CsmConfiguration getConfiguration() { String profileName = getProfileName(); BasicProfile profile = getProfile(profileName); if (profile == null) { throw new SdkClientException(String.format("Could not find the '%s' profile!", profileName)); } String enabled = profile.getPropertyValue(CSM_ENABLED_PROPERTY); if (enabled == null) { throw new SdkClientException(String.format("The '%s' profile does not define all the" + " required properties!", profileName)); } String host = profile.getPropertyValue(CSM_HOST_PROPERTY); host = host == null ? DEFAULT_AWS_CSM_HOST : host; String port = profile.getPropertyValue(CSM_PORT_PROPERTY); String clientId = profile.getPropertyValue(CSM_CLIENT_ID_PROPERTY); clientId = clientId == null ? DEFAULT_AWS_CSM_CLIENT_ID : clientId; try { int portNumber = port == null ? DEFAULT_AWS_CSM_PORT : Integer.parseInt(port); return CsmConfiguration.builder() .withEnabled(Boolean.parseBoolean(enabled)) .withHost(host) .withPort(portNumber) .withClientId(clientId) .build(); } catch (Exception e) { throw new SdkClientException(String.format("Unable to load configuration from the '%s'" + " profile!", profileName), e); } } ProfileCsmConfigurationProvider();  ProfileCsmConfigurationProvider(String profileName);  ProfileCsmConfigurationProvider(String profileName,
            AwsProfileFileLocationProvider configFileLocationProvider); @Override CsmConfiguration getConfiguration(); static final String CSM_ENABLED_PROPERTY; static final String CSM_HOST_PROPERTY; static final String CSM_PORT_PROPERTY; static final String CSM_CLIENT_ID_PROPERTY; }