From b5321cfc697da795bb4167400f0fd15f6254aede Mon Sep 17 00:00:00 2001 From: NipuniBhagya Date: Thu, 10 Oct 2024 22:18:46 +0530 Subject: [PATCH] Remove Spring dependencies in the IDP management API --- .../pom.xml | 5 - .../common/IdentityProviderServiceHolder.java | 85 +++--- .../ClaimMetadataMgtOSGIServiceFactory.java | 52 ---- .../factory/IdPMgtOSGIServiceFactory.java | 51 ---- .../TemplateMgtOSGIServiceFactory.java | 53 ---- .../pom.xml | 5 - .../server/idp/v1/IdentityProvidersApi.java | 12 +- .../server/idp/v1/TrustedTokenIssuersApi.java | 13 +- .../IdentityProvidersApiServiceFactory.java | 42 +-- .../TrustedTokenIssuersApiServiceFactory.java | 14 +- .../v1/core/ServerIdpManagementService.java | 241 ++++++++---------- .../ServerIdpManagementServiceFactory.java | 64 +++++ .../impl/IdentityProvidersApiServiceImpl.java | 21 +- .../TrustedTokenIssuersApiServiceImpl.java | 15 +- .../META-INF/cxf/idp-server-v1-cxf.xml | 35 --- 15 files changed, 278 insertions(+), 430 deletions(-) delete mode 100644 components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.common/src/main/java/org/wso2/carbon/identity/api/server/idp/common/factory/ClaimMetadataMgtOSGIServiceFactory.java delete mode 100644 components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.common/src/main/java/org/wso2/carbon/identity/api/server/idp/common/factory/IdPMgtOSGIServiceFactory.java delete mode 100644 components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.common/src/main/java/org/wso2/carbon/identity/api/server/idp/common/factory/TemplateMgtOSGIServiceFactory.java create mode 100644 components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/main/java/org/wso2/carbon/identity/api/server/idp/v1/factories/ServerIdpManagementServiceFactory.java delete mode 100644 components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/main/resources/META-INF/cxf/idp-server-v1-cxf.xml diff --git a/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.common/pom.xml b/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.common/pom.xml index 227a472fe0..9900ba0b8f 100644 --- a/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.common/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.common/pom.xml @@ -53,11 +53,6 @@ org.wso2.carbon.identity.claim.metadata.mgt provided - - org.springframework - spring-web - provided - org.wso2.carbon.identity.framework org.wso2.carbon.identity.template.mgt diff --git a/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.common/src/main/java/org/wso2/carbon/identity/api/server/idp/common/IdentityProviderServiceHolder.java b/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.common/src/main/java/org/wso2/carbon/identity/api/server/idp/common/IdentityProviderServiceHolder.java index d0f358d8a6..a9c6a3d6cd 100644 --- a/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.common/src/main/java/org/wso2/carbon/identity/api/server/idp/common/IdentityProviderServiceHolder.java +++ b/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.common/src/main/java/org/wso2/carbon/identity/api/server/idp/common/IdentityProviderServiceHolder.java @@ -1,21 +1,24 @@ /* - * Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - *                                                                          - * Licensed under the Apache License, Version 2.0 (the "License");          - * you may not use this file except in compliance with the License.         - * You may obtain a copy of the License at                                  - *                                                                          - * http://www.apache.org/licenses/LICENSE-2.0                               - *                                                                          - * Unless required by applicable law or agreed to in writing, software      - * distributed under the License is distributed on an "AS IS" BASIS,        - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and      - * limitations under the License. + * Copyright (c) 2019-2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. */ package org.wso2.carbon.identity.api.server.idp.common; +import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.identity.claim.metadata.mgt.ClaimMetadataManagementService; import org.wso2.carbon.identity.template.mgt.TemplateManager; import org.wso2.carbon.idp.mgt.IdentityProviderManager; @@ -25,59 +28,41 @@ */ public class IdentityProviderServiceHolder { - private static IdentityProviderManager identityProviderManager; - private static ClaimMetadataManagementService claimMetadataManagementService; - private static TemplateManager templateManager; + private IdentityProviderServiceHolder() {} - /** - * Get IdentityProviderManager osgi service. - * - * @return IdentityProviderManager - */ - public static IdentityProviderManager getIdentityProviderManager() { - - return identityProviderManager; + private static class IdentityProviderManagerHolder { + static final IdentityProviderManager SERVICE = (IdentityProviderManager) PrivilegedCarbonContext + .getThreadLocalCarbonContext().getOSGiService(IdentityProviderManager.class, null); } - /** - * Set IdentityProviderManager osgi service. - * - * @param identityProviderManager IdentityProviderManager. - */ - public static void setIdentityProviderManager(IdentityProviderManager identityProviderManager) { - - IdentityProviderServiceHolder.identityProviderManager = identityProviderManager; + private static class ClaimMetadataManagementServiceHolder { + static final ClaimMetadataManagementService SERVICE = (ClaimMetadataManagementService) PrivilegedCarbonContext + .getThreadLocalCarbonContext().getOSGiService(ClaimMetadataManagementService.class, null); } - /** - * Get ClaimMetadataManagementService osgi service. - * - * @return ClaimMetadataManagementService. - */ - public static ClaimMetadataManagementService getClaimMetadataManagementService() { - - return claimMetadataManagementService; + private static class TemplateManagerHolder { + static final TemplateManager SERVICE = (TemplateManager) PrivilegedCarbonContext + .getThreadLocalCarbonContext().getOSGiService(TemplateManager.class, null); } /** - * Set ClaimMetadataManagementService osgi service. + * Get IdentityProviderManager osgi service. * - * @param claimMetadataManagementService ClaimMetadataManagementService. + * @return IdentityProviderManager */ - public static void setClaimMetadataManagementService( - ClaimMetadataManagementService claimMetadataManagementService) { + public static IdentityProviderManager getIdentityProviderManager() { - IdentityProviderServiceHolder.claimMetadataManagementService = claimMetadataManagementService; + return IdentityProviderManagerHolder.SERVICE; } /** - * Set TemplateManager osgi service. + * Get ClaimMetadataManagementService osgi service. * - * @param templateManager TemplateManager service + * @return ClaimMetadataManagementService. */ - public static void setTemplateManager(TemplateManager templateManager) { + public static ClaimMetadataManagementService getClaimMetadataManagementService() { - IdentityProviderServiceHolder.templateManager = templateManager; + return ClaimMetadataManagementServiceHolder.SERVICE; } /** @@ -87,6 +72,6 @@ public static void setTemplateManager(TemplateManager templateManager) { */ public static TemplateManager getTemplateManager() { - return templateManager; + return TemplateManagerHolder.SERVICE; } } diff --git a/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.common/src/main/java/org/wso2/carbon/identity/api/server/idp/common/factory/ClaimMetadataMgtOSGIServiceFactory.java b/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.common/src/main/java/org/wso2/carbon/identity/api/server/idp/common/factory/ClaimMetadataMgtOSGIServiceFactory.java deleted file mode 100644 index f752f5f123..0000000000 --- a/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.common/src/main/java/org/wso2/carbon/identity/api/server/idp/common/factory/ClaimMetadataMgtOSGIServiceFactory.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - *                                                                          - * Licensed under the Apache License, Version 2.0 (the "License");          - * you may not use this file except in compliance with the License.         - * You may obtain a copy of the License at                                  - *                                                                          - * http://www.apache.org/licenses/LICENSE-2.0                               - *                                                                          - * Unless required by applicable law or agreed to in writing, software      - * distributed under the License is distributed on an "AS IS" BASIS,        - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and      - * limitations under the License. - */ - -package org.wso2.carbon.identity.api.server.idp.common.factory; - -import org.springframework.beans.factory.config.AbstractFactoryBean; -import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.identity.claim.metadata.mgt.ClaimMetadataManagementService; - -/** - * Factory Beans serves as a factory for creating other beans within the IOC container. This factory bean is used to - * instantiate the ClaimMetadataManagementService type of object inside the container. - */ -public class ClaimMetadataMgtOSGIServiceFactory extends AbstractFactoryBean { - - private ClaimMetadataManagementService claimMetadataManagementService; - - @Override - public Class getObjectType() { - - return Object.class; - } - - @Override - protected ClaimMetadataManagementService createInstance() throws Exception { - - if (this.claimMetadataManagementService == null) { - ClaimMetadataManagementService taskOperationService = - (ClaimMetadataManagementService) PrivilegedCarbonContext. - getThreadLocalCarbonContext().getOSGiService(ClaimMetadataManagementService.class, null); - if (taskOperationService != null) { - this.claimMetadataManagementService = taskOperationService; - } else { - throw new Exception("Unable to retrieve identityProviderManager service."); - } - } - return this.claimMetadataManagementService; - } -} diff --git a/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.common/src/main/java/org/wso2/carbon/identity/api/server/idp/common/factory/IdPMgtOSGIServiceFactory.java b/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.common/src/main/java/org/wso2/carbon/identity/api/server/idp/common/factory/IdPMgtOSGIServiceFactory.java deleted file mode 100644 index 2efdaa9e25..0000000000 --- a/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.common/src/main/java/org/wso2/carbon/identity/api/server/idp/common/factory/IdPMgtOSGIServiceFactory.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - *                                                                          - * Licensed under the Apache License, Version 2.0 (the "License");          - * you may not use this file except in compliance with the License.         - * You may obtain a copy of the License at                                  - *                                                                          - * http://www.apache.org/licenses/LICENSE-2.0                               - *                                                                          - * Unless required by applicable law or agreed to in writing, software      - * distributed under the License is distributed on an "AS IS" BASIS,        - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and      - * limitations under the License. - */ - -package org.wso2.carbon.identity.api.server.idp.common.factory; - -import org.springframework.beans.factory.config.AbstractFactoryBean; -import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.idp.mgt.IdpManager; - -/** - * Factory Beans serves as a factory for creating other beans within the IOC container. This factory bean is used to - * instantiate the IdentityProviderManager type of object inside the container. - */ -public class IdPMgtOSGIServiceFactory extends AbstractFactoryBean { - - private IdpManager identityProviderManager; - - @Override - public Class getObjectType() { - - return Object.class; - } - - @Override - protected IdpManager createInstance() throws Exception { - - if (this.identityProviderManager == null) { - IdpManager taskOperationService = (IdpManager) PrivilegedCarbonContext. - getThreadLocalCarbonContext().getOSGiService(IdpManager.class, null); - if (taskOperationService != null) { - this.identityProviderManager = taskOperationService; - } else { - throw new Exception("Unable to retrieve identityProviderManager service."); - } - } - return this.identityProviderManager; - } -} diff --git a/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.common/src/main/java/org/wso2/carbon/identity/api/server/idp/common/factory/TemplateMgtOSGIServiceFactory.java b/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.common/src/main/java/org/wso2/carbon/identity/api/server/idp/common/factory/TemplateMgtOSGIServiceFactory.java deleted file mode 100644 index fc62e1cc76..0000000000 --- a/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.common/src/main/java/org/wso2/carbon/identity/api/server/idp/common/factory/TemplateMgtOSGIServiceFactory.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.wso2.carbon.identity.api.server.idp.common.factory; - -import org.springframework.beans.factory.config.AbstractFactoryBean; -import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.identity.template.mgt.TemplateManager; - -/** - * Factory Beans serves as a factory for creating other beans within the IOC container. This factory bean is used to - * instantiate the TemplateManager type of object inside the container. - */ -public class TemplateMgtOSGIServiceFactory extends AbstractFactoryBean { - - private TemplateManager templateManager; - - @Override - public Class getObjectType() { - - return Object.class; - } - - @Override - protected TemplateManager createInstance() throws Exception { - - if (this.templateManager == null) { - TemplateManager taskOperationService = (TemplateManager) PrivilegedCarbonContext. - getThreadLocalCarbonContext().getOSGiService(TemplateManager.class, null); - if (taskOperationService != null) { - this.templateManager = taskOperationService; - } else { - throw new Exception("Unable to retrieve TemplateManager service."); - } - } - return this.templateManager; - } -} diff --git a/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/pom.xml b/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/pom.xml index c3d2902374..b2c74adc9e 100644 --- a/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/pom.xml @@ -107,11 +107,6 @@ cxf-rt-rs-service-description provided - - org.springframework - spring-web - provided - javax.ws.rs javax.ws.rs-api diff --git a/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/gen/java/org/wso2/carbon/identity/api/server/idp/v1/IdentityProvidersApi.java b/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/gen/java/org/wso2/carbon/identity/api/server/idp/v1/IdentityProvidersApi.java index 1c004ca914..ddb4acb1f7 100644 --- a/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/gen/java/org/wso2/carbon/identity/api/server/idp/v1/IdentityProvidersApi.java +++ b/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/gen/java/org/wso2/carbon/identity/api/server/idp/v1/IdentityProvidersApi.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * Copyright (c) 2023-2024, WSO2 LLC. (http://www.wso2.com). * * WSO2 LLC. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except @@ -19,12 +19,12 @@ package org.wso2.carbon.identity.api.server.idp.v1; import org.apache.cxf.jaxrs.ext.search.SearchContext; -import org.springframework.beans.factory.annotation.Autowired; import org.apache.cxf.jaxrs.ext.multipart.Attachment; import org.apache.cxf.jaxrs.ext.multipart.Multipart; import java.io.InputStream; import java.util.List; +import org.wso2.carbon.identity.api.server.idp.v1.factories.IdentityProvidersApiServiceFactory; import org.wso2.carbon.identity.api.server.idp.v1.model.AssociationRequest; import org.wso2.carbon.identity.api.server.idp.v1.model.AssociationResponse; import org.wso2.carbon.identity.api.server.idp.v1.model.Claims; @@ -53,7 +53,6 @@ import org.wso2.carbon.identity.api.server.idp.v1.model.Patch; import org.wso2.carbon.identity.api.server.idp.v1.model.ProvisioningResponse; import org.wso2.carbon.identity.api.server.idp.v1.model.Roles; -import org.wso2.carbon.identity.api.server.idp.v1.IdentityProvidersApiService; import javax.validation.Valid; import javax.ws.rs.*; @@ -68,8 +67,11 @@ public class IdentityProvidersApi { - @Autowired - private IdentityProvidersApiService delegate; + private final IdentityProvidersApiService delegate; + + public IdentityProvidersApi() { + this.delegate = IdentityProvidersApiServiceFactory.getIdentityProvidersApi(); + } @Valid @POST diff --git a/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/gen/java/org/wso2/carbon/identity/api/server/idp/v1/TrustedTokenIssuersApi.java b/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/gen/java/org/wso2/carbon/identity/api/server/idp/v1/TrustedTokenIssuersApi.java index 187b7bf112..53b059f8cb 100644 --- a/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/gen/java/org/wso2/carbon/identity/api/server/idp/v1/TrustedTokenIssuersApi.java +++ b/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/gen/java/org/wso2/carbon/identity/api/server/idp/v1/TrustedTokenIssuersApi.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * Copyright (c) 2023-2024, WSO2 LLC. (http://www.wso2.com). * * WSO2 LLC. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except @@ -18,17 +18,15 @@ package org.wso2.carbon.identity.api.server.idp.v1; -import org.springframework.beans.factory.annotation.Autowired; - import java.util.List; +import org.wso2.carbon.identity.api.server.idp.v1.factories.TrustedTokenIssuersApiServiceFactory; import org.wso2.carbon.identity.api.server.idp.v1.model.Error; import org.wso2.carbon.identity.api.server.idp.v1.model.IdentityProviderListResponse; import java.util.List; import org.wso2.carbon.identity.api.server.idp.v1.model.Patch; import org.wso2.carbon.identity.api.server.idp.v1.model.TrustedTokenIssuerPOSTRequest; import org.wso2.carbon.identity.api.server.idp.v1.model.TrustedTokenIssuerResponse; -import org.wso2.carbon.identity.api.server.idp.v1.TrustedTokenIssuersApiService; import javax.validation.Valid; import javax.ws.rs.*; @@ -41,8 +39,11 @@ public class TrustedTokenIssuersApi { - @Autowired - private TrustedTokenIssuersApiService delegate; + private final TrustedTokenIssuersApiService delegate; + + public TrustedTokenIssuersApi() { + this.delegate = TrustedTokenIssuersApiServiceFactory.getTrustedTokenIssuersApi(); + } @Valid @POST diff --git a/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/gen/java/org/wso2/carbon/identity/api/server/idp/v1/factories/IdentityProvidersApiServiceFactory.java b/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/gen/java/org/wso2/carbon/identity/api/server/idp/v1/factories/IdentityProvidersApiServiceFactory.java index 21fd2ea36c..e20f7dd852 100644 --- a/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/gen/java/org/wso2/carbon/identity/api/server/idp/v1/factories/IdentityProvidersApiServiceFactory.java +++ b/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/gen/java/org/wso2/carbon/identity/api/server/idp/v1/factories/IdentityProvidersApiServiceFactory.java @@ -1,30 +1,40 @@ /* -* Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Copyright (c) 2019-2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ package org.wso2.carbon.identity.api.server.idp.v1.factories; import org.wso2.carbon.identity.api.server.idp.v1.IdentityProvidersApiService; import org.wso2.carbon.identity.api.server.idp.v1.impl.IdentityProvidersApiServiceImpl; +/** + * Factory class for Identity Providers API. + */ public class IdentityProvidersApiServiceFactory { - private final static IdentityProvidersApiService service = new IdentityProvidersApiServiceImpl(); + private final static IdentityProvidersApiService SERVICE = new IdentityProvidersApiServiceImpl(); + /** + * Get Identity Providers API Service. + * + * @return IdentityProvidersApiService + */ public static IdentityProvidersApiService getIdentityProvidersApi() { - return service; + return SERVICE; } } diff --git a/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/gen/java/org/wso2/carbon/identity/api/server/idp/v1/factories/TrustedTokenIssuersApiServiceFactory.java b/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/gen/java/org/wso2/carbon/identity/api/server/idp/v1/factories/TrustedTokenIssuersApiServiceFactory.java index e896c1d5e9..51fdaf816d 100644 --- a/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/gen/java/org/wso2/carbon/identity/api/server/idp/v1/factories/TrustedTokenIssuersApiServiceFactory.java +++ b/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/gen/java/org/wso2/carbon/identity/api/server/idp/v1/factories/TrustedTokenIssuersApiServiceFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * Copyright (c) 2023-2024, WSO2 LLC. (http://www.wso2.com). * * WSO2 LLC. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except @@ -21,12 +21,20 @@ import org.wso2.carbon.identity.api.server.idp.v1.TrustedTokenIssuersApiService; import org.wso2.carbon.identity.api.server.idp.v1.impl.TrustedTokenIssuersApiServiceImpl; +/** + * Factory class for Trusted Token Issuers API. + */ public class TrustedTokenIssuersApiServiceFactory { - private final static TrustedTokenIssuersApiService service = new TrustedTokenIssuersApiServiceImpl(); + private final static TrustedTokenIssuersApiService SERVICE = new TrustedTokenIssuersApiServiceImpl(); + /** + * Get Trusted Token Issuers API Service. + * + * @return TrustedTokenIssuersApiService + */ public static TrustedTokenIssuersApiService getTrustedTokenIssuersApi() { - return service; + return SERVICE; } } diff --git a/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/main/java/org/wso2/carbon/identity/api/server/idp/v1/core/ServerIdpManagementService.java b/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/main/java/org/wso2/carbon/identity/api/server/idp/v1/core/ServerIdpManagementService.java index da4f38f5c9..d94f95dc97 100644 --- a/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/main/java/org/wso2/carbon/identity/api/server/idp/v1/core/ServerIdpManagementService.java +++ b/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/main/java/org/wso2/carbon/identity/api/server/idp/v1/core/ServerIdpManagementService.java @@ -1,7 +1,7 @@ /* - * Copyright (c) 2019 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2019-2024, WSO2 LLC. (http://www.wso2.com). * - * WSO2 Inc. licenses this file to you under the Apache License, + * WSO2 LLC. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except * in compliance with the License. * You may obtain a copy of the License at @@ -40,7 +40,6 @@ import org.wso2.carbon.identity.api.server.common.error.APIError; import org.wso2.carbon.identity.api.server.common.error.ErrorResponse; import org.wso2.carbon.identity.api.server.idp.common.Constants; -import org.wso2.carbon.identity.api.server.idp.common.IdentityProviderServiceHolder; import org.wso2.carbon.identity.api.server.idp.v1.model.AssociationRequest; import org.wso2.carbon.identity.api.server.idp.v1.model.AssociationResponse; import org.wso2.carbon.identity.api.server.idp.v1.model.Certificate; @@ -94,6 +93,7 @@ import org.wso2.carbon.identity.application.common.model.RoleMapping; import org.wso2.carbon.identity.application.common.model.SubProperty; import org.wso2.carbon.identity.application.common.util.IdentityApplicationConstants; +import org.wso2.carbon.identity.claim.metadata.mgt.ClaimMetadataManagementService; import org.wso2.carbon.identity.claim.metadata.mgt.exception.ClaimMetadataException; import org.wso2.carbon.identity.claim.metadata.mgt.model.LocalClaim; import org.wso2.carbon.identity.configuration.mgt.core.model.ResourceSearchBean; @@ -111,6 +111,7 @@ import org.wso2.carbon.idp.mgt.IdentityProviderManagementClientException; import org.wso2.carbon.idp.mgt.IdentityProviderManagementException; import org.wso2.carbon.idp.mgt.IdentityProviderManagementServerException; +import org.wso2.carbon.idp.mgt.IdentityProviderManager; import org.wso2.carbon.idp.mgt.dao.IdPManagementDAO; import org.wso2.carbon.idp.mgt.model.ConnectedAppsResult; import org.wso2.carbon.idp.mgt.model.IdpSearchResult; @@ -178,8 +179,20 @@ */ public class ServerIdpManagementService { + private final IdentityProviderManager identityProviderManager; + private final ClaimMetadataManagementService claimMetadataManagementService; + private final TemplateManager templateManager; + private static final Log log = LogFactory.getLog(ServerIdpManagementService.class); + public ServerIdpManagementService(IdentityProviderManager identityProviderManager, TemplateManager templateManager, + ClaimMetadataManagementService claimMetadataManagementService) { + + this.identityProviderManager = identityProviderManager; + this.templateManager = templateManager; + this.claimMetadataManagementService = claimMetadataManagementService; + } + /** * Get list of identity providers. * @@ -199,9 +212,8 @@ public IdentityProviderListResponse getIDPs(String requiredAttributes, Integer l if (StringUtils.isNotBlank(requiredAttributes)) { requestedAttributeList = new ArrayList<>(Arrays.asList(requiredAttributes.split(","))); } - return createIDPListResponse( - IdentityProviderServiceHolder.getIdentityProviderManager().getIdPs(limit, offset, filter, - sortOrder, sortBy, ContextLoader.getTenantDomainFromContext(), requestedAttributeList), + return createIDPListResponse(identityProviderManager.getIdPs(limit, offset, filter, sortOrder, sortBy, + ContextLoader.getTenantDomainFromContext(), requestedAttributeList), requestedAttributeList); } catch (IdentityProviderManagementException e) { throw handleIdPException(e, Constants.ErrorMessage.ERROR_CODE_ERROR_LISTING_IDPS, null); @@ -227,10 +239,9 @@ public IdentityProviderListResponse getTrustedTokenIssuers(String requiredAttrib if (StringUtils.isNotBlank(requiredAttributes)) { requestedAttributeList = new ArrayList<>(Arrays.asList(requiredAttributes.split(","))); } - return createIDPListResponse( - IdentityProviderServiceHolder.getIdentityProviderManager().getTrustedTokenIssuers(limit, offset, - filter, sortBy, sortOrder, ContextLoader.getTenantDomainFromContext(), - requestedAttributeList), requestedAttributeList); + return createIDPListResponse(identityProviderManager.getTrustedTokenIssuers(limit, offset, filter, sortBy, + sortOrder, ContextLoader.getTenantDomainFromContext(), requestedAttributeList), + requestedAttributeList); } catch (IdentityProviderManagementException e) { throw handleIdPException(e, Constants.ErrorMessage.ERROR_CODE_ERROR_LISTING_TRUSTED_TOKEN_ISSUERS, null); } @@ -247,8 +258,8 @@ public IdentityProviderResponse addIDP(IdentityProviderPOSTRequest identityProvi IdentityProvider identityProvider; try { validateSystemReservedIDP(identityProviderPOSTRequest.getName()); - identityProvider = IdentityProviderServiceHolder.getIdentityProviderManager().addIdPWithResourceId( - createIDP(identityProviderPOSTRequest), ContextLoader.getTenantDomainFromContext()); + identityProvider = identityProviderManager.addIdPWithResourceId(createIDP(identityProviderPOSTRequest), + ContextLoader.getTenantDomainFromContext()); } catch (IdentityProviderManagementException e) { throw handleIdPException(e, Constants.ErrorMessage.ERROR_CODE_ERROR_ADDING_IDP, null); } @@ -264,8 +275,7 @@ public IdentityProviderResponse addIDP(IdentityProviderPOSTRequest identityProvi public IdentityProviderResponse getIDP(String idpId) { try { - IdentityProvider identityProvider = - IdentityProviderServiceHolder.getIdentityProviderManager().getIdPByResourceId(idpId, + IdentityProvider identityProvider = identityProviderManager.getIdPByResourceId(idpId, ContextLoader.getTenantDomainFromContext(), true); if (identityProvider == null) { throw handleException(Response.Status.NOT_FOUND, Constants.ErrorMessage.ERROR_CODE_IDP_NOT_FOUND, @@ -290,9 +300,8 @@ public IdentityProviderResponse getIDP(String idpId) { public IdentityProviderResponse patchIDP(String identityProviderId, List patchRequest) { try { - IdentityProvider identityProvider = - IdentityProviderServiceHolder.getIdentityProviderManager().getIdPByResourceId(identityProviderId, - ContextLoader.getTenantDomainFromContext(), true); + IdentityProvider identityProvider = identityProviderManager.getIdPByResourceId(identityProviderId, + ContextLoader.getTenantDomainFromContext(), true); if (identityProvider == null) { throw handleException(Response.Status.NOT_FOUND, Constants.ErrorMessage.ERROR_CODE_IDP_NOT_FOUND, identityProviderId); @@ -300,9 +309,8 @@ public IdentityProviderResponse patchIDP(String identityProviderId, List IdentityProvider idpToUpdate = createIdPClone(identityProvider); processPatchRequest(patchRequest, idpToUpdate); validateSystemReservedIDP(idpToUpdate.getIdentityProviderName()); - IdentityProvider updatedIdP = IdentityProviderServiceHolder.getIdentityProviderManager() - .updateIdPByResourceId(identityProviderId, idpToUpdate, - ContextLoader.getTenantDomainFromContext()); + IdentityProvider updatedIdP = identityProviderManager.updateIdPByResourceId(identityProviderId, idpToUpdate, + ContextLoader.getTenantDomainFromContext()); return createIDPResponse(updatedIdP); } catch (IdentityProviderManagementException e) { @@ -318,7 +326,7 @@ public IdentityProviderResponse patchIDP(String identityProviderId, List public void deleteIDP(String identityProviderId) { try { - IdentityProviderServiceHolder.getIdentityProviderManager().deleteIdPByResourceId(identityProviderId, + identityProviderManager.deleteIdPByResourceId(identityProviderId, ContextLoader.getTenantDomainFromContext()); } catch (IdentityProviderManagementException e) { throw handleIdPException(e, Constants.ErrorMessage.ERROR_CODE_ERROR_DELETING_IDP, identityProviderId); @@ -334,7 +342,7 @@ public void deleteIDP(String identityProviderId) { public void forceDeleteIDP(String identityProviderId) { try { - IdentityProviderServiceHolder.getIdentityProviderManager().forceDeleteIdpByResourceId(identityProviderId, + identityProviderManager.forceDeleteIdpByResourceId(identityProviderId, ContextLoader.getTenantDomainFromContext()); } catch (IdentityProviderManagementException e) { throw handleIdPException(e, Constants.ErrorMessage.ERROR_CODE_ERROR_DELETING_IDP, identityProviderId); @@ -365,8 +373,7 @@ public FileContent exportIDP(String idpId, boolean excludeSecrets, String fileTy String tenantDomain = ContextLoader.getTenantDomainFromContext(); identityProvider = RESIDENT_IDP_RESERVED_NAME.equals(idpId) ? dao.getIdPByName(null, RESIDENT_IDP_RESERVED_NAME, IdentityTenantUtil.getTenantId(tenantDomain), tenantDomain) : - IdentityProviderServiceHolder.getIdentityProviderManager(). - getIdPByResourceId(idpId, tenantDomain, true); + identityProviderManager.getIdPByResourceId(idpId, tenantDomain, true); idpToExport = createIdPClone(identityProvider); if (idpToExport == null) { throw handleException(Response.Status.NOT_FOUND, @@ -406,7 +413,7 @@ public String importIDP(InputStream fileInputStream, Attachment fileDetail) { IdentityProvider identityProvider; try { String tenantDomain = ContextLoader.getTenantDomainFromContext(); - identityProvider = IdentityProviderServiceHolder.getIdentityProviderManager().addIdPWithResourceId( + identityProvider = identityProviderManager.addIdPWithResourceId( getIDPFromFile(fileInputStream, fileDetail), tenantDomain); } catch (IdentityProviderManagementException e) { throw handleIdPException(e, Constants.ErrorMessage.ERROR_CODE_ERROR_IMPORTING_IDP, null); @@ -428,11 +435,9 @@ public void updateIDPFromFile(String identityProviderId, InputStream fileInputSt identityProvider = getIDPFromFile(fileInputStream, fileDetail); String tenantDomain = ContextLoader.getTenantDomainFromContext(); if (RESIDENT_IDP_RESERVED_NAME.equals(identityProviderId)) { - IdentityProviderServiceHolder.getIdentityProviderManager().updateResidentIdP(identityProvider, - tenantDomain); + identityProviderManager.updateResidentIdP(identityProvider, tenantDomain); } else { - IdentityProviderServiceHolder.getIdentityProviderManager().updateIdPByResourceId(identityProviderId, - identityProvider, tenantDomain); + identityProviderManager.updateIdPByResourceId(identityProviderId, identityProvider, tenantDomain); } } catch (IdentityProviderManagementException e) { throw handleIdPException(e, Constants.ErrorMessage.ERROR_CODE_ERROR_UPDATING_IDP, null); @@ -448,9 +453,8 @@ public List getMetaFederatedAuthenticators() List metaAuthenticators = new ArrayList<>(); try { - FederatedAuthenticatorConfig[] authenticatorConfigs = - IdentityProviderServiceHolder.getIdentityProviderManager() - .getAllFederatedAuthenticators(); + FederatedAuthenticatorConfig[] authenticatorConfigs = identityProviderManager + .getAllFederatedAuthenticators(); if (ArrayUtils.isNotEmpty(authenticatorConfigs)) { for (FederatedAuthenticatorConfig authenticatorConfig : authenticatorConfigs) { MetaFederatedAuthenticatorListItem metaFederatedAuthenticator = @@ -475,9 +479,8 @@ public MetaFederatedAuthenticator getMetaFederatedAuthenticator(String id) { MetaFederatedAuthenticator authenticator = null; try { String authenticatorName = decodeAuthenticatorID(id); - FederatedAuthenticatorConfig[] authenticatorConfigs = - IdentityProviderServiceHolder.getIdentityProviderManager() - .getAllFederatedAuthenticators(); + FederatedAuthenticatorConfig[] authenticatorConfigs = identityProviderManager + .getAllFederatedAuthenticators(); if (ArrayUtils.isNotEmpty(authenticatorConfigs)) { for (FederatedAuthenticatorConfig authenticatorConfig : authenticatorConfigs) { if (StringUtils.equals(authenticatorConfig.getName(), authenticatorName)) { @@ -521,8 +524,7 @@ public List getMetaOutboundConnectors() { List metaOutboundConnectors = new ArrayList<>(); try { - ProvisioningConnectorConfig[] connectorConfigs = IdentityProviderServiceHolder.getIdentityProviderManager() - .getAllProvisioningConnectors(); + ProvisioningConnectorConfig[] connectorConfigs = identityProviderManager.getAllProvisioningConnectors(); if (ArrayUtils.isNotEmpty(connectorConfigs)) { for (ProvisioningConnectorConfig connectorConfig : connectorConfigs) { MetaOutboundConnectorListItem metaOutboundConnector = createMetaOutboundConnectorListItem @@ -547,8 +549,7 @@ public MetaOutboundConnector getMetaOutboundConnector(String id) { String connectorName = base64URLDecode(id); MetaOutboundConnector connector = null; try { - ProvisioningConnectorConfig[] connectorConfigs = IdentityProviderServiceHolder.getIdentityProviderManager() - .getAllProvisioningConnectors(); + ProvisioningConnectorConfig[] connectorConfigs = identityProviderManager.getAllProvisioningConnectors(); if (ArrayUtils.isNotEmpty(connectorConfigs)) { for (ProvisioningConnectorConfig connectorConfig : connectorConfigs) { if (StringUtils.equals(connectorConfig.getName(), connectorName)) { @@ -574,9 +575,8 @@ public FederatedAuthenticatorListResponse getFederatedAuthenticators(String idpI FederatedAuthenticatorListResponse listResponse; try { - IdentityProvider idP = - IdentityProviderServiceHolder.getIdentityProviderManager().getIdPByResourceId(idpId, ContextLoader - .getTenantDomainFromContext(), true); + IdentityProvider idP = identityProviderManager.getIdPByResourceId(idpId, ContextLoader + .getTenantDomainFromContext(), true); if (idP == null) { throw handleException(Response.Status.NOT_FOUND, Constants.ErrorMessage.ERROR_CODE_IDP_NOT_FOUND, @@ -629,9 +629,8 @@ public FederatedAuthenticatorListResponse getFederatedAuthenticators(String idpI public FederatedAuthenticator getFederatedAuthenticator(String idpId, String authenticatorId) { try { - IdentityProvider idp = - IdentityProviderServiceHolder.getIdentityProviderManager().getIdPByResourceId(idpId, ContextLoader - .getTenantDomainFromContext(), true); + IdentityProvider idp = identityProviderManager.getIdPByResourceId(idpId, ContextLoader + .getTenantDomainFromContext(), true); if (idp == null) { throw handleException(Response.Status.NOT_FOUND, Constants.ErrorMessage.ERROR_CODE_IDP_NOT_FOUND, idpId); @@ -663,9 +662,8 @@ public FederatedAuthenticatorListResponse updateFederatedAuthenticators(String i authenticatorRequest) { try { - IdentityProvider idp = - IdentityProviderServiceHolder.getIdentityProviderManager().getIdPByResourceId(idpId, ContextLoader - .getTenantDomainFromContext(), true); + IdentityProvider idp = identityProviderManager.getIdPByResourceId(idpId, ContextLoader + .getTenantDomainFromContext(), true); if (idp == null) { throw handleException(Response.Status.NOT_FOUND, Constants.ErrorMessage.ERROR_CODE_IDP_NOT_FOUND, idpId); @@ -675,9 +673,8 @@ public FederatedAuthenticatorListResponse updateFederatedAuthenticators(String i IdentityProvider idpToUpdate = createIdPClone(idp); updateFederatedAuthenticatorConfig(idpToUpdate, authenticatorRequest); - IdentityProvider updatedIdp = IdentityProviderServiceHolder.getIdentityProviderManager() - .updateIdPByResourceId( - idpId, idpToUpdate, ContextLoader.getTenantDomainFromContext()); + IdentityProvider updatedIdp = identityProviderManager.updateIdPByResourceId(idpId, idpToUpdate, + ContextLoader.getTenantDomainFromContext()); return createFederatedAuthenticatorResponse(updatedIdp); } catch (IdentityProviderManagementException e) { throw handleIdPException(e, Constants.ErrorMessage.ERROR_CODE_ERROR_UPDATING_IDP, StringUtils.EMPTY); @@ -696,9 +693,8 @@ public FederatedAuthenticator updateFederatedAuthenticator(String idpId, String FederatedAuthenticatorPUTRequest authenticator) { try { - IdentityProvider idp = - IdentityProviderServiceHolder.getIdentityProviderManager().getIdPByResourceId(idpId, ContextLoader - .getTenantDomainFromContext(), true); + IdentityProvider idp = identityProviderManager.getIdPByResourceId(idpId, ContextLoader + .getTenantDomainFromContext(), true); if (idp == null) { throw handleException(Response.Status.NOT_FOUND, Constants.ErrorMessage.ERROR_CODE_IDP_NOT_FOUND, idpId); @@ -736,9 +732,8 @@ public FederatedAuthenticator updateFederatedAuthenticator(String idpId, String idpToUpdate.setDefaultAuthenticatorConfig(null); } - IdentityProvider updatedIdP = IdentityProviderServiceHolder.getIdentityProviderManager() - .updateIdPByResourceId(idpId, idpToUpdate, ContextLoader - .getTenantDomainFromContext()); + IdentityProvider updatedIdP = identityProviderManager.updateIdPByResourceId(idpId, idpToUpdate, + ContextLoader.getTenantDomainFromContext()); return createFederatedAuthenticator(federatedAuthenticatorId, updatedIdP); } catch (IdentityProviderManagementException e) { throw handleIdPException(e, Constants.ErrorMessage.ERROR_CODE_ERROR_UPDATING_IDP_AUTHENTICATOR, @@ -755,9 +750,8 @@ public FederatedAuthenticator updateFederatedAuthenticator(String idpId, String public OutboundConnectorListResponse getOutboundConnectors(String idpId) { try { - IdentityProvider idp = - IdentityProviderServiceHolder.getIdentityProviderManager().getIdPByResourceId(idpId, ContextLoader - .getTenantDomainFromContext(), true); + IdentityProvider idp = identityProviderManager.getIdPByResourceId(idpId, ContextLoader + .getTenantDomainFromContext(), true); if (idp == null) { throw handleException(Response.Status.NOT_FOUND, Constants.ErrorMessage.ERROR_CODE_IDP_NOT_FOUND, idpId); @@ -796,9 +790,8 @@ public OutboundConnectorListResponse getOutboundConnectors(String idpId) { public OutboundConnector getOutboundConnector(String idpId, String connectorId) { try { - IdentityProvider idp = - IdentityProviderServiceHolder.getIdentityProviderManager().getIdPByResourceId(idpId, ContextLoader - .getTenantDomainFromContext(), true); + IdentityProvider idp = identityProviderManager.getIdPByResourceId(idpId, ContextLoader + .getTenantDomainFromContext(), true); if (idp == null) { throw handleException(Response.Status.NOT_FOUND, Constants.ErrorMessage.ERROR_CODE_IDP_NOT_FOUND, idpId); @@ -829,9 +822,8 @@ public OutboundConnectorListResponse updateOutboundConnectors(String idpId, Outb outboundConnectorRequest) { try { - IdentityProvider idp = - IdentityProviderServiceHolder.getIdentityProviderManager().getIdPByResourceId(idpId, ContextLoader - .getTenantDomainFromContext(), true); + IdentityProvider idp = identityProviderManager.getIdPByResourceId(idpId, ContextLoader + .getTenantDomainFromContext(), true); if (idp == null) { throw handleException(Response.Status.NOT_FOUND, Constants.ErrorMessage.ERROR_CODE_IDP_NOT_FOUND, idpId); @@ -841,9 +833,8 @@ public OutboundConnectorListResponse updateOutboundConnectors(String idpId, Outb IdentityProvider idpToUpdate = createIdPClone(idp); updateOutboundConnectorConfig(idpToUpdate, outboundConnectorRequest); - IdentityProvider updatedIdp = IdentityProviderServiceHolder.getIdentityProviderManager() - .updateIdPByResourceId( - idpId, idpToUpdate, ContextLoader.getTenantDomainFromContext()); + IdentityProvider updatedIdp = identityProviderManager.updateIdPByResourceId(idpId, idpToUpdate, + ContextLoader.getTenantDomainFromContext()); return createOutboundProvisioningResponse(updatedIdp); } catch (IdentityProviderManagementException e) { throw handleIdPException(e, Constants.ErrorMessage.ERROR_CODE_ERROR_UPDATING_IDP, StringUtils.EMPTY); @@ -863,9 +854,8 @@ public OutboundConnector updateOutboundConnector(String idpId, String connectorI outboundConnector) { try { - IdentityProvider idp = - IdentityProviderServiceHolder.getIdentityProviderManager().getIdPByResourceId(idpId, ContextLoader - .getTenantDomainFromContext(), true); + IdentityProvider idp = identityProviderManager.getIdPByResourceId(idpId, ContextLoader + .getTenantDomainFromContext(), true); if (idp == null) { throw handleException(Response.Status.NOT_FOUND, Constants.ErrorMessage.ERROR_CODE_IDP_NOT_FOUND, idpId); @@ -900,9 +890,8 @@ public OutboundConnector updateOutboundConnector(String idpId, String connectorI idpToUpdate.setDefaultProvisioningConnectorConfig(null); } - IdentityProvider updatedIdP = IdentityProviderServiceHolder.getIdentityProviderManager() - .updateIdPByResourceId(idpId, idpToUpdate, ContextLoader - .getTenantDomainFromContext()); + IdentityProvider updatedIdP = identityProviderManager.updateIdPByResourceId(idpId, idpToUpdate, + ContextLoader.getTenantDomainFromContext()); return createOutboundConnector(connectorId, updatedIdP); } catch (IdentityProviderManagementException e) { throw handleIdPException(e, Constants.ErrorMessage.ERROR_CODE_ERROR_UPDATING_IDP_CONNECTOR, connectorId); @@ -918,9 +907,8 @@ public OutboundConnector updateOutboundConnector(String idpId, String connectorI public Claims getClaimConfig(String idpId) { try { - IdentityProvider identityProvider = - IdentityProviderServiceHolder.getIdentityProviderManager().getIdPByResourceId(idpId, ContextLoader - .getTenantDomainFromContext(), true); + IdentityProvider identityProvider = identityProviderManager.getIdPByResourceId(idpId, ContextLoader + .getTenantDomainFromContext(), true); if (identityProvider == null) { throw handleException(Response.Status.NOT_FOUND, Constants.ErrorMessage.ERROR_CODE_IDP_NOT_FOUND, idpId); @@ -945,16 +933,13 @@ public Claims updateClaimConfig(String idpId, Claims claims) { String tenantDomain = ContextLoader.getTenantDomainFromContext(); validateClaims(tenantDomain, claims); IdentityProvider idP = - createIdPClone(IdentityProviderServiceHolder.getIdentityProviderManager().getIdPByResourceId(idpId, - tenantDomain, true)); + createIdPClone(identityProviderManager.getIdPByResourceId(idpId, tenantDomain, true)); if (idP == null) { throw handleException(Response.Status.NOT_FOUND, Constants.ErrorMessage.ERROR_CODE_IDP_NOT_FOUND, idpId); } updateClaims(idP, claims); - IdentityProvider updatedIdP = - IdentityProviderServiceHolder.getIdentityProviderManager().updateIdPByResourceId(idpId, - idP, tenantDomain); + IdentityProvider updatedIdP = identityProviderManager.updateIdPByResourceId(idpId, idP, tenantDomain); return createClaimResponse(updatedIdP.getClaimConfig()); } catch (IdentityProviderManagementException e) { throw handleIdPException(e, Constants.ErrorMessage.ERROR_CODE_ERROR_UPDATING_IDP_CLAIMS, idpId); @@ -970,9 +955,8 @@ public Claims updateClaimConfig(String idpId, Claims claims) { public Roles getRoleConfig(String idpId) { try { - IdentityProvider identityProvider = - IdentityProviderServiceHolder.getIdentityProviderManager().getIdPByResourceId(idpId, ContextLoader - .getTenantDomainFromContext(), true); + IdentityProvider identityProvider = identityProviderManager.getIdPByResourceId(idpId, ContextLoader + .getTenantDomainFromContext(), true); if (identityProvider == null) { throw handleException(Response.Status.NOT_FOUND, Constants.ErrorMessage.ERROR_CODE_IDP_NOT_FOUND, idpId); @@ -993,8 +977,7 @@ public Roles getRoleConfig(String idpId) { public Roles updateRoleConfig(String idpId, Roles roles) { try { - IdentityProvider idP = - IdentityProviderServiceHolder.getIdentityProviderManager().getIdPByResourceId(idpId, ContextLoader + IdentityProvider idP = identityProviderManager.getIdPByResourceId(idpId, ContextLoader .getTenantDomainFromContext(), true); if (idP == null) { throw handleException(Response.Status.NOT_FOUND, Constants.ErrorMessage.ERROR_CODE_IDP_NOT_FOUND, @@ -1002,8 +985,7 @@ public Roles updateRoleConfig(String idpId, Roles roles) { } updateRoles(idP, roles); - IdentityProvider updatedIdP = - IdentityProviderServiceHolder.getIdentityProviderManager().updateIdPByResourceId(idpId, + IdentityProvider updatedIdP = identityProviderManager.updateIdPByResourceId(idpId, idP, ContextLoader.getTenantDomainFromContext()); return createRoleResponse(updatedIdP); } catch (IdentityProviderManagementException e) { @@ -1020,8 +1002,8 @@ public Roles updateRoleConfig(String idpId, Roles roles) { public List getGroupConfig(String idpId) { try { - IdentityProvider identityProvider = IdentityProviderServiceHolder.getIdentityProviderManager() - .getIdPByResourceId(idpId, ContextLoader.getTenantDomainFromContext(), true); + IdentityProvider identityProvider = identityProviderManager.getIdPByResourceId(idpId, + ContextLoader.getTenantDomainFromContext(), true); if (identityProvider == null) { throw handleException(Response.Status.NOT_FOUND, Constants.ErrorMessage.ERROR_CODE_IDP_NOT_FOUND, idpId); @@ -1042,17 +1024,16 @@ public List getGroupConfig(String idpId) { public List updateGroupConfig(String idpId, List groups) { try { - IdentityProvider idP = IdentityProviderServiceHolder.getIdentityProviderManager() - .getIdPByResourceId(idpId, ContextLoader.getTenantDomainFromContext(), true); + IdentityProvider idP = identityProviderManager.getIdPByResourceId(idpId, ContextLoader + .getTenantDomainFromContext(), true); if (idP == null) { throw handleException(Response.Status.NOT_FOUND, Constants.ErrorMessage.ERROR_CODE_IDP_NOT_FOUND, idpId); } updateGroups(idP, groups); - IdentityProvider updatedIdP = - IdentityProviderServiceHolder.getIdentityProviderManager().updateIdPByResourceId(idpId, - idP, ContextLoader.getTenantDomainFromContext()); + IdentityProvider updatedIdP = identityProviderManager.updateIdPByResourceId(idpId, idP, + ContextLoader.getTenantDomainFromContext()); return createGroupResponse(updatedIdP); } catch (IdentityProviderManagementException e) { throw handleIdPException(e, Constants.ErrorMessage.ERROR_CODE_ERROR_UPDATING_IDP_GROUPS, idpId); @@ -1068,9 +1049,8 @@ public List updateGroupConfig(String idpId, List groups) { public ProvisioningResponse getProvisioningConfig(String idpId) { try { - IdentityProvider identityProvider = - IdentityProviderServiceHolder.getIdentityProviderManager().getIdPByResourceId(idpId, ContextLoader - .getTenantDomainFromContext(), true); + IdentityProvider identityProvider = identityProviderManager.getIdPByResourceId(idpId, ContextLoader + .getTenantDomainFromContext(), true); if (identityProvider == null) { throw handleException(Response.Status.NOT_FOUND, Constants.ErrorMessage.ERROR_CODE_IDP_NOT_FOUND, idpId); @@ -1084,9 +1064,8 @@ public ProvisioningResponse getProvisioningConfig(String idpId) { public AssociationResponse getFederatedAssociationConfig(String idpId) { try { - IdentityProvider identityProvider = - IdentityProviderServiceHolder.getIdentityProviderManager().getIdPByResourceId(idpId, ContextLoader - .getTenantDomainFromContext(), true); + IdentityProvider identityProvider = identityProviderManager.getIdPByResourceId(idpId, ContextLoader + .getTenantDomainFromContext(), true); if (identityProvider == null) { throw handleException(Response.Status.NOT_FOUND, Constants.ErrorMessage.ERROR_CODE_IDP_NOT_FOUND, idpId); @@ -1101,9 +1080,8 @@ public AssociationResponse getFederatedAssociationConfig(String idpId) { public AssociationResponse updateFederatedAssociationConfig(String idpId, AssociationRequest associationRequest) { try { - IdentityProvider idP = - IdentityProviderServiceHolder.getIdentityProviderManager().getIdPByResourceId(idpId, ContextLoader - .getTenantDomainFromContext(), true); + IdentityProvider idP = identityProviderManager.getIdPByResourceId(idpId, ContextLoader + .getTenantDomainFromContext(), true); if (idP == null) { throw handleException(Response.Status.NOT_FOUND, Constants.ErrorMessage.ERROR_CODE_IDP_NOT_FOUND, @@ -1112,9 +1090,8 @@ public AssociationResponse updateFederatedAssociationConfig(String idpId, Associ updateFederatedAssociation(idP, associationRequest); - IdentityProvider updatedIdP = - IdentityProviderServiceHolder.getIdentityProviderManager().updateIdPByResourceId(idpId, - idP, ContextLoader.getTenantDomainFromContext()); + IdentityProvider updatedIdP = identityProviderManager.updateIdPByResourceId(idpId, idP, ContextLoader + .getTenantDomainFromContext()); return createAssociationResponse(updatedIdP); } catch (IdentityProviderManagementException e) { @@ -1131,8 +1108,7 @@ public AssociationResponse updateFederatedAssociationConfig(String idpId, Associ public JustInTimeProvisioning getJITConfig(String idpId) { try { - IdentityProvider identityProvider = - IdentityProviderServiceHolder.getIdentityProviderManager().getIdPByResourceId(idpId, ContextLoader + IdentityProvider identityProvider = identityProviderManager.getIdPByResourceId(idpId, ContextLoader .getTenantDomainFromContext(), true); if (identityProvider == null) { throw handleException(Response.Status.NOT_FOUND, Constants.ErrorMessage.ERROR_CODE_IDP_NOT_FOUND, @@ -1154,18 +1130,16 @@ public JustInTimeProvisioning getJITConfig(String idpId) { public JustInTimeProvisioning updateJITConfig(String idpId, JustInTimeProvisioning justInTimeProvisioningConfig) { try { - IdentityProvider idP = - IdentityProviderServiceHolder.getIdentityProviderManager().getIdPByResourceId(idpId, ContextLoader - .getTenantDomainFromContext(), true); + IdentityProvider idP = identityProviderManager.getIdPByResourceId(idpId, ContextLoader + .getTenantDomainFromContext(), true); if (idP == null) { throw handleException(Response.Status.NOT_FOUND, Constants.ErrorMessage.ERROR_CODE_IDP_NOT_FOUND, idpId); } updateJIT(idP, justInTimeProvisioningConfig); - IdentityProvider updatedIdP = - IdentityProviderServiceHolder.getIdentityProviderManager().updateIdPByResourceId(idpId, - idP, ContextLoader.getTenantDomainFromContext()); + IdentityProvider updatedIdP = identityProviderManager.updateIdPByResourceId(idpId, idP, ContextLoader + .getTenantDomainFromContext()); return createJITResponse(updatedIdP); } catch (IdentityProviderManagementException e) { throw handleIdPException(e, Constants.ErrorMessage.ERROR_CODE_ERROR_UPDATING_IDP_JIT, idpId); @@ -1183,9 +1157,8 @@ public JustInTimeProvisioning updateJITConfig(String idpId, JustInTimeProvisioni public ConnectedApps getConnectedApps(String resourceId, Integer limit, Integer offset) { try { - ConnectedAppsResult connectedAppsResult = - IdentityProviderServiceHolder.getIdentityProviderManager().getConnectedApplications(resourceId, - limit, offset, ContextLoader.getTenantDomainFromContext()); + ConnectedAppsResult connectedAppsResult = identityProviderManager.getConnectedApplications(resourceId, + limit, offset, ContextLoader.getTenantDomainFromContext()); return createConnectedAppsResponse(resourceId, connectedAppsResult); } catch (IdentityProviderManagementException e) { throw handleIdPException(e, Constants.ErrorMessage.ERROR_CODE_ERROR_RETRIEVING_IDP_CONNECTED_APPS, @@ -1205,7 +1178,6 @@ public IdentityProviderTemplateListResponse getIDPTemplates(Integer limit, Integ searchContext) { try { - TemplateManager templateManager = IdentityProviderServiceHolder.getTemplateManager(); List