From f30a4543c4ae117e6e19c6e227d3544da3e2e11a Mon Sep 17 00:00:00 2001 From: thisarawelmilla Date: Thu, 3 Oct 2024 10:14:39 +0530 Subject: [PATCH] Comments addressed. --- .../model/FederatedAuthenticatorConfig.java | 26 +++++----- .../model/LocalAuthenticatorConfig.java | 28 ++++++----- .../model/RequestPathAuthenticatorConfig.java | 6 +++ .../mgt/dao/impl/ApplicationDAOImpl.java | 29 ++++++----- .../ApplicationManagementServiceImplTest.java | 15 ++++-- .../framework/ApplicationAuthenticator.java | 11 +++-- .../FederatedApplicationAuthenticator.java | 6 +-- .../LocalApplicationAuthenticator.java | 8 ++-- .../RequestPathApplicationAuthenticator.java | 7 +++ .../internal/FrameworkServiceComponent.java | 13 ++--- .../framework/util/FrameworkUtils.java | 4 +- .../base/AuthenticatorPropertiesConstant.java | 29 +++++++++++ .../idp/mgt/IdentityProviderManager.java | 14 +++--- .../carbon/idp/mgt/dao/IdPManagementDAO.java | 48 ++++++++++--------- ...IdentityProviderManagementServiceTest.java | 31 ++++++------ .../idp/mgt/dao/CacheBackedIdPMgtDAOTest.java | 19 ++++---- .../idp/mgt/dao/IdPManagementDAOTest.java | 23 ++++----- 17 files changed, 187 insertions(+), 130 deletions(-) create mode 100644 components/identity-core/org.wso2.carbon.identity.base/src/main/java/org/wso2/carbon/identity/base/AuthenticatorPropertiesConstant.java 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 228fb884542f..1cb753743e22 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 @@ -24,7 +24,8 @@ import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.wso2.carbon.identity.base.IdentityConstants; +import org.wso2.carbon.identity.base.AuthenticatorPropertiesConstant.AuthenticationType; +import org.wso2.carbon.identity.base.AuthenticatorPropertiesConstant.DefinedByType; import java.io.Serializable; import java.util.ArrayList; @@ -68,10 +69,10 @@ public class FederatedAuthenticatorConfig implements Serializable { protected String[] tags; @XmlElement(name = "DefinedBy") - protected IdentityConstants.DefinedByType definedByType; + protected DefinedByType definedByType; @XmlElement(name = "AuthenticationType") - protected IdentityConstants.AuthenticationType authenticationType; + protected AuthenticationType authenticationType; public static FederatedAuthenticatorConfig build(OMElement federatedAuthenticatorConfigOM) { @@ -113,15 +114,14 @@ public static FederatedAuthenticatorConfig build(OMElement federatedAuthenticato } } else if ("DefinedBy".equals(elementName)) { federatedAuthenticatorConfig.setDefinedByType( - IdentityConstants.DefinedByType.valueOf(element.getText())); + DefinedByType.valueOf(element.getText())); } } if (federatedAuthenticatorConfig.getDefinedByType() == null) { - federatedAuthenticatorConfig.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM); - LOG.debug("The defined by type is not set for the : " + federatedAuthenticatorConfig.getName()); + federatedAuthenticatorConfig.setDefinedByType(DefinedByType.SYSTEM); } - federatedAuthenticatorConfig.setAuthenticationType(IdentityConstants.AuthenticationType.IDENTIFICATION); + federatedAuthenticatorConfig.setAuthenticationType(AuthenticationType.IDENTIFICATION); return federatedAuthenticatorConfig; } @@ -253,9 +253,9 @@ public void setTags(String[] tagList) { /** * Get the defined by type of the federated authenticator config. * - * @return IdentityConstants.DefinedByType + * @return DefinedByType */ - public IdentityConstants.DefinedByType getDefinedByType() { + public DefinedByType getDefinedByType() { return definedByType; } @@ -265,7 +265,7 @@ public IdentityConstants.DefinedByType getDefinedByType() { * * @param type The defined by type of the authenticator config. */ - public void setDefinedByType(IdentityConstants.DefinedByType type) { + public void setDefinedByType(DefinedByType type) { definedByType = type; } @@ -273,9 +273,9 @@ public void setDefinedByType(IdentityConstants.DefinedByType type) { /** * Get the authentication type of the federated authenticator config. * - * @return IdentityConstants.AuthenticationType + * @return AuthenticationType */ - public IdentityConstants.AuthenticationType getAuthenticationType() { + public AuthenticationType getAuthenticationType() { return authenticationType; } @@ -285,7 +285,7 @@ public IdentityConstants.AuthenticationType getAuthenticationType() { * * @param type The authentication type. */ - public void setAuthenticationType(IdentityConstants.AuthenticationType type) { + public void setAuthenticationType(AuthenticationType type) { authenticationType = 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 fb80c1edf170..786331064264 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 @@ -24,6 +24,8 @@ import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.wso2.carbon.identity.base.AuthenticatorPropertiesConstant.AuthenticationType; +import org.wso2.carbon.identity.base.AuthenticatorPropertiesConstant.DefinedByType; import org.wso2.carbon.identity.base.IdentityConstants; import java.io.Serializable; @@ -69,10 +71,10 @@ public class LocalAuthenticatorConfig implements Serializable { protected String[] tags; @XmlElement(name = "DefinedBy") - protected IdentityConstants.DefinedByType definedByType; + protected DefinedByType definedByType; @XmlElement(name = "AuthenticationType") - protected IdentityConstants.AuthenticationType authenticationType; + protected AuthenticationType authenticationType; /* * @@ -123,15 +125,15 @@ public static LocalAuthenticatorConfig build(OMElement localAuthenticatorConfigO localAuthenticatorConfig.setProperties(propertiesArr); } } else if ("DefinedBy".equals(member.getLocalName())) { - localAuthenticatorConfig.setDefinedByType(IdentityConstants.DefinedByType.valueOf(member.getText())); + localAuthenticatorConfig.setDefinedByType(DefinedByType.valueOf(member.getText())); } else if ("AuthenticationType".equals(member.getLocalName())) { localAuthenticatorConfig.setAuthenticationType( - IdentityConstants.AuthenticationType.valueOf(member.getText())); + AuthenticationType.valueOf(member.getText())); } } if (localAuthenticatorConfig.getDefinedByType() == null) { - localAuthenticatorConfig.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM); + localAuthenticatorConfig.setDefinedByType(DefinedByType.SYSTEM); LOG.debug("The defined by type is not set for the {}. Hence setting default SYSTEM value.", localAuthenticatorConfig.getName()); } @@ -139,9 +141,9 @@ public static LocalAuthenticatorConfig build(OMElement localAuthenticatorConfigO if (localAuthenticatorConfig.getTags() != null && Arrays.stream(localAuthenticatorConfig.getTags()).anyMatch(s -> s.equalsIgnoreCase(TAG_2FA))) { localAuthenticatorConfig.setAuthenticationType( - IdentityConstants.AuthenticationType.VERIFICATION_ONLY); + AuthenticationType.VERIFICATION_ONLY); } else { - localAuthenticatorConfig.setAuthenticationType(IdentityConstants.AuthenticationType.IDENTIFICATION); + localAuthenticatorConfig.setAuthenticationType(AuthenticationType.IDENTIFICATION); } LOG.debug("The defined by type is not set for the: {}. Hence setting value based on the factor for the: {}", localAuthenticatorConfig.getName(), localAuthenticatorConfig.getAuthenticationType().toString()); @@ -262,9 +264,9 @@ public void setTags(String[] tagList) { /** * Get the defined by type of the Local authenticator config. * - * @return IdentityConstants.DefinedByType + * @return DefinedByType */ - public IdentityConstants.DefinedByType getDefinedByType() { + public DefinedByType getDefinedByType() { return definedByType; } @@ -274,7 +276,7 @@ public IdentityConstants.DefinedByType getDefinedByType() { * * @param type The defined by type of the authenticator config. */ - public void setDefinedByType(IdentityConstants.DefinedByType type) { + public void setDefinedByType(DefinedByType type) { definedByType = type; } @@ -282,9 +284,9 @@ public void setDefinedByType(IdentityConstants.DefinedByType type) { /** * Get the authentication type of the Local authenticator config . * - * @return IdentityConstants.AuthenticationType + * @return AuthenticationType */ - public IdentityConstants.AuthenticationType getAuthenticationType() { + public AuthenticationType getAuthenticationType() { return authenticationType; } @@ -294,7 +296,7 @@ public IdentityConstants.AuthenticationType getAuthenticationType() { * * @param type The authentication type. */ - public void setAuthenticationType(IdentityConstants.AuthenticationType type) { + public void setAuthenticationType(AuthenticationType type) { authenticationType = type; } diff --git a/components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/RequestPathAuthenticatorConfig.java b/components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/RequestPathAuthenticatorConfig.java index 0da3dc5a37a1..c1b2295d7232 100644 --- a/components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/RequestPathAuthenticatorConfig.java +++ b/components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/RequestPathAuthenticatorConfig.java @@ -20,6 +20,8 @@ import org.apache.axiom.om.OMElement; import org.apache.commons.collections.CollectionUtils; +import org.wso2.carbon.identity.base.AuthenticatorPropertiesConstant.AuthenticationType; +import org.wso2.carbon.identity.base.AuthenticatorPropertiesConstant.DefinedByType; import java.util.ArrayList; import java.util.Iterator; @@ -74,6 +76,10 @@ public static RequestPathAuthenticatorConfig build(OMElement requestPathAuthenti } } } + + requestPathAuthenticatorConfig.setAuthenticationType(AuthenticationType.REQUEST_PATH); + requestPathAuthenticatorConfig.setDefinedByType(DefinedByType.SYSTEM); + return requestPathAuthenticatorConfig; } 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 09e374a82cf8..776f36715e30 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,7 +77,8 @@ 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.AuthenticatorPropertiesConstant.AuthenticationType; +import org.wso2.carbon.identity.base.AuthenticatorPropertiesConstant.DefinedByType; import org.wso2.carbon.identity.base.IdentityException; import org.wso2.carbon.identity.base.IdentityRuntimeException; import org.wso2.carbon.identity.core.CertificateRetrievingException; @@ -1568,14 +1569,12 @@ private void updateLocalAndOutboundAuthenticationConfiguration(int applicationId lclAuthenticator.getName(), lclAuthenticator.getDisplayName()); } else { - if (lclAuthenticator.getDefinedByType() == null) { - log.debug("Authenticator already exists. Updating the authenticator, but the " + - "defined by type is not set."); - } else { - log.debug("Authenticator already exists. Updating the authenticator.The defined " + /* On demand migration for already saved local authenticators to save definedBy and + authenticationType properties to the database. + Remove this else block, once on-demand migration is done.*/ + log.debug("Authenticator already exists. Updating the authenticator.The defined " + "by type is set to: " + lclAuthenticator.getDefinedByType().toString()); - //TODO: Update database with defined by properties for local authenticators. - } + //TODO: Update database with defined by properties for local authenticators. } if (authenticatorId > 0) { // ID, TENANT_ID, AUTHENTICATOR_ID @@ -3098,9 +3097,9 @@ private LocalAndOutboundAuthenticationConfig getLocalAndOutboundAuthenticationCo .get(ApplicationConstants.IDP_AUTHENTICATOR_NAME)); localAuthenticator.setDisplayName(authenticatorInfo .get(ApplicationConstants.IDP_AUTHENTICATOR_DISPLAY_NAME)); - localAuthenticator.setDefinedByType(IdentityConstants.DefinedByType.valueOf( + localAuthenticator.setDefinedByType(DefinedByType.valueOf( authenticatorInfo.get(ApplicationConstants.IDP_AUTHENTICATOR_DEFINED_BY_TYPE))); - localAuthenticator.setAuthenticationType(IdentityConstants.AuthenticationType.valueOf( + localAuthenticator.setAuthenticationType(AuthenticationType.valueOf( authenticatorInfo.get(ApplicationConstants.IDP_AUTHENTICATOR_AUTHENTICATION_TYPE))); stepLocalAuth.get(step).add(localAuthenticator); } else { @@ -3120,9 +3119,9 @@ private LocalAndOutboundAuthenticationConfig getLocalAndOutboundAuthenticationCo .get(ApplicationConstants.IDP_AUTHENTICATOR_NAME)); fedAuthenticator.setDisplayName(authenticatorInfo .get(ApplicationConstants.IDP_AUTHENTICATOR_DISPLAY_NAME)); - fedAuthenticator.setDefinedByType(IdentityConstants.DefinedByType.valueOf( + fedAuthenticator.setDefinedByType(DefinedByType.valueOf( authenticatorInfo.get(ApplicationConstants.IDP_AUTHENTICATOR_DEFINED_BY_TYPE))); - fedAuthenticator.setAuthenticationType(IdentityConstants.AuthenticationType.IDENTIFICATION); + fedAuthenticator.setAuthenticationType(AuthenticationType.IDENTIFICATION); idpAuths.add(fedAuthenticator); } @@ -5036,7 +5035,7 @@ private Map getAuthenticatorInfo(Connection conn, int tenantId, } // TODO: Read from database and set the DefinedBy and authenticationType properties to the authenticator. returnData.put(ApplicationConstants.IDP_AUTHENTICATOR_DEFINED_BY_TYPE, - IdentityConstants.DefinedByType.SYSTEM.toString()); + DefinedByType.SYSTEM.toString()); } finally { IdentityApplicationManagementUtil.closeStatement(prepStmt); } @@ -5070,8 +5069,8 @@ 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()); - //TODO: prepStmt.setString(8, IdentityConstants.AuthenticationType..toString()); + //TODO: prepStmt.setString(7, DefinedByType.SYSTEM.toString()); + //TODO: prepStmt.setString(8, AuthenticationType..toString()); prepStmt.execute(); rs = prepStmt.getGeneratedKeys(); if (rs.next()) { diff --git a/components/application-mgt/org.wso2.carbon.identity.application.mgt/src/test/java/org/wso2/carbon/identity/application/mgt/ApplicationManagementServiceImplTest.java b/components/application-mgt/org.wso2.carbon.identity.application.mgt/src/test/java/org/wso2/carbon/identity/application/mgt/ApplicationManagementServiceImplTest.java index aa5dffdf25aa..8163ec8b84fd 100644 --- a/components/application-mgt/org.wso2.carbon.identity.application.mgt/src/test/java/org/wso2/carbon/identity/application/mgt/ApplicationManagementServiceImplTest.java +++ b/components/application-mgt/org.wso2.carbon.identity.application.mgt/src/test/java/org/wso2/carbon/identity/application/mgt/ApplicationManagementServiceImplTest.java @@ -65,7 +65,8 @@ import org.wso2.carbon.identity.application.mgt.internal.ApplicationManagementServiceComponentHolder; import org.wso2.carbon.identity.application.mgt.provider.ApplicationPermissionProvider; import org.wso2.carbon.identity.application.mgt.provider.RegistryBasedApplicationPermissionProvider; -import org.wso2.carbon.identity.base.IdentityConstants; +import org.wso2.carbon.identity.base.AuthenticatorPropertiesConstant.AuthenticationType; +import org.wso2.carbon.identity.base.AuthenticatorPropertiesConstant.DefinedByType; import org.wso2.carbon.identity.common.testng.WithH2Database; import org.wso2.carbon.identity.common.testng.realm.InMemoryRealmService; import org.wso2.carbon.identity.common.testng.realm.MockUserStoreManager; @@ -673,12 +674,14 @@ public void testGetConfiguredAuthenticators() throws IdentityApplicationManageme for (AuthenticationStep step : steps) { LocalAuthenticatorConfig[] localAuthenticators = step.getLocalAuthenticatorConfigs(); for (LocalAuthenticatorConfig localConfig : localAuthenticators) { - Assert.assertNotNull(localConfig.getDefinedByType()); + Assert.assertEquals(localConfig.getDefinedByType(), DefinedByType.SYSTEM); + Assert.assertEquals(localConfig.getAuthenticationType(), AuthenticationType.IDENTIFICATION); } IdentityProvider[] identityProviders = step.getFederatedIdentityProviders(); for (IdentityProvider idp : identityProviders) { for (FederatedAuthenticatorConfig fedConfig: idp.getFederatedAuthenticatorConfigs()) { - Assert.assertNotNull(fedConfig.getDefinedByType()); + Assert.assertEquals(fedConfig.getDefinedByType(), DefinedByType.SYSTEM); + Assert.assertEquals(fedConfig.getAuthenticationType(), AuthenticationType.IDENTIFICATION); } } } @@ -1314,13 +1317,15 @@ private void addApplicationConfigurations(ServiceProvider serviceProvider) { identityProvider.setIdentityProviderName(IDP_NAME_1); FederatedAuthenticatorConfig federatedAuthenticatorConfig = new FederatedAuthenticatorConfig(); federatedAuthenticatorConfig.setName("Federated authenticator"); - federatedAuthenticatorConfig.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM); + federatedAuthenticatorConfig.setDefinedByType(DefinedByType.SYSTEM); + federatedAuthenticatorConfig.setAuthenticationType(AuthenticationType.IDENTIFICATION); identityProvider.setFederatedAuthenticatorConfigs(new FederatedAuthenticatorConfig[] {federatedAuthenticatorConfig}); authenticationStep.setFederatedIdentityProviders(new IdentityProvider[]{identityProvider}); LocalAuthenticatorConfig localAuthenticatorConfig = new LocalAuthenticatorConfig(); localAuthenticatorConfig.setName("Local authenticator"); - localAuthenticatorConfig.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM); + localAuthenticatorConfig.setDefinedByType(DefinedByType.SYSTEM); + federatedAuthenticatorConfig.setAuthenticationType(AuthenticationType.IDENTIFICATION); authenticationStep.setLocalAuthenticatorConfigs(new LocalAuthenticatorConfig[]{localAuthenticatorConfig}); authenticationConfig.setAuthenticationSteps(new AuthenticationStep[]{authenticationStep}); serviceProvider.setLocalAndOutBoundAuthenticationConfig(authenticationConfig); 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 32607488621e..8ac9e05619ab 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,7 +24,8 @@ 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 org.wso2.carbon.identity.base.AuthenticatorPropertiesConstant.AuthenticationType; +import org.wso2.carbon.identity.base.AuthenticatorPropertiesConstant.DefinedByType; import java.io.Serializable; import java.util.List; @@ -177,9 +178,9 @@ default String getI18nKey() { * * @return Authenticator Type. */ - default IdentityConstants.DefinedByType getDefinedByType() { + default DefinedByType getDefinedByType() { - return IdentityConstants.DefinedByType.SYSTEM; + return DefinedByType.SYSTEM; } /** @@ -187,8 +188,8 @@ default IdentityConstants.DefinedByType getDefinedByType() { * * @return Authenticator Type. */ - default IdentityConstants.AuthenticationType getAuthenticationType() { + default AuthenticationType getAuthenticationType() { - return null; + return AuthenticationType.IDENTIFICATION; } } diff --git a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/FederatedApplicationAuthenticator.java b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/FederatedApplicationAuthenticator.java index 2a4e0fec7e16..3962f7da3d57 100644 --- a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/FederatedApplicationAuthenticator.java +++ b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/FederatedApplicationAuthenticator.java @@ -18,7 +18,7 @@ package org.wso2.carbon.identity.application.authentication.framework; -import org.wso2.carbon.identity.base.IdentityConstants; +import org.wso2.carbon.identity.base.AuthenticatorPropertiesConstant.AuthenticationType; /** * Federated application authenticator. @@ -26,9 +26,9 @@ public interface FederatedApplicationAuthenticator extends ApplicationAuthenticator { @Override - default IdentityConstants.AuthenticationType getAuthenticationType() { + default AuthenticationType getAuthenticationType() { - return IdentityConstants.AuthenticationType.IDENTIFICATION; + return AuthenticationType.IDENTIFICATION; } } diff --git a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/LocalApplicationAuthenticator.java b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/LocalApplicationAuthenticator.java index c3f42c20921d..0379b869ce91 100644 --- a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/LocalApplicationAuthenticator.java +++ b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/LocalApplicationAuthenticator.java @@ -18,7 +18,7 @@ package org.wso2.carbon.identity.application.authentication.framework; -import org.wso2.carbon.identity.base.IdentityConstants; +import org.wso2.carbon.identity.base.AuthenticatorPropertiesConstant.AuthenticationType; import java.util.Arrays; @@ -30,12 +30,12 @@ public interface LocalApplicationAuthenticator extends ApplicationAuthenticator { @Override - default IdentityConstants.AuthenticationType getAuthenticationType() { + default AuthenticationType getAuthenticationType() { if (getTags() != null && Arrays.stream(getTags()).anyMatch(s -> s.equalsIgnoreCase(TAG_2FA))) { - return IdentityConstants.AuthenticationType.VERIFICATION_ONLY; + return AuthenticationType.VERIFICATION_ONLY; } - return IdentityConstants.AuthenticationType.IDENTIFICATION; + return AuthenticationType.IDENTIFICATION; } } diff --git a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/RequestPathApplicationAuthenticator.java b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/RequestPathApplicationAuthenticator.java index 4773349ef272..202f5edfd7e6 100644 --- a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/RequestPathApplicationAuthenticator.java +++ b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/RequestPathApplicationAuthenticator.java @@ -18,9 +18,16 @@ package org.wso2.carbon.identity.application.authentication.framework; +import org.wso2.carbon.identity.base.AuthenticatorPropertiesConstant.AuthenticationType; + /** * Request path application authenticator. */ public interface RequestPathApplicationAuthenticator extends ApplicationAuthenticator { + @Override + default AuthenticationType getAuthenticationType() { + + return AuthenticationType.REQUEST_PATH; + } } 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 8bfa93966666..11b2c49fdf07 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,7 +99,8 @@ 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.base.AuthenticatorPropertiesConstant.AuthenticationType; +import org.wso2.carbon.identity.base.AuthenticatorPropertiesConstant.DefinedByType; 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; @@ -129,7 +130,6 @@ import javax.servlet.Servlet; import static org.wso2.carbon.identity.application.authentication.framework.util.FrameworkUtils.promptOnLongWait; -import static org.wso2.carbon.identity.base.IdentityConstants.AuthenticationType; import static org.wso2.carbon.identity.base.IdentityConstants.TAG_2FA; import static org.wso2.carbon.identity.base.IdentityConstants.TRUE; @@ -510,7 +510,7 @@ protected void setAuthenticator(ApplicationAuthenticator authenticator) { localAuthenticatorConfig.setProperties(configProperties); localAuthenticatorConfig.setDisplayName(authenticator.getFriendlyName()); localAuthenticatorConfig.setTags(getTags(authenticator)); - localAuthenticatorConfig.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM); + localAuthenticatorConfig.setDefinedByType(DefinedByType.SYSTEM); if (localAuthenticatorConfig.getTags() != null && Arrays.stream(localAuthenticatorConfig.getTags()).anyMatch(s -> s.equalsIgnoreCase(TAG_2FA))) { localAuthenticatorConfig.setAuthenticationType(AuthenticationType.VERIFICATION_ONLY); @@ -526,8 +526,8 @@ protected void setAuthenticator(ApplicationAuthenticator authenticator) { federatedAuthenticatorConfig.setProperties(configProperties); federatedAuthenticatorConfig.setDisplayName(authenticator.getFriendlyName()); federatedAuthenticatorConfig.setTags(getTags(authenticator)); - federatedAuthenticatorConfig.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM); - federatedAuthenticatorConfig.setAuthenticationType(IdentityConstants.AuthenticationType.IDENTIFICATION); + federatedAuthenticatorConfig.setDefinedByType(DefinedByType.SYSTEM); + federatedAuthenticatorConfig.setAuthenticationType(AuthenticationType.IDENTIFICATION); ApplicationAuthenticatorService.getInstance().addFederatedAuthenticator(federatedAuthenticatorConfig); } else if (authenticator instanceof RequestPathApplicationAuthenticator) { RequestPathAuthenticatorConfig reqPathAuthenticatorConfig = new RequestPathAuthenticatorConfig(); @@ -537,7 +537,8 @@ protected void setAuthenticator(ApplicationAuthenticator authenticator) { reqPathAuthenticatorConfig.setTags(getTags(authenticator)); AuthenticatorConfig fileBasedConfig = getAuthenticatorConfig(authenticator.getName()); reqPathAuthenticatorConfig.setEnabled(fileBasedConfig.isEnabled()); - reqPathAuthenticatorConfig.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM); + reqPathAuthenticatorConfig.setDefinedByType(DefinedByType.SYSTEM); + reqPathAuthenticatorConfig.setAuthenticationType(AuthenticationType.REQUEST_PATH); ApplicationAuthenticatorService.getInstance().addRequestPathAuthenticator(reqPathAuthenticatorConfig); } diff --git a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/util/FrameworkUtils.java b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/util/FrameworkUtils.java index ea9a6e922cf9..4679d8fbfe7a 100644 --- a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/util/FrameworkUtils.java +++ b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/util/FrameworkUtils.java @@ -115,7 +115,7 @@ import org.wso2.carbon.identity.application.common.model.Property; import org.wso2.carbon.identity.application.common.model.ServiceProvider; import org.wso2.carbon.identity.application.mgt.ApplicationConstants; -import org.wso2.carbon.identity.base.IdentityConstants; +import org.wso2.carbon.identity.base.AuthenticatorPropertiesConstant.DefinedByType; import org.wso2.carbon.identity.base.IdentityException; import org.wso2.carbon.identity.base.IdentityRuntimeException; import org.wso2.carbon.identity.central.log.mgt.utils.LoggerUtils; @@ -4198,7 +4198,7 @@ public static boolean isURLRelative(String uriString) throws URISyntaxException * @param authenticatorName Name of the authenticator. * @return The defined by type. */ - public static IdentityConstants.DefinedByType getAuthenticatorDefinedByType(String authenticatorName) { + public static DefinedByType getAuthenticatorDefinedByType(String authenticatorName) { for (ApplicationAuthenticator authenticator: FrameworkServiceComponent.getAuthenticators()) { if (authenticator.getName().equals(authenticatorName)) { diff --git a/components/identity-core/org.wso2.carbon.identity.base/src/main/java/org/wso2/carbon/identity/base/AuthenticatorPropertiesConstant.java b/components/identity-core/org.wso2.carbon.identity.base/src/main/java/org/wso2/carbon/identity/base/AuthenticatorPropertiesConstant.java new file mode 100644 index 000000000000..31bf8b1bda87 --- /dev/null +++ b/components/identity-core/org.wso2.carbon.identity.base/src/main/java/org/wso2/carbon/identity/base/AuthenticatorPropertiesConstant.java @@ -0,0 +1,29 @@ +package org.wso2.carbon.identity.base; + +public class AuthenticatorPropertiesConstant { + + /** + * The Defined by Types - SYSTEM: system define authenticator, USER: user defined authentication extension. + */ + public static enum DefinedByType { + + SYSTEM, + USER + } + + /** + * The Authentication Types - + * External User Account Authentication: This authenticator can authenticate federated users + * and provision them. + * Internal User Account Authentication: This authenticator collects the identifiers and authenticates user + * accounts managed within the organization. + * 2FA Authentication: This authenticator can only verify users in the second or + * subsequent steps of the login process. + */ + public static enum AuthenticationType { + + IDENTIFICATION, + VERIFICATION_ONLY, + REQUEST_PATH + } + } 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 750a7bd06d8a..bc6c6af792f9 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 @@ -43,6 +43,8 @@ import org.wso2.carbon.identity.application.common.model.SubProperty; import org.wso2.carbon.identity.application.common.util.IdentityApplicationConstants; import org.wso2.carbon.identity.application.common.util.IdentityApplicationManagementUtil; +import org.wso2.carbon.identity.base.AuthenticatorPropertiesConstant.AuthenticationType; +import org.wso2.carbon.identity.base.AuthenticatorPropertiesConstant.DefinedByType; import org.wso2.carbon.identity.base.IdentityConstants; import org.wso2.carbon.identity.base.IdentityException; import org.wso2.carbon.identity.core.ServiceURLBuilder; @@ -171,9 +173,9 @@ public void addResidentIdP(IdentityProvider identityProvider, String tenantDomai if (saml2SSOResidentAuthenticatorConfig == null) { saml2SSOResidentAuthenticatorConfig = new FederatedAuthenticatorConfig(); saml2SSOResidentAuthenticatorConfig.setName(IdentityApplicationConstants.Authenticator.SAML2SSO.NAME); - saml2SSOResidentAuthenticatorConfig.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM); + saml2SSOResidentAuthenticatorConfig.setDefinedByType(DefinedByType.SYSTEM); saml2SSOResidentAuthenticatorConfig.setAuthenticationType( - IdentityConstants.AuthenticationType.IDENTIFICATION); + AuthenticationType.IDENTIFICATION); } if (saml2SSOResidentAuthenticatorConfig.getProperties() == null) { saml2SSOResidentAuthenticatorConfig.setProperties(new Property[0]); @@ -258,8 +260,8 @@ 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); - oidcAuthenticationConfig.setAuthenticationType(IdentityConstants.AuthenticationType.IDENTIFICATION); + oidcAuthenticationConfig.setDefinedByType(DefinedByType.SYSTEM); + oidcAuthenticationConfig.setAuthenticationType(AuthenticationType.IDENTIFICATION); Property passiveStsProperty = new Property(); passiveStsProperty.setName(IdentityApplicationConstants.Authenticator.PassiveSTS.IDENTITY_PROVIDER_ENTITY_ID); @@ -268,8 +270,8 @@ 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); - passiveStsAuthenticationConfig.setAuthenticationType(IdentityConstants.AuthenticationType.IDENTIFICATION); + passiveStsAuthenticationConfig.setDefinedByType(DefinedByType.SYSTEM); + passiveStsAuthenticationConfig.setAuthenticationType(AuthenticationType.IDENTIFICATION); 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 35caff783b99..217221493e80 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 @@ -44,6 +44,8 @@ import org.wso2.carbon.identity.application.common.model.RoleMapping; import org.wso2.carbon.identity.application.common.util.IdentityApplicationConstants; import org.wso2.carbon.identity.application.common.util.IdentityApplicationManagementUtil; +import org.wso2.carbon.identity.base.AuthenticatorPropertiesConstant.AuthenticationType; +import org.wso2.carbon.identity.base.AuthenticatorPropertiesConstant.DefinedByType; import org.wso2.carbon.identity.base.IdentityConstants; import org.wso2.carbon.identity.core.ConnectorConfig; import org.wso2.carbon.identity.core.ConnectorException; @@ -1149,8 +1151,8 @@ private FederatedAuthenticatorConfig[] getFederatedAuthenticatorConfigs( authnConfig.setDisplayName(rs.getString("DISPLAY_NAME")); // TODO: Read from database and set the DefinedBy property to the authenticator. - authnConfig.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM); - authnConfig.setAuthenticationType(IdentityConstants.AuthenticationType.IDENTIFICATION); + authnConfig.setDefinedByType(DefinedByType.SYSTEM); + authnConfig.setAuthenticationType(AuthenticationType.IDENTIFICATION); if (defaultAuthName != null && authnConfig.getName().equals(defaultAuthName)) { federatedIdp.getDefaultAuthenticatorConfig().setDisplayName(authnConfig.getDisplayName()); @@ -1428,7 +1430,7 @@ public void addFederatedAuthenticatorConfig(FederatedAuthenticatorConfig authnCo prepStmt1.setString(4, authnConfig.getName()); prepStmt1.setString(5, authnConfig.getDisplayName()); //TODO: prepStmt1.setString(6, authnConfig.getDefinedByType().toString()); - //TODO: prepStmt1.setString(7, IdentityConstants.AuthenticationType.EXTERNAL_ACCOUNT); + //TODO: prepStmt1.setString(7, AuthenticationType.EXTERNAL_ACCOUNT); prepStmt1.execute(); int authnId = getAuthenticatorIdentifier(dbConnection, idpId, authnConfig.getName()); @@ -2335,8 +2337,8 @@ private FederatedAuthenticatorConfig buildSAMLProperties(IdentityProvider identi if (samlFederatedAuthConfig == null) { samlFederatedAuthConfig = new FederatedAuthenticatorConfig(); samlFederatedAuthConfig.setName(IdentityApplicationConstants.Authenticator.SAML2SSO.NAME); - samlFederatedAuthConfig.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM); - samlFederatedAuthConfig.setAuthenticationType(IdentityConstants.AuthenticationType.IDENTIFICATION); + samlFederatedAuthConfig.setDefinedByType(DefinedByType.SYSTEM); + samlFederatedAuthConfig.setAuthenticationType(AuthenticationType.IDENTIFICATION); } List propertiesList = new ArrayList<>(); @@ -2720,8 +2722,8 @@ private void fillResidentIdpProperties(IdentityProvider identityProvider, String if (openIdFedAuthn == null) { openIdFedAuthn = new FederatedAuthenticatorConfig(); openIdFedAuthn.setName(IdentityApplicationConstants.Authenticator.OpenID.NAME); - openIdFedAuthn.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM); - openIdFedAuthn.setAuthenticationType(IdentityConstants.AuthenticationType.IDENTIFICATION); + openIdFedAuthn.setDefinedByType(DefinedByType.SYSTEM); + openIdFedAuthn.setAuthenticationType(AuthenticationType.IDENTIFICATION); } propertiesList = new ArrayList<>(Arrays.asList(openIdFedAuthn.getProperties())); if (IdentityApplicationManagementUtil.getProperty(openIdFedAuthn.getProperties(), @@ -2744,8 +2746,8 @@ private void fillResidentIdpProperties(IdentityProvider identityProvider, String if (oauth1FedAuthn == null) { oauth1FedAuthn = new FederatedAuthenticatorConfig(); oauth1FedAuthn.setName(IdentityApplicationConstants.OAuth10A.NAME); - oauth1FedAuthn.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM); - oauth1FedAuthn.setAuthenticationType(IdentityConstants.AuthenticationType.IDENTIFICATION); + oauth1FedAuthn.setDefinedByType(DefinedByType.SYSTEM); + oauth1FedAuthn.setAuthenticationType(AuthenticationType.IDENTIFICATION); } propertiesList = new ArrayList<>(Arrays.asList(oauth1FedAuthn.getProperties())); if (IdentityApplicationManagementUtil.getProperty(oauth1FedAuthn.getProperties(), @@ -2781,8 +2783,8 @@ private void fillResidentIdpProperties(IdentityProvider identityProvider, String if (oidcFedAuthn == null) { oidcFedAuthn = new FederatedAuthenticatorConfig(); oidcFedAuthn.setName(IdentityApplicationConstants.Authenticator.OIDC.NAME); - oidcFedAuthn.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM); - oidcFedAuthn.setAuthenticationType(IdentityConstants.AuthenticationType.IDENTIFICATION); + oidcFedAuthn.setDefinedByType(DefinedByType.SYSTEM); + oidcFedAuthn.setAuthenticationType(AuthenticationType.IDENTIFICATION); } propertiesList = new ArrayList<>(); @@ -2854,8 +2856,8 @@ private void fillResidentIdpProperties(IdentityProvider identityProvider, String if (passiveSTSFedAuthn == null) { passiveSTSFedAuthn = new FederatedAuthenticatorConfig(); passiveSTSFedAuthn.setName(IdentityApplicationConstants.Authenticator.PassiveSTS.NAME); - passiveSTSFedAuthn.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM); - passiveSTSFedAuthn.setAuthenticationType(IdentityConstants.AuthenticationType.IDENTIFICATION); + passiveSTSFedAuthn.setDefinedByType(DefinedByType.SYSTEM); + passiveSTSFedAuthn.setAuthenticationType(AuthenticationType.IDENTIFICATION); } propertiesList = new ArrayList<>(); @@ -2895,8 +2897,8 @@ private void fillResidentIdpProperties(IdentityProvider identityProvider, String if (stsFedAuthn == null) { stsFedAuthn = new FederatedAuthenticatorConfig(); stsFedAuthn.setName(IdentityApplicationConstants.Authenticator.WSTrust.NAME); - stsFedAuthn.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM); - stsFedAuthn.setAuthenticationType(IdentityConstants.AuthenticationType.IDENTIFICATION); + stsFedAuthn.setDefinedByType(DefinedByType.SYSTEM); + stsFedAuthn.setAuthenticationType(AuthenticationType.IDENTIFICATION); } propertiesList = new ArrayList<>(Arrays.asList(stsFedAuthn.getProperties())); if (IdentityApplicationManagementUtil.getProperty(stsFedAuthn.getProperties(), @@ -2911,8 +2913,8 @@ private void fillResidentIdpProperties(IdentityProvider identityProvider, String FederatedAuthenticatorConfig sessionTimeoutConfig = new FederatedAuthenticatorConfig(); sessionTimeoutConfig.setName(IdentityApplicationConstants.NAME); - sessionTimeoutConfig.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM); - sessionTimeoutConfig.setAuthenticationType(IdentityConstants.AuthenticationType.IDENTIFICATION); + sessionTimeoutConfig.setDefinedByType(DefinedByType.SYSTEM); + sessionTimeoutConfig.setAuthenticationType(AuthenticationType.IDENTIFICATION); propertiesList = new ArrayList<>(Arrays.asList(sessionTimeoutConfig.getProperties())); @@ -3429,7 +3431,7 @@ public IdentityProvider getIdPByAuthenticatorPropertyValue(Connection dbConnecti String defaultAuthenticatorName = rs.getString("DEFAULT_AUTHENTICATOR_NAME"); // TODO: Read from database and set the DefinedBy property to the authenticator. - String defaultAuthenticatorDefinedByType = IdentityConstants.DefinedByType.SYSTEM.toString(); + String defaultAuthenticatorDefinedByType = DefinedByType.SYSTEM.toString(); String defaultProvisioningConnectorConfigName = rs.getString("DEFAULT_PRO_CONNECTOR_NAME"); federatedIdp.setIdentityProviderDescription(rs.getString("DESCRIPTION")); @@ -3464,9 +3466,9 @@ public IdentityProvider getIdPByAuthenticatorPropertyValue(Connection dbConnecti if (defaultAuthenticatorName != null) { FederatedAuthenticatorConfig defaultAuthenticator = new FederatedAuthenticatorConfig(); defaultAuthenticator.setName(defaultAuthenticatorName); - defaultAuthenticator.setDefinedByType(IdentityConstants.DefinedByType.valueOf( + defaultAuthenticator.setDefinedByType(DefinedByType.valueOf( defaultAuthenticatorDefinedByType)); - defaultAuthenticator.setAuthenticationType(IdentityConstants.AuthenticationType.IDENTIFICATION); + defaultAuthenticator.setAuthenticationType(AuthenticationType.IDENTIFICATION); federatedIdp.setDefaultAuthenticatorConfig(defaultAuthenticator); } @@ -3597,7 +3599,7 @@ public IdentityProvider getIdPByAuthenticatorPropertyValue(Connection dbConnecti String defaultAuthenticatorName = rs.getString("DEFAULT_AUTHENTICATOR_NAME"); // TODO: Read from database and set the DefinedBy property to the authenticator. - String defaultAuthenticatorDefinedByType = IdentityConstants.DefinedByType.SYSTEM.toString(); + String defaultAuthenticatorDefinedByType = DefinedByType.SYSTEM.toString(); String defaultProvisioningConnectorConfigName = rs.getString("DEFAULT_PRO_CONNECTOR_NAME"); federatedIdp.setIdentityProviderDescription(rs.getString("DESCRIPTION")); @@ -3632,9 +3634,9 @@ public IdentityProvider getIdPByAuthenticatorPropertyValue(Connection dbConnecti if (defaultAuthenticatorName != null) { FederatedAuthenticatorConfig defaultAuthenticator = new FederatedAuthenticatorConfig(); defaultAuthenticator.setName(defaultAuthenticatorName); - defaultAuthenticator.setDefinedByType(IdentityConstants.DefinedByType.valueOf( + defaultAuthenticator.setDefinedByType(DefinedByType.valueOf( defaultAuthenticatorDefinedByType)); - defaultAuthenticator.setAuthenticationType(IdentityConstants.AuthenticationType.IDENTIFICATION); + defaultAuthenticator.setAuthenticationType(AuthenticationType.IDENTIFICATION); federatedIdp.setDefaultAuthenticatorConfig(defaultAuthenticator); } 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 0fdc45a6a3f7..2cd9cd48c58f 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 @@ -38,7 +38,8 @@ 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.base.AuthenticatorPropertiesConstant.AuthenticationType; +import org.wso2.carbon.identity.base.AuthenticatorPropertiesConstant.DefinedByType; 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; @@ -134,8 +135,8 @@ public Object[][] addIdPData() { federatedAuthenticatorConfig.setDisplayName("DisplayName1"); federatedAuthenticatorConfig.setName("Name"); federatedAuthenticatorConfig.setEnabled(true); - federatedAuthenticatorConfig.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM); - federatedAuthenticatorConfig.setAuthenticationType(IdentityConstants.AuthenticationType.IDENTIFICATION); + federatedAuthenticatorConfig.setDefinedByType(DefinedByType.SYSTEM); + federatedAuthenticatorConfig.setAuthenticationType(AuthenticationType.IDENTIFICATION); Property property1 = new Property(); property1.setName("Property1"); property1.setValue("value1"); @@ -561,8 +562,8 @@ public Object[][] updateIdPData() { newFederatedAuthenticatorConfig.setDisplayName("DisplayName1New"); newFederatedAuthenticatorConfig.setName("Name"); newFederatedAuthenticatorConfig.setEnabled(true); - newFederatedAuthenticatorConfig.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM); - newFederatedAuthenticatorConfig.setAuthenticationType(IdentityConstants.AuthenticationType.IDENTIFICATION); + newFederatedAuthenticatorConfig.setDefinedByType(DefinedByType.SYSTEM); + newFederatedAuthenticatorConfig.setAuthenticationType(AuthenticationType.IDENTIFICATION); Property newProperty1 = new Property(); newProperty1.setName("Property1New"); newProperty1.setValue("value1New"); @@ -802,8 +803,8 @@ public Object[][] updateResidentIdPData() { facNew.setDisplayName("DisplayName1New"); facNew.setName("Name"); facNew.setEnabled(true); - facNew.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM); - facNew.setAuthenticationType(IdentityConstants.AuthenticationType.IDENTIFICATION); + facNew.setDefinedByType(DefinedByType.SYSTEM); + facNew.setAuthenticationType(AuthenticationType.IDENTIFICATION); idp2New.setFederatedAuthenticatorConfigs(new FederatedAuthenticatorConfig[]{facNew}); // Initialize New Resident Identity Provider 3. @@ -901,8 +902,8 @@ public void testGetResidentIDPMetadata() throws Exception { facNew.setDisplayName("SAML2SSO"); facNew.setName("saml2sso"); facNew.setEnabled(true); - facNew.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM); - facNew.setAuthenticationType(IdentityConstants.AuthenticationType.IDENTIFICATION); + facNew.setDefinedByType(DefinedByType.SYSTEM); + facNew.setAuthenticationType(AuthenticationType.IDENTIFICATION); newIdp.setFederatedAuthenticatorConfigs(new FederatedAuthenticatorConfig[]{facNew}); identityProviderManagementService.updateResidentIdP((IdentityProvider) newIdp); @@ -925,8 +926,8 @@ public void testGetResidentIDPMetadataException() throws Exception { facNew.setDisplayName("SAML2SSO"); facNew.setName("saml2sso"); facNew.setEnabled(true); - facNew.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM); - facNew.setAuthenticationType(IdentityConstants.AuthenticationType.IDENTIFICATION); + facNew.setDefinedByType(DefinedByType.SYSTEM); + facNew.setAuthenticationType(AuthenticationType.IDENTIFICATION); newIdp.setFederatedAuthenticatorConfigs(new FederatedAuthenticatorConfig[]{facNew}); identityProviderManagementService.updateResidentIdP((IdentityProvider) newIdp); @@ -962,8 +963,8 @@ private void addTestIdps() throws IdentityProviderManagementException { federatedAuthenticatorConfig.setDisplayName("DisplayName1"); federatedAuthenticatorConfig.setName("Name"); federatedAuthenticatorConfig.setEnabled(true); - federatedAuthenticatorConfig.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM); - federatedAuthenticatorConfig.setAuthenticationType(IdentityConstants.AuthenticationType.IDENTIFICATION); + federatedAuthenticatorConfig.setDefinedByType(DefinedByType.SYSTEM); + federatedAuthenticatorConfig.setAuthenticationType(AuthenticationType.IDENTIFICATION); Property property1 = new Property(); property1.setName("Property1"); property1.setValue("value1"); @@ -1118,8 +1119,8 @@ private IdentityProvider addIdPDataWithSameIdpEntityId(String idpName) { federatedAuthenticatorConfig.setDisplayName("DisplayName"); federatedAuthenticatorConfig.setName("SAMLSSOAuthenticator"); federatedAuthenticatorConfig.setEnabled(true); - federatedAuthenticatorConfig.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM); - federatedAuthenticatorConfig.setAuthenticationType(IdentityConstants.AuthenticationType.IDENTIFICATION); + federatedAuthenticatorConfig.setDefinedByType(DefinedByType.SYSTEM); + federatedAuthenticatorConfig.setAuthenticationType(AuthenticationType.IDENTIFICATION); 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 143860e1e661..bca322e25ac6 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,7 +39,8 @@ 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.base.AuthenticatorPropertiesConstant.AuthenticationType; +import org.wso2.carbon.identity.base.AuthenticatorPropertiesConstant.DefinedByType; import org.wso2.carbon.identity.core.model.ExpressionNode; import org.wso2.carbon.identity.core.util.IdentityDatabaseUtil; import org.wso2.carbon.identity.core.util.IdentityTenantUtil; @@ -743,8 +744,8 @@ public Object[][] addIdPData() { federatedAuthenticatorConfig.setDisplayName("DisplayName1"); federatedAuthenticatorConfig.setName("Name"); federatedAuthenticatorConfig.setEnabled(true); - federatedAuthenticatorConfig.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM); - federatedAuthenticatorConfig.setAuthenticationType(IdentityConstants.AuthenticationType.IDENTIFICATION); + federatedAuthenticatorConfig.setDefinedByType(DefinedByType.SYSTEM); + federatedAuthenticatorConfig.setAuthenticationType(AuthenticationType.IDENTIFICATION); Property property1 = new Property(); property1.setName("Property1"); property1.setValue("value1"); @@ -848,8 +849,8 @@ public Object[][] updateIdPData() { federatedAuthenticatorConfig.setDisplayName("DisplayName1"); federatedAuthenticatorConfig.setName("Name"); federatedAuthenticatorConfig.setEnabled(true); - federatedAuthenticatorConfig.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM); - federatedAuthenticatorConfig.setAuthenticationType(IdentityConstants.AuthenticationType.IDENTIFICATION); + federatedAuthenticatorConfig.setDefinedByType(DefinedByType.SYSTEM); + federatedAuthenticatorConfig.setAuthenticationType(AuthenticationType.IDENTIFICATION); Property property1 = new Property(); property1.setName("Property1"); property1.setValue("value1"); @@ -907,8 +908,8 @@ public Object[][] updateIdPData() { newFederatedAuthenticatorConfig.setDisplayName("DisplayName1New"); newFederatedAuthenticatorConfig.setName("Name"); newFederatedAuthenticatorConfig.setEnabled(true); - newFederatedAuthenticatorConfig.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM); - newFederatedAuthenticatorConfig.setAuthenticationType(IdentityConstants.AuthenticationType.IDENTIFICATION); + newFederatedAuthenticatorConfig.setDefinedByType(DefinedByType.SYSTEM); + newFederatedAuthenticatorConfig.setAuthenticationType(AuthenticationType.IDENTIFICATION); Property property1New = new Property(); property1New.setName("Property1New"); property1New.setValue("value1New"); @@ -1456,8 +1457,8 @@ private void addTestIdps() throws IdentityProviderManagementException { FederatedAuthenticatorConfig federatedAuthenticatorConfig = new FederatedAuthenticatorConfig(); federatedAuthenticatorConfig.setDisplayName("DisplayName1"); federatedAuthenticatorConfig.setName("Name"); - federatedAuthenticatorConfig.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM); - federatedAuthenticatorConfig.setAuthenticationType(IdentityConstants.AuthenticationType.IDENTIFICATION); + federatedAuthenticatorConfig.setDefinedByType(DefinedByType.SYSTEM); + federatedAuthenticatorConfig.setAuthenticationType(AuthenticationType.IDENTIFICATION); 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 e056f3f5e6e0..1c04b0b796e5 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,7 +40,8 @@ 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.base.AuthenticatorPropertiesConstant.AuthenticationType; +import org.wso2.carbon.identity.base.AuthenticatorPropertiesConstant.DefinedByType; import org.wso2.carbon.identity.core.model.ExpressionNode; import org.wso2.carbon.identity.core.util.IdentityDatabaseUtil; import org.wso2.carbon.identity.core.util.IdentityTenantUtil; @@ -586,8 +587,8 @@ public Object[][] addIdPData() { federatedAuthenticatorConfig.setDisplayName("DisplayName1"); federatedAuthenticatorConfig.setName("Name"); federatedAuthenticatorConfig.setEnabled(true); - federatedAuthenticatorConfig.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM); - federatedAuthenticatorConfig.setAuthenticationType(IdentityConstants.AuthenticationType.IDENTIFICATION); + federatedAuthenticatorConfig.setDefinedByType(DefinedByType.SYSTEM); + federatedAuthenticatorConfig.setAuthenticationType(AuthenticationType.IDENTIFICATION); Property property1 = new Property(); property1.setName("Property1"); property1.setValue("value1"); @@ -1106,8 +1107,8 @@ public Object[][] updateIdPData() { federatedAuthenticatorConfig.setDisplayName("DisplayName1"); federatedAuthenticatorConfig.setName("Name"); federatedAuthenticatorConfig.setEnabled(true); - federatedAuthenticatorConfig.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM); - federatedAuthenticatorConfig.setAuthenticationType(IdentityConstants.AuthenticationType.IDENTIFICATION); + federatedAuthenticatorConfig.setDefinedByType(DefinedByType.SYSTEM); + federatedAuthenticatorConfig.setAuthenticationType(AuthenticationType.IDENTIFICATION); Property property1 = new Property(); property1.setName("Property1"); property1.setValue("value1"); @@ -1165,8 +1166,8 @@ public Object[][] updateIdPData() { newFederatedAuthenticatorConfig.setDisplayName("DisplayName1New"); newFederatedAuthenticatorConfig.setName("Name"); newFederatedAuthenticatorConfig.setEnabled(true); - newFederatedAuthenticatorConfig.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM); - newFederatedAuthenticatorConfig.setAuthenticationType(IdentityConstants.AuthenticationType.IDENTIFICATION); + newFederatedAuthenticatorConfig.setDefinedByType(DefinedByType.SYSTEM); + newFederatedAuthenticatorConfig.setAuthenticationType(AuthenticationType.IDENTIFICATION); Property property1New = new Property(); property1New.setName("Property1New"); property1New.setValue("value1New"); @@ -1739,8 +1740,8 @@ private void addTestIdps() throws IdentityProviderManagementException { federatedAuthenticatorConfig.setDisplayName("DisplayName1"); federatedAuthenticatorConfig.setName("Name"); federatedAuthenticatorConfig.setEnabled(true); - federatedAuthenticatorConfig.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM); - federatedAuthenticatorConfig.setAuthenticationType(IdentityConstants.AuthenticationType.IDENTIFICATION); + federatedAuthenticatorConfig.setDefinedByType(DefinedByType.SYSTEM); + federatedAuthenticatorConfig.setAuthenticationType(AuthenticationType.IDENTIFICATION); Property property1 = new Property(); property1.setName("Property1"); property1.setValue("value1"); @@ -1873,8 +1874,8 @@ private void addTestTrustedTokenIssuers() throws IdentityProviderManagementExcep federatedAuthenticatorConfig.setDisplayName("DisplayName1"); federatedAuthenticatorConfig.setName("Name"); federatedAuthenticatorConfig.setEnabled(true); - federatedAuthenticatorConfig.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM); - federatedAuthenticatorConfig.setAuthenticationType(IdentityConstants.AuthenticationType.IDENTIFICATION); + federatedAuthenticatorConfig.setDefinedByType(DefinedByType.SYSTEM); + federatedAuthenticatorConfig.setAuthenticationType(AuthenticationType.IDENTIFICATION); Property property1 = new Property(); property1.setName("Property1"); property1.setValue("value1");