Skip to content

Commit

Permalink
Addressed comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Thisara-Welmilla committed Oct 7, 2024
1 parent d356fae commit afdfbae
Showing 1 changed file with 14 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1772,16 +1772,7 @@ private void updateFederatedAuthenticatorConfig(IdentityProvider idp, FederatedA
authConfig.setName(base64URLDecode(authenticator.getAuthenticatorId()));
authConfig.setDisplayName(getDisplayNameOfAuthenticator(authConfig.getName()));
authConfig.setEnabled(authenticator.getIsEnabled());
/* Resolve definedBy type: If there is authenticator by same name and its type is system: SYSTEM.
If not: USER. */
FederatedAuthenticatorConfig authenticatorConfig = ApplicationAuthenticatorService.getInstance()
.getFederatedAuthenticatorByName(authenticator.getAuthenticatorId());
if (authenticatorConfig != null &&
DefinedByType.SYSTEM.equals(authenticatorConfig.getDefinedByType())) {
authConfig.setDefinedByType(DefinedByType.SYSTEM);
} else {
authConfig.setDefinedByType(DefinedByType.USER);
}
authConfig.setDefinedByType(resolveDefinedByType(authenticator.getAuthenticatorId()));
List<org.wso2.carbon.identity.api.server.idp.v1.model.Property> authProperties =
authenticator.getProperties();
if (IdentityApplicationConstants.Authenticator.SAML2SSO.FED_AUTH_NAME.equals(authConfig.getName())) {
Expand Down Expand Up @@ -2851,15 +2842,7 @@ private FederatedAuthenticatorConfig createFederatedAuthenticatorConfig(String f
authConfig.setName(authenticatorName);
authConfig.setDisplayName(getDisplayNameOfAuthenticator(authenticatorName));
authConfig.setEnabled(authenticator.getIsEnabled());
// Resolve definedBy type: If there is authenticator by same name and its type is system: SYSTEM. If not: USER.
FederatedAuthenticatorConfig authenticatorConfig = ApplicationAuthenticatorService.getInstance()
.getFederatedAuthenticatorByName(authenticatorName);
if (authenticatorConfig != null &&
DefinedByType.SYSTEM.equals(authenticatorConfig.getDefinedByType())) {
authConfig.setDefinedByType(DefinedByType.SYSTEM);
} else {
authConfig.setDefinedByType(DefinedByType.USER);
}
authConfig.setDefinedByType(resolveDefinedByType(authenticatorName));
List<org.wso2.carbon.identity.api.server.idp.v1.model.Property> authProperties = authenticator.getProperties();
if (IdentityApplicationConstants.Authenticator.SAML2SSO.FED_AUTH_NAME.equals(authenticatorName)) {
validateSamlMetadata(authProperties);
Expand All @@ -2873,6 +2856,18 @@ private FederatedAuthenticatorConfig createFederatedAuthenticatorConfig(String f
return authConfig;
}

private DefinedByType resolveDefinedByType(String authenticatorName) {

// Resolve definedBy type: If there is authenticator by same name and its type is system: SYSTEM. If not: USER.
FederatedAuthenticatorConfig authenticatorConfig = ApplicationAuthenticatorService.getInstance()
.getFederatedAuthenticatorByName(authenticatorName);
if (authenticatorConfig != null &&
DefinedByType.SYSTEM.equals(authenticatorConfig.getDefinedByType())) {
return DefinedByType.SYSTEM;
}
return DefinedByType.USER;
}

/**
* Verify if scopes have not been set in both Scopes field and Additional Query Parameters field
*
Expand Down

0 comments on commit afdfbae

Please sign in to comment.