Skip to content

Commit

Permalink
Add new DefinedBy property to authenticator config.
Browse files Browse the repository at this point in the history
  • Loading branch information
Thisara-Welmilla committed Sep 17, 2024
1 parent 8ddc6a3 commit 9fc695e
Show file tree
Hide file tree
Showing 15 changed files with 151 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

package org.wso2.carbon.identity.application.common;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.identity.application.common.model.FederatedAuthenticatorConfig;
import org.wso2.carbon.identity.application.common.model.LocalAuthenticatorConfig;
import org.wso2.carbon.identity.application.common.model.RequestPathAuthenticatorConfig;
Expand All @@ -31,6 +33,7 @@
public class ApplicationAuthenticatorService {

private static volatile ApplicationAuthenticatorService instance;
private static final Log LOG = LogFactory.getLog(ApplicationAuthenticatorService.class);

Check warning on line 36 in components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/ApplicationAuthenticatorService.java

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/ApplicationAuthenticatorService.java#L36

Added line #L36 was not covered by tests

private List<LocalAuthenticatorConfig> localAuthenticators = new ArrayList<>();
private List<FederatedAuthenticatorConfig> federatedAuthenticators = new ArrayList<>();
Expand Down Expand Up @@ -88,6 +91,9 @@ public RequestPathAuthenticatorConfig getRequestPathAuthenticatorByName(String n

public void addLocalAuthenticator(LocalAuthenticatorConfig authenticator) {
if (authenticator != null) {
if (authenticator.getDefinedByType() == null) {
LOG.warn("The defined by type is not set for the : " + authenticator.getName());

Check warning on line 95 in components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/ApplicationAuthenticatorService.java

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/ApplicationAuthenticatorService.java#L95

Added line #L95 was not covered by tests
}
localAuthenticators.add(authenticator);
}
}
Expand All @@ -100,6 +106,9 @@ public void removeLocalAuthenticator(LocalAuthenticatorConfig authenticator) {

public void addFederatedAuthenticator(FederatedAuthenticatorConfig authenticator) {
if (authenticator != null) {
if (authenticator.getDefinedByType() == null) {
LOG.warn("The defined by type is not set for the : " + authenticator.getName());

Check warning on line 110 in components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/ApplicationAuthenticatorService.java

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/ApplicationAuthenticatorService.java#L110

Added line #L110 was not covered by tests
}
federatedAuthenticators.add(authenticator);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
import org.apache.axiom.om.OMElement;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.wso2.carbon.identity.base.IdentityConstants;

import java.io.Serializable;
import java.util.ArrayList;
Expand All @@ -46,6 +49,7 @@
public class FederatedAuthenticatorConfig implements Serializable {

private static final long serialVersionUID = -2361107623257323257L;
private static final Logger LOG = LoggerFactory.getLogger(LocalAuthenticatorConfig.class);

Check warning on line 52 in components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/FederatedAuthenticatorConfig.java

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/FederatedAuthenticatorConfig.java#L52

Added line #L52 was not covered by tests

@XmlElement(name = "Name")
protected String name;
Expand All @@ -63,6 +67,9 @@ public class FederatedAuthenticatorConfig implements Serializable {
@XmlElement(name = "Tags")
protected String[] tags;

@XmlElement(name = "DefinedBy")
protected IdentityConstants.DefinedByType definedByType;

public static FederatedAuthenticatorConfig build(OMElement federatedAuthenticatorConfigOM) {

if (federatedAuthenticatorConfigOM == null) {
Expand Down Expand Up @@ -101,9 +108,15 @@ public static FederatedAuthenticatorConfig build(OMElement federatedAuthenticato
Property[] propertiesArr = propertiesArrList.toArray(new Property[propertiesArrList.size()]);
federatedAuthenticatorConfig.setProperties(propertiesArr);
}
} else if ("DefinedBy".equals(elementName)) {
federatedAuthenticatorConfig.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM);

Check warning on line 112 in components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/FederatedAuthenticatorConfig.java

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/FederatedAuthenticatorConfig.java#L112

Added line #L112 was not covered by tests
}
}

if (federatedAuthenticatorConfig.getDefinedByType() == null) {
LOG.warn("The defined by type is not set for the : " + federatedAuthenticatorConfig.getName());

Check warning on line 117 in components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/FederatedAuthenticatorConfig.java

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/FederatedAuthenticatorConfig.java#L117

Added line #L117 was not covered by tests
}

return federatedAuthenticatorConfig;
}

Expand Down Expand Up @@ -230,4 +243,24 @@ public void setTags(String[] tagList) {

tags = tagList;
}

/**
* Get the tag list of the Local authenticator.
*
* @return String[]
*/
public IdentityConstants.DefinedByType getDefinedByType() {

return definedByType;

Check warning on line 254 in components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/FederatedAuthenticatorConfig.java

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/FederatedAuthenticatorConfig.java#L254

Added line #L254 was not covered by tests
}

/**
* Set the tag list for Local authenticator config.
*
* @param type authenticator.
*/
public void setDefinedByType(IdentityConstants.DefinedByType type) {

definedByType = type;
}

Check warning on line 265 in components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/FederatedAuthenticatorConfig.java

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/FederatedAuthenticatorConfig.java#L264-L265

Added lines #L264 - L265 were not covered by tests
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
public class IdentityProvider implements Serializable {

private static final long serialVersionUID = 2199048941051702943L;
private static final Log LOG = LogFactory.getLog(IdentityProvider.class);

Check warning on line 61 in components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/IdentityProvider.java

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/IdentityProvider.java#L61

Added line #L61 was not covered by tests

private static final Log log = LogFactory.getLog(IdentityProvider.class);
private static final String FILE_ELEMENT_IDENTITY_PROVIDER_NAME = "IdentityProviderName";
Expand Down Expand Up @@ -419,6 +420,11 @@ public void setFederatedAuthenticatorConfigs(
if (federatedAuthenticatorConfigs == null) {
return;
}
for (FederatedAuthenticatorConfig config: federatedAuthenticatorConfigs) {
if (config.getDefinedByType() == null) {
LOG.warn("The defined by type is not set for the : " + config.getName());

Check warning on line 425 in components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/IdentityProvider.java

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/IdentityProvider.java#L425

Added line #L425 was not covered by tests
}
}
Set<FederatedAuthenticatorConfig> propertySet =
new HashSet<FederatedAuthenticatorConfig>(Arrays.asList(federatedAuthenticatorConfigs));
this.federatedAuthenticatorConfigs = propertySet.toArray(new FederatedAuthenticatorConfig[propertySet.size()]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import org.apache.axiom.om.OMElement;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.wso2.carbon.identity.base.IdentityConstants;

import java.io.Serializable;
Expand All @@ -46,6 +48,7 @@
public class LocalAuthenticatorConfig implements Serializable {

private static final long serialVersionUID = 3363298518257599291L;
private static final Logger LOG = LoggerFactory.getLogger(LocalAuthenticatorConfig.class);

Check warning on line 51 in components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/LocalAuthenticatorConfig.java

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/LocalAuthenticatorConfig.java#L51

Added line #L51 was not covered by tests

@XmlElement(name = "Name")
protected String name;
Expand All @@ -63,6 +66,9 @@ public class LocalAuthenticatorConfig implements Serializable {
@XmlElement(name = "Tags")
protected String[] tags;

@XmlElement(name = "DefinedBy")
protected IdentityConstants.DefinedByType definedByType;

/*
* <LocalAuthenticatorConfig> <Name></Name> <DisplayName></DisplayName> <IsEnabled></IsEnabled>
* <Properties></Properties> </LocalAuthenticatorConfig>
Expand Down Expand Up @@ -111,8 +117,13 @@ public static LocalAuthenticatorConfig build(OMElement localAuthenticatorConfigO
Property[] propertiesArr = propertiesArrList.toArray(new Property[0]);
localAuthenticatorConfig.setProperties(propertiesArr);
}
} else if ("DefinedBy".equals(member.getLocalName())) {
localAuthenticatorConfig.setDefinedByType(IdentityConstants.DefinedByType.valueOf(member.getText()));

Check warning on line 121 in components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/LocalAuthenticatorConfig.java

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/LocalAuthenticatorConfig.java#L121

Added line #L121 was not covered by tests
}
}
if (localAuthenticatorConfig.getDefinedByType() == null) {
LOG.warn("The defined by type is not set for the : " + localAuthenticatorConfig.getName());

Check warning on line 125 in components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/LocalAuthenticatorConfig.java

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/LocalAuthenticatorConfig.java#L125

Added line #L125 was not covered by tests
}
return localAuthenticatorConfig;
}

Expand Down Expand Up @@ -224,4 +235,24 @@ public void setTags(String[] tagList) {

tags = tagList;
}

/**
* Get the tag list of the Local authenticator.
*
* @return String[]
*/
public IdentityConstants.DefinedByType getDefinedByType() {

return definedByType;

Check warning on line 246 in components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/LocalAuthenticatorConfig.java

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/LocalAuthenticatorConfig.java#L246

Added line #L246 was not covered by tests
}

/**
* Set the tag list for Local authenticator config.
*
* @param type authenticator.
*/
public void setDefinedByType(IdentityConstants.DefinedByType type) {

definedByType = type;
}

Check warning on line 257 in components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/LocalAuthenticatorConfig.java

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/LocalAuthenticatorConfig.java#L256-L257

Added lines #L256 - L257 were not covered by tests
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
import org.wso2.carbon.identity.application.mgt.dao.PaginatableFilterableApplicationDAO;
import org.wso2.carbon.identity.application.mgt.internal.ApplicationManagementServiceComponent;
import org.wso2.carbon.identity.application.mgt.internal.ApplicationManagementServiceComponentHolder;
import org.wso2.carbon.identity.base.IdentityConstants;
import org.wso2.carbon.identity.base.IdentityException;
import org.wso2.carbon.identity.base.IdentityRuntimeException;
import org.wso2.carbon.identity.core.CertificateRetrievingException;
Expand Down Expand Up @@ -1566,6 +1567,15 @@ private void updateLocalAndOutboundAuthenticationConfiguration(int applicationId
ApplicationConstants.LOCAL_IDP_NAME,
lclAuthenticator.getName(),
lclAuthenticator.getDisplayName());
} else {
if (lclAuthenticator.getDefinedByType() == null) {
log.warn("Authenticator already exists. Updating the authenticator, but the " +

Check warning on line 1572 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L1572

Added line #L1572 was not covered by tests
"defined by type is not set.");
} else {
log.debug("Authenticator already exists. Updating the authenticator.The defined "
+ "by type is set to: " + lclAuthenticator.getDefinedByType().toString());

Check warning on line 1576 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L1575-L1576

Added lines #L1575 - L1576 were not covered by tests
//TODO: Update database with defined by properties for local authenticators.
}
}
if (authenticatorId > 0) {
// ID, TENANT_ID, AUTHENTICATOR_ID
Expand Down Expand Up @@ -3088,6 +3098,7 @@ private LocalAndOutboundAuthenticationConfig getLocalAndOutboundAuthenticationCo
.get(ApplicationConstants.IDP_AUTHENTICATOR_NAME));
localAuthenticator.setDisplayName(authenticatorInfo
.get(ApplicationConstants.IDP_AUTHENTICATOR_DISPLAY_NAME));
localAuthenticator.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM);

Check warning on line 3101 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L3101

Added line #L3101 was not covered by tests
stepLocalAuth.get(step).add(localAuthenticator);
} else {
Map<String, List<FederatedAuthenticatorConfig>> stepFedIdps = stepFedIdPAuthenticators
Expand All @@ -3106,6 +3117,7 @@ private LocalAndOutboundAuthenticationConfig getLocalAndOutboundAuthenticationCo
.get(ApplicationConstants.IDP_AUTHENTICATOR_NAME));
fedAuthenticator.setDisplayName(authenticatorInfo
.get(ApplicationConstants.IDP_AUTHENTICATOR_DISPLAY_NAME));
fedAuthenticator.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM);
idpAuths.add(fedAuthenticator);
}

Expand Down Expand Up @@ -5038,7 +5050,7 @@ private int addAuthenticator(Connection conn, int tenantId, String idpName,
int authenticatorId = -1;
PreparedStatement prepStmt = null;
ResultSet rs = null;
// TENANT_ID, IDP_ID, NAME,IS_ENABLED, DISPLAY_NAME
// TENANT_ID, IDP_ID, NAME,IS_ENABLED, DISPLAY_NAME, DEFINED_BY
String sqlStmt = ApplicationMgtDBQueries.STORE_LOCAL_AUTHENTICATOR;
try {
String dbProductName = conn.getMetaData().getDatabaseProductName();
Expand All @@ -5050,6 +5062,7 @@ private int addAuthenticator(Connection conn, int tenantId, String idpName,
prepStmt.setString(4, authenticatorName);
prepStmt.setString(5, "1");
prepStmt.setString(6, authenticatorDispalyName);
//TODO: prepStmt.setString(7, IdentityConstants.DefinedByType.SYSTEM.toString());
prepStmt.execute();
rs = prepStmt.getGeneratedKeys();
if (rs.next()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.wso2.carbon.identity.application.authentication.framework.exception.LogoutFailedException;
import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatorData;
import org.wso2.carbon.identity.application.common.model.Property;
import org.wso2.carbon.identity.base.IdentityConstants;

import java.io.Serializable;
import java.util.List;
Expand Down Expand Up @@ -171,4 +172,13 @@ default String getI18nKey() {
return StringUtils.EMPTY;
}

/**
* Get the authenticator type. Default value will be SYSTEM.
*
* @return Authenticator Type.
*/
default IdentityConstants.DefinedByType getDefinedByType() {

return IdentityConstants.DefinedByType.SYSTEM;

Check warning on line 182 in components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/ApplicationAuthenticator.java

View check run for this annotation

Codecov / codecov/patch

components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/ApplicationAuthenticator.java#L182

Added line #L182 was not covered by tests
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
import org.wso2.carbon.identity.application.common.model.Property;
import org.wso2.carbon.identity.application.common.model.RequestPathAuthenticatorConfig;
import org.wso2.carbon.identity.application.mgt.ApplicationManagementService;
import org.wso2.carbon.identity.base.IdentityConstants;
import org.wso2.carbon.identity.claim.metadata.mgt.ClaimMetadataManagementService;
import org.wso2.carbon.identity.configuration.mgt.core.ConfigurationManager;
import org.wso2.carbon.identity.core.handler.HandlerComparator;
Expand Down Expand Up @@ -506,6 +507,7 @@ protected void setAuthenticator(ApplicationAuthenticator authenticator) {
localAuthenticatorConfig.setProperties(configProperties);
localAuthenticatorConfig.setDisplayName(authenticator.getFriendlyName());
localAuthenticatorConfig.setTags(getTags(authenticator));
localAuthenticatorConfig.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM);

Check warning on line 510 in components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/internal/FrameworkServiceComponent.java

View check run for this annotation

Codecov / codecov/patch

components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/internal/FrameworkServiceComponent.java#L510

Added line #L510 was not covered by tests
AuthenticatorConfig fileBasedConfig = getAuthenticatorConfig(authenticator.getName());
localAuthenticatorConfig.setEnabled(fileBasedConfig.isEnabled());
ApplicationAuthenticatorService.getInstance().addLocalAuthenticator(localAuthenticatorConfig);
Expand All @@ -515,6 +517,7 @@ protected void setAuthenticator(ApplicationAuthenticator authenticator) {
federatedAuthenticatorConfig.setProperties(configProperties);
federatedAuthenticatorConfig.setDisplayName(authenticator.getFriendlyName());
federatedAuthenticatorConfig.setTags(getTags(authenticator));
federatedAuthenticatorConfig.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM);

Check warning on line 520 in components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/internal/FrameworkServiceComponent.java

View check run for this annotation

Codecov / codecov/patch

components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/internal/FrameworkServiceComponent.java#L520

Added line #L520 was not covered by tests
ApplicationAuthenticatorService.getInstance().addFederatedAuthenticator(federatedAuthenticatorConfig);
} else if (authenticator instanceof RequestPathApplicationAuthenticator) {
RequestPathAuthenticatorConfig reqPathAuthenticatorConfig = new RequestPathAuthenticatorConfig();
Expand All @@ -524,6 +527,7 @@ protected void setAuthenticator(ApplicationAuthenticator authenticator) {
reqPathAuthenticatorConfig.setTags(getTags(authenticator));
AuthenticatorConfig fileBasedConfig = getAuthenticatorConfig(authenticator.getName());
reqPathAuthenticatorConfig.setEnabled(fileBasedConfig.isEnabled());
reqPathAuthenticatorConfig.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM);

Check warning on line 530 in components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/internal/FrameworkServiceComponent.java

View check run for this annotation

Codecov / codecov/patch

components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/internal/FrameworkServiceComponent.java#L530

Added line #L530 was not covered by tests
ApplicationAuthenticatorService.getInstance().addRequestPathAuthenticator(reqPathAuthenticatorConfig);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -619,4 +619,13 @@ public static class APIResponse {

public static final String SET_ACCOUNT_LOCK_AUTH_FAILURE_REASON = "APIResponse.SetAccountLockAuthFailureReason";
}

/**
* The Authentication Type - SYSTEM: system define authenticator, CUSTOM: user defined authentication extension.
*/
public enum DefinedByType {

SYSTEM,
USER
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ public void addResidentIdP(IdentityProvider identityProvider, String tenantDomai
if (saml2SSOResidentAuthenticatorConfig == null) {
saml2SSOResidentAuthenticatorConfig = new FederatedAuthenticatorConfig();
saml2SSOResidentAuthenticatorConfig.setName(IdentityApplicationConstants.Authenticator.SAML2SSO.NAME);
saml2SSOResidentAuthenticatorConfig.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM);

Check warning on line 174 in components/idp-mgt/org.wso2.carbon.idp.mgt/src/main/java/org/wso2/carbon/idp/mgt/IdentityProviderManager.java

View check run for this annotation

Codecov / codecov/patch

components/idp-mgt/org.wso2.carbon.idp.mgt/src/main/java/org/wso2/carbon/idp/mgt/IdentityProviderManager.java#L174

Added line #L174 was not covered by tests
}
if (saml2SSOResidentAuthenticatorConfig.getProperties() == null) {
saml2SSOResidentAuthenticatorConfig.setProperties(new Property[0]);
Expand Down Expand Up @@ -255,6 +256,7 @@ public void addResidentIdP(IdentityProvider identityProvider, String tenantDomai
FederatedAuthenticatorConfig oidcAuthenticationConfig = new FederatedAuthenticatorConfig();
oidcAuthenticationConfig.setProperties(new Property[]{oidcProperty});
oidcAuthenticationConfig.setName(IdentityApplicationConstants.Authenticator.OIDC.NAME);
oidcAuthenticationConfig.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM);

Check warning on line 259 in components/idp-mgt/org.wso2.carbon.idp.mgt/src/main/java/org/wso2/carbon/idp/mgt/IdentityProviderManager.java

View check run for this annotation

Codecov / codecov/patch

components/idp-mgt/org.wso2.carbon.idp.mgt/src/main/java/org/wso2/carbon/idp/mgt/IdentityProviderManager.java#L259

Added line #L259 was not covered by tests

Property passiveStsProperty = new Property();
passiveStsProperty.setName(IdentityApplicationConstants.Authenticator.PassiveSTS.IDENTITY_PROVIDER_ENTITY_ID);
Expand All @@ -263,6 +265,7 @@ public void addResidentIdP(IdentityProvider identityProvider, String tenantDomai
FederatedAuthenticatorConfig passiveStsAuthenticationConfig = new FederatedAuthenticatorConfig();
passiveStsAuthenticationConfig.setProperties(new Property[]{passiveStsProperty});
passiveStsAuthenticationConfig.setName(IdentityApplicationConstants.Authenticator.PassiveSTS.NAME);
passiveStsAuthenticationConfig.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM);

Check warning on line 268 in components/idp-mgt/org.wso2.carbon.idp.mgt/src/main/java/org/wso2/carbon/idp/mgt/IdentityProviderManager.java

View check run for this annotation

Codecov / codecov/patch

components/idp-mgt/org.wso2.carbon.idp.mgt/src/main/java/org/wso2/carbon/idp/mgt/IdentityProviderManager.java#L268

Added line #L268 was not covered by tests

FederatedAuthenticatorConfig[] federatedAuthenticatorConfigs = {saml2SSOResidentAuthenticatorConfig,
passiveStsAuthenticationConfig, oidcAuthenticationConfig};
Expand Down
Loading

0 comments on commit 9fc695e

Please sign in to comment.