From e8a5d3672d06506ad8dd3bffa08161cc10146798 Mon Sep 17 00:00:00 2001
From: Lashini Jayasekara <30428591+lashinijay@users.noreply.github.com>
Date: Thu, 12 Dec 2024 15:30:53 +0530
Subject: [PATCH 1/8] [Spring Cleanup] Remove spring dependency in client
attestation filter (#2634)
---
.../pom.xml | 5 --
.../filter/ClientAttestationProxy.java | 4 +-
.../ClientAttestationServiceHolder.java | 59 +++++++------------
.../ApplicationManagementServiceFactory.java | 56 ------------------
.../ClientAttestationServiceFactory.java | 54 -----------------
.../src/main/webapp/WEB-INF/cxf-servlet.xml | 2 -
6 files changed, 23 insertions(+), 157 deletions(-)
delete mode 100644 components/org.wso2.carbon.identity.client.attestation.filter/src/main/java/org/wso2/carbon/identity/client/attestation/filter/factory/ApplicationManagementServiceFactory.java
delete mode 100644 components/org.wso2.carbon.identity.client.attestation.filter/src/main/java/org/wso2/carbon/identity/client/attestation/filter/factory/ClientAttestationServiceFactory.java
diff --git a/components/org.wso2.carbon.identity.client.attestation.filter/pom.xml b/components/org.wso2.carbon.identity.client.attestation.filter/pom.xml
index d7893b06371..81781a6633a 100644
--- a/components/org.wso2.carbon.identity.client.attestation.filter/pom.xml
+++ b/components/org.wso2.carbon.identity.client.attestation.filter/pom.xml
@@ -46,11 +46,6 @@
org.wso2.carbon.identity.inbound.auth.oauth2
org.wso2.carbon.identity.oauth
-
- org.springframework
- spring-web
- provided
-
org.wso2.carbon.identity.framework
org.wso2.carbon.identity.base
diff --git a/components/org.wso2.carbon.identity.client.attestation.filter/src/main/java/org/wso2/carbon/identity/client/attestation/filter/ClientAttestationProxy.java b/components/org.wso2.carbon.identity.client.attestation.filter/src/main/java/org/wso2/carbon/identity/client/attestation/filter/ClientAttestationProxy.java
index 4e17820081c..204dc068d9f 100644
--- a/components/org.wso2.carbon.identity.client.attestation.filter/src/main/java/org/wso2/carbon/identity/client/attestation/filter/ClientAttestationProxy.java
+++ b/components/org.wso2.carbon.identity.client.attestation.filter/src/main/java/org/wso2/carbon/identity/client/attestation/filter/ClientAttestationProxy.java
@@ -115,7 +115,7 @@ public void handleMessage(Message message) {
// Attestation validation should be performed only if API-based authentication is enabled.
if (serviceProvider.isAPIBasedAuthenticationEnabled()) {
// Validate the attestation header and obtain client attestation context
- clientAttestationContext = ClientAttestationServiceHolder.getInstance()
+ clientAttestationContext = ClientAttestationServiceHolder
.getClientAttestationService().validateAttestation(attestationHeader,
serviceProvider.getApplicationResourceId(),
IdentityTenantUtil.resolveTenantDomain());
@@ -265,7 +265,7 @@ private ServiceProvider getServiceProvider(String clientId, String tenantDomain)
ServiceProvider serviceProvider;
try {
- serviceProvider = ClientAttestationServiceHolder.getInstance().getApplicationManagementService()
+ serviceProvider = ClientAttestationServiceHolder.getApplicationManagementService()
.getServiceProviderByClientId(clientId, OAUTH2, tenantDomain);
} catch (IdentityApplicationManagementClientException e) {
throw new WebApplicationException(
diff --git a/components/org.wso2.carbon.identity.client.attestation.filter/src/main/java/org/wso2/carbon/identity/client/attestation/filter/ClientAttestationServiceHolder.java b/components/org.wso2.carbon.identity.client.attestation.filter/src/main/java/org/wso2/carbon/identity/client/attestation/filter/ClientAttestationServiceHolder.java
index 57f6f01e246..6a0aa1f4d2e 100644
--- a/components/org.wso2.carbon.identity.client.attestation.filter/src/main/java/org/wso2/carbon/identity/client/attestation/filter/ClientAttestationServiceHolder.java
+++ b/components/org.wso2.carbon.identity.client.attestation.filter/src/main/java/org/wso2/carbon/identity/client/attestation/filter/ClientAttestationServiceHolder.java
@@ -19,6 +19,7 @@
package org.wso2.carbon.identity.client.attestation.filter;
+import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.identity.application.mgt.ApplicationManagementService;
import org.wso2.carbon.identity.client.attestation.mgt.services.ClientAttestationService;
@@ -29,43 +30,32 @@
*/
public class ClientAttestationServiceHolder {
- // Singleton instance
- private static ClientAttestationServiceHolder instance = new ClientAttestationServiceHolder();
-
// Service instances
- private ClientAttestationService clientAttestationService;
- private ApplicationManagementService applicationManagementService;
- // Private constructor to enforce Singleton pattern
- private ClientAttestationServiceHolder() {}
-
- /**
- * Returns the singleton instance of the ClientAttestationServiceHolder.
- *
- * @return The singleton instance.
- */
- public static ClientAttestationServiceHolder getInstance() {
+ private static class ClientAttestationHolder {
- return instance;
+ static final ClientAttestationService SERVICE = (ClientAttestationService)
+ PrivilegedCarbonContext.getThreadLocalCarbonContext()
+ .getOSGiService(ClientAttestationService.class, null);
}
- /**
- * Gets the instance of the Client Attestation Service.
- *
- * @return The Client Attestation Service instance.
- */
- public ClientAttestationService getClientAttestationService() {
+ private static class ApplicationManagementHolder {
- return ClientAttestationServiceHolder.getInstance().clientAttestationService;
+ static final ApplicationManagementService SERVICE = (ApplicationManagementService)
+ PrivilegedCarbonContext.getThreadLocalCarbonContext()
+ .getOSGiService(ApplicationManagementService.class, null);
}
/**
- * Sets the instance of the Client Attestation Service.
+ * Gets the instance of the Client Attestation Service.
*
- * @param clientAttestationService The Client Attestation Service instance to set.
+ * @return The Client Attestation Service instance.
*/
- public void setClientAttestationService(ClientAttestationService clientAttestationService) {
+ public static ClientAttestationService getClientAttestationService() {
- ClientAttestationServiceHolder.getInstance().clientAttestationService = clientAttestationService;
+ if (ClientAttestationHolder.SERVICE == null) {
+ throw new IllegalStateException("ClientAttestationService is not available from OSGI context.");
+ }
+ return ClientAttestationHolder.SERVICE;
}
/**
@@ -73,18 +63,11 @@ public void setClientAttestationService(ClientAttestationService clientAttestati
*
* @return The Application Management Service instance.
*/
- public ApplicationManagementService getApplicationManagementService() {
-
- return ClientAttestationServiceHolder.getInstance().applicationManagementService;
- }
-
- /**
- * Sets the instance of the Application Management Service.
- *
- * @param applicationManagementService The Application Management Service instance to set.
- */
- public void setApplicationManagementService(ApplicationManagementService applicationManagementService) {
+ public static ApplicationManagementService getApplicationManagementService() {
- ClientAttestationServiceHolder.getInstance().applicationManagementService = applicationManagementService;
+ if (ApplicationManagementHolder.SERVICE == null) {
+ throw new IllegalStateException("ApplicationManagementService is not available from OSGI context.");
+ }
+ return ApplicationManagementHolder.SERVICE;
}
}
diff --git a/components/org.wso2.carbon.identity.client.attestation.filter/src/main/java/org/wso2/carbon/identity/client/attestation/filter/factory/ApplicationManagementServiceFactory.java b/components/org.wso2.carbon.identity.client.attestation.filter/src/main/java/org/wso2/carbon/identity/client/attestation/filter/factory/ApplicationManagementServiceFactory.java
deleted file mode 100644
index 79e17064f31..00000000000
--- a/components/org.wso2.carbon.identity.client.attestation.filter/src/main/java/org/wso2/carbon/identity/client/attestation/filter/factory/ApplicationManagementServiceFactory.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 2023, 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.client.attestation.filter.factory;
-
-import org.springframework.beans.factory.config.AbstractFactoryBean;
-import org.wso2.carbon.context.PrivilegedCarbonContext;
-import org.wso2.carbon.identity.application.mgt.ApplicationManagementService;
-
-/**
- * Factory Beans serves as a factory for creating other beans within the IOC container. This factory bean is used to
- * instantiate the ApplicationManagementService type of object inside the container.
- */
-public class ApplicationManagementServiceFactory extends AbstractFactoryBean {
-
- public ApplicationManagementService applicationManagementService;
-
-
- @Override
- public Class getObjectType() {
-
- return ApplicationManagementService.class;
- }
-
- @Override
- protected ApplicationManagementService createInstance() throws Exception {
-
- if (this.applicationManagementService != null) {
- return this.applicationManagementService;
- } else {
- ApplicationManagementService applicationManagementService =
- (ApplicationManagementService) PrivilegedCarbonContext
- .getThreadLocalCarbonContext().getOSGiService(ApplicationManagementService.class, null);
- if (applicationManagementService != null) {
- this.applicationManagementService = applicationManagementService;
- }
- return applicationManagementService;
- }
- }
-}
diff --git a/components/org.wso2.carbon.identity.client.attestation.filter/src/main/java/org/wso2/carbon/identity/client/attestation/filter/factory/ClientAttestationServiceFactory.java b/components/org.wso2.carbon.identity.client.attestation.filter/src/main/java/org/wso2/carbon/identity/client/attestation/filter/factory/ClientAttestationServiceFactory.java
deleted file mode 100644
index 517da3f082d..00000000000
--- a/components/org.wso2.carbon.identity.client.attestation.filter/src/main/java/org/wso2/carbon/identity/client/attestation/filter/factory/ClientAttestationServiceFactory.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2023, 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.client.attestation.filter.factory;
-
-import org.springframework.beans.factory.config.AbstractFactoryBean;
-import org.wso2.carbon.context.PrivilegedCarbonContext;
-import org.wso2.carbon.identity.client.attestation.mgt.services.ClientAttestationService;
-
-/**
- * Factory Beans serves as a factory for creating other beans within the IOC container. This factory bean is used to
- * instantiate the ClientAttestationService type of object inside the container.
- */
-public class ClientAttestationServiceFactory extends AbstractFactoryBean {
-
- public ClientAttestationService clientAttestationService;
-
- @Override
- public Class getObjectType() {
-
- return ClientAttestationService.class;
- }
-
- @Override
- protected ClientAttestationService createInstance() throws Exception {
-
- if (this.clientAttestationService != null) {
- return this.clientAttestationService;
- } else {
- ClientAttestationService clientAttestationService = (ClientAttestationService) PrivilegedCarbonContext
- .getThreadLocalCarbonContext().getOSGiService(ClientAttestationService.class, null);
- if (clientAttestationService != null) {
- this.clientAttestationService = clientAttestationService;
- }
- return clientAttestationService;
- }
- }
-}
diff --git a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/org.wso2.carbon.identity.oauth.endpoint/src/main/webapp/WEB-INF/cxf-servlet.xml
index 912d5458a4e..4c5a34b03d9 100644
--- a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/webapp/WEB-INF/cxf-servlet.xml
+++ b/components/org.wso2.carbon.identity.oauth.endpoint/src/main/webapp/WEB-INF/cxf-servlet.xml
@@ -68,8 +68,6 @@
-
-
From d73a48a228ed6a290b1f9608cb7489fe7f61059a Mon Sep 17 00:00:00 2001
From: Lashini Jayasekara <30428591+lashinijay@users.noreply.github.com>
Date: Tue, 7 Jan 2025 12:18:08 +0530
Subject: [PATCH 2/8] [Spring Cleanup] Remove spring dependency in client authn
filter (#2656)
---
.../pom.xml | 5 ---
.../filter/OAuthClientAuthenticatorProxy.java | 16 +-------
.../OAuthClientAuthnServiceFactory.java | 38 ++++++++-----------
3 files changed, 17 insertions(+), 42 deletions(-)
diff --git a/components/org.wso2.carbon.identity.oauth.client.authn.filter/pom.xml b/components/org.wso2.carbon.identity.oauth.client.authn.filter/pom.xml
index 6e0d59371c2..7df7b8e965f 100644
--- a/components/org.wso2.carbon.identity.oauth.client.authn.filter/pom.xml
+++ b/components/org.wso2.carbon.identity.oauth.client.authn.filter/pom.xml
@@ -45,11 +45,6 @@
org.wso2.carbon.identity.inbound.auth.oauth2
org.wso2.carbon.identity.oauth
-
- org.springframework
- spring-web
- provided
-
diff --git a/components/org.wso2.carbon.identity.oauth.client.authn.filter/src/main/java/org/wso2/carbon/identity/oauth/client/authn/filter/OAuthClientAuthenticatorProxy.java b/components/org.wso2.carbon.identity.oauth.client.authn.filter/src/main/java/org/wso2/carbon/identity/oauth/client/authn/filter/OAuthClientAuthenticatorProxy.java
index cad84aadd7f..d1229ed2296 100644
--- a/components/org.wso2.carbon.identity.oauth.client.authn.filter/src/main/java/org/wso2/carbon/identity/oauth/client/authn/filter/OAuthClientAuthenticatorProxy.java
+++ b/components/org.wso2.carbon.identity.oauth.client.authn.filter/src/main/java/org/wso2/carbon/identity/oauth/client/authn/filter/OAuthClientAuthenticatorProxy.java
@@ -30,7 +30,6 @@
import org.wso2.carbon.identity.oauth.common.OAuth2ErrorCodes;
import org.wso2.carbon.identity.oauth.common.OAuthConstants;
import org.wso2.carbon.identity.oauth2.bean.OAuthClientAuthnContext;
-import org.wso2.carbon.identity.oauth2.client.authentication.OAuthClientAuthnService;
import java.util.Arrays;
import java.util.HashMap;
@@ -51,7 +50,6 @@ public class OAuthClientAuthenticatorProxy extends AbstractPhaseInterceptor PROXY_ENDPOINT_LIST = Arrays.asList("/oauth2/token", "/oauth2/revoke",
"/oauth2/device_authorize", "/oauth2/ciba", "/oauth2/par", "/oauth2/authorize");
- private OAuthClientAuthnService oAuthClientAuthnService;
private static final String SLASH = "/";
public OAuthClientAuthenticatorProxy() {
@@ -60,16 +58,6 @@ public OAuthClientAuthenticatorProxy() {
super(Phase.PRE_INVOKE);
}
- public OAuthClientAuthnService getOAuthClientAuthnService() {
-
- return oAuthClientAuthnService;
- }
-
- public void setOAuthClientAuthnService(OAuthClientAuthnService oAuthClientAuthnService) {
-
- this.oAuthClientAuthnService = oAuthClientAuthnService;
- }
-
/**
* Handles the incoming JAX-RS message for the purpose of OAuth2 client authentication.
*
@@ -82,8 +70,8 @@ public void handleMessage(Message message) {
HttpServletRequest request = ((HttpServletRequest) message.get(HTTP_REQUEST));
if (canHandle(message)) {
try {
- OAuthClientAuthnContext oAuthClientAuthnContext = oAuthClientAuthnService
- .authenticateClient(request, bodyContentParams);
+ OAuthClientAuthnContext oAuthClientAuthnContext = OAuthClientAuthnServiceFactory
+ .getOAuthClientAuthnService().authenticateClient(request, bodyContentParams);
if (!oAuthClientAuthnContext.isPreviousAuthenticatorEngaged()) {
/* If the previous authenticator is not engaged it means that either client authentication
flow failed or no supported authenticaiton mechanism was found.If the error details are already
diff --git a/components/org.wso2.carbon.identity.oauth.client.authn.filter/src/main/java/org/wso2/carbon/identity/oauth/client/authn/filter/OAuthClientAuthnServiceFactory.java b/components/org.wso2.carbon.identity.oauth.client.authn.filter/src/main/java/org/wso2/carbon/identity/oauth/client/authn/filter/OAuthClientAuthnServiceFactory.java
index 8cf4955e76d..8bb57472b36 100644
--- a/components/org.wso2.carbon.identity.oauth.client.authn.filter/src/main/java/org/wso2/carbon/identity/oauth/client/authn/filter/OAuthClientAuthnServiceFactory.java
+++ b/components/org.wso2.carbon.identity.oauth.client.authn.filter/src/main/java/org/wso2/carbon/identity/oauth/client/authn/filter/OAuthClientAuthnServiceFactory.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
@@ -18,37 +18,29 @@
package org.wso2.carbon.identity.oauth.client.authn.filter;
-import org.springframework.beans.factory.config.AbstractFactoryBean;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.identity.oauth2.client.authentication.OAuthClientAuthnService;
/**
- * Factory Beans serves as a factory for creating other beans within the IOC container. This factory bean is used to
- * instantiate the OAuthClientAuthnService type of object inside the container.
+ * Factory class to get OAuthClientAuthnService OSGI service.
*/
-public class OAuthClientAuthnServiceFactory extends AbstractFactoryBean {
+public class OAuthClientAuthnServiceFactory {
- public OAuthClientAuthnService oAuthClientAuthnService;
+ private static final OAuthClientAuthnService SERVICE;
+ static {
+ OAuthClientAuthnService oAuthClientAuthnService = (OAuthClientAuthnService) PrivilegedCarbonContext
+ .getThreadLocalCarbonContext().getOSGiService(OAuthClientAuthnService.class, null);
- @Override
- public Class getObjectType() {
+ if (oAuthClientAuthnService == null) {
+ throw new IllegalStateException("OAuthClientAuthnService is not available from OSGI context.");
+ }
- return OAuthClientAuthnService.class;
+ SERVICE = oAuthClientAuthnService;
}
- @Override
- protected OAuthClientAuthnService createInstance() throws Exception {
-
- if (this.oAuthClientAuthnService != null) {
- return this.oAuthClientAuthnService;
- } else {
- OAuthClientAuthnService oAuthClientAuthnService = (OAuthClientAuthnService) PrivilegedCarbonContext
- .getThreadLocalCarbonContext().getOSGiService(OAuthClientAuthnService.class, null);
- if (oAuthClientAuthnService != null) {
- this.oAuthClientAuthnService = oAuthClientAuthnService;
- }
- return oAuthClientAuthnService;
- }
+ public static OAuthClientAuthnService getOAuthClientAuthnService() {
+
+ return SERVICE;
}
}
From dde81abad73574aa09ef278125b7e7661bb84074 Mon Sep 17 00:00:00 2001
From: Lashini Jayasekara <30428591+lashinijay@users.noreply.github.com>
Date: Wed, 8 Jan 2025 14:02:35 +0530
Subject: [PATCH 3/8] [Spring Cleanup] Remove Spring dependency from oauth
component (#2648)
* remove spring dependency from oauth2 components
* fix formattings and unit tests
---
.../pom.xml | 7 +-
.../endpoint/authz/OAuth2AuthzEndpoint.java | 56 +--
.../authz/OAuth2AuthzServiceFactory.java | 44 +++
.../endpoint/ciba/OAuth2CibaEndpoint.java | 5 +-
.../oauth/endpoint/device/DeviceEndpoint.java | 10 +-
.../endpoint/device/DeviceServiceFactory.java | 45 +++
.../device/UserAuthenticationEndpoint.java | 11 +-
.../endpoint/factory/CibaServiceFactory.java | 54 ---
.../factory/DeviceAuthServiceFactory.java | 53 ---
.../endpoint/factory/IDPManagerFactory.java | 53 ---
.../factory/OAuth2ScopeServiceFactory.java | 53 ---
.../factory/OAuth2ServiceFactory.java | 53 ---
.../factory/OAuthAdminServiceFactory.java | 53 ---
.../OAuthServerConfigurationFactory.java | 53 ---
.../OpenIDConnectClaimFilterFactory.java | 55 ---
.../endpoint/factory/ParServiceFactory.java | 52 ---
.../factory/RequestObjectServiceFactory.java | 53 ---
.../factory/SSOConsentServiceFactory.java | 53 ---
.../oidcdiscovery/OIDCDiscoveryEndpoint.java | 18 +-
.../OIDCDiscoveryServiceFactory.java | 44 +++
.../oauth/endpoint/par/OAuth2ParEndpoint.java | 4 +-
.../revoke/OAuthRevocationEndpoint.java | 2 +-
.../state/OAuthRequestStateValidator.java | 2 +-
.../endpoint/token/OAuth2TokenEndpoint.java | 3 +-
.../impl/UserInfoISAccessTokenValidator.java | 5 +-
.../oauth/endpoint/util/EndpointUtil.java | 221 ++---------
.../util/factory/CibaAuthServiceFactory.java | 46 +++
.../factory/IdpManagerServiceFactory.java | 45 +++
.../util/factory/OAuth2ServiceFactory.java | 45 +++
.../OAuth2TokenValidatorServiceFactory.java | 46 +++
.../factory/OAuthAdminServiceFactory.java | 46 +++
.../OAuthServerConfigurationFactory.java | 45 +++
.../OIDCProviderRequestValidatorFactory.java | 46 +++
.../factory/OIDCProviderServiceFactory.java | 46 +++
.../factory/Oauth2ScopeServiceFactory.java | 45 +++
.../util/factory/ParAuthServiceFactory.java | 45 +++
.../factory/RequestObjectServiceFactory.java | 45 +++
.../factory/SSOConsentServiceFactory.java | 45 +++
.../factory/ScopeMetadataServiceFactory.java} | 56 +--
.../util/factory/WebFingerServiceFactory.java | 46 +++
.../src/main/webapp/WEB-INF/web.xml | 37 +-
.../authz/OAuth2AuthzEndpointTest.java | 301 +++++++++++----
.../endpoint/ciba/OAuth2CibaEndpointTest.java | 68 +++-
.../endpoint/device/DeviceEndpointTest.java | 39 +-
.../UserAuthenticationEndpointTest.java | 34 +-
.../OIDCDiscoveryEndpointTest.java | 88 ++++-
.../endpoint/par/OAuth2ParEndpointTest.java | 50 ++-
.../revoke/OAuthRevocationEndpointTest.java | 47 ++-
.../token/OAuth2TokenEndpointTest.java | 49 ++-
.../UserInfoISAccessTokenValidatorTest.java | 67 +++-
.../impl/UserInfoJSONResponseBuilderTest.java | 350 +++++++++---------
.../oauth/endpoint/util/EndpointUtilTest.java | 203 ++++++----
52 files changed, 1725 insertions(+), 1317 deletions(-)
create mode 100644 components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/authz/OAuth2AuthzServiceFactory.java
create mode 100644 components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/device/DeviceServiceFactory.java
delete mode 100644 components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/factory/CibaServiceFactory.java
delete mode 100644 components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/factory/DeviceAuthServiceFactory.java
delete mode 100644 components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/factory/IDPManagerFactory.java
delete mode 100644 components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/factory/OAuth2ScopeServiceFactory.java
delete mode 100644 components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/factory/OAuth2ServiceFactory.java
delete mode 100644 components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/factory/OAuthAdminServiceFactory.java
delete mode 100644 components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/factory/OAuthServerConfigurationFactory.java
delete mode 100644 components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/factory/OpenIDConnectClaimFilterFactory.java
delete mode 100644 components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/factory/ParServiceFactory.java
delete mode 100644 components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/factory/RequestObjectServiceFactory.java
delete mode 100644 components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/factory/SSOConsentServiceFactory.java
create mode 100644 components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/oidcdiscovery/OIDCDiscoveryServiceFactory.java
create mode 100644 components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/util/factory/CibaAuthServiceFactory.java
create mode 100644 components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/util/factory/IdpManagerServiceFactory.java
create mode 100644 components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/util/factory/OAuth2ServiceFactory.java
create mode 100644 components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/util/factory/OAuth2TokenValidatorServiceFactory.java
create mode 100644 components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/util/factory/OAuthAdminServiceFactory.java
create mode 100644 components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/util/factory/OAuthServerConfigurationFactory.java
create mode 100644 components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/util/factory/OIDCProviderRequestValidatorFactory.java
create mode 100644 components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/util/factory/OIDCProviderServiceFactory.java
create mode 100644 components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/util/factory/Oauth2ScopeServiceFactory.java
create mode 100644 components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/util/factory/ParAuthServiceFactory.java
create mode 100644 components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/util/factory/RequestObjectServiceFactory.java
create mode 100644 components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/util/factory/SSOConsentServiceFactory.java
rename components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/{factory/ScopeServiceFactory.java => util/factory/ScopeMetadataServiceFactory.java} (70%)
create mode 100644 components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/util/factory/WebFingerServiceFactory.java
diff --git a/components/org.wso2.carbon.identity.oauth.endpoint/pom.xml b/components/org.wso2.carbon.identity.oauth.endpoint/pom.xml
index 1c4f3c90e4a..2d5a0beb41f 100644
--- a/components/org.wso2.carbon.identity.oauth.endpoint/pom.xml
+++ b/components/org.wso2.carbon.identity.oauth.endpoint/pom.xml
@@ -169,11 +169,6 @@
org.wso2.carbon.identity.client.attestation.filter
provided
-
- org.springframework
- spring-web
- provided
-
com.fasterxml.jackson.core
jackson-databind
@@ -331,7 +326,7 @@
COMPLEXITY
COVEREDRATIO
- 0.48
+ 0.47
diff --git a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/authz/OAuth2AuthzEndpoint.java b/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/authz/OAuth2AuthzEndpoint.java
index c6724c68cdb..b12082cac57 100644
--- a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/authz/OAuth2AuthzEndpoint.java
+++ b/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/authz/OAuth2AuthzEndpoint.java
@@ -136,7 +136,6 @@
import org.wso2.carbon.identity.oauth2.model.OAuth2Parameters;
import org.wso2.carbon.identity.oauth2.responsemode.provider.AuthorizationResponseDTO;
import org.wso2.carbon.identity.oauth2.responsemode.provider.ResponseModeProvider;
-import org.wso2.carbon.identity.oauth2.scopeservice.ScopeMetadataService;
import org.wso2.carbon.identity.oauth2.token.bindings.TokenBinder;
import org.wso2.carbon.identity.oauth2.util.OAuth2Util;
import org.wso2.carbon.identity.oauth2.util.RequestUtil;
@@ -144,7 +143,6 @@
import org.wso2.carbon.identity.oidc.session.util.OIDCSessionManagementUtil;
import org.wso2.carbon.identity.openidconnect.OIDCConstants;
import org.wso2.carbon.identity.openidconnect.OIDCRequestObjectUtil;
-import org.wso2.carbon.identity.openidconnect.OpenIDConnectClaimFilterImpl;
import org.wso2.carbon.identity.openidconnect.model.RequestObject;
import org.wso2.carbon.identity.openidconnect.model.RequestedClaim;
import org.wso2.carbon.utils.CarbonUtils;
@@ -211,12 +209,13 @@
import static org.wso2.carbon.identity.oauth.endpoint.state.OAuthAuthorizeState.USER_CONSENT_RESPONSE;
import static org.wso2.carbon.identity.oauth.endpoint.util.EndpointUtil.getErrorPageURL;
import static org.wso2.carbon.identity.oauth.endpoint.util.EndpointUtil.getLoginPageURL;
-import static org.wso2.carbon.identity.oauth.endpoint.util.EndpointUtil.getOAuth2Service;
import static org.wso2.carbon.identity.oauth.endpoint.util.EndpointUtil.getOAuthAuthzRequest;
-import static org.wso2.carbon.identity.oauth.endpoint.util.EndpointUtil.getOAuthServerConfiguration;
-import static org.wso2.carbon.identity.oauth.endpoint.util.EndpointUtil.getSSOConsentService;
import static org.wso2.carbon.identity.oauth.endpoint.util.EndpointUtil.retrieveStateForErrorURL;
import static org.wso2.carbon.identity.oauth.endpoint.util.EndpointUtil.validateParams;
+import static org.wso2.carbon.identity.oauth.endpoint.util.factory.OAuth2ServiceFactory.getOAuth2Service;
+import static org.wso2.carbon.identity.oauth.endpoint.util.factory.OAuthServerConfigurationFactory.getOAuthServerConfiguration;
+import static org.wso2.carbon.identity.oauth.endpoint.util.factory.RequestObjectServiceFactory.getRequestObjectService;
+import static org.wso2.carbon.identity.oauth.endpoint.util.factory.SSOConsentServiceFactory.getSSOConsentService;
import static org.wso2.carbon.identity.oauth2.OAuth2Constants.TokenBinderType.CLIENT_REQUEST;
import static org.wso2.carbon.identity.oauth2.util.OAuth2Util.ACCESS_TOKEN_JS_OBJECT;
import static org.wso2.carbon.identity.oauth2.util.OAuth2Util.DYNAMIC_TOKEN_DATA_FUNCTION;
@@ -276,37 +275,11 @@ public class OAuth2AuthzEndpoint {
private static final String OIDC_DIALECT = "http://wso2.org/oidc/claim";
- private static OpenIDConnectClaimFilterImpl openIDConnectClaimFilter;
-
- private static ScopeMetadataService scopeMetadataService;
-
private static DeviceAuthService deviceAuthService;
private static final String AUTH_SERVICE_RESPONSE = "authServiceResponse";
private static final String IS_API_BASED_AUTH_HANDLED = "isApiBasedAuthHandled";
private static final ApiAuthnHandler API_AUTHN_HANDLER = new ApiAuthnHandler();
- public static OpenIDConnectClaimFilterImpl getOpenIDConnectClaimFilter() {
-
- return openIDConnectClaimFilter;
- }
-
- public static void setOpenIDConnectClaimFilter(OpenIDConnectClaimFilterImpl openIDConnectClaimFilter) {
-
- OAuth2AuthzEndpoint.openIDConnectClaimFilter = openIDConnectClaimFilter;
- }
-
- public static ScopeMetadataService getScopeMetadataService() {
-
- return scopeMetadataService;
- }
-
- public static void setScopeMetadataService(ScopeMetadataService scopeMetadataService) {
-
- OAuth2AuthzEndpoint.scopeMetadataService = scopeMetadataService;
- }
-
- private static Class extends OAuthAuthzRequest> oAuthAuthzRequestClass;
-
@GET
@Path("/")
@Consumes("application/x-www-form-urlencoded")
@@ -1005,9 +978,11 @@ private ConsentClaimsData getConsentRequiredClaims(AuthenticatedUser user, Servi
if (hasPromptContainsConsent(oAuth2Parameters)) {
// Ignore all previous consents and get consent required claims
- return getSSOConsentService().getConsentRequiredClaimsWithoutExistingConsents(serviceProvider, user);
+ return getSSOConsentService().getConsentRequiredClaimsWithoutExistingConsents(
+ serviceProvider, user);
} else {
- return getSSOConsentService().getConsentRequiredClaimsWithExistingConsents(serviceProvider, user);
+ return getSSOConsentService().getConsentRequiredClaimsWithExistingConsents(
+ serviceProvider, user);
}
}
@@ -1147,7 +1122,7 @@ private void handleDeniedConsent(OAuthMessage oAuthMessage, AuthorizationRespons
getOauth2Params(oAuthMessage).getApplicationName(), false,
oauth2Params.getClientId());
- OAuthErrorDTO oAuthErrorDTO = EndpointUtil.getOAuth2Service().handleUserConsentDenial(oauth2Params);
+ OAuthErrorDTO oAuthErrorDTO = getOAuth2Service().handleUserConsentDenial(oauth2Params);
OAuthProblemException consentDenialException = buildConsentDenialException(oAuthErrorDTO);
if (ResponseModeProvider.AuthResponseType.POST_RESPONSE.equals(responseModeProvider.getAuthResponseType())) {
@@ -1384,7 +1359,7 @@ private Response handleFailedAuthentication(OAuthMessage oAuthMessage, OAuth2Par
AuthorizationResponseDTO authorizationResponseDTO)
throws URISyntaxException {
- OAuthErrorDTO oAuthErrorDTO = EndpointUtil.getOAuth2Service().handleAuthenticationFailure(oauth2Params);
+ OAuthErrorDTO oAuthErrorDTO = getOAuth2Service().handleAuthenticationFailure(oauth2Params);
OAuthProblemException oauthException = buildOAuthProblemException(authnResult, oAuthErrorDTO);
return handleFailedState(oAuthMessage, oauth2Params, oauthException, authorizationResponseDTO);
}
@@ -2355,9 +2330,9 @@ private void persistRequestObject(OAuth2Parameters params, RequestObject request
throws RequestObjectException {
String sessionDataKey = params.getSessionDataKey();
- if (EndpointUtil.getRequestObjectService() != null) {
+ if (getRequestObjectService() != null) {
if (requestObject != null && MapUtils.isNotEmpty(requestObject.getRequestedClaims())) {
- EndpointUtil.getRequestObjectService().addRequestObject(params.getClientId(), sessionDataKey,
+ getRequestObjectService().addRequestObject(params.getClientId(), sessionDataKey,
new ArrayList(requestObject.getRequestedClaims().values()));
params.setRequestObjectFlow(true);
}
@@ -3443,16 +3418,17 @@ private List getRequestedOidcClaimsList(ConsentClaimsData claimsF
// Get the claims uri list of all the requested scopes. Eg:- country, email.
List claimListOfScopes =
- openIDConnectClaimFilter.getClaimsFilteredByOIDCScopes(oauth2Params.getScopes(), spTenantDomain);
+ OAuth2AuthzServiceFactory.getOpenIdClaimFilterImpl().getClaimsFilteredByOIDCScopes(
+ oauth2Params.getScopes(), spTenantDomain);
List essentialRequestedClaims = new ArrayList<>();
if (oauth2Params.isRequestObjectFlow()) {
// Get the requested claims came through request object.
- List requestedClaimsOfIdToken = EndpointUtil.getRequestObjectService()
+ List requestedClaimsOfIdToken = getRequestObjectService()
.getRequestedClaimsForSessionDataKey(oauth2Params.getSessionDataKey(), false);
- List requestedClaimsOfUserInfo = EndpointUtil.getRequestObjectService()
+ List requestedClaimsOfUserInfo = getRequestObjectService()
.getRequestedClaimsForSessionDataKey(oauth2Params.getSessionDataKey(), true);
diff --git a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/authz/OAuth2AuthzServiceFactory.java b/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/authz/OAuth2AuthzServiceFactory.java
new file mode 100644
index 00000000000..661e12843aa
--- /dev/null
+++ b/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/authz/OAuth2AuthzServiceFactory.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 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.oauth.endpoint.authz;
+
+import org.wso2.carbon.context.PrivilegedCarbonContext;
+import org.wso2.carbon.identity.openidconnect.OpenIDConnectClaimFilterImpl;
+
+/**
+ * Service holder for managing instances of OAuth2 Authorization related services.
+ */
+public class OAuth2AuthzServiceFactory {
+
+ private static final OpenIDConnectClaimFilterImpl SERVICE;
+
+ static {
+ OpenIDConnectClaimFilterImpl openIDConnectClaimFilter = (OpenIDConnectClaimFilterImpl) PrivilegedCarbonContext
+ .getThreadLocalCarbonContext().getOSGiService(OpenIDConnectClaimFilterImpl.class, null);
+ if (openIDConnectClaimFilter == null) {
+ throw new IllegalStateException("OpenIDConnectClaimFilterImpl is not available from OSGi context.");
+ }
+ SERVICE = openIDConnectClaimFilter;
+ }
+
+ public static OpenIDConnectClaimFilterImpl getOpenIdClaimFilterImpl() {
+
+ return SERVICE;
+ }
+}
diff --git a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/ciba/OAuth2CibaEndpoint.java b/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/ciba/OAuth2CibaEndpoint.java
index e1da2d43456..c8d409a976c 100644
--- a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/ciba/OAuth2CibaEndpoint.java
+++ b/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/ciba/OAuth2CibaEndpoint.java
@@ -35,7 +35,7 @@
import org.wso2.carbon.identity.oauth.endpoint.OAuthRequestWrapper;
import org.wso2.carbon.identity.oauth.endpoint.exception.CibaAuthFailureException;
import org.wso2.carbon.identity.oauth.endpoint.exception.InvalidRequestException;
-import org.wso2.carbon.identity.oauth.endpoint.util.EndpointUtil;
+import org.wso2.carbon.identity.oauth.endpoint.util.factory.CibaAuthServiceFactory;
import org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception;
import org.wso2.carbon.identity.oauth2.RequestObjectException;
import org.wso2.carbon.identity.oauth2.bean.OAuthClientAuthnContext;
@@ -161,7 +161,8 @@ private CibaAuthCodeResponse getCibaAuthCodeResponse(CibaAuthCodeRequest cibaAut
throws CibaAuthFailureException {
try {
- cibaAuthCodeResponse = EndpointUtil.getCibaAuthService().generateAuthCodeResponse(cibaAuthCodeRequest);
+ cibaAuthCodeResponse = CibaAuthServiceFactory.getCibaAuthService()
+ .generateAuthCodeResponse(cibaAuthCodeRequest);
} catch (CibaCoreException | CibaClientException e) {
throw new CibaAuthFailureException(OAuth2ErrorCodes.SERVER_ERROR, "Error while generating " +
"authentication response.", e);
diff --git a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/device/DeviceEndpoint.java b/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/device/DeviceEndpoint.java
index e3d0d8b4199..79d577d33bd 100644
--- a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/device/DeviceEndpoint.java
+++ b/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/device/DeviceEndpoint.java
@@ -37,7 +37,6 @@
import org.wso2.carbon.identity.oauth.endpoint.util.EndpointUtil;
import org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception;
import org.wso2.carbon.identity.oauth2.bean.OAuthClientAuthnContext;
-import org.wso2.carbon.identity.oauth2.device.api.DeviceAuthService;
import org.wso2.carbon.identity.oauth2.device.codegenerator.GenerateKeys;
import org.wso2.carbon.identity.oauth2.device.constants.Constants;
import org.wso2.carbon.identity.oauth2.device.util.DeviceFlowUtil;
@@ -61,12 +60,6 @@
@InInterceptors(classes = OAuthClientAuthenticatorProxy.class)
public class DeviceEndpoint {
private static final Log log = LogFactory.getLog(DeviceEndpoint.class);
- private DeviceAuthService deviceAuthService;
-
- public void setDeviceAuthService(DeviceAuthService deviceAuthService) {
-
- this.deviceAuthService = deviceAuthService;
- }
@POST
@Path("/")
@@ -108,7 +101,8 @@ private String getUniqueUserCode(String deviceCode, String clientId, String scop
String temporaryUserCode = GenerateKeys.getKey(OAuthServerConfiguration.getInstance().getDeviceCodeKeyLength());
long quantifier = GenerateKeys.getCurrentQuantifier();
- return deviceAuthService.generateDeviceResponse(deviceCode, temporaryUserCode, quantifier, clientId, scopes);
+ return DeviceServiceFactory.getDeviceAuthService().generateDeviceResponse(deviceCode, temporaryUserCode,
+ quantifier, clientId, scopes);
}
private void validateRepeatedParams(HttpServletRequest request, MultivaluedMap paramMap)
diff --git a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/device/DeviceServiceFactory.java b/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/device/DeviceServiceFactory.java
new file mode 100644
index 00000000000..f6bb6170ac9
--- /dev/null
+++ b/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/device/DeviceServiceFactory.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 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.oauth.endpoint.device;
+
+import org.wso2.carbon.context.PrivilegedCarbonContext;
+import org.wso2.carbon.identity.oauth2.device.api.DeviceAuthService;
+import org.wso2.carbon.identity.oauth2.device.api.DeviceAuthServiceImpl;
+
+/**
+ * Service holder for managing instances of Device Authentication related services.
+ */
+public class DeviceServiceFactory {
+
+ private static final DeviceAuthServiceImpl SERVICE;
+
+ static {
+ DeviceAuthServiceImpl deviceAuthService = (DeviceAuthServiceImpl) PrivilegedCarbonContext
+ .getThreadLocalCarbonContext().getOSGiService(DeviceAuthServiceImpl.class, null);
+ if (deviceAuthService == null) {
+ throw new IllegalStateException("DeviceAuthService is not available from OSGi context.");
+ }
+ SERVICE = deviceAuthService;
+ }
+
+ public static DeviceAuthService getDeviceAuthService() {
+
+ return SERVICE;
+ }
+}
diff --git a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/device/UserAuthenticationEndpoint.java b/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/device/UserAuthenticationEndpoint.java
index 127a7aa3105..afff573f89c 100644
--- a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/device/UserAuthenticationEndpoint.java
+++ b/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/device/UserAuthenticationEndpoint.java
@@ -33,7 +33,6 @@
import org.wso2.carbon.identity.oauth.endpoint.exception.InvalidRequestParentException;
import org.wso2.carbon.identity.oauth.endpoint.util.EndpointUtil;
import org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception;
-import org.wso2.carbon.identity.oauth2.device.api.DeviceAuthService;
import org.wso2.carbon.identity.oauth2.device.constants.Constants;
import org.wso2.carbon.identity.oauth2.device.dao.DeviceFlowPersistenceFactory;
import org.wso2.carbon.identity.oauth2.device.model.DeviceFlowDO;
@@ -63,12 +62,6 @@ public class UserAuthenticationEndpoint {
public static final String INVALID_CODE_ERROR_KEY = "invalid.code";
private OAuth2AuthzEndpoint oAuth2AuthzEndpoint = new OAuth2AuthzEndpoint();
private DeviceFlowDO deviceFlowDO = new DeviceFlowDO();
- private DeviceAuthService deviceAuthService;
-
- public void setDeviceAuthService(DeviceAuthService deviceAuthService) {
-
- this.deviceAuthService = deviceAuthService;
- }
@POST
@Path("/")
@@ -89,10 +82,10 @@ public Response deviceAuthorize(@Context HttpServletRequest request, @Context Ht
return Response.status(HttpServletResponse.SC_FOUND).location(URI.create(error)).build();
}
DeviceFlowDO deviceFlowDODetails =
- deviceAuthService.getDetailsByUserCode(userCode);
+ DeviceServiceFactory.getDeviceAuthService().getDetailsByUserCode(userCode);
if (!isExpiredUserCode(deviceFlowDODetails)) {
String clientId = deviceFlowDODetails.getConsumerKey();
- deviceAuthService.setAuthenticationStatus(userCode);
+ DeviceServiceFactory.getDeviceAuthService().setAuthenticationStatus(userCode);
CommonAuthRequestWrapper commonAuthRequestWrapper = new CommonAuthRequestWrapper(request);
commonAuthRequestWrapper.setParameter(Constants.CLIENT_ID, clientId);
commonAuthRequestWrapper.setParameter(Constants.RESPONSE_TYPE, Constants.RESPONSE_TYPE_DEVICE);
diff --git a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/factory/CibaServiceFactory.java b/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/factory/CibaServiceFactory.java
deleted file mode 100644
index a46e71617de..00000000000
--- a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/factory/CibaServiceFactory.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2019, 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.oauth.endpoint.factory;
-
-import org.springframework.beans.factory.config.AbstractFactoryBean;
-import org.wso2.carbon.context.PrivilegedCarbonContext;
-import org.wso2.carbon.identity.oauth.ciba.api.CibaAuthService;
-import org.wso2.carbon.identity.oauth.ciba.api.CibaAuthServiceImpl;
-
-/**
- * This class is used to register CibaAuthService as a factory bean.
- */
-public class CibaServiceFactory extends AbstractFactoryBean {
-
- private CibaAuthServiceImpl cibaAuthService;
-
- @Override
- public Class getObjectType() {
-
- return CibaAuthServiceImpl.class;
- }
-
- @Override
- protected CibaAuthServiceImpl createInstance() throws Exception {
-
- if (cibaAuthService != null) {
- return cibaAuthService;
- } else {
- CibaAuthServiceImpl cibaAuthService = (CibaAuthServiceImpl)
- PrivilegedCarbonContext.getThreadLocalCarbonContext().
- getOSGiService(CibaAuthService.class, null);
- if (cibaAuthService != null) {
- this.cibaAuthService = cibaAuthService;
- }
- return cibaAuthService;
- }
- }
-}
diff --git a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/factory/DeviceAuthServiceFactory.java b/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/factory/DeviceAuthServiceFactory.java
deleted file mode 100644
index e3c737bcb37..00000000000
--- a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/factory/DeviceAuthServiceFactory.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 2019, 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.oauth.endpoint.factory;
-
-import org.springframework.beans.factory.config.AbstractFactoryBean;
-import org.wso2.carbon.context.PrivilegedCarbonContext;
-import org.wso2.carbon.identity.oauth2.device.api.DeviceAuthService;
-
-/**
- * This class is used to register DeviceAuthService as a factory bean.
- */
-public class DeviceAuthServiceFactory extends AbstractFactoryBean {
-
- private DeviceAuthService deviceAuthService;
-
- @Override
- public Class getObjectType() {
-
- return DeviceAuthService.class;
- }
-
- @Override
- protected DeviceAuthService createInstance() throws Exception {
-
- if (this.deviceAuthService != null) {
- return this.deviceAuthService;
- } else {
- DeviceAuthService deviceAuthService = (DeviceAuthService)
- PrivilegedCarbonContext.getThreadLocalCarbonContext().
- getOSGiService(DeviceAuthService.class, null);
- if (deviceAuthService != null) {
- this.deviceAuthService = deviceAuthService;
- }
- return deviceAuthService;
- }
- }
-}
diff --git a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/factory/IDPManagerFactory.java b/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/factory/IDPManagerFactory.java
deleted file mode 100644
index a91b038495e..00000000000
--- a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/factory/IDPManagerFactory.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 2021, 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.oauth.endpoint.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 IDP Management service type of object inside the container.
- */
-public class IDPManagerFactory extends AbstractFactoryBean {
-
- private IdpManager idpManager;
-
- @Override
- public Class getObjectType() {
-
- return IdpManager.class;
- }
-
- @Override
- protected IdpManager createInstance() throws Exception {
-
- if (this.idpManager != null) {
- return idpManager;
- } else {
- IdpManager idpManager = (IdpManager) PrivilegedCarbonContext.getThreadLocalCarbonContext()
- .getOSGiService(IdpManager.class, null);
- if (idpManager != null) {
- this.idpManager = idpManager;
- }
- return idpManager;
- }
- }
-}
diff --git a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/factory/OAuth2ScopeServiceFactory.java b/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/factory/OAuth2ScopeServiceFactory.java
deleted file mode 100644
index 6cc13c943ec..00000000000
--- a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/factory/OAuth2ScopeServiceFactory.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 2021, 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.oauth.endpoint.factory;
-
-import org.springframework.beans.factory.config.AbstractFactoryBean;
-import org.wso2.carbon.context.PrivilegedCarbonContext;
-import org.wso2.carbon.identity.oauth2.OAuth2ScopeService;
-
-/**
- * Factory Beans serves as a factory for creating other beans within the IOC container. This factory bean is used to
- * instantiate the OAuth2ScopeService type of object inside the container.
- */
-public class OAuth2ScopeServiceFactory extends AbstractFactoryBean {
-
- private OAuth2ScopeService oAuth2ScopeService;
-
- @Override
- public Class getObjectType() {
-
- return OAuth2ScopeService.class;
- }
-
- @Override
- protected OAuth2ScopeService createInstance() throws Exception {
-
- if (this.oAuth2ScopeService != null) {
- return this.oAuth2ScopeService;
- } else {
- OAuth2ScopeService oAuth2ScopeService = (OAuth2ScopeService) PrivilegedCarbonContext
- .getThreadLocalCarbonContext().getOSGiService(OAuth2ScopeService.class, null);
- if (oAuth2ScopeService != null) {
- this.oAuth2ScopeService = oAuth2ScopeService;
- }
- return oAuth2ScopeService;
- }
- }
-}
diff --git a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/factory/OAuth2ServiceFactory.java b/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/factory/OAuth2ServiceFactory.java
deleted file mode 100644
index 57b9aabcf01..00000000000
--- a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/factory/OAuth2ServiceFactory.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 2019, 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.oauth.endpoint.factory;
-
-import org.springframework.beans.factory.config.AbstractFactoryBean;
-import org.wso2.carbon.context.PrivilegedCarbonContext;
-import org.wso2.carbon.identity.oauth2.OAuth2Service;
-
-/**
- * Factory Beans serves as a factory for creating other beans within the IOC container. This factory bean is used to
- * instantiate the OAuth2Service type of object inside the container.
- */
-public class OAuth2ServiceFactory extends AbstractFactoryBean {
-
- private OAuth2Service oauth2Service;
-
- @Override
- public Class getObjectType() {
-
- return OAuth2Service.class;
- }
-
- @Override
- protected OAuth2Service createInstance() throws Exception {
-
- if (this.oauth2Service != null) {
- return this.oauth2Service;
- } else {
- OAuth2Service oauth2Service = (OAuth2Service) PrivilegedCarbonContext
- .getThreadLocalCarbonContext().getOSGiService(OAuth2Service.class, null);
- if (oauth2Service != null) {
- this.oauth2Service = oauth2Service;
- }
- return oauth2Service;
- }
- }
-}
diff --git a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/factory/OAuthAdminServiceFactory.java b/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/factory/OAuthAdminServiceFactory.java
deleted file mode 100644
index 0d80643ff15..00000000000
--- a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/factory/OAuthAdminServiceFactory.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 2021, 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.oauth.endpoint.factory;
-
-import org.springframework.beans.factory.config.AbstractFactoryBean;
-import org.wso2.carbon.context.PrivilegedCarbonContext;
-import org.wso2.carbon.identity.oauth.OAuthAdminServiceImpl;
-
-/**
- * Factory Beans serves as a factory for creating other beans within the IOC container. This factory bean is used to
- * instantiate the OAuthAdminService type of object inside the container.
- */
-public class OAuthAdminServiceFactory extends AbstractFactoryBean {
-
- private OAuthAdminServiceImpl oAuthAdminService;
-
- @Override
- public Class getObjectType() {
-
- return OAuthAdminServiceImpl.class;
- }
-
- @Override
- protected OAuthAdminServiceImpl createInstance() throws Exception {
-
- if (this.oAuthAdminService != null) {
- return this.oAuthAdminService;
- } else {
- OAuthAdminServiceImpl oAuthAdminService = (OAuthAdminServiceImpl) PrivilegedCarbonContext
- .getThreadLocalCarbonContext().getOSGiService(OAuthAdminServiceImpl.class, null);
- if (oAuthAdminService != null) {
- this.oAuthAdminService = oAuthAdminService;
- }
- return oAuthAdminService;
- }
- }
-}
diff --git a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/factory/OAuthServerConfigurationFactory.java b/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/factory/OAuthServerConfigurationFactory.java
deleted file mode 100644
index 75250a7ef7c..00000000000
--- a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/factory/OAuthServerConfigurationFactory.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 2019, 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.oauth.endpoint.factory;
-
-import org.springframework.beans.factory.config.AbstractFactoryBean;
-import org.wso2.carbon.context.PrivilegedCarbonContext;
-import org.wso2.carbon.identity.oauth.config.OAuthServerConfiguration;
-
-/**
- * Factory Beans serves as a factory for creating other beans within the IOC container. This factory bean is used to
- * instantiate the OAuthServerConfiguration type of object inside the container.
- */
-public class OAuthServerConfigurationFactory extends AbstractFactoryBean {
-
- private OAuthServerConfiguration oAuthServerConfiguration;
-
- @Override
- public Class getObjectType() {
-
- return OAuthServerConfiguration.class;
- }
-
- @Override
- protected OAuthServerConfiguration createInstance() throws Exception {
-
- if (this.oAuthServerConfiguration != null) {
- return this.oAuthServerConfiguration;
- } else {
- OAuthServerConfiguration oAuthServerConfiguration = (OAuthServerConfiguration) PrivilegedCarbonContext.
- getThreadLocalCarbonContext().getOSGiService(OAuthServerConfiguration.class, null);
- if (oAuthServerConfiguration != null) {
- this.oAuthServerConfiguration = oAuthServerConfiguration;
- }
- return oAuthServerConfiguration;
- }
- }
-}
diff --git a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/factory/OpenIDConnectClaimFilterFactory.java b/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/factory/OpenIDConnectClaimFilterFactory.java
deleted file mode 100644
index a865e317d14..00000000000
--- a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/factory/OpenIDConnectClaimFilterFactory.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2019, 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.oauth.endpoint.factory;
-
-import org.springframework.beans.factory.config.AbstractFactoryBean;
-import org.wso2.carbon.context.PrivilegedCarbonContext;
-import org.wso2.carbon.identity.openidconnect.OpenIDConnectClaimFilter;
-import org.wso2.carbon.identity.openidconnect.OpenIDConnectClaimFilterImpl;
-
-/**
- * Factory Beans serves as a factory for creating other beans within the IOC container. This factory bean is used to
- * instantiate the OpenIDConnectClaimFilterImpl type of object inside the container.
- */
-public class OpenIDConnectClaimFilterFactory extends AbstractFactoryBean {
-
- private OpenIDConnectClaimFilterImpl openIDConnectClaimFilter;
-
- @Override
- public Class getObjectType() {
-
- return OpenIDConnectClaimFilterImpl.class;
- }
-
- @Override
- protected OpenIDConnectClaimFilterImpl createInstance() throws Exception {
-
- if (this.openIDConnectClaimFilter != null) {
- return this.openIDConnectClaimFilter;
- } else {
- OpenIDConnectClaimFilterImpl openIDConnectClaimFilter = (OpenIDConnectClaimFilterImpl)
- PrivilegedCarbonContext.getThreadLocalCarbonContext().
- getOSGiService(OpenIDConnectClaimFilter.class, null);
- if (openIDConnectClaimFilter != null) {
- this.openIDConnectClaimFilter = openIDConnectClaimFilter;
- }
- return openIDConnectClaimFilter;
- }
- }
-}
diff --git a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/factory/ParServiceFactory.java b/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/factory/ParServiceFactory.java
deleted file mode 100644
index 64c060c442b..00000000000
--- a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/factory/ParServiceFactory.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * Copyright (c) 2023, WSO2 LLC. (https://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.oauth.endpoint.factory;
-
-import org.springframework.beans.factory.config.AbstractFactoryBean;
-import org.wso2.carbon.context.PrivilegedCarbonContext;
-import org.wso2.carbon.identity.oauth.par.core.ParAuthService;
-
-/**
- * PAR Service Factory.
- */
-public class ParServiceFactory extends AbstractFactoryBean {
- private ParAuthService parAuthService;
-
- @Override
- public Class getObjectType() {
-
- return ParAuthService.class;
- }
-
- @Override
- protected ParAuthService createInstance() throws Exception {
-
- if (parAuthService != null) {
- return parAuthService;
- }
-
- ParAuthService parAuthService = (ParAuthService)
- PrivilegedCarbonContext.getThreadLocalCarbonContext().
- getOSGiService(ParAuthService.class, null);
- if (parAuthService != null) {
- this.parAuthService = parAuthService;
- }
- return parAuthService;
- }
-}
diff --git a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/factory/RequestObjectServiceFactory.java b/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/factory/RequestObjectServiceFactory.java
deleted file mode 100644
index cb9465cc3bc..00000000000
--- a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/factory/RequestObjectServiceFactory.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 2019, 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.oauth.endpoint.factory;
-
-import org.springframework.beans.factory.config.AbstractFactoryBean;
-import org.wso2.carbon.context.PrivilegedCarbonContext;
-import org.wso2.carbon.identity.openidconnect.RequestObjectService;
-
-/**
- * Factory Beans serves as a factory for creating other beans within the IOC container. This factory bean is used to
- * instantiate the RequestObjectService type of object inside the container.
- */
-public class RequestObjectServiceFactory extends AbstractFactoryBean {
-
- private RequestObjectService requestObjectService;
-
- @Override
- public Class getObjectType() {
-
- return RequestObjectService.class;
- }
-
- @Override
- protected RequestObjectService createInstance() throws Exception {
-
- if (this.requestObjectService != null) {
- return this.requestObjectService;
- } else {
- RequestObjectService requestObjectService = (RequestObjectService) PrivilegedCarbonContext.
- getThreadLocalCarbonContext().getOSGiService(RequestObjectService.class, null);
- if (requestObjectService != null) {
- this.requestObjectService = requestObjectService;
- }
- return requestObjectService;
- }
- }
-}
diff --git a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/factory/SSOConsentServiceFactory.java b/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/factory/SSOConsentServiceFactory.java
deleted file mode 100644
index 7523727293b..00000000000
--- a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/factory/SSOConsentServiceFactory.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 2019, 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.oauth.endpoint.factory;
-
-import org.springframework.beans.factory.config.AbstractFactoryBean;
-import org.wso2.carbon.context.PrivilegedCarbonContext;
-import org.wso2.carbon.identity.application.authentication.framework.handler.request.impl.consent.SSOConsentService;
-
-/**
- * Factory Beans serves as a factory for creating other beans within the IOC container. This factory bean is used to
- * instantiate the SSOConsentService type of object inside the container.
- */
-public class SSOConsentServiceFactory extends AbstractFactoryBean {
-
- private SSOConsentService ssoConsentService;
-
- @Override
- public Class getObjectType() {
-
- return SSOConsentService.class;
- }
-
- @Override
- protected SSOConsentService createInstance() throws Exception {
-
- if (this.ssoConsentService != null) {
- return this.ssoConsentService;
- } else {
- SSOConsentService ssoConsentService = (SSOConsentService) PrivilegedCarbonContext.
- getThreadLocalCarbonContext().getOSGiService(SSOConsentService.class, null);
- if (ssoConsentService != null) {
- this.ssoConsentService = ssoConsentService;
- }
- return ssoConsentService;
- }
- }
-}
diff --git a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/oidcdiscovery/OIDCDiscoveryEndpoint.java b/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/oidcdiscovery/OIDCDiscoveryEndpoint.java
index 87b0088cc43..359fdb8eddc 100644
--- a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/oidcdiscovery/OIDCDiscoveryEndpoint.java
+++ b/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/oidcdiscovery/OIDCDiscoveryEndpoint.java
@@ -21,7 +21,6 @@
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.springframework.beans.factory.annotation.Autowired;
import org.wso2.carbon.base.MultitenantConstants;
import org.wso2.carbon.base.ServerConfigurationException;
import org.wso2.carbon.identity.core.util.IdentityUtil;
@@ -29,7 +28,7 @@
import org.wso2.carbon.identity.discovery.OIDCProcessor;
import org.wso2.carbon.identity.discovery.builders.OIDProviderResponseBuilder;
import org.wso2.carbon.identity.oauth.common.OAuthConstants;
-import org.wso2.carbon.identity.oauth.endpoint.util.EndpointUtil;
+import org.wso2.carbon.identity.oauth.endpoint.util.factory.OIDCProviderServiceFactory;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -97,9 +96,9 @@ private boolean isValidIssuer(String issuer) {
private Response getResponse(HttpServletRequest request, String tenant) {
String response;
- OIDCProcessor processor = EndpointUtil.getOIDCService();
+ OIDCProcessor processor = OIDCProviderServiceFactory.getOIDCService();
try {
- OIDProviderResponseBuilder responseBuilder = getOidProviderResponseBuilder();
+ OIDProviderResponseBuilder responseBuilder = OIDCDiscoveryServiceFactory.getOIDProviderResponseBuilder();
response = responseBuilder.getOIDProviderConfigString(processor.getResponse(request, tenant));
} catch (OIDCDiscoveryEndPointException e) {
Response.ResponseBuilder errorResponse = Response.status(processor.handleError(e));
@@ -112,15 +111,4 @@ private Response getResponse(HttpServletRequest request, String tenant) {
Response.ResponseBuilder responseBuilder = Response.status(HttpServletResponse.SC_OK);
return responseBuilder.entity(response).build();
}
-
- @Autowired
- public void setOidProviderResponseBuilder(OIDProviderResponseBuilder oidProviderResponseBuilder) {
-
- this.oidProviderResponseBuilder = oidProviderResponseBuilder;
- }
-
- public OIDProviderResponseBuilder getOidProviderResponseBuilder() {
-
- return this.oidProviderResponseBuilder;
- }
}
diff --git a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/oidcdiscovery/OIDCDiscoveryServiceFactory.java b/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/oidcdiscovery/OIDCDiscoveryServiceFactory.java
new file mode 100644
index 00000000000..d9fd4c64285
--- /dev/null
+++ b/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/oidcdiscovery/OIDCDiscoveryServiceFactory.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 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.oauth.endpoint.oidcdiscovery;
+
+import org.wso2.carbon.context.PrivilegedCarbonContext;
+import org.wso2.carbon.identity.discovery.builders.OIDProviderResponseBuilder;
+
+/**
+ * Service holder for managing instances of OIDC Discovery related services.
+ */
+public class OIDCDiscoveryServiceFactory {
+
+ private static final OIDProviderResponseBuilder SERVICE;
+
+ static {
+ OIDProviderResponseBuilder oidProviderResponseBuilder = (OIDProviderResponseBuilder) PrivilegedCarbonContext
+ .getThreadLocalCarbonContext().getOSGiService(OIDProviderResponseBuilder.class, null);
+ if (oidProviderResponseBuilder == null) {
+ throw new IllegalStateException("OIDProviderResponseBuilder is not available from OSGi context.");
+ }
+ SERVICE = oidProviderResponseBuilder;
+ }
+
+ public static OIDProviderResponseBuilder getOIDProviderResponseBuilder() {
+
+ return SERVICE;
+ }
+}
diff --git a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/par/OAuth2ParEndpoint.java b/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/par/OAuth2ParEndpoint.java
index 4f4479cb0a0..0b3f2886979 100644
--- a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/par/OAuth2ParEndpoint.java
+++ b/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/par/OAuth2ParEndpoint.java
@@ -77,11 +77,11 @@
import static org.wso2.carbon.identity.oauth.common.OAuthConstants.OAuth20Params.RESPONSE_MODE;
import static org.wso2.carbon.identity.oauth.common.OAuthConstants.OAuth20Params.RESPONSE_TYPE;
import static org.wso2.carbon.identity.oauth.common.OAuthConstants.OAuth20Params.SCOPE;
-import static org.wso2.carbon.identity.oauth.endpoint.util.EndpointUtil.getOAuth2Service;
import static org.wso2.carbon.identity.oauth.endpoint.util.EndpointUtil.getOAuthAuthzRequest;
-import static org.wso2.carbon.identity.oauth.endpoint.util.EndpointUtil.getParAuthService;
import static org.wso2.carbon.identity.oauth.endpoint.util.EndpointUtil.getSPTenantDomainFromClientId;
import static org.wso2.carbon.identity.oauth.endpoint.util.EndpointUtil.validateParams;
+import static org.wso2.carbon.identity.oauth.endpoint.util.factory.OAuth2ServiceFactory.getOAuth2Service;
+import static org.wso2.carbon.identity.oauth.endpoint.util.factory.ParAuthServiceFactory.getParAuthService;
/**
* REST implementation for OAuth2 PAR endpoint.
diff --git a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/revoke/OAuthRevocationEndpoint.java b/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/revoke/OAuthRevocationEndpoint.java
index 2643328de7b..b97fd313e41 100644
--- a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/revoke/OAuthRevocationEndpoint.java
+++ b/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/revoke/OAuthRevocationEndpoint.java
@@ -69,9 +69,9 @@
import static org.wso2.carbon.identity.oauth.common.OAuthConstants.HTTP_RESP_HEADER_VAL_CACHE_CONTROL_NO_STORE;
import static org.wso2.carbon.identity.oauth.common.OAuthConstants.HTTP_RESP_HEADER_VAL_PRAGMA_NO_CACHE;
import static org.wso2.carbon.identity.oauth.endpoint.util.EndpointUtil.extractCredentialsFromAuthzHeader;
-import static org.wso2.carbon.identity.oauth.endpoint.util.EndpointUtil.getOAuth2Service;
import static org.wso2.carbon.identity.oauth.endpoint.util.EndpointUtil.getRealmInfo;
import static org.wso2.carbon.identity.oauth.endpoint.util.EndpointUtil.validateParams;
+import static org.wso2.carbon.identity.oauth.endpoint.util.factory.OAuth2ServiceFactory.getOAuth2Service;
/**
* Rest implementation for oauth revocation endpoint.
diff --git a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/state/OAuthRequestStateValidator.java b/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/state/OAuthRequestStateValidator.java
index aa2ae22854c..a06d69fe4f5 100644
--- a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/state/OAuthRequestStateValidator.java
+++ b/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/state/OAuthRequestStateValidator.java
@@ -36,7 +36,7 @@
import static org.wso2.carbon.identity.oauth.endpoint.state.OAuthAuthorizeState.AUTHENTICATION_RESPONSE;
import static org.wso2.carbon.identity.oauth.endpoint.state.OAuthAuthorizeState.INITIAL_REQUEST;
import static org.wso2.carbon.identity.oauth.endpoint.state.OAuthAuthorizeState.USER_CONSENT_RESPONSE;
-import static org.wso2.carbon.identity.oauth.endpoint.util.EndpointUtil.getOAuth2Service;
+import static org.wso2.carbon.identity.oauth.endpoint.util.factory.OAuth2ServiceFactory.getOAuth2Service;
/**
* This class validate the OAuth request state.
diff --git a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/token/OAuth2TokenEndpoint.java b/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/token/OAuth2TokenEndpoint.java
index acff55c6e87..7120aa71608 100644
--- a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/token/OAuth2TokenEndpoint.java
+++ b/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/token/OAuth2TokenEndpoint.java
@@ -42,6 +42,7 @@
import org.wso2.carbon.identity.oauth.endpoint.exception.InvalidRequestParentException;
import org.wso2.carbon.identity.oauth.endpoint.exception.TokenEndpointBadRequestException;
import org.wso2.carbon.identity.oauth.endpoint.util.EndpointUtil;
+import org.wso2.carbon.identity.oauth.endpoint.util.factory.OAuth2ServiceFactory;
import org.wso2.carbon.identity.oauth2.ResponseHeader;
import org.wso2.carbon.identity.oauth2.bean.OAuthClientAuthnContext;
import org.wso2.carbon.identity.oauth2.dto.OAuth2AccessTokenReqDTO;
@@ -383,7 +384,7 @@ private OAuth2AccessTokenRespDTO issueAccessToken(CarbonOAuthTokenRequest oauthR
OAuth2AccessTokenReqDTO tokenReqDTO = buildAccessTokenReqDTO(oauthRequest, httpServletRequestWrapper,
httpServletResponseWrapper);
- return EndpointUtil.getOAuth2Service().issueAccessToken(tokenReqDTO);
+ return OAuth2ServiceFactory.getOAuth2Service().issueAccessToken(tokenReqDTO);
}
private OAuth2AccessTokenReqDTO buildAccessTokenReqDTO(CarbonOAuthTokenRequest oauthRequest,
diff --git a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/user/impl/UserInfoISAccessTokenValidator.java b/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/user/impl/UserInfoISAccessTokenValidator.java
index c54f13bebb7..ecac085e6b6 100644
--- a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/user/impl/UserInfoISAccessTokenValidator.java
+++ b/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/user/impl/UserInfoISAccessTokenValidator.java
@@ -20,7 +20,7 @@
import org.apache.commons.lang.ArrayUtils;
import org.apache.oltu.oauth2.common.error.OAuthError;
import org.wso2.carbon.identity.oauth.common.exception.InvalidOAuthClientException;
-import org.wso2.carbon.identity.oauth.endpoint.util.EndpointUtil;
+import org.wso2.carbon.identity.oauth.endpoint.util.factory.OAuth2TokenValidatorServiceFactory;
import org.wso2.carbon.identity.oauth.user.UserInfoAccessTokenValidator;
import org.wso2.carbon.identity.oauth.user.UserInfoEndpointException;
import org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception;
@@ -61,7 +61,8 @@ public OAuth2TokenValidationResponseDTO validateToken(String accessTokenIdentifi
accessToken.setTokenType("bearer");
accessToken.setIdentifier(accessTokenIdentifier);
dto.setAccessToken(accessToken);
- OAuth2TokenValidationResponseDTO response = EndpointUtil.getOAuth2TokenValidationService().validate(dto);
+ OAuth2TokenValidationResponseDTO response = OAuth2TokenValidatorServiceFactory
+ .getOAuth2TokenValidatorService().validate(dto);
AccessTokenDO accessTokenDO;
// invalid access token
diff --git a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/util/EndpointUtil.java b/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/util/EndpointUtil.java
index 2c7fa73ccfb..6bfbb91868d 100644
--- a/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/util/EndpointUtil.java
+++ b/components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/util/EndpointUtil.java
@@ -44,7 +44,6 @@
import org.wso2.carbon.identity.application.authentication.framework.cache.AuthenticationRequestCacheEntry;
import org.wso2.carbon.identity.application.authentication.framework.config.builder.FileBasedConfigurationBuilder;
import org.wso2.carbon.identity.application.authentication.framework.exception.UserIdNotFoundException;
-import org.wso2.carbon.identity.application.authentication.framework.handler.request.impl.consent.SSOConsentService;
import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser;
import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticationRequest;
import org.wso2.carbon.identity.application.authentication.framework.util.FrameworkConstants;
@@ -62,19 +61,13 @@
import org.wso2.carbon.identity.core.URLBuilderException;
import org.wso2.carbon.identity.core.util.IdentityTenantUtil;
import org.wso2.carbon.identity.core.util.IdentityUtil;
-import org.wso2.carbon.identity.discovery.DefaultOIDCProcessor;
-import org.wso2.carbon.identity.discovery.OIDCProcessor;
-import org.wso2.carbon.identity.discovery.builders.DefaultOIDCProviderRequestBuilder;
-import org.wso2.carbon.identity.discovery.builders.OIDCProviderRequestBuilder;
import org.wso2.carbon.identity.event.IdentityEventException;
import org.wso2.carbon.identity.event.event.Event;
import org.wso2.carbon.identity.event.services.IdentityEventService;
import org.wso2.carbon.identity.oauth.IdentityOAuthAdminException;
-import org.wso2.carbon.identity.oauth.OAuthAdminServiceImpl;
import org.wso2.carbon.identity.oauth.cache.SessionDataCache;
import org.wso2.carbon.identity.oauth.cache.SessionDataCacheEntry;
import org.wso2.carbon.identity.oauth.cache.SessionDataCacheKey;
-import org.wso2.carbon.identity.oauth.ciba.api.CibaAuthServiceImpl;
import org.wso2.carbon.identity.oauth.common.OAuth2ErrorCodes;
import org.wso2.carbon.identity.oauth.common.OAuthConstants;
import org.wso2.carbon.identity.oauth.common.exception.InvalidOAuthClientException;
@@ -86,16 +79,13 @@
import org.wso2.carbon.identity.oauth.endpoint.exception.InvalidRequestException;
import org.wso2.carbon.identity.oauth.endpoint.exception.TokenEndpointBadRequestException;
import org.wso2.carbon.identity.oauth.endpoint.message.OAuthMessage;
-import org.wso2.carbon.identity.oauth.par.core.ParAuthService;
+import org.wso2.carbon.identity.oauth.endpoint.util.factory.OAuth2ServiceFactory;
import org.wso2.carbon.identity.oauth.par.exceptions.ParClientException;
import org.wso2.carbon.identity.oauth.user.UserInfoEndpointException;
import org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception;
import org.wso2.carbon.identity.oauth2.IdentityOAuth2ScopeConsentException;
import org.wso2.carbon.identity.oauth2.IdentityOAuth2ScopeException;
import org.wso2.carbon.identity.oauth2.IdentityOAuth2ScopeServerException;
-import org.wso2.carbon.identity.oauth2.OAuth2ScopeService;
-import org.wso2.carbon.identity.oauth2.OAuth2Service;
-import org.wso2.carbon.identity.oauth2.OAuth2TokenValidationService;
import org.wso2.carbon.identity.oauth2.Oauth2ScopeConstants;
import org.wso2.carbon.identity.oauth2.RequestObjectException;
import org.wso2.carbon.identity.oauth2.bean.OAuthClientAuthnContext;
@@ -106,20 +96,15 @@
import org.wso2.carbon.identity.oauth2.model.OAuth2Parameters;
import org.wso2.carbon.identity.oauth2.model.OAuth2ScopeConsentResponse;
import org.wso2.carbon.identity.oauth2.scopeservice.OAuth2Resource;
-import org.wso2.carbon.identity.oauth2.scopeservice.ScopeMetadataService;
import org.wso2.carbon.identity.oauth2.util.AuthzUtil;
import org.wso2.carbon.identity.oauth2.util.OAuth2Util;
import org.wso2.carbon.identity.openidconnect.OIDCRequestObjectUtil;
import org.wso2.carbon.identity.openidconnect.RequestObjectBuilder;
-import org.wso2.carbon.identity.openidconnect.RequestObjectService;
import org.wso2.carbon.identity.openidconnect.RequestObjectValidator;
import org.wso2.carbon.identity.openidconnect.internal.OpenIDConnectServiceComponentHolder;
import org.wso2.carbon.identity.openidconnect.model.RequestObject;
-import org.wso2.carbon.identity.webfinger.DefaultWebFingerProcessor;
-import org.wso2.carbon.identity.webfinger.WebFingerProcessor;
import org.wso2.carbon.idp.mgt.IdentityProviderManagementException;
import org.wso2.carbon.idp.mgt.IdentityProviderManager;
-import org.wso2.carbon.idp.mgt.IdpManager;
import org.wso2.carbon.utils.DiagnosticLog;
import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
@@ -157,6 +142,10 @@
import static org.wso2.carbon.identity.oauth.common.OAuthConstants.HTTP_REQ_HEADER_AUTH_METHOD_BASIC;
import static org.wso2.carbon.identity.oauth.common.OAuthConstants.OauthAppStates.APP_STATE_ACTIVE;
import static org.wso2.carbon.identity.oauth.common.OAuthConstants.ResponseModes.JWT;
+import static org.wso2.carbon.identity.oauth.endpoint.util.factory.OAuthAdminServiceFactory.getOAuthAdminService;
+import static org.wso2.carbon.identity.oauth.endpoint.util.factory.OAuthServerConfigurationFactory.getOAuthServerConfiguration;
+import static org.wso2.carbon.identity.oauth.endpoint.util.factory.Oauth2ScopeServiceFactory.getOAuth2ScopeService;
+import static org.wso2.carbon.identity.oauth.endpoint.util.factory.ScopeMetadataServiceFactory.getScopeMetadataService;
import static org.wso2.carbon.identity.oauth.par.common.ParConstants.PRE_HANDLE_PAR_REQUEST;
import static org.wso2.carbon.identity.oauth.par.common.ParConstants.REQUEST_HEADERS;
import static org.wso2.carbon.identity.oauth.par.common.ParConstants.REQUEST_PARAMETERS;
@@ -185,154 +174,15 @@ public class EndpointUtil {
private static final String REQUEST_URI = "request_uri";
private static final String NOT_AVAILABLE = "N/A";
private static final String UNKNOWN_ERROR = "unknown_error";
- private static OAuth2Service oAuth2Service;
- private static OAuth2ScopeService oAuth2ScopeService;
- private static OAuthAdminServiceImpl oAuthAdminService;
- private static ScopeMetadataService scopeMetadataService;
- private static SSOConsentService ssoConsentService;
- private static OAuthServerConfiguration oauthServerConfiguration;
- private static RequestObjectService requestObjectService;
- private static CibaAuthServiceImpl cibaAuthService;
- private static ParAuthService parAuthService;
- private static IdpManager idpManager;
private static final String ALLOW_ADDITIONAL_PARAMS_FROM_ERROR_URL = "OAuth.AllowAdditionalParamsFromErrorUrl";
private static final String KEEP_OIDC_SCOPES_IN_CONSENT_URL = "OAuth.KeepOIDCScopesInConsentURL";
private static final String IDP_ENTITY_ID = "IdPEntityId";
private static Class extends OAuthAuthzRequest> oAuthAuthzRequestClass;
- public static void setIdpManager(IdpManager idpManager) {
-
- EndpointUtil.idpManager = idpManager;
- }
-
- public static void setOAuth2Service(OAuth2Service oAuth2Service) {
-
- EndpointUtil.oAuth2Service = oAuth2Service;
- }
-
- public static void setOAuth2ScopeService(OAuth2ScopeService oAuth2ScopeService) {
-
- EndpointUtil.oAuth2ScopeService = oAuth2ScopeService;
- }
-
- public static void setOAuthAdminService(OAuthAdminServiceImpl oAuthAdminService) {
-
- EndpointUtil.oAuthAdminService = oAuthAdminService;
- }
-
- public static void setSSOConsentService(SSOConsentService ssoConsentService) {
-
- EndpointUtil.ssoConsentService = ssoConsentService;
- }
-
- public static void setOauthServerConfiguration(OAuthServerConfiguration oauthServerConfiguration) {
-
- EndpointUtil.oauthServerConfiguration = oauthServerConfiguration;
- }
-
- public static void setRequestObjectService(RequestObjectService requestObjectService) {
-
- EndpointUtil.requestObjectService = requestObjectService;
- }
-
- public static ScopeMetadataService getScopeMetadataService() {
-
- return scopeMetadataService;
- }
-
- public static void setScopeMetadataService(ScopeMetadataService scopeMetadataService) {
-
- EndpointUtil.scopeMetadataService = scopeMetadataService;
- }
-
private EndpointUtil() {
}
- /**
- * Returns the registered {@code {@link SSOConsentService}} instance
- *
- * @return
- */
- public static SSOConsentService getSSOConsentService() {
-
- return ssoConsentService;
- }
-
- /**
- * Returns the {@code DefaultWebFingerProcessor} instance
- *
- * @return DefaultWebFingerProcessor
- */
- public static DefaultWebFingerProcessor getWebFingerService() {
-
- return (DefaultWebFingerProcessor) PrivilegedCarbonContext.getThreadLocalCarbonContext().getOSGiService
- (WebFingerProcessor.class, null);
- }
-
- /**
- * Returns the {@code OIDCProviderRequestBuilder} instance
- *
- * @return DefaultOIDCProviderRequestBuilder
- */
- public static DefaultOIDCProviderRequestBuilder getOIDProviderRequestValidator() {
-
- return (DefaultOIDCProviderRequestBuilder) PrivilegedCarbonContext.getThreadLocalCarbonContext().getOSGiService
- (OIDCProviderRequestBuilder.class, null);
- }
-
- /**
- * Returns the {@code DefaultOIDCProcessor} instance
- *
- * @return DefaultOIDCProcessor
- */
- public static DefaultOIDCProcessor getOIDCService() {
-
- return (DefaultOIDCProcessor) PrivilegedCarbonContext.getThreadLocalCarbonContext().getOSGiService
- (OIDCProcessor.class, null);
- }
-
- /**
- * Returns the {@code RequestObjectService} instance
- *
- * @return RequestObjectService
- */
- public static RequestObjectService getRequestObjectService() {
-
- return requestObjectService;
- }
-
- /**
- * Returns the {@code OAuth2Service} instance
- *
- * @return OAuth2Service
- */
- public static OAuth2Service getOAuth2Service() {
-
- return oAuth2Service;
- }
-
- /**
- * Returns the {@code OAuthServerConfiguration} instance
- *
- * @return OAuthServerConfiguration
- */
- public static OAuthServerConfiguration getOAuthServerConfiguration() {
-
- return oauthServerConfiguration;
- }
-
- /**
- * Returns the {@code OAuthServerConfiguration} instance
- *
- * @return OAuth2TokenValidationService
- */
- public static OAuth2TokenValidationService getOAuth2TokenValidationService() {
-
- return (OAuth2TokenValidationService) PrivilegedCarbonContext.getThreadLocalCarbonContext()
- .getOSGiService(OAuth2TokenValidationService.class, null);
- }
-
/**
* Returns the request validator class name
*
@@ -922,7 +772,7 @@ private static ServiceProvider getServiceProvider(OAuth2Parameters params) throw
private static String getScopeMetadataQueryParam(Set scopes, String tenantDomain) {
try {
- List oidcScopeList = oAuthAdminService.getRegisteredOIDCScope(tenantDomain);
+ List oidcScopeList = getOAuthAdminService().getRegisteredOIDCScope(tenantDomain);
List nonOidcScopeList = new ArrayList<>();
oidcScopeList.retainAll(scopes);
nonOidcScopeList.addAll(scopes.stream().filter(scope ->
@@ -931,7 +781,7 @@ private static String getScopeMetadataQueryParam(Set scopes, String tena
if (nonOidcScopeList.isEmpty()) {
return null;
}
- List scopesMetaData = scopeMetadataService.getMetadata(nonOidcScopeList);
+ List scopesMetaData = getScopeMetadataService().getMetadata(nonOidcScopeList);
String scopeMetadata = new Gson().toJson(scopesMetaData);
return "scopeMetadata=" + URLEncoder.encode(scopeMetadata, UTF_8);
} catch (Exception e) {
@@ -1067,7 +917,7 @@ public static boolean isUserAlreadyConsentedForOAuthScopes(AuthenticatedUser use
}
String userId = getUserIdOfAuthenticatedUser(user);
String appId = getAppIdFromClientId(oAuth2Parameters.getClientId());
- return oAuth2ScopeService.hasUserProvidedConsentForAllRequestedScopes(userId, appId,
+ return getOAuth2ScopeService().hasUserProvidedConsentForAllRequestedScopes(userId, appId,
IdentityTenantUtil.getTenantId(user.getTenantDomain()), scopesToBeConsented);
}
@@ -1107,25 +957,25 @@ public static void storeOAuthScopeConsent(AuthenticatedUser user, OAuth2Paramete
log.debug("Overriding existing consents of the user : " + userId + " for application : " +
appId);
}
- oAuth2ScopeService.addUserConsentForApplication(userId, appId,
+ getOAuth2ScopeService().addUserConsentForApplication(userId, appId,
IdentityTenantUtil.getTenantId(user.getTenantDomain()),
userApprovedScopes, null);
} else {
- boolean isUserConsentExist = oAuth2ScopeService.isUserHasAnExistingConsentForApp(
+ boolean isUserConsentExist = getOAuth2ScopeService().isUserHasAnExistingConsentForApp(
userId, appId, IdentityTenantUtil.getTenantId(user.getTenantDomain()));
if (isUserConsentExist) {
if (log.isDebugEnabled()) {
log.debug("Updating existing consents of the user : " + userId + " for application : " +
appId);
}
- oAuth2ScopeService.updateUserConsentForApplication(userId, appId,
+ getOAuth2ScopeService().updateUserConsentForApplication(userId, appId,
IdentityTenantUtil.getTenantId(user.getTenantDomain()),
userApprovedScopes, null);
} else {
if (log.isDebugEnabled()) {
log.debug("Adding new consent to the user : " + userId + " for application : " + appId);
}
- oAuth2ScopeService.addUserConsentForApplication(userId, appId,
+ getOAuth2ScopeService().addUserConsentForApplication(userId, appId,
IdentityTenantUtil.getTenantId(user.getTenantDomain()),
userApprovedScopes, null);
}
@@ -1165,7 +1015,7 @@ public static void storeOAuthScopeConsent(AuthenticatedUser user, OAuth2Paramete
private static List getOIDCScopeNames() throws IdentityOAuthAdminException {
- return Arrays.asList(ArrayUtils.nullToEmpty(oAuthAdminService.getScopeNames()));
+ return Arrays.asList(ArrayUtils.nullToEmpty(getOAuthAdminService().getScopeNames()));
}
/**
@@ -1192,7 +1042,7 @@ private static List getRequestedOIDCScopes(OAuth2Parameters params)
List requestedOIDCScopes = new ArrayList<>();
try {
// Get registered OIDC scopes.
- List oidcScopeList = oAuthAdminService.getRegisteredOIDCScope(params.getTenantDomain());
+ List oidcScopeList = getOAuthAdminService().getRegisteredOIDCScope(params.getTenantDomain());
for (String scope : allowedScopes) {
if (oidcScopeList.contains(scope)) {
requestedOIDCScopes.add(scope.toLowerCase());
@@ -1222,7 +1072,7 @@ private static List dropOIDCAndUnregisteredScopesFromConsentRequiredScop
/* If DropUnregisteredScopes scopes config is enabled then any unregistered scopes(excluding internal
scopes and allowed scopes) will be dropped. Therefore, they will not be shown in the user consent
screen.*/
- if (oauthServerConfiguration.isDropUnregisteredScopes()) {
+ if (getOAuthServerConfiguration().isDropUnregisteredScopes()) {
if (log.isDebugEnabled()) {
log.debug("DropUnregisteredScopes config is enabled. Attempting to drop unregistered scopes.");
}
@@ -1234,7 +1084,7 @@ private static List dropOIDCAndUnregisteredScopesFromConsentRequiredScop
allowedRegisteredScopes.addAll(allowedScopes);
} else {
// Get registered OIDC scopes.
- String[] oidcScopes = oAuthAdminService.getScopeNames();
+ String[] oidcScopes = getOAuthAdminService().getScopeNames();
List oidcScopeList = new ArrayList<>(Arrays.asList(oidcScopes));
for (String scope : allowedScopes) {
if (!oidcScopeList.contains(scope)) {
@@ -1265,7 +1115,7 @@ private static List filterConsentRequiredScopes(AuthenticatedUser user,
if (user != null && !isPromptContainsConsent(params)) {
String userId = getUserIdOfAuthenticatedUser(user);
String appId = getAppIdFromClientId(params.getClientId());
- OAuth2ScopeConsentResponse existingUserConsent = oAuth2ScopeService.getUserConsentForApp(
+ OAuth2ScopeConsentResponse existingUserConsent = getOAuth2ScopeService().getUserConsentForApp(
userId, appId, IdentityTenantUtil.getTenantId(user.getTenantDomain()));
if (existingUserConsent != null) {
if (CollectionUtils.isNotEmpty(existingUserConsent.getApprovedScopes())) {
@@ -1327,7 +1177,7 @@ private static Set dropUnregisteredScopes(OAuth2Parameters params) throw
Set requestedScopes = new HashSet<>(params.getScopes());
Set registeredScopes = getRegisteredScopes(requestedScopes, params.getTenantDomain());
- List allowedScopesFromConfig = oauthServerConfiguration.getAllowedScopes();
+ List allowedScopesFromConfig = getOAuthServerConfiguration().getAllowedScopes();
Set filteredScopes = new HashSet<>();
// Filtering allowed scopes.
@@ -1360,7 +1210,8 @@ private static Set getRegisteredScopes(Set requestedScopes, Stri
try {
String requestedScopesStr = StringUtils.join(requestedScopes, " ");
Set registeredScopes = new HashSet<>();
- Set registeredScopeSet = oAuth2ScopeService.getScopes(null, null, true, requestedScopesStr);
+ Set registeredScopeSet = getOAuth2ScopeService().getScopes(null, null,
+ true, requestedScopesStr);
registeredScopeSet.forEach(scope -> registeredScopes.add(scope.getName()));
if (!AuthzUtil.isLegacyAuthzRuntime()) {
List registeredAPIScopes = getRegisteredAPIScopes(requestedScopes, tenantDomain);
@@ -1544,7 +1395,7 @@ public static void startSuperTenantFlow() {
*/
public static void validateOauthApplication(String consumerKey) throws InvalidApplicationClientException {
- String appState = EndpointUtil.getOAuth2Service().getOauthApplicationState(consumerKey);
+ String appState = OAuth2ServiceFactory.getOAuth2Service().getOauthApplicationState(consumerKey);
DiagnosticLog.DiagnosticLogBuilder diagnosticLogBuilder = null;
if (LoggerUtils.isDiagnosticLogsEnabled()) {
@@ -1807,36 +1658,6 @@ private static void addStringToMap(String name, String value, Map {
+public class ScopeMetadataServiceFactory {
- private ScopeMetadataService scopeMetadataService;
+ private static final ScopeMetadataService SERVICE;
- private static final Log log = LogFactory.getLog(ScopeServiceFactory.class);
+ private static final Log LOG = LogFactory.getLog(ScopeMetadataServiceFactory.class);
- @Override
- public Class getObjectType() {
+ static {
+ ScopeMetadataService scopeMetadataService = setScopeMetadataService();
- return ScopeMetadataService.class;
+ if (scopeMetadataService == null) {
+ throw new IllegalStateException("ScopeMetadataService is not available from OSGi context.");
+ }
+ SERVICE = scopeMetadataService;
}
- @Override
- protected ScopeMetadataService createInstance() throws Exception {
-
- if (this.scopeMetadataService != null) {
- return this.scopeMetadataService;
- }
+ private static ScopeMetadataService setScopeMetadataService() {
- ScopeMetadataService scopeMetadataService = getScopeMetadataService();
+ ScopeMetadataService scopeMetadataService = getScopeMetadataServiceFromConfig();
if (scopeMetadataService != null) {
- this.scopeMetadataService = scopeMetadataService;
- return this.scopeMetadataService;
+ return scopeMetadataService;
}
+
// Get the OSGi services registered for ScopeService interface.
List