From 7c68916080645deca64fd819ce17fcca5c4f45b1 Mon Sep 17 00:00:00 2001 From: Osara-B Date: Fri, 20 Dec 2024 14:17:14 +0530 Subject: [PATCH] Introduce SAMLSSOServiceProviderDAO Factory class --- .../core/SAMLSSOServiceProviderManager.java | 6 +- ...egistrySAMLSSOServiceProviderDAOImpl.java} | 6 +- ...viceProviderPersistenceManagerFactory.java | 58 ++++++++++++++ .../IdentityPersistenceManager.java | 9 ++- .../dao/SAMLSSOServiceProviderDAOTest.java | 4 +- ...ProviderPersistenceManagerFactoryTest.java | 78 +++++++++++++++++++ .../src/test/resources/testng.xml | 1 + 7 files changed, 151 insertions(+), 11 deletions(-) rename components/identity-core/org.wso2.carbon.identity.core/src/main/java/org/wso2/carbon/identity/core/dao/{SAMLSSOServiceProviderRegistryDAOImpl.java => RegistrySAMLSSOServiceProviderDAOImpl.java} (99%) create mode 100644 components/identity-core/org.wso2.carbon.identity.core/src/main/java/org/wso2/carbon/identity/core/dao/SAMLServiceProviderPersistenceManagerFactory.java create mode 100644 components/identity-core/org.wso2.carbon.identity.core/src/test/java/org/wso2/carbon/identity/core/dao/SAMLServiceProviderPersistenceManagerFactoryTest.java diff --git a/components/identity-core/org.wso2.carbon.identity.core/src/main/java/org/wso2/carbon/identity/core/SAMLSSOServiceProviderManager.java b/components/identity-core/org.wso2.carbon.identity.core/src/main/java/org/wso2/carbon/identity/core/SAMLSSOServiceProviderManager.java index 297c8205258f..b2b0040a84a4 100644 --- a/components/identity-core/org.wso2.carbon.identity.core/src/main/java/org/wso2/carbon/identity/core/SAMLSSOServiceProviderManager.java +++ b/components/identity-core/org.wso2.carbon.identity.core/src/main/java/org/wso2/carbon/identity/core/SAMLSSOServiceProviderManager.java @@ -19,8 +19,8 @@ package org.wso2.carbon.identity.core; import org.wso2.carbon.identity.base.IdentityException; +import org.wso2.carbon.identity.core.dao.SAMLServiceProviderPersistenceManagerFactory; import org.wso2.carbon.identity.core.dao.SAMLSSOServiceProviderDAO; -import org.wso2.carbon.identity.core.dao.SAMLSSOServiceProviderRegistryDAOImpl; import org.wso2.carbon.identity.core.model.SAMLSSOServiceProviderDO; /** @@ -29,7 +29,9 @@ */ public class SAMLSSOServiceProviderManager { - private static SAMLSSOServiceProviderDAO serviceProviderDAO = new SAMLSSOServiceProviderRegistryDAOImpl(); + SAMLServiceProviderPersistenceManagerFactory + samlSSOPersistenceManagerFactory = new SAMLServiceProviderPersistenceManagerFactory(); + SAMLSSOServiceProviderDAO serviceProviderDAO = samlSSOPersistenceManagerFactory.getSAMLServiceProviderPersistenceManager(); /** * Add a saml service provider. diff --git a/components/identity-core/org.wso2.carbon.identity.core/src/main/java/org/wso2/carbon/identity/core/dao/SAMLSSOServiceProviderRegistryDAOImpl.java b/components/identity-core/org.wso2.carbon.identity.core/src/main/java/org/wso2/carbon/identity/core/dao/RegistrySAMLSSOServiceProviderDAOImpl.java similarity index 99% rename from components/identity-core/org.wso2.carbon.identity.core/src/main/java/org/wso2/carbon/identity/core/dao/SAMLSSOServiceProviderRegistryDAOImpl.java rename to components/identity-core/org.wso2.carbon.identity.core/src/main/java/org/wso2/carbon/identity/core/dao/RegistrySAMLSSOServiceProviderDAOImpl.java index 84e410a5d70e..f07d50eb03b5 100644 --- a/components/identity-core/org.wso2.carbon.identity.core/src/main/java/org/wso2/carbon/identity/core/dao/SAMLSSOServiceProviderRegistryDAOImpl.java +++ b/components/identity-core/org.wso2.carbon.identity.core/src/main/java/org/wso2/carbon/identity/core/dao/RegistrySAMLSSOServiceProviderDAOImpl.java @@ -55,7 +55,7 @@ /** * This class is used for managing SAML SSO service providers in the Registry. */ -public class SAMLSSOServiceProviderRegistryDAOImpl extends AbstractDAO +public class RegistrySAMLSSOServiceProviderDAOImpl extends AbstractDAO implements SAMLSSOServiceProviderDAO { private static final String CERTIFICATE_PROPERTY_NAME = "CERTIFICATE"; @@ -67,9 +67,9 @@ public class SAMLSSOServiceProviderRegistryDAOImpl extends AbstractDAO clazz, String fieldName, Object newValue) + throws NoSuchFieldException, IllegalAccessException { + + Field field = clazz.getDeclaredField(fieldName); + field.setAccessible(true); + field.set(null, newValue); + } +} diff --git a/components/identity-core/org.wso2.carbon.identity.core/src/test/resources/testng.xml b/components/identity-core/org.wso2.carbon.identity.core/src/test/resources/testng.xml index 043fa43d7ae7..086c07b39dae 100644 --- a/components/identity-core/org.wso2.carbon.identity.core/src/test/resources/testng.xml +++ b/components/identity-core/org.wso2.carbon.identity.core/src/test/resources/testng.xml @@ -25,6 +25,7 @@ +