@@ -57,6 +57,8 @@ public final class ProfileCredentialsUtils {
5757 "software.amazon.awssdk.services.sts.internal.StsProfileCredentialsProviderFactory" ;
5858 private static final String SSO_PROFILE_CREDENTIALS_PROVIDER_FACTORY =
5959 "software.amazon.awssdk.services.sso.auth.SsoProfileCredentialsProviderFactory" ;
60+ private static final String LOGIN_PROFILE_CREDENTIALS_PROVIDER_FACTORY =
61+ "software.amazon.awssdk.services.signin.auth.LoginProfileCredentialsProviderFactory" ;
6062
6163 /**
6264 * The profile file containing {@code profile}.
@@ -144,6 +146,10 @@ private Optional<CredentialsWithFeatureId> credentialsProviderWithFeatureID(Set<
144146 }
145147 }
146148
149+ if (properties .containsKey (ProfileProperty .LOGIN_SESSION )) {
150+ return Optional .of (loginProfileCredentialsProvider ());
151+ }
152+
147153 if (properties .containsKey (ProfileProperty .CREDENTIAL_PROCESS )) {
148154 return Optional .of (credentialProcessCredentialsProvider ());
149155 }
@@ -243,6 +249,20 @@ private boolean isLegacySsoConfiguration() {
243249 return !properties .containsKey (ProfileSection .SSO_SESSION .getPropertyKeyName ());
244250 }
245251
252+ /**
253+ * Create the SSO credentials provider based on the related profile properties.
254+ */
255+ private CredentialsWithFeatureId loginProfileCredentialsProvider () {
256+ AwsCredentialsProvider provider = loginCredentialsProviderFactory ().create (
257+ ProfileProviderCredentialsContext .builder ()
258+ .profile (profile )
259+ .profileFile (profileFile )
260+ .sourceChain (BusinessMetricFeatureId .CREDENTIALS_PROFILE_LOGIN .value ())
261+ .build ());
262+
263+ return new CredentialsWithFeatureId (provider , BusinessMetricFeatureId .CREDENTIALS_PROFILE_LOGIN .value ());
264+ }
265+
246266 private CredentialsWithFeatureId roleAndWebIdentityTokenProfileCredentialsProvider () {
247267 requireProperties (ProfileProperty .ROLE_ARN , ProfileProperty .WEB_IDENTITY_TOKEN_FILE );
248268
@@ -418,4 +438,17 @@ private ProfileCredentialsProviderFactory ssoCredentialsProviderFactory() {
418438 throw new IllegalStateException ("Failed to create the '" + name + "' profile credentials provider." , e );
419439 }
420440 }
441+
442+ private ProfileCredentialsProviderFactory loginCredentialsProviderFactory () {
443+ try {
444+ Class <?> loginProfileCredentialsProviderFactory =
445+ ClassLoaderHelper .loadClass (LOGIN_PROFILE_CREDENTIALS_PROVIDER_FACTORY , getClass ());
446+ return (ProfileCredentialsProviderFactory ) loginProfileCredentialsProviderFactory .getConstructor ().newInstance ();
447+ } catch (ClassNotFoundException e ) {
448+ throw new IllegalStateException ("To use login_session property in the '" + name + "' profile, the 'signin' service "
449+ + "module must be on the class path." , e );
450+ } catch (NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e ) {
451+ throw new IllegalStateException ("Failed to create the '" + name + "' profile credentials provider." , e );
452+ }
453+ }
421454}
0 commit comments