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 df556be
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import org.wso2.carbon.identity.application.common.model.ServiceProvider;
import org.wso2.carbon.identity.application.common.model.script.AuthenticationScriptConfig;
import org.wso2.carbon.identity.application.mgt.ApplicationConstants;
import org.wso2.carbon.identity.base.AuthenticatorPropertiesConstant.DefinedByType;
import org.wso2.carbon.identity.base.AuthenticatorPropertyConstants.DefinedByType;

import java.util.ArrayList;
import java.util.Collections;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
import org.wso2.carbon.identity.application.common.model.IdentityProvider;
import org.wso2.carbon.identity.application.common.model.LocalAuthenticatorConfig;
import org.wso2.carbon.identity.application.common.model.RequestPathAuthenticatorConfig;
import org.wso2.carbon.identity.base.AuthenticatorPropertiesConstant.DefinedByType;
import org.wso2.carbon.identity.base.AuthenticatorPropertyConstants.DefinedByType;
import org.wso2.carbon.identity.base.IdentityException;
import org.wso2.carbon.identity.core.model.ExpressionNode;
import org.wso2.carbon.identity.core.model.FilterTreeBuilder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
import org.wso2.carbon.identity.application.common.model.RoleMapping;
import org.wso2.carbon.identity.application.common.model.SubProperty;
import org.wso2.carbon.identity.application.common.util.IdentityApplicationConstants;
import org.wso2.carbon.identity.base.AuthenticatorPropertiesConstant.DefinedByType;
import org.wso2.carbon.identity.base.AuthenticatorPropertyConstants.DefinedByType;
import org.wso2.carbon.identity.claim.metadata.mgt.exception.ClaimMetadataException;
import org.wso2.carbon.identity.claim.metadata.mgt.model.LocalClaim;
import org.wso2.carbon.identity.configuration.mgt.core.model.ResourceSearchBean;
Expand Down 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 df556be

Please sign in to comment.