Skip to content

Commit

Permalink
sonar
Browse files Browse the repository at this point in the history
Change-Id: Ib40f1152fe3c2682e6019d6869764ba7b603b750
  • Loading branch information
mikeroda committed Sep 28, 2024
1 parent acae8b0 commit d36fa59
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package org.cloudfoundry.identity.uaa.provider.oauth;

import org.cloudfoundry.identity.uaa.authentication.UaaAuthentication;
import org.cloudfoundry.identity.uaa.authentication.UaaAuthenticationDetails;
import org.cloudfoundry.identity.uaa.authentication.UaaLoginHint;
import org.cloudfoundry.identity.uaa.authentication.UaaPrincipal;
import org.cloudfoundry.identity.uaa.constants.OriginKeys;
import org.cloudfoundry.identity.uaa.provider.AbstractExternalOAuthIdentityProviderDefinition;
Expand Down Expand Up @@ -72,11 +70,9 @@ public String constructOAuthProviderLogoutUrl(final HttpServletRequest request,
sb.append("&client_id=");
sb.append(oauthConfig.getRelyingPartyId());

if (authentication instanceof UaaAuthentication uaaAuthentication) {
if (uaaAuthentication.getIdpIdToken() != null) {
sb.append("&id_token_hint=");
sb.append(uaaAuthentication.getIdpIdToken());
}
if (authentication instanceof UaaAuthentication uaaAuthentication && uaaAuthentication.getIdpIdToken() != null) {
sb.append("&id_token_hint=");
sb.append(uaaAuthentication.getIdpIdToken());
}
return sb.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.nimbusds.jose.JOSEException;
import com.nimbusds.jose.JWSAlgorithm;
import com.nimbusds.jose.JWSSigner;

import org.cloudfoundry.identity.uaa.authentication.UaaAuthentication;
import org.cloudfoundry.identity.uaa.authentication.UaaPrincipal;
import org.cloudfoundry.identity.uaa.cache.StaleUrlCache;
Expand All @@ -17,7 +16,6 @@
import org.cloudfoundry.identity.uaa.provider.IdentityProvider;
import org.cloudfoundry.identity.uaa.provider.IdentityProviderProvisioning;
import org.cloudfoundry.identity.uaa.provider.OIDCIdentityProviderDefinition;
import org.cloudfoundry.identity.uaa.provider.oauth.ExternalOAuthAuthenticationManager.AuthenticationData;
import org.cloudfoundry.identity.uaa.scim.jdbc.JdbcScimGroupExternalMembershipManager;
import org.cloudfoundry.identity.uaa.user.UaaUser;
import org.cloudfoundry.identity.uaa.util.TimeServiceImpl;
Expand Down Expand Up @@ -460,15 +458,10 @@ public void populateAuthenticationAttributes_setsIdpIdToken() {
entry(EXPIRY_IN_SECONDS, ((int) (System.currentTimeMillis()/1000L)) + 60),
entry(SUB, "abc-def-asdf")
);
Map<String, Object> externalGroupMapping = map(
entry(FAMILY_NAME_ATTRIBUTE_NAME, "external_family_name")
);
oidcConfig.setAttributeMappings(externalGroupMapping);
provider.setConfig(oidcConfig);
IdentityZoneHolder.get().getConfig().getTokenPolicy().setKeys(Collections.singletonMap("uaa-key", uaaIdentityZoneTokenSigningKey));
String idTokenJwt = UaaTokenUtils.constructToken(header, claims, signer);
ExternalOAuthCodeToken oidcAuthentication = new ExternalOAuthCodeToken(null, origin, "http://google.com", idTokenJwt, "accesstoken", "signedrequest");
AuthenticationData authenticationData = authManager.getExternalAuthenticationDetails(oidcAuthentication);
ExternalOAuthAuthenticationManager.AuthenticationData authenticationData = authManager.getExternalAuthenticationDetails(oidcAuthentication);
authManager.populateAuthenticationAttributes(authentication, oidcAuthentication, authenticationData);
assertEquals(idTokenJwt, authentication.getIdpIdToken());
}
Expand All @@ -490,9 +483,6 @@ public void getClaimsFromToken_setsIdToken() {
entry(EXPIRY_IN_SECONDS, ((int) (System.currentTimeMillis()/1000L)) + 60),
entry(SUB, "abc-def-asdf")
);
Map<String, Object> externalGroupMapping = map(
entry(FAMILY_NAME_ATTRIBUTE_NAME, "external_family_name")
);
String idTokenJwt = UaaTokenUtils.constructToken(header, claims, signer);
ExternalOAuthCodeToken codeToken = new ExternalOAuthCodeToken("thecode", origin, "http://google.com", null, "accesstoken", "signedrequest");

Expand All @@ -502,7 +492,6 @@ protected String getTokenFromCode(ExternalOAuthCodeToken codeToken, AbstractExte
return idTokenJwt;
}
};

authManager.getClaimsFromToken(codeToken, oidcConfig);
assertEquals(idTokenJwt, codeToken.getIdToken());
}
Expand Down

0 comments on commit d36fa59

Please sign in to comment.