diff --git a/components/action-mgt/org.wso2.carbon.identity.action.management/src/test/resources/dbscripts/h2.sql b/components/action-mgt/org.wso2.carbon.identity.action.management/src/test/resources/dbscripts/h2.sql index 4dc871f5af93..6a254b1b4c27 100644 --- a/components/action-mgt/org.wso2.carbon.identity.action.management/src/test/resources/dbscripts/h2.sql +++ b/components/action-mgt/org.wso2.carbon.identity.action.management/src/test/resources/dbscripts/h2.sql @@ -605,6 +605,7 @@ CREATE TABLE IF NOT EXISTS IDP_AUTHENTICATOR ( NAME VARCHAR(255) NOT NULL, IS_ENABLED CHAR (1) DEFAULT '1', DISPLAY_NAME VARCHAR(255), + DEFINED_BY VARCHAR(255) NOT NULL, PRIMARY KEY (ID), UNIQUE (TENANT_ID, IDP_ID, NAME), FOREIGN KEY (IDP_ID) REFERENCES IDP(ID) ON DELETE CASCADE); diff --git a/components/api-resource-mgt/org.wso2.carbon.identity.api.resource.mgt/src/test/resources/dbscripts/h2.sql b/components/api-resource-mgt/org.wso2.carbon.identity.api.resource.mgt/src/test/resources/dbscripts/h2.sql index 66edbc6db4c3..e45d08bcf056 100644 --- a/components/api-resource-mgt/org.wso2.carbon.identity.api.resource.mgt/src/test/resources/dbscripts/h2.sql +++ b/components/api-resource-mgt/org.wso2.carbon.identity.api.resource.mgt/src/test/resources/dbscripts/h2.sql @@ -590,6 +590,7 @@ CREATE TABLE IF NOT EXISTS IDP_AUTHENTICATOR ( NAME VARCHAR(255) NOT NULL, IS_ENABLED CHAR (1) DEFAULT '1', DISPLAY_NAME VARCHAR(255), + DEFINED_BY VARCHAR(255) NOT NULL, PRIMARY KEY (ID), UNIQUE (TENANT_ID, IDP_ID, NAME), FOREIGN KEY (IDP_ID) REFERENCES IDP(ID) ON DELETE CASCADE); diff --git a/components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/FederatedAuthenticatorConfig.java b/components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/FederatedAuthenticatorConfig.java index 40ad2fb904b5..f1c948ad18b4 100644 --- a/components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/FederatedAuthenticatorConfig.java +++ b/components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/FederatedAuthenticatorConfig.java @@ -22,6 +22,7 @@ import org.apache.axiom.om.OMElement; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang.StringUtils; +import org.wso2.carbon.identity.base.IdentityConstants; import java.io.Serializable; import java.util.ArrayList; @@ -63,6 +64,8 @@ public class FederatedAuthenticatorConfig implements Serializable { @XmlElement(name = "Tags") protected String[] tags; + protected IdentityConstants.DefinedByType definedByType; + public static FederatedAuthenticatorConfig build(OMElement federatedAuthenticatorConfigOM) { if (federatedAuthenticatorConfigOM == null) { @@ -101,6 +104,9 @@ 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.valueOf(element.getText())); } } @@ -230,4 +236,24 @@ public void setTags(String[] tagList) { tags = tagList; } + + /** + * Get the tag list of the Local authenticator. + * + * @return String[] + */ + public IdentityConstants.DefinedByType getDefinedByType() { + + return definedByType; + } + + /** + * Set the tag list for Local authenticator config. + * + * @param type authenticator. + */ + public void setDefinedByType(IdentityConstants.DefinedByType type) { + + definedByType = type; + } } diff --git a/components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/LocalAuthenticatorConfig.java b/components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/LocalAuthenticatorConfig.java index cfe369a544e3..07bdc7235af0 100644 --- a/components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/LocalAuthenticatorConfig.java +++ b/components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/LocalAuthenticatorConfig.java @@ -63,6 +63,8 @@ public class LocalAuthenticatorConfig implements Serializable { @XmlElement(name = "Tags") protected String[] tags; + protected IdentityConstants.DefinedByType definedByType; + /* * * @@ -111,6 +113,8 @@ 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())); } } return localAuthenticatorConfig; @@ -224,4 +228,24 @@ public void setTags(String[] tagList) { tags = tagList; } + + /** + * Get the tag list of the Local authenticator. + * + * @return String[] + */ + public IdentityConstants.DefinedByType getDefinedByType() { + + return definedByType; + } + + /** + * Set the tag list for Local authenticator config. + * + * @param type authenticator. + */ + public void setDefinedByType(IdentityConstants.DefinedByType type) { + + definedByType = type; + } } diff --git a/components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/ApplicationMgtDBQueries.java b/components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/ApplicationMgtDBQueries.java index 70ffca50df7d..92ef160eaea1 100644 --- a/components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/ApplicationMgtDBQueries.java +++ b/components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/ApplicationMgtDBQueries.java @@ -289,7 +289,8 @@ public class ApplicationMgtDBQueries { "B.DISPLAY_NAME FROM IDP A JOIN IDP_AUTHENTICATOR B ON A.ID = B.IDP_ID WHERE B.ID =? AND ((A.TENANT_ID =?" + " AND B.TENANT_ID =?) OR (A.TENANT_ID=? AND A.NAME LIKE 'SHARED_%' AND B.TENANT_ID=?))"; public static final String STORE_LOCAL_AUTHENTICATOR = "INSERT INTO IDP_AUTHENTICATOR (TENANT_ID, IDP_ID, NAME," + - "IS_ENABLED, DISPLAY_NAME) VALUES (?, (SELECT ID FROM IDP WHERE IDP.NAME=? AND IDP.TENANT_ID =?), ?, ?, ?)"; + "IS_ENABLED, DISPLAY_NAME, SCOPE) VALUES " + + "(?, (SELECT ID FROM IDP WHERE IDP.NAME=? AND IDP.TENANT_ID =?), ?, ?, ?, ?)"; public static final String GET_SP_METADATA_BY_SP_ID = "SELECT ID, NAME, VALUE, DISPLAY_NAME FROM SP_METADATA " + "WHERE SP_ID = ?"; diff --git a/components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java b/components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java index 745068863338..4e6c0a9a1f79 100644 --- a/components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java +++ b/components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java @@ -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; @@ -1566,6 +1567,9 @@ private void updateLocalAndOutboundAuthenticationConfiguration(int applicationId ApplicationConstants.LOCAL_IDP_NAME, lclAuthenticator.getName(), lclAuthenticator.getDisplayName()); + } else { + addAuthenticatorDefinedByType(connection, tenantID, authenticatorId, + lclAuthenticator.getDefinedByType().toString()); } if (authenticatorId > 0) { // ID, TENANT_ID, AUTHENTICATOR_ID @@ -5038,7 +5042,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(); @@ -5050,6 +5054,7 @@ private int addAuthenticator(Connection conn, int tenantId, String idpName, prepStmt.setString(4, authenticatorName); prepStmt.setString(5, "1"); prepStmt.setString(6, authenticatorDispalyName); + prepStmt.setString(7, IdentityConstants.DefinedByType.SYSTEM.toString()); prepStmt.execute(); rs = prepStmt.getGeneratedKeys(); if (rs.next()) { @@ -5061,6 +5066,25 @@ private int addAuthenticator(Connection conn, int tenantId, String idpName, return authenticatorId; } + private void addAuthenticatorDefinedByType(Connection conn, int tenantId, int authenticatorId, + String authenticatorDefinedByType) throws SQLException { + + PreparedStatement prepStmt = null; + ResultSet rs = null; + String sqlStmt = ApplicationMgtDBQueries.UPDATE_AUTHENTICATOR_DEFINED_BY_TYPE; + try { + String dbProductName = conn.getMetaData().getDatabaseProductName(); + prepStmt = conn.prepareStatement(sqlStmt, new String[] { + DBUtils.getConvertedAutoGeneratedColumnName(dbProductName, "ID")}); + prepStmt.setString(1, authenticatorDefinedByType); + prepStmt.setInt(2, authenticatorId); + prepStmt.setInt(3, tenantId); + prepStmt.execute(); + } finally { + IdentityApplicationManagementUtil.closeStatement(prepStmt); + } + } + /** * Read application role permissions for a given application name * diff --git a/components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationMgtDBQueries.java b/components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationMgtDBQueries.java index d5818025a738..30fe29d95529 100644 --- a/components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationMgtDBQueries.java +++ b/components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationMgtDBQueries.java @@ -293,7 +293,10 @@ public class ApplicationMgtDBQueries { "B.DISPLAY_NAME FROM IDP A JOIN IDP_AUTHENTICATOR B ON A.ID = B.IDP_ID WHERE B.ID =? AND ((A.TENANT_ID =?" + " AND B.TENANT_ID =?) OR (A.TENANT_ID=? AND A.NAME LIKE 'SHARED_%' AND B.TENANT_ID=?))"; public static final String STORE_LOCAL_AUTHENTICATOR = "INSERT INTO IDP_AUTHENTICATOR (TENANT_ID, IDP_ID, NAME," + - "IS_ENABLED, DISPLAY_NAME) VALUES (?, (SELECT ID FROM IDP WHERE IDP.NAME=? AND IDP.TENANT_ID =?), ?, ?, ?)"; + "IS_ENABLED, DISPLAY_NAME, DEFINED_BY) VALUES " + + "(?, (SELECT ID FROM IDP WHERE IDP.NAME=? AND IDP.TENANT_ID =?), ?, ?, ?, ?)"; + public static final String UPDATE_AUTHENTICATOR_DEFINED_BY_TYPE = "UPDATE IDP_AUTHENTICATOR SET " + + "DEFINED_BY= ? WHERE ID = ? AND TENANT_ID = ?"; public static final String GET_SP_METADATA_BY_SP_ID = "SELECT ID, NAME, VALUE, DISPLAY_NAME FROM SP_METADATA " + "WHERE SP_ID = ?"; diff --git a/components/application-mgt/org.wso2.carbon.identity.application.mgt/src/test/resources/dbscripts/identity.sql b/components/application-mgt/org.wso2.carbon.identity.application.mgt/src/test/resources/dbscripts/identity.sql index ff1e7a44b2d4..4ec3188658cd 100644 --- a/components/application-mgt/org.wso2.carbon.identity.application.mgt/src/test/resources/dbscripts/identity.sql +++ b/components/application-mgt/org.wso2.carbon.identity.application.mgt/src/test/resources/dbscripts/identity.sql @@ -602,6 +602,7 @@ CREATE TABLE IF NOT EXISTS IDP_AUTHENTICATOR ( NAME VARCHAR(255) NOT NULL, IS_ENABLED CHAR (1) DEFAULT '1', DISPLAY_NAME VARCHAR(255), + DEFINED_BY VARCHAR(255) NOT NULL, PRIMARY KEY (ID), UNIQUE (TENANT_ID, IDP_ID, NAME), FOREIGN KEY (IDP_ID) REFERENCES IDP(ID) ON DELETE CASCADE); diff --git a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/ApplicationAuthenticator.java b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/ApplicationAuthenticator.java index 6c974a31d83b..c9756c44a120 100644 --- a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/ApplicationAuthenticator.java +++ b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/ApplicationAuthenticator.java @@ -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; @@ -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; + } } diff --git a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/internal/FrameworkServiceComponent.java b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/internal/FrameworkServiceComponent.java index c781132f5f08..e07d52a59813 100644 --- a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/internal/FrameworkServiceComponent.java +++ b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/internal/FrameworkServiceComponent.java @@ -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; @@ -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); AuthenticatorConfig fileBasedConfig = getAuthenticatorConfig(authenticator.getName()); localAuthenticatorConfig.setEnabled(fileBasedConfig.isEnabled()); ApplicationAuthenticatorService.getInstance().addLocalAuthenticator(localAuthenticatorConfig); @@ -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); ApplicationAuthenticatorService.getInstance().addFederatedAuthenticator(federatedAuthenticatorConfig); } else if (authenticator instanceof RequestPathApplicationAuthenticator) { RequestPathAuthenticatorConfig reqPathAuthenticatorConfig = new RequestPathAuthenticatorConfig(); @@ -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); ApplicationAuthenticatorService.getInstance().addRequestPathAuthenticator(reqPathAuthenticatorConfig); } diff --git a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/dbScripts/h2.sql b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/dbScripts/h2.sql index f985ed495cff..707df1d55124 100644 --- a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/dbScripts/h2.sql +++ b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/dbScripts/h2.sql @@ -571,6 +571,7 @@ CREATE TABLE IF NOT EXISTS IDP_AUTHENTICATOR ( NAME VARCHAR(255) NOT NULL, IS_ENABLED CHAR (1) DEFAULT '1', DISPLAY_NAME VARCHAR(255), + DEFINED_BY VARCHAR(255) NOT NULL, PRIMARY KEY (ID), UNIQUE (TENANT_ID, IDP_ID, NAME), FOREIGN KEY (IDP_ID) REFERENCES IDP(ID) ON DELETE CASCADE); diff --git a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/config/builder/test-sp-1.xml b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/config/builder/test-sp-1.xml index 44ec88d52dc8..c5d1833f5a52 100644 --- a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/config/builder/test-sp-1.xml +++ b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/config/builder/test-sp-1.xml @@ -37,6 +37,7 @@ BasicAuthenticator basicauth true + SYSTEM true diff --git a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/config/model/graph/js-sp-1.xml b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/config/model/graph/js-sp-1.xml index c35c0cd0916f..3cac5e5a2980 100644 --- a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/config/model/graph/js-sp-1.xml +++ b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/config/model/graph/js-sp-1.xml @@ -37,6 +37,7 @@ BasicAuthenticator basicauth true + SYSTEM true diff --git a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/request/impl/default-sp-1.xml b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/request/impl/default-sp-1.xml index f9bd84a5c572..730d65374a77 100644 --- a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/request/impl/default-sp-1.xml +++ b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/request/impl/default-sp-1.xml @@ -37,6 +37,7 @@ BasicMockAuthenticator basicauth true + SYSTEM true diff --git a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/disabled-js-sp-1.xml b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/disabled-js-sp-1.xml index fd7cdb1eb9a4..bc13d623b51c 100644 --- a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/disabled-js-sp-1.xml +++ b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/disabled-js-sp-1.xml @@ -37,6 +37,7 @@ BasicMockAuthenticator basicauth true + SYSTEM true diff --git a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/incorrect-function-js-sp-1.xml b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/incorrect-function-js-sp-1.xml index 640fc3267fa0..ecc26a5febe9 100644 --- a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/incorrect-function-js-sp-1.xml +++ b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/incorrect-function-js-sp-1.xml @@ -37,6 +37,7 @@ BasicMockAuthenticator basicauth true + SYSTEM true diff --git a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/incorrect-js-sp-1.xml b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/incorrect-js-sp-1.xml index 8d285e8c5d2a..569537e5bd63 100644 --- a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/incorrect-js-sp-1.xml +++ b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/incorrect-js-sp-1.xml @@ -37,6 +37,7 @@ BasicMockAuthenticator basicauth true + SYSTEM true diff --git a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/js-sp-1.xml b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/js-sp-1.xml index 22ec2a89a033..57140d8e628b 100644 --- a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/js-sp-1.xml +++ b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/js-sp-1.xml @@ -37,6 +37,7 @@ BasicMockAuthenticator basicauth true + SYSTEM true diff --git a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/js-sp-2.xml b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/js-sp-2.xml index ad433285aca2..6038bdbb9a91 100644 --- a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/js-sp-2.xml +++ b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/js-sp-2.xml @@ -37,6 +37,7 @@ BasicMockAuthenticator basicauth true + SYSTEM true diff --git a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/js-sp-3.xml b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/js-sp-3.xml index 58a638b5d4da..8c2a6bc47590 100644 --- a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/js-sp-3.xml +++ b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/js-sp-3.xml @@ -37,6 +37,7 @@ BasicMockAuthenticator basicauth true + SYSTEM true diff --git a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/js-sp-4-claim.xml b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/js-sp-4-claim.xml index 9e2cda58d347..a14a2c7e2b70 100644 --- a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/js-sp-4-claim.xml +++ b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/js-sp-4-claim.xml @@ -37,6 +37,7 @@ BasicMockAuthenticator basicauth true + SYSTEM true diff --git a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/js-sp-5-claim.xml b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/js-sp-5-claim.xml index c90b15dfa764..48084a527bfa 100644 --- a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/js-sp-5-claim.xml +++ b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/js-sp-5-claim.xml @@ -37,6 +37,7 @@ BasicMockAuthenticator basicauth true + SYSTEM true diff --git a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/js-sp-dynamic-1.xml b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/js-sp-dynamic-1.xml index 60af8fbc979e..9b00ba6300b4 100644 --- a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/js-sp-dynamic-1.xml +++ b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/js-sp-dynamic-1.xml @@ -37,6 +37,7 @@ BasicMockAuthenticator basicauth true + SYSTEM true diff --git a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/js-sp-dynamic-on-fail.xml b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/js-sp-dynamic-on-fail.xml index 95b372d95f1b..0300ba078158 100644 --- a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/js-sp-dynamic-on-fail.xml +++ b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/js-sp-dynamic-on-fail.xml @@ -36,6 +36,7 @@ BasicMockAuthenticator basicauth + SYSTEM true @@ -85,6 +86,7 @@ BasicFailingMockAuthenticator basicauthfialing true + SYSTEM true diff --git a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/js-sp-dynamic-on-fallback.xml b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/js-sp-dynamic-on-fallback.xml index f4245893aa92..9ea3bcb46786 100644 --- a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/js-sp-dynamic-on-fallback.xml +++ b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/js-sp-dynamic-on-fallback.xml @@ -37,6 +37,7 @@ BasicMockAuthenticator basicauth true + SYSTEM true @@ -85,6 +86,7 @@ MockFallbackAuthenticator basicauthfallback true + SYSTEM true diff --git a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/js-sp-exception-retry.xml b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/js-sp-exception-retry.xml index 1be3b3ca555a..7f4135274605 100644 --- a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/js-sp-exception-retry.xml +++ b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/js-sp-exception-retry.xml @@ -37,6 +37,7 @@ BasicMockAuthenticator basicauth true + SYSTEM true diff --git a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/js-sp-fail-method-with-params-onFail.xml b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/js-sp-fail-method-with-params-onFail.xml index 01e655ce5802..3f845b1a6872 100644 --- a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/js-sp-fail-method-with-params-onFail.xml +++ b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/js-sp-fail-method-with-params-onFail.xml @@ -37,6 +37,7 @@ BasicMockAuthenticator basicauth true + SYSTEM true diff --git a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/js-sp-fail-method-with-params-onSuccess.xml b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/js-sp-fail-method-with-params-onSuccess.xml index d711487f2b2c..0d5e7ba8f00b 100644 --- a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/js-sp-fail-method-with-params-onSuccess.xml +++ b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/js-sp-fail-method-with-params-onSuccess.xml @@ -37,6 +37,7 @@ BasicMockAuthenticator basicauth true + SYSTEM true diff --git a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/js-sp-fail-method-without-params-onFail.xml b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/js-sp-fail-method-without-params-onFail.xml index 50552737033d..8a1bf4439ce1 100644 --- a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/js-sp-fail-method-without-params-onFail.xml +++ b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/js-sp-fail-method-without-params-onFail.xml @@ -37,6 +37,7 @@ BasicMockAuthenticator basicauth true + SYSTEM true diff --git a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/js-sp-fail-method-without-params-onSuccsss.xml b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/js-sp-fail-method-without-params-onSuccsss.xml index 7c9ccd48f3bc..8148497e6592 100644 --- a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/js-sp-fail-method-without-params-onSuccsss.xml +++ b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/js-sp-fail-method-without-params-onSuccsss.xml @@ -37,6 +37,7 @@ BasicMockAuthenticator basicauth true + SYSTEM true diff --git a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/js-sp-longwait-1.xml b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/js-sp-longwait-1.xml index 3cbd00f0b97c..eecff7c2d5cd 100644 --- a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/js-sp-longwait-1.xml +++ b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/js-sp-longwait-1.xml @@ -37,6 +37,7 @@ BasicMockAuthenticator basicauth true + SYSTEM true diff --git a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/no-js-sp-1.xml b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/no-js-sp-1.xml index fb3b8cb657d1..3fb1fe134b44 100644 --- a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/no-js-sp-1.xml +++ b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/test/resources/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/no-js-sp-1.xml @@ -37,6 +37,7 @@ BasicMockAuthenticator basicauth true + SYSTEM true diff --git a/components/entitlement/org.wso2.carbon.identity.entitlement/src/test/resources/dbscripts/h2.sql b/components/entitlement/org.wso2.carbon.identity.entitlement/src/test/resources/dbscripts/h2.sql index aa0c8893b4f6..69086bdbb2d5 100644 --- a/components/entitlement/org.wso2.carbon.identity.entitlement/src/test/resources/dbscripts/h2.sql +++ b/components/entitlement/org.wso2.carbon.identity.entitlement/src/test/resources/dbscripts/h2.sql @@ -593,6 +593,7 @@ CREATE TABLE IF NOT EXISTS IDP_AUTHENTICATOR ( NAME VARCHAR(255) NOT NULL, IS_ENABLED CHAR (1) DEFAULT '1', DISPLAY_NAME VARCHAR(255), + DEFINED_BY VARCHAR(255) NOT NULL, PRIMARY KEY (ID), UNIQUE (TENANT_ID, IDP_ID, NAME), FOREIGN KEY (IDP_ID) REFERENCES IDP(ID) ON DELETE CASCADE); diff --git a/components/identity-core/org.wso2.carbon.identity.base/src/main/java/org/wso2/carbon/identity/base/IdentityConstants.java b/components/identity-core/org.wso2.carbon.identity.base/src/main/java/org/wso2/carbon/identity/base/IdentityConstants.java index a5b96babf759..c2a3cbdbe557 100644 --- a/components/identity-core/org.wso2.carbon.identity.base/src/main/java/org/wso2/carbon/identity/base/IdentityConstants.java +++ b/components/identity-core/org.wso2.carbon.identity.base/src/main/java/org/wso2/carbon/identity/base/IdentityConstants.java @@ -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 + } } diff --git a/components/idp-mgt/org.wso2.carbon.idp.mgt/src/main/java/org/wso2/carbon/idp/mgt/IdentityProviderManager.java b/components/idp-mgt/org.wso2.carbon.idp.mgt/src/main/java/org/wso2/carbon/idp/mgt/IdentityProviderManager.java index c383da9a34ff..a28c1db25115 100644 --- a/components/idp-mgt/org.wso2.carbon.idp.mgt/src/main/java/org/wso2/carbon/idp/mgt/IdentityProviderManager.java +++ b/components/idp-mgt/org.wso2.carbon.idp.mgt/src/main/java/org/wso2/carbon/idp/mgt/IdentityProviderManager.java @@ -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); } if (saml2SSOResidentAuthenticatorConfig.getProperties() == null) { saml2SSOResidentAuthenticatorConfig.setProperties(new Property[0]); @@ -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); Property passiveStsProperty = new Property(); passiveStsProperty.setName(IdentityApplicationConstants.Authenticator.PassiveSTS.IDENTITY_PROVIDER_ENTITY_ID); @@ -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); FederatedAuthenticatorConfig[] federatedAuthenticatorConfigs = {saml2SSOResidentAuthenticatorConfig, passiveStsAuthenticationConfig, oidcAuthenticationConfig}; diff --git a/components/idp-mgt/org.wso2.carbon.idp.mgt/src/main/java/org/wso2/carbon/idp/mgt/dao/IdPManagementDAO.java b/components/idp-mgt/org.wso2.carbon.idp.mgt/src/main/java/org/wso2/carbon/idp/mgt/dao/IdPManagementDAO.java index 3c382c249765..b43b2f760af3 100644 --- a/components/idp-mgt/org.wso2.carbon.idp.mgt/src/main/java/org/wso2/carbon/idp/mgt/dao/IdPManagementDAO.java +++ b/components/idp-mgt/org.wso2.carbon.idp.mgt/src/main/java/org/wso2/carbon/idp/mgt/dao/IdPManagementDAO.java @@ -1148,6 +1148,8 @@ private FederatedAuthenticatorConfig[] getFederatedAuthenticatorConfigs( } authnConfig.setDisplayName(rs.getString("DISPLAY_NAME")); + authnConfig.setDefinedByType(IdentityConstants.DefinedByType.valueOf( + rs.getString("DEFINED_BY"))); if (defaultAuthName != null && authnConfig.getName().equals(defaultAuthName)) { federatedIdp.getDefaultAuthenticatorConfig().setDisplayName(authnConfig.getDisplayName()); @@ -1424,6 +1426,7 @@ public void addFederatedAuthenticatorConfig(FederatedAuthenticatorConfig authnCo } prepStmt1.setString(4, authnConfig.getName()); prepStmt1.setString(5, authnConfig.getDisplayName()); + prepStmt1.setString(6, authnConfig.getDefinedByType().toString()); prepStmt1.execute(); int authnId = getAuthenticatorIdentifier(dbConnection, idpId, authnConfig.getName()); diff --git a/components/idp-mgt/org.wso2.carbon.idp.mgt/src/main/java/org/wso2/carbon/idp/mgt/util/IdPManagementConstants.java b/components/idp-mgt/org.wso2.carbon.idp.mgt/src/main/java/org/wso2/carbon/idp/mgt/util/IdPManagementConstants.java index 0cfbadd94eac..b815943350c0 100644 --- a/components/idp-mgt/org.wso2.carbon.idp.mgt/src/main/java/org/wso2/carbon/idp/mgt/util/IdPManagementConstants.java +++ b/components/idp-mgt/org.wso2.carbon.idp.mgt/src/main/java/org/wso2/carbon/idp/mgt/util/IdPManagementConstants.java @@ -235,7 +235,7 @@ public static class SQLQueries { public static final String GET_IDP_ID_BY_NAME_SQL = "SELECT ID " + "FROM IDP WHERE TENANT_ID=? AND NAME=?"; - public static final String GET_ALL_IDP_AUTH_SQL = "SELECT ID, NAME, IS_ENABLED, DISPLAY_NAME FROM " + + public static final String GET_ALL_IDP_AUTH_SQL = "SELECT ID, NAME, IS_ENABLED, DISPLAY_NAME, DEFINED_BY FROM " + "IDP_AUTHENTICATOR WHERE IDP_ID = ?"; public static final String GET_IDP_AUTH_SQL = "SELECT ID FROM IDP_AUTHENTICATOR WHERE IDP_ID = ? AND NAME = ?"; @@ -357,7 +357,7 @@ public static class SQLQueries { public static final String TRUSTED_TOKEN_ISSUER_FILTER_SQL = "IDP_METADATA.\"VALUE\" = 'true' AND "; public static final String ADD_IDP_AUTH_SQL = "INSERT INTO IDP_AUTHENTICATOR " + - "(IDP_ID, TENANT_ID, IS_ENABLED, NAME, DISPLAY_NAME) VALUES (?,?,?,?,?)"; + "(IDP_ID, TENANT_ID, IS_ENABLED, NAME, DISPLAY_NAME, DEFINED_BY) VALUES (?,?,?,?,?,?)"; public static final String DELETE_IDP_AUTH_SQL = "DELETE FROM IDP_AUTHENTICATOR WHERE IDP_ID=? AND NAME=?"; diff --git a/components/idp-mgt/org.wso2.carbon.idp.mgt/src/test/java/org/wso2/carbon/idp/mgt/IdentityProviderManagementServiceTest.java b/components/idp-mgt/org.wso2.carbon.idp.mgt/src/test/java/org/wso2/carbon/idp/mgt/IdentityProviderManagementServiceTest.java index a9c3a7926b21..d54c396949f9 100644 --- a/components/idp-mgt/org.wso2.carbon.idp.mgt/src/test/java/org/wso2/carbon/idp/mgt/IdentityProviderManagementServiceTest.java +++ b/components/idp-mgt/org.wso2.carbon.idp.mgt/src/test/java/org/wso2/carbon/idp/mgt/IdentityProviderManagementServiceTest.java @@ -37,6 +37,7 @@ import org.wso2.carbon.identity.application.common.model.ProvisioningConnectorConfig; import org.wso2.carbon.identity.application.common.model.RoleMapping; import org.wso2.carbon.identity.application.common.util.IdentityApplicationConstants; +import org.wso2.carbon.identity.base.IdentityConstants; import org.wso2.carbon.identity.claim.metadata.mgt.ClaimMetadataManagementServiceImpl; import org.wso2.carbon.identity.claim.metadata.mgt.exception.ClaimMetadataException; import org.wso2.carbon.identity.claim.metadata.mgt.model.LocalClaim; @@ -132,6 +133,7 @@ public Object[][] addIdPData() { federatedAuthenticatorConfig.setDisplayName("DisplayName1"); federatedAuthenticatorConfig.setName("Name"); federatedAuthenticatorConfig.setEnabled(true); + federatedAuthenticatorConfig.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM); Property property1 = new Property(); property1.setName("Property1"); property1.setValue("value1"); @@ -557,6 +559,7 @@ public Object[][] updateIdPData() { newFederatedAuthenticatorConfig.setDisplayName("DisplayName1New"); newFederatedAuthenticatorConfig.setName("Name"); newFederatedAuthenticatorConfig.setEnabled(true); + newFederatedAuthenticatorConfig.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM); Property newProperty1 = new Property(); newProperty1.setName("Property1New"); newProperty1.setValue("value1New"); @@ -796,6 +799,7 @@ public Object[][] updateResidentIdPData() { facNew.setDisplayName("DisplayName1New"); facNew.setName("Name"); facNew.setEnabled(true); + facNew.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM); idp2New.setFederatedAuthenticatorConfigs(new FederatedAuthenticatorConfig[]{facNew}); // Initialize New Resident Identity Provider 3. @@ -893,6 +897,7 @@ public void testGetResidentIDPMetadata() throws Exception { facNew.setDisplayName("SAML2SSO"); facNew.setName("saml2sso"); facNew.setEnabled(true); + facNew.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM); newIdp.setFederatedAuthenticatorConfigs(new FederatedAuthenticatorConfig[]{facNew}); identityProviderManagementService.updateResidentIdP((IdentityProvider) newIdp); @@ -915,6 +920,7 @@ public void testGetResidentIDPMetadataException() throws Exception { facNew.setDisplayName("SAML2SSO"); facNew.setName("saml2sso"); facNew.setEnabled(true); + facNew.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM); newIdp.setFederatedAuthenticatorConfigs(new FederatedAuthenticatorConfig[]{facNew}); identityProviderManagementService.updateResidentIdP((IdentityProvider) newIdp); @@ -950,6 +956,7 @@ private void addTestIdps() throws IdentityProviderManagementException { federatedAuthenticatorConfig.setDisplayName("DisplayName1"); federatedAuthenticatorConfig.setName("Name"); federatedAuthenticatorConfig.setEnabled(true); + federatedAuthenticatorConfig.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM); Property property1 = new Property(); property1.setName("Property1"); property1.setValue("value1"); @@ -1103,6 +1110,7 @@ private IdentityProvider addIdPDataWithSameIdpEntityId(String idpName) { federatedAuthenticatorConfig.setDisplayName("DisplayName"); federatedAuthenticatorConfig.setName("SAMLSSOAuthenticator"); federatedAuthenticatorConfig.setEnabled(true); + federatedAuthenticatorConfig.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM); Property property1 = new Property(); property1.setName("SPEntityId"); property1.setValue("wso2-is"); diff --git a/components/idp-mgt/org.wso2.carbon.idp.mgt/src/test/java/org/wso2/carbon/idp/mgt/dao/CacheBackedIdPMgtDAOTest.java b/components/idp-mgt/org.wso2.carbon.idp.mgt/src/test/java/org/wso2/carbon/idp/mgt/dao/CacheBackedIdPMgtDAOTest.java index 853052a55842..1d00094a3b1a 100644 --- a/components/idp-mgt/org.wso2.carbon.idp.mgt/src/test/java/org/wso2/carbon/idp/mgt/dao/CacheBackedIdPMgtDAOTest.java +++ b/components/idp-mgt/org.wso2.carbon.idp.mgt/src/test/java/org/wso2/carbon/idp/mgt/dao/CacheBackedIdPMgtDAOTest.java @@ -39,6 +39,7 @@ import org.wso2.carbon.identity.application.common.model.Property; import org.wso2.carbon.identity.application.common.model.ProvisioningConnectorConfig; import org.wso2.carbon.identity.application.common.model.RoleMapping; +import org.wso2.carbon.identity.base.IdentityConstants; import org.wso2.carbon.identity.core.model.ExpressionNode; import org.wso2.carbon.identity.core.util.IdentityDatabaseUtil; import org.wso2.carbon.identity.core.util.IdentityTenantUtil; @@ -742,6 +743,7 @@ public Object[][] addIdPData() { federatedAuthenticatorConfig.setDisplayName("DisplayName1"); federatedAuthenticatorConfig.setName("Name"); federatedAuthenticatorConfig.setEnabled(true); + federatedAuthenticatorConfig.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM); Property property1 = new Property(); property1.setName("Property1"); property1.setValue("value1"); @@ -845,6 +847,7 @@ public Object[][] updateIdPData() { federatedAuthenticatorConfig.setDisplayName("DisplayName1"); federatedAuthenticatorConfig.setName("Name"); federatedAuthenticatorConfig.setEnabled(true); + federatedAuthenticatorConfig.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM); Property property1 = new Property(); property1.setName("Property1"); property1.setValue("value1"); @@ -902,6 +905,7 @@ public Object[][] updateIdPData() { newFederatedAuthenticatorConfig.setDisplayName("DisplayName1New"); newFederatedAuthenticatorConfig.setName("Name"); newFederatedAuthenticatorConfig.setEnabled(true); + newFederatedAuthenticatorConfig.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM); Property property1New = new Property(); property1New.setName("Property1New"); property1New.setValue("value1New"); @@ -1449,6 +1453,7 @@ private void addTestIdps() throws IdentityProviderManagementException { FederatedAuthenticatorConfig federatedAuthenticatorConfig = new FederatedAuthenticatorConfig(); federatedAuthenticatorConfig.setDisplayName("DisplayName1"); federatedAuthenticatorConfig.setName("Name"); + federatedAuthenticatorConfig.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM); federatedAuthenticatorConfig.setEnabled(true); Property property1 = new Property(); property1.setName("Property1"); diff --git a/components/idp-mgt/org.wso2.carbon.idp.mgt/src/test/java/org/wso2/carbon/idp/mgt/dao/IdPManagementDAOTest.java b/components/idp-mgt/org.wso2.carbon.idp.mgt/src/test/java/org/wso2/carbon/idp/mgt/dao/IdPManagementDAOTest.java index e7b93e916790..f196b9a35447 100644 --- a/components/idp-mgt/org.wso2.carbon.idp.mgt/src/test/java/org/wso2/carbon/idp/mgt/dao/IdPManagementDAOTest.java +++ b/components/idp-mgt/org.wso2.carbon.idp.mgt/src/test/java/org/wso2/carbon/idp/mgt/dao/IdPManagementDAOTest.java @@ -40,6 +40,7 @@ import org.wso2.carbon.identity.application.common.model.Property; import org.wso2.carbon.identity.application.common.model.ProvisioningConnectorConfig; import org.wso2.carbon.identity.application.common.model.RoleMapping; +import org.wso2.carbon.identity.base.IdentityConstants; import org.wso2.carbon.identity.core.model.ExpressionNode; import org.wso2.carbon.identity.core.util.IdentityDatabaseUtil; import org.wso2.carbon.identity.core.util.IdentityTenantUtil; @@ -588,6 +589,7 @@ public Object[][] addIdPData() { federatedAuthenticatorConfig.setDisplayName("DisplayName1"); federatedAuthenticatorConfig.setName("Name"); federatedAuthenticatorConfig.setEnabled(true); + federatedAuthenticatorConfig.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM); Property property1 = new Property(); property1.setName("Property1"); property1.setValue("value1"); @@ -1104,6 +1106,7 @@ public Object[][] updateIdPData() { federatedAuthenticatorConfig.setDisplayName("DisplayName1"); federatedAuthenticatorConfig.setName("Name"); federatedAuthenticatorConfig.setEnabled(true); + federatedAuthenticatorConfig.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM); Property property1 = new Property(); property1.setName("Property1"); property1.setValue("value1"); @@ -1161,6 +1164,7 @@ public Object[][] updateIdPData() { newFederatedAuthenticatorConfig.setDisplayName("DisplayName1New"); newFederatedAuthenticatorConfig.setName("Name"); newFederatedAuthenticatorConfig.setEnabled(true); + newFederatedAuthenticatorConfig.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM); Property property1New = new Property(); property1New.setName("Property1New"); property1New.setValue("value1New"); @@ -1733,6 +1737,7 @@ private void addTestIdps() throws IdentityProviderManagementException { federatedAuthenticatorConfig.setDisplayName("DisplayName1"); federatedAuthenticatorConfig.setName("Name"); federatedAuthenticatorConfig.setEnabled(true); + federatedAuthenticatorConfig.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM); Property property1 = new Property(); property1.setName("Property1"); property1.setValue("value1"); @@ -1864,6 +1869,7 @@ private void addTestTrustedTokenIssuers() throws IdentityProviderManagementExcep federatedAuthenticatorConfig.setDisplayName("DisplayName1"); federatedAuthenticatorConfig.setName("Name"); federatedAuthenticatorConfig.setEnabled(true); + federatedAuthenticatorConfig.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM); Property property1 = new Property(); property1.setName("Property1"); property1.setValue("value1"); diff --git a/components/idp-mgt/org.wso2.carbon.idp.mgt/src/test/resources/dbscripts/h2.sql b/components/idp-mgt/org.wso2.carbon.idp.mgt/src/test/resources/dbscripts/h2.sql index 79494d2b9d30..dc2af66b4f82 100644 --- a/components/idp-mgt/org.wso2.carbon.idp.mgt/src/test/resources/dbscripts/h2.sql +++ b/components/idp-mgt/org.wso2.carbon.idp.mgt/src/test/resources/dbscripts/h2.sql @@ -582,6 +582,7 @@ CREATE TABLE IF NOT EXISTS IDP_AUTHENTICATOR ( NAME VARCHAR(255) NOT NULL, IS_ENABLED CHAR (1) DEFAULT '1', DISPLAY_NAME VARCHAR(255), + DEFINED_BY VARCHAR(255) NOT NULL, PRIMARY KEY (ID), UNIQUE (TENANT_ID, IDP_ID, NAME), FOREIGN KEY (IDP_ID) REFERENCES IDP(ID) ON DELETE CASCADE); diff --git a/features/application-mgt/org.wso2.carbon.identity.application.mgt.server.feature/resources/identity/service-providers/default.xml b/features/application-mgt/org.wso2.carbon.identity.application.mgt.server.feature/resources/identity/service-providers/default.xml index acab17557805..ba8682638a72 100644 --- a/features/application-mgt/org.wso2.carbon.identity.application.mgt.server.feature/resources/identity/service-providers/default.xml +++ b/features/application-mgt/org.wso2.carbon.identity.application.mgt.server.feature/resources/identity/service-providers/default.xml @@ -35,6 +35,7 @@ BasicAuthenticator basicauth true + SYSTEM