Skip to content

Commit

Permalink
Fix 16482
Browse files Browse the repository at this point in the history
  • Loading branch information
Hasanthi Dissanayake committed Aug 31, 2023
1 parent 690f16d commit a1b11b6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public class ServiceProviderToApiModel implements Function<ServiceProvider, Appl
private static final Set<String> systemApplications = ApplicationManagementServiceHolder
.getApplicationManagementService().getSystemApplications();
private static final String IS_FRAGMENT_APP = "isFragmentApp";
private static final String useUserIdForDefaultSubject = "useUserIdForDefaultSubject";

@Override
public ApplicationResponseModel apply(ServiceProvider application) {
Expand Down Expand Up @@ -283,9 +284,7 @@ private SubjectConfig buildSubjectClaimConfig(ServiceProvider application) {
subjectConfig.includeUserDomain(localAndOutboundAuthConfig.isUseUserstoreDomainInLocalSubjectIdentifier());

if (StringUtils.isBlank(localAndOutboundAuthConfig.getSubjectClaimUri())) {
if (isLocalClaimDialectUsedBySp(application)) {
subjectConfig.claim(buildClaimModel(FrameworkConstants.USERNAME_CLAIM));
}
assignClaimForSubjectValue(application, subjectConfig);
} else {
subjectConfig.claim(buildClaimModel(localAndOutboundAuthConfig.getSubjectClaimUri()));
}
Expand All @@ -294,6 +293,26 @@ private SubjectConfig buildSubjectClaimConfig(ServiceProvider application) {
return subjectConfig;
}

private void assignClaimForSubjectValue(ServiceProvider application, SubjectConfig subjectConfig) {
if (isLocalClaimDialectUsedBySp(application)) {
if (isUserIdUsedAsDefaultSubject(application.getSpProperties())) {
subjectConfig.claim(buildClaimModel(FrameworkConstants.USER_ID_CLAIM));
} else {
subjectConfig.claim(buildClaimModel(FrameworkConstants.USERNAME_CLAIM));
}
}
}

private boolean isUserIdUsedAsDefaultSubject (ServiceProviderProperty[] spProperties) {

for (ServiceProviderProperty spProperty : spProperties) {
if (useUserIdForDefaultSubject.equals(spProperty.getName())) {
return true;
}
}
return false;
}

private ClaimConfiguration.DialectEnum getDialect(ServiceProvider application) {

if (isLocalClaimDialectUsedBySp(application)) {
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@
<maven.buildnumber.plugin.version>1.4</maven.buildnumber.plugin.version>
<org.apache.felix.annotations.version>1.2.4</org.apache.felix.annotations.version>
<identity.governance.version>1.8.57</identity.governance.version>
<carbon.identity.framework.version>5.25.198</carbon.identity.framework.version>
<carbon.identity.framework.version>5.25.302</carbon.identity.framework.version>
<maven.findbugsplugin.version>3.0.5</maven.findbugsplugin.version>
<identity.workflow.impl.bps.version>5.2.0</identity.workflow.impl.bps.version>
<maven.checkstyleplugin.excludes>**/gen/**/*</maven.checkstyleplugin.excludes>
Expand Down

0 comments on commit a1b11b6

Please sign in to comment.