Skip to content

Commit

Permalink
Merge pull request #479 from DMHP/master
Browse files Browse the repository at this point in the history
Fix 16482
  • Loading branch information
DMHP authored Sep 1, 2023
2 parents 82a0525 + e381bed commit 84dbc8c
Showing 1 changed file with 23 additions and 3 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,27 @@ 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

0 comments on commit 84dbc8c

Please sign in to comment.