diff --git a/components/org.wso2.carbon.identity.api.server.dcr/pom.xml b/components/org.wso2.carbon.identity.api.server.dcr/pom.xml
index 413f30b0df6..8c3dce5a3df 100644
--- a/components/org.wso2.carbon.identity.api.server.dcr/pom.xml
+++ b/components/org.wso2.carbon.identity.api.server.dcr/pom.xml
@@ -23,12 +23,12 @@
org.wso2.carbon.identity.inbound.auth.oauth2
identity-inbound-auth-oauth
- 7.0.191-SNAPSHOT
+ 7.0.214-SNAPSHOT
../../pom.xml
org.wso2.carbon.identity.api.server.dcr
- 7.0.191-SNAPSHOT
+ 7.0.214-SNAPSHOT
WSO2 Carbon - User DCR Rest API
WSO2 Carbon - User DCR Rest API
@@ -48,11 +48,6 @@
jackson-databind
provided
-
- org.springframework
- spring-web
- provided
-
junit
junit
@@ -151,6 +146,10 @@
jaxp-ri
test
+
+ org.wso2.carbon.identity.framework
+ org.wso2.carbon.identity.testutil
+
diff --git a/components/org.wso2.carbon.identity.api.server.dcr/src/gen/java/org/wso2/carbon/identity/oauth2/dcr/endpoint/factories/RegisterApiServiceFactory.java b/components/org.wso2.carbon.identity.api.server.dcr/src/gen/java/org/wso2/carbon/identity/oauth2/dcr/endpoint/factories/RegisterApiServiceFactory.java
index 59bf0f207ac..7c48e314b10 100644
--- a/components/org.wso2.carbon.identity.api.server.dcr/src/gen/java/org/wso2/carbon/identity/oauth2/dcr/endpoint/factories/RegisterApiServiceFactory.java
+++ b/components/org.wso2.carbon.identity.api.server.dcr/src/gen/java/org/wso2/carbon/identity/oauth2/dcr/endpoint/factories/RegisterApiServiceFactory.java
@@ -5,10 +5,10 @@
public class RegisterApiServiceFactory {
- private final static RegisterApiService service = new RegisterApiServiceImpl();
+ private static final RegisterApiService SERVICE = new RegisterApiServiceImpl();
public static RegisterApiService getRegisterApi()
{
- return service;
+ return SERVICE;
}
}
diff --git a/components/org.wso2.carbon.identity.api.server.dcr/src/main/java/org/wso2/carbon/identity/oauth2/dcr/endpoint/factory/OAuth2DCRMServiceFactory.java b/components/org.wso2.carbon.identity.api.server.dcr/src/main/java/org/wso2/carbon/identity/oauth2/dcr/endpoint/factory/OAuth2DCRMServiceFactory.java
deleted file mode 100644
index ae8bc997340..00000000000
--- a/components/org.wso2.carbon.identity.api.server.dcr/src/main/java/org/wso2/carbon/identity/oauth2/dcr/endpoint/factory/OAuth2DCRMServiceFactory.java
+++ /dev/null
@@ -1,51 +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.oauth2.dcr.endpoint.factory;
-
-import org.springframework.beans.factory.config.AbstractFactoryBean;
-import org.wso2.carbon.context.PrivilegedCarbonContext;
-import org.wso2.carbon.identity.oauth.dcr.service.DCRMService;
-
-/**
- * Factory Beans serves as a factory for creating other beans within the IOC container. This factory bean is used to
- * instantiate the DCRMService type of object inside the container.
- */
-public class OAuth2DCRMServiceFactory extends AbstractFactoryBean {
-
- private DCRMService oAuth2DCRMService;
-
- @Override
- public Class getObjectType() {
-
- return DCRMService.class;
- }
-
- @Override
- protected DCRMService createInstance() throws Exception {
-
- if (this.oAuth2DCRMService == null) {
- DCRMService oAuth2DCRMService = (DCRMService) PrivilegedCarbonContext.
- getThreadLocalCarbonContext().getOSGiService(DCRMService.class, null);
- if (oAuth2DCRMService != null) {
- this.oAuth2DCRMService = oAuth2DCRMService;
- }
- }
- return this.oAuth2DCRMService;
- }
-}
diff --git a/components/org.wso2.carbon.identity.api.server.dcr/src/main/java/org/wso2/carbon/identity/oauth2/dcr/endpoint/util/DCRMUtils.java b/components/org.wso2.carbon.identity.api.server.dcr/src/main/java/org/wso2/carbon/identity/oauth2/dcr/endpoint/util/DCRMUtils.java
index 35e56919384..331780788da 100644
--- a/components/org.wso2.carbon.identity.api.server.dcr/src/main/java/org/wso2/carbon/identity/oauth2/dcr/endpoint/util/DCRMUtils.java
+++ b/components/org.wso2.carbon.identity.api.server.dcr/src/main/java/org/wso2/carbon/identity/oauth2/dcr/endpoint/util/DCRMUtils.java
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ * Copyright (c) 2017-2024, WSO2 LLC. (http://www.wso2.org).
*
- * 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
@@ -20,6 +20,7 @@
import org.apache.commons.logging.Log;
import org.slf4j.MDC;
+import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.identity.oauth.dcr.DCRMConstants;
import org.wso2.carbon.identity.oauth.dcr.bean.Application;
import org.wso2.carbon.identity.oauth.dcr.bean.ApplicationRegistrationRequest;
@@ -44,16 +45,15 @@ public class DCRMUtils {
private static final String NOT_FOUND_STATUS = "NOT_FOUND_";
private static final String FORBIDDEN_STATUS = "FORBIDDEN_";
- private static DCRMService oAuth2DCRMService;
+ private static class OAuth2DCRMServiceHolder {
- public static void setOAuth2DCRMService(DCRMService oAuth2DCRMService) {
-
- DCRMUtils.oAuth2DCRMService = oAuth2DCRMService;
+ private static final DCRMService SERVICE = (DCRMService) PrivilegedCarbonContext
+ .getThreadLocalCarbonContext().getOSGiService(DCRMService.class, null);
}
public static DCRMService getOAuth2DCRMService() {
- return oAuth2DCRMService;
+ return OAuth2DCRMServiceHolder.SERVICE;
}
public static ApplicationRegistrationRequest getApplicationRegistrationRequest(
@@ -307,5 +307,4 @@ private static DCRMEndpointException buildDCRMEndpointException(Response.Status
return new DCRMEndpointException(status, errorDTO);
}
}
-
}
diff --git a/components/org.wso2.carbon.identity.api.server.dcr/src/main/resources/META-INF/cxf/oauth2-dcr-v1-1-cxf.xml b/components/org.wso2.carbon.identity.api.server.dcr/src/main/resources/META-INF/cxf/oauth2-dcr-v1-1-cxf.xml
deleted file mode 100644
index e88978d4d65..00000000000
--- a/components/org.wso2.carbon.identity.api.server.dcr/src/main/resources/META-INF/cxf/oauth2-dcr-v1-1-cxf.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
diff --git a/components/org.wso2.carbon.identity.api.server.dcr/src/test/java/org/wso2/carbon/identity/oauth2/dcr/endpoint/impl/RegisterApiServiceImplExceptionTest.java b/components/org.wso2.carbon.identity.api.server.dcr/src/test/java/org/wso2/carbon/identity/oauth2/dcr/endpoint/impl/RegisterApiServiceImplExceptionTest.java
index 18cf707512e..47edaa66c5b 100644
--- a/components/org.wso2.carbon.identity.api.server.dcr/src/test/java/org/wso2/carbon/identity/oauth2/dcr/endpoint/impl/RegisterApiServiceImplExceptionTest.java
+++ b/components/org.wso2.carbon.identity.api.server.dcr/src/test/java/org/wso2/carbon/identity/oauth2/dcr/endpoint/impl/RegisterApiServiceImplExceptionTest.java
@@ -33,6 +33,7 @@
import org.wso2.carbon.context.internal.OSGiDataHolder;
import org.wso2.carbon.identity.application.common.IdentityApplicationManagementException;
import org.wso2.carbon.identity.application.mgt.ApplicationManagementService;
+import org.wso2.carbon.identity.common.testng.WithCarbonHome;
import org.wso2.carbon.identity.oauth.dcr.exception.DCRMException;
import org.wso2.carbon.identity.oauth.dcr.internal.DCRDataHolder;
import org.wso2.carbon.identity.oauth.dcr.service.DCRMService;
@@ -40,7 +41,6 @@
import org.wso2.carbon.identity.oauth2.dcr.endpoint.dto.RegistrationRequestDTO;
import org.wso2.carbon.identity.oauth2.dcr.endpoint.dto.UpdateRequestDTO;
import org.wso2.carbon.identity.oauth2.dcr.endpoint.exceptions.DCRMEndpointException;
-import org.wso2.carbon.identity.oauth2.dcr.endpoint.util.DCRMUtils;
import java.util.ArrayList;
import java.util.List;
@@ -49,11 +49,13 @@
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.lenient;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.mockConstruction;
import static org.mockito.Mockito.mockStatic;
import static org.mockito.Mockito.when;
import static org.testng.Assert.assertEquals;
+@WithCarbonHome
@Listeners(MockitoTestNGListener.class)
public class RegisterApiServiceImplExceptionTest {
@@ -70,13 +72,22 @@ public class RegisterApiServiceImplExceptionTest {
ApplicationManagementService applicationManagementService;
@Mock
- DCRMService mockedDCRMService;
+ PrivilegedCarbonContext privilegedCarbonContext;
MockedConstruction mockedConstruction;
+ private MockedStatic mockedPrivilegedCarbonContext;
@BeforeMethod
public void setUp() throws Exception {
+ if (mockedPrivilegedCarbonContext != null) {
+ mockedPrivilegedCarbonContext.close();
+ }
+ mockedPrivilegedCarbonContext = mockStatic(PrivilegedCarbonContext.class);
+ when(PrivilegedCarbonContext.getThreadLocalCarbonContext()).thenReturn(privilegedCarbonContext);
+ lenient().when(PrivilegedCarbonContext.getThreadLocalCarbonContext()
+ .getOSGiService(DCRMService.class, null)).thenReturn(mock(DCRMService.class));
+
// Initializing variables.
registerApiService = new RegisterApiServiceImpl();
@@ -104,7 +115,6 @@ public void tearDown() {
public void testDeleteApplicationClientException() throws Exception {
try {
- DCRMUtils.setOAuth2DCRMService(mockedDCRMService);
registerApiService.deleteApplication("");
} catch (DCRMEndpointException e) {
assertEquals(e.getResponse().getStatus(), Response.Status.BAD_REQUEST.getStatusCode());
@@ -126,7 +136,6 @@ public void testDeleteApplicationThrowableException() throws DCRMException {
public void testGetApplicationClientException() throws Exception {
try {
- DCRMUtils.setOAuth2DCRMService(mockedDCRMService);
registerApiService.getApplication("");
} catch (DCRMEndpointException e) {
assertEquals(e.getResponse().getStatus(), Response.Status.BAD_REQUEST.getStatusCode());
@@ -155,7 +164,6 @@ public void testRegisterApplicationClientException() throws DCRMException {
registrationRequestDTO.setClientName("Test App");
registrationRequestDTO.setGrantTypes(granttypes);
registrationRequestDTO.setRedirectUris(redirectUris);
- DCRMUtils.setOAuth2DCRMService(mockedDCRMService);
dcrDataHolder.when(DCRDataHolder::getInstance).thenReturn(dataHolder);
lenient().when(dataHolder.getApplicationManagementService()).thenReturn(applicationManagementService);
@@ -180,7 +188,6 @@ public void testRegisterApplicationServerException() throws DCRMException, Ident
registrationRequestDTO.setGrantTypes(granttypes);
registrationRequestDTO.setRedirectUris(redirectUris);
- DCRMUtils.setOAuth2DCRMService(mockedDCRMService);
dcrDataHolder.when(DCRDataHolder::getInstance).thenReturn(dataHolder);
lenient().when(dataHolder.getApplicationManagementService()).thenReturn(applicationManagementService);
lenient().when(applicationManagementService.getServiceProvider(any(String.class), any(String.class))).
@@ -218,7 +225,6 @@ public void testUpdateApplicationClientException() throws DCRMException {
updateRequestDTO.setClientName("Test App");
updateRequestDTO.setGrantTypes(granttypes);
updateRequestDTO.setRedirectUris(redirectUris);
- DCRMUtils.setOAuth2DCRMService(mockedDCRMService);
dcrDataHolder.when(DCRDataHolder::getInstance).thenReturn(dataHolder);
lenient().when(dataHolder.getApplicationManagementService()).thenReturn(applicationManagementService);
diff --git a/components/org.wso2.carbon.identity.api.server.dcr/src/test/java/org/wso2/carbon/identity/oauth2/dcr/endpoint/impl/RegisterApiServiceImplTest.java b/components/org.wso2.carbon.identity.api.server.dcr/src/test/java/org/wso2/carbon/identity/oauth2/dcr/endpoint/impl/RegisterApiServiceImplTest.java
index feb6af16d6b..cb56642834f 100644
--- a/components/org.wso2.carbon.identity.api.server.dcr/src/test/java/org/wso2/carbon/identity/oauth2/dcr/endpoint/impl/RegisterApiServiceImplTest.java
+++ b/components/org.wso2.carbon.identity.api.server.dcr/src/test/java/org/wso2/carbon/identity/oauth2/dcr/endpoint/impl/RegisterApiServiceImplTest.java
@@ -20,6 +20,7 @@
import org.mockito.Mock;
import org.mockito.MockedConstruction;
+import org.mockito.MockedStatic;
import org.mockito.testng.MockitoTestNGListener;
import org.osgi.framework.BundleContext;
import org.osgi.util.tracker.ServiceTracker;
@@ -30,6 +31,7 @@
import org.testng.annotations.Test;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.context.internal.OSGiDataHolder;
+import org.wso2.carbon.identity.common.testng.WithCarbonHome;
import org.wso2.carbon.identity.oauth.dcr.bean.Application;
import org.wso2.carbon.identity.oauth.dcr.bean.ApplicationRegistrationRequest;
import org.wso2.carbon.identity.oauth.dcr.bean.ApplicationUpdateRequest;
@@ -40,7 +42,6 @@
import org.wso2.carbon.identity.oauth2.dcr.endpoint.dto.RegistrationRequestDTO;
import org.wso2.carbon.identity.oauth2.dcr.endpoint.dto.UpdateRequestDTO;
import org.wso2.carbon.identity.oauth2.dcr.endpoint.exceptions.DCRMEndpointException;
-import org.wso2.carbon.identity.oauth2.dcr.endpoint.util.DCRMUtils;
import java.util.ArrayList;
import java.util.List;
@@ -49,11 +50,13 @@
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.lenient;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.mockConstruction;
+import static org.mockito.Mockito.mockStatic;
import static org.mockito.Mockito.when;
+@WithCarbonHome
@Listeners(MockitoTestNGListener.class)
public class RegisterApiServiceImplTest {
@@ -69,10 +72,20 @@ public class RegisterApiServiceImplTest {
@Mock
private DCRMService dcrmService;
+ @Mock
+ PrivilegedCarbonContext privilegedCarbonContext;
+
MockedConstruction mockedConstruction;
+ private MockedStatic mockedPrivilegedCarbonContext;
@BeforeMethod
public void setUp() throws Exception {
+
+ mockedPrivilegedCarbonContext = mockStatic(PrivilegedCarbonContext.class);
+ lenient().when(PrivilegedCarbonContext.getThreadLocalCarbonContext()).thenReturn(privilegedCarbonContext);
+ lenient().when(PrivilegedCarbonContext.getThreadLocalCarbonContext()
+ .getOSGiService(DCRMService.class, null)).thenReturn(mock(DCRMService.class));
+
//Initializing variables.
registerApiService = new RegisterApiServiceImpl();
validclientId = "N2QqQluzQuL5X6CtM3KZwqzLQhUa";
@@ -101,16 +114,15 @@ public void tearDown() {
mockedConstruction.close();
PrivilegedCarbonContext.endTenantFlow();
+ mockedPrivilegedCarbonContext.close();
}
@Test
public void testDeleteApplication() throws Exception {
- DCRMUtils.setOAuth2DCRMService(dcrmService);
- doNothing().when(dcrmService).deleteApplication(validclientId);
+ lenient().doNothing().when(dcrmService).deleteApplication(validclientId);
Assert.assertEquals(registerApiService.deleteApplication(validclientId).getStatus(),
Response.Status.NO_CONTENT.getStatusCode());
-
}
@Test
@@ -127,8 +139,7 @@ public void testDeleteApplicationServerException() throws Exception {
@Test
public void testGetApplication() throws Exception {
- DCRMUtils.setOAuth2DCRMService(dcrmService);
- when(dcrmService.getApplication(validclientId)).thenReturn(application);
+ lenient().when(dcrmService.getApplication(validclientId)).thenReturn(application);
Assert.assertEquals(registerApiService.getApplication(validclientId).getStatus(),
Response.Status.OK.getStatusCode());
@@ -153,8 +164,7 @@ public void testRegisterApplication() throws Exception {
RegistrationRequestDTO registrationRequestDTO = new RegistrationRequestDTO();
registrationRequestDTO.setClientName("app1");
- DCRMUtils.setOAuth2DCRMService(dcrmService);
- when(dcrmService.registerApplication(any(ApplicationRegistrationRequest.class)))
+ lenient().when(dcrmService.registerApplication(any(ApplicationRegistrationRequest.class)))
.thenReturn(application);
Assert.assertEquals(registerApiService.registerApplication(registrationRequestDTO)
.getStatus(), Response.Status.CREATED.getStatusCode());
@@ -179,8 +189,7 @@ public void testUpdateApplication() throws Exception {
UpdateRequestDTO updateRequestDTO1 = new UpdateRequestDTO();
updateRequestDTO1.setClientName("Client1");
String clientID = "clientID1";
- DCRMUtils.setOAuth2DCRMService(dcrmService);
- when(dcrmService.updateApplication
+ lenient().when(dcrmService.updateApplication
(any(ApplicationUpdateRequest.class), anyString()))
.thenReturn(application);
Assert.assertEquals(registerApiService.updateApplication(updateRequestDTO1, clientID)
diff --git a/components/org.wso2.carbon.identity.api.server.dcr/src/test/java/org/wso2/carbon/identity/oauth2/dcr/endpoint/util/DCRMUtilsTest.java b/components/org.wso2.carbon.identity.api.server.dcr/src/test/java/org/wso2/carbon/identity/oauth2/dcr/endpoint/util/DCRMUtilsTest.java
index 0a1a17abe24..269fd02187a 100644
--- a/components/org.wso2.carbon.identity.api.server.dcr/src/test/java/org/wso2/carbon/identity/oauth2/dcr/endpoint/util/DCRMUtilsTest.java
+++ b/components/org.wso2.carbon.identity.api.server.dcr/src/test/java/org/wso2/carbon/identity/oauth2/dcr/endpoint/util/DCRMUtilsTest.java
@@ -18,11 +18,19 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.mockito.Mock;
+import org.mockito.MockedStatic;
+import org.mockito.testng.MockitoTestNGListener;
import org.testng.Assert;
+import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
import org.testng.annotations.Test;
+import org.wso2.carbon.context.PrivilegedCarbonContext;
+import org.wso2.carbon.identity.common.testng.WithCarbonHome;
import org.wso2.carbon.identity.oauth.dcr.exception.DCRMException;
+import org.wso2.carbon.identity.oauth.dcr.service.DCRMService;
import org.wso2.carbon.identity.oauth2.dcr.endpoint.dto.RegistrationRequestDTO;
import org.wso2.carbon.identity.oauth2.dcr.endpoint.dto.UpdateRequestDTO;
import org.wso2.carbon.identity.oauth2.dcr.endpoint.exceptions.DCRMEndpointException;
@@ -32,19 +40,42 @@
import javax.ws.rs.core.Response;
+import static org.mockito.Mockito.lenient;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.mockStatic;
+import static org.mockito.Mockito.when;
+
+@WithCarbonHome
+@Listeners(MockitoTestNGListener.class)
public class DCRMUtilsTest {
private List redirectUris = new ArrayList<>();
private List grantTypes = new ArrayList<>();
private final String clientName = "Application";
+ @Mock
+ PrivilegedCarbonContext privilegedCarbonContext;
+
+ private MockedStatic mockedPrivilegedCarbonContext;
+
@BeforeMethod
public void setUp() throws Exception {
+ mockedPrivilegedCarbonContext = mockStatic(PrivilegedCarbonContext.class);
+ when(PrivilegedCarbonContext.getThreadLocalCarbonContext()).thenReturn(privilegedCarbonContext);
+ lenient().when(PrivilegedCarbonContext.getThreadLocalCarbonContext().getOSGiService(DCRMService.class, null))
+ .thenReturn(mock(DCRMService.class));
+
redirectUris.add("https://op.certification.openid.net:60845/authz_cb");
grantTypes.add("authorization_code");
}
+ @AfterMethod
+ public void tearDown() {
+
+ mockedPrivilegedCarbonContext.close();
+ }
+
@Test
public void testGetApplicationRegistrationRequest() throws Exception {
diff --git a/components/org.wso2.carbon.identity.api.server.dcr/src/test/resources/repository/conf/carbon.xml b/components/org.wso2.carbon.identity.api.server.dcr/src/test/resources/repository/conf/carbon.xml
new file mode 100644
index 00000000000..faae9528f41
--- /dev/null
+++ b/components/org.wso2.carbon.identity.api.server.dcr/src/test/resources/repository/conf/carbon.xml
@@ -0,0 +1,684 @@
+
+
+
+
+
+
+
+ WSO2 Identity Server
+
+
+ IS
+
+
+ 5.3.0
+
+
+ localhost
+
+
+ localhost
+
+
+ local:/${carbon.context}/services/
+
+
+
+
+
+
+ IdentityServer
+
+
+
+
+
+
+ org.wso2.carbon
+
+
+ /
+
+
+
+
+
+
+
+
+ 15
+
+
+
+
+
+
+
+
+ 0
+
+
+
+
+ 9999
+
+ 11111
+
+
+
+
+
+ 10389
+
+ 8000
+
+
+
+
+
+ 10500
+
+
+
+
+
+
+
+
+ org.wso2.carbon.tomcat.jndi.CarbonJavaURLContextFactory
+
+
+
+
+
+
+
+
+ java
+
+
+
+
+
+
+
+
+
+ false
+
+
+ false
+
+
+ 600
+
+
+
+ false
+
+
+
+
+
+
+
+ 30
+
+
+
+
+
+
+
+
+ 15
+
+
+
+
+
+ ${carbon.home}/repository/deployment/server/
+
+
+ 15
+
+
+ ${carbon.home}/repository/conf/axis2/axis2.xml
+
+
+ 30000
+
+
+ ${carbon.home}/repository/deployment/client/
+
+ ${carbon.home}/repository/conf/axis2/axis2_client.xml
+
+ false
+
+
+
+
+
+
+
+
+
+ admin
+ Default Administrator Role
+
+
+ user
+ Default User Role
+
+
+
+
+ false
+
+
+
+
+
+
+ ${carbon.home}/repository/resources/security/wso2carbon.jks
+
+ JKS
+
+ wso2carbon
+
+ wso2carbon
+
+ wso2carbon
+
+
+
+
+
+ ${carbon.home}/repository/resources/security/client-truststore.jks
+
+ JKS
+
+ wso2carbon
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ UserManager
+
+
+ false
+
+ org.wso2.carbon.identity.provider.AttributeCallbackHandler
+
+
+ org.wso2.carbon.identity.sts.store.DBTokenStore
+
+
+ true
+ allow
+
+
+
+
+
+
+claim_mgt_menu
+identity_mgt_emailtemplate_menu
+identity_security_questions_menu
+
+
+
+ ${carbon.home}/tmp/work
+
+
+
+
+
+ true
+
+
+ 10
+
+
+ 30
+
+
+
+
+
+ 100
+
+
+
+ keystore
+ certificate
+ *
+
+ org.wso2.carbon.ui.transports.fileupload.AnyFileUploadExecutor
+
+
+
+
+ jarZip
+
+ org.wso2.carbon.ui.transports.fileupload.JarZipUploadExecutor
+
+
+
+ dbs
+
+ org.wso2.carbon.ui.transports.fileupload.DBSFileUploadExecutor
+
+
+
+ tools
+
+ org.wso2.carbon.ui.transports.fileupload.ToolsFileUploadExecutor
+
+
+
+ toolsAny
+
+ org.wso2.carbon.ui.transports.fileupload.ToolsAnyFileUploadExecutor
+
+
+
+
+
+
+
+
+
+ - info
+ org.wso2.carbon.core.transports.util.InfoProcessor
+
+
+ - wsdl
+ org.wso2.carbon.core.transports.util.Wsdl11Processor
+
+
+ - wsdl2
+ org.wso2.carbon.core.transports.util.Wsdl20Processor
+
+
+ - xsd
+ org.wso2.carbon.core.transports.util.XsdProcessor
+
+
+
+
+
+ false
+ false
+ true
+ svn
+ http://svnrepo.example.com/repos/
+ username
+ password
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ${require.carbon.servlet}
+
+
+
+
+ true
+
+
+
+
+
+
+ default repository
+ http://product-dist.wso2.com/p2/carbon/releases/wilkes/
+
+
+
+
+
+
+
+ true
+
+
+
+
+
+ true
+
+
diff --git a/components/org.wso2.carbon.identity.api.server.oauth.scope/pom.xml b/components/org.wso2.carbon.identity.api.server.oauth.scope/pom.xml
index 03a3dd40972..64699f2d52c 100644
--- a/components/org.wso2.carbon.identity.api.server.oauth.scope/pom.xml
+++ b/components/org.wso2.carbon.identity.api.server.oauth.scope/pom.xml
@@ -1,6 +1,6 @@
-
-
-
-
-
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 067644ec1b2..c0b59585ae0 100644
--- a/components/org.wso2.carbon.identity.client.attestation.filter/pom.xml
+++ b/components/org.wso2.carbon.identity.client.attestation.filter/pom.xml
@@ -22,7 +22,7 @@
org.wso2.carbon.identity.inbound.auth.oauth2
identity-inbound-auth-oauth
- 7.0.191-SNAPSHOT
+ 7.0.214-SNAPSHOT
../../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.discovery/pom.xml b/components/org.wso2.carbon.identity.discovery/pom.xml
index 2c641bcb07c..3d51245f526 100644
--- a/components/org.wso2.carbon.identity.discovery/pom.xml
+++ b/components/org.wso2.carbon.identity.discovery/pom.xml
@@ -21,7 +21,7 @@
org.wso2.carbon.identity.inbound.auth.oauth2
identity-inbound-auth-oauth
../../pom.xml
- 7.0.191-SNAPSHOT
+ 7.0.214-SNAPSHOT
4.0.0
diff --git a/components/org.wso2.carbon.identity.oauth.ciba/pom.xml b/components/org.wso2.carbon.identity.oauth.ciba/pom.xml
index e155302d75a..3d08bf7559c 100644
--- a/components/org.wso2.carbon.identity.oauth.ciba/pom.xml
+++ b/components/org.wso2.carbon.identity.oauth.ciba/pom.xml
@@ -20,7 +20,7 @@
identity-inbound-auth-oauth
org.wso2.carbon.identity.inbound.auth.oauth2
- 7.0.191-SNAPSHOT
+ 7.0.214-SNAPSHOT
../../pom.xml
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 92f248f0475..b5da02cf474 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
@@ -22,7 +22,7 @@
org.wso2.carbon.identity.inbound.auth.oauth2
identity-inbound-auth-oauth
../../pom.xml
- 7.0.191-SNAPSHOT
+ 7.0.214-SNAPSHOT
4.0.0
@@ -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;
}
}
diff --git a/components/org.wso2.carbon.identity.oauth.common/pom.xml b/components/org.wso2.carbon.identity.oauth.common/pom.xml
index 54b269b6b00..69e0752a0db 100644
--- a/components/org.wso2.carbon.identity.oauth.common/pom.xml
+++ b/components/org.wso2.carbon.identity.oauth.common/pom.xml
@@ -23,7 +23,7 @@
org.wso2.carbon.identity.inbound.auth.oauth2
identity-inbound-auth-oauth
../../pom.xml
- 7.0.191-SNAPSHOT
+ 7.0.214-SNAPSHOT
4.0.0
diff --git a/components/org.wso2.carbon.identity.oauth.common/src/main/java/org/wso2/carbon/identity/oauth/common/OAuthConstants.java b/components/org.wso2.carbon.identity.oauth.common/src/main/java/org/wso2/carbon/identity/oauth/common/OAuthConstants.java
index 7ee3e18fa16..f4466f49f57 100644
--- a/components/org.wso2.carbon.identity.oauth.common/src/main/java/org/wso2/carbon/identity/oauth/common/OAuthConstants.java
+++ b/components/org.wso2.carbon.identity.oauth.common/src/main/java/org/wso2/carbon/identity/oauth/common/OAuthConstants.java
@@ -117,6 +117,8 @@ public final class OAuthConstants {
public static final String READ_AMR_VALUE_FROM_IDP = "OAuth.ReplaceDefaultAMRValuesWithIDPSentValues";
+ public static final String OAUTH_APP = "OAuthAppDO";
+
public static final String CNF = "cnf";
public static final String MTLS_AUTH_HEADER = "MutualTLS.ClientCertificateHeader";
public static final String BEGIN_CERT = "-----BEGIN CERTIFICATE-----";
@@ -579,6 +581,7 @@ public static class OIDCClaims {
public static final String EMAIL_VERIFIED = "email_verified";
public static final String ADDRESS = "address";
public static final String ROLES = "roles";
+ public static final String APP_ROLES = "application_roles";
public static final String CUSTOM = "custom";
public static final String AZP = "azp";
public static final String AUTH_TIME = "auth_time";
diff --git a/components/org.wso2.carbon.identity.oauth.dcr.endpoint/pom.xml b/components/org.wso2.carbon.identity.oauth.dcr.endpoint/pom.xml
index 22550842e46..a3ca06d917a 100644
--- a/components/org.wso2.carbon.identity.oauth.dcr.endpoint/pom.xml
+++ b/components/org.wso2.carbon.identity.oauth.dcr.endpoint/pom.xml
@@ -6,7 +6,7 @@
org.wso2.carbon.identity.inbound.auth.oauth2
identity-inbound-auth-oauth
../../pom.xml
- 7.0.191-SNAPSHOT
+ 7.0.214-SNAPSHOT
4.0.0
@@ -31,11 +31,6 @@
jackson-databind
provided
-
- org.springframework
- spring-web
- provided
-
io.swagger
swagger-jaxrs
diff --git a/components/org.wso2.carbon.identity.oauth.dcr.endpoint/src/main/webapp/WEB-INF/web.xml b/components/org.wso2.carbon.identity.oauth.dcr.endpoint/src/main/webapp/WEB-INF/web.xml
index 3dc8da7d2f3..98dd7589942 100644
--- a/components/org.wso2.carbon.identity.oauth.dcr.endpoint/src/main/webapp/WEB-INF/web.xml
+++ b/components/org.wso2.carbon.identity.oauth.dcr.endpoint/src/main/webapp/WEB-INF/web.xml
@@ -49,28 +49,30 @@
*
-
- contextConfigLocation
- WEB-INF/beans.xml
-
-
-
- org.springframework.web.context.ContextLoaderListener
-
-
-
CXFServlet
- org.apache.cxf.transport.servlet.CXFServlet
+ org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet
1
-
+
+
+ jaxrs.serviceClasses
+
+ org.wso2.carbon.identity.oauth2.dcr.endpoint.RegisterApi
+
+
-
- CXFServlet
- /*
-
+
+ jaxrs.providers
+
+ com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider,
+ org.wso2.carbon.identity.oauth2.dcr.endpoint.exmapper.JsonProcessingExceptionMapper,
+ com.fasterxml.jackson.jaxrs.base.JsonMappingExceptionMapper,
+ com.fasterxml.jackson.jaxrs.base.JsonParseExceptionMapper
+
+
+
60
diff --git a/components/org.wso2.carbon.identity.oauth.dcr/pom.xml b/components/org.wso2.carbon.identity.oauth.dcr/pom.xml
index e96c26a8bdb..e8b7e935466 100644
--- a/components/org.wso2.carbon.identity.oauth.dcr/pom.xml
+++ b/components/org.wso2.carbon.identity.oauth.dcr/pom.xml
@@ -22,7 +22,7 @@
org.wso2.carbon.identity.inbound.auth.oauth2
identity-inbound-auth-oauth
../../pom.xml
- 7.0.191-SNAPSHOT
+ 7.0.214-SNAPSHOT
4.0.0
@@ -126,7 +126,10 @@
org.wso2.carbon.identity.framework
org.wso2.carbon.identity.configuration.mgt.core
-
+
+ org.wso2.carbon.identity.organization.management.core
+ org.wso2.carbon.identity.organization.management.service
+
@@ -165,6 +168,8 @@
org.wso2.carbon.identity.application.common.model;version="${carbon.identity.framework.imp.pkg.version.range}",
org.wso2.carbon.identity.application.mgt.*;version="${carbon.identity.framework.imp.pkg.version.range}",
org.wso2.carbon.identity.application.authentication.framework.*;version="${carbon.identity.framework.imp.pkg.version.range}",
+ org.wso2.carbon.identity.organization.management.service; version="${carbon.identity.organization.management.core.version.range}",
+ org.wso2.carbon.identity.organization.management.service.exception; version="${carbon.identity.organization.management.core.version.range}",
javax.servlet.http; version="${imp.pkg.version.javax.servlet}",
org.wso2.carbon.user.api; version="${carbon.user.api.imp.pkg.version.range}",
org.wso2.carbon.identity.oauth.*;version="${identity.inbound.auth.oauth.imp.pkg.version.range}",
diff --git a/components/org.wso2.carbon.identity.oauth.dcr/src/main/java/org/wso2/carbon/identity/oauth/dcr/DCRMConstants.java b/components/org.wso2.carbon.identity.oauth.dcr/src/main/java/org/wso2/carbon/identity/oauth/dcr/DCRMConstants.java
index 83b32bb5e0d..8eabb696ce1 100644
--- a/components/org.wso2.carbon.identity.oauth.dcr/src/main/java/org/wso2/carbon/identity/oauth/dcr/DCRMConstants.java
+++ b/components/org.wso2.carbon.identity.oauth.dcr/src/main/java/org/wso2/carbon/identity/oauth/dcr/DCRMConstants.java
@@ -60,7 +60,8 @@ public enum ErrorMessages {
SIGNATURE_VALIDATION_FAILED("Signature validation failed for the software statement"),
MANDATORY_SOFTWARE_STATEMENT("Mandatory software statement is missing"),
FAILED_TO_READ_SSA("Error occurred while reading the software statement"),
- ADDITIONAL_ATTRIBUTE_ERROR("Error occurred while handling additional attributes");
+ ADDITIONAL_ATTRIBUTE_ERROR("Error occurred while handling additional attributes"),
+ FAILED_TO_RESOLVE_TENANT_DOMAIN("Error while resolving tenant domain from the organization id: %s");
private final String message;
private final String errorCode;
diff --git a/components/org.wso2.carbon.identity.oauth.dcr/src/main/java/org/wso2/carbon/identity/oauth/dcr/internal/DCRDataHolder.java b/components/org.wso2.carbon.identity.oauth.dcr/src/main/java/org/wso2/carbon/identity/oauth/dcr/internal/DCRDataHolder.java
index eaaf88e4f68..25bf98dbe34 100644
--- a/components/org.wso2.carbon.identity.oauth.dcr/src/main/java/org/wso2/carbon/identity/oauth/dcr/internal/DCRDataHolder.java
+++ b/components/org.wso2.carbon.identity.oauth.dcr/src/main/java/org/wso2/carbon/identity/oauth/dcr/internal/DCRDataHolder.java
@@ -23,6 +23,7 @@
import org.wso2.carbon.identity.oauth.dcr.handler.RegistrationHandler;
import org.wso2.carbon.identity.oauth.dcr.handler.UnRegistrationHandler;
import org.wso2.carbon.identity.oauth2.token.bindings.TokenBinder;
+import org.wso2.carbon.identity.organization.management.service.OrganizationManager;
import java.util.ArrayList;
import java.util.List;
@@ -33,7 +34,6 @@
* This was deprecated as part of deprecating the legacy identity/register DCR endpoint.
* The recommendation is to use /identity/oauth2/dcr/v1.1 instead.
*/
-@Deprecated
public class DCRDataHolder {
private static DCRDataHolder thisInstance = new DCRDataHolder();
@@ -42,6 +42,7 @@ public class DCRDataHolder {
private List unRegistrationHandlerList = new ArrayList<>();
private List tokenBinders = new ArrayList<>();
private ConfigurationManager configurationManager;
+ private OrganizationManager organizationManager;
private DCRDataHolder() {
@@ -111,4 +112,14 @@ public void setConfigurationManager(ConfigurationManager configurationManager) {
this.configurationManager = configurationManager;
}
+
+ public OrganizationManager getOrganizationManager() {
+
+ return organizationManager;
+ }
+
+ public void setOrganizationManager(OrganizationManager organizationManager) {
+
+ this.organizationManager = organizationManager;
+ }
}
diff --git a/components/org.wso2.carbon.identity.oauth.dcr/src/main/java/org/wso2/carbon/identity/oauth/dcr/internal/DCRServiceComponent.java b/components/org.wso2.carbon.identity.oauth.dcr/src/main/java/org/wso2/carbon/identity/oauth/dcr/internal/DCRServiceComponent.java
index fedd5a94b7f..6a0b63318a1 100644
--- a/components/org.wso2.carbon.identity.oauth.dcr/src/main/java/org/wso2/carbon/identity/oauth/dcr/internal/DCRServiceComponent.java
+++ b/components/org.wso2.carbon.identity.oauth.dcr/src/main/java/org/wso2/carbon/identity/oauth/dcr/internal/DCRServiceComponent.java
@@ -42,6 +42,7 @@
import org.wso2.carbon.identity.oauth.dcr.processor.DCRProcessor;
import org.wso2.carbon.identity.oauth.dcr.service.DCRMService;
import org.wso2.carbon.identity.oauth2.token.bindings.TokenBinder;
+import org.wso2.carbon.identity.organization.management.service.OrganizationManager;
/**
* OAuth DCRM service component.
@@ -52,7 +53,6 @@
name = "identity.oauth.dcr",
immediate = true
)
-@Deprecated
public class DCRServiceComponent {
private static final Log log = LogFactory.getLog(DCRServiceComponent.class);
@@ -254,4 +254,23 @@ protected void unregisterConfigurationManager(ConfigurationManager configuration
log.debug("Unregistering the ConfigurationManager in DCR Service Component.");
DCRDataHolder.getInstance().setConfigurationManager(null);
}
+
+ @Reference(
+ name = "organization.service",
+ service = OrganizationManager.class,
+ cardinality = ReferenceCardinality.MANDATORY,
+ policy = ReferencePolicy.DYNAMIC,
+ unbind = "unsetOrganizationManager"
+ )
+ protected void setOrganizationManager(OrganizationManager organizationManager) {
+
+ DCRDataHolder.getInstance().setOrganizationManager(organizationManager);
+ log.debug("Set the organization management service.");
+ }
+
+ protected void unsetOrganizationManager(OrganizationManager organizationManager) {
+
+ DCRDataHolder.getInstance().setOrganizationManager(null);
+ log.debug("Unset organization management service.");
+ }
}
diff --git a/components/org.wso2.carbon.identity.oauth.dcr/src/main/java/org/wso2/carbon/identity/oauth/dcr/service/DCRMService.java b/components/org.wso2.carbon.identity.oauth.dcr/src/main/java/org/wso2/carbon/identity/oauth/dcr/service/DCRMService.java
index 8e2c9c147f7..ae87ca10fe5 100644
--- a/components/org.wso2.carbon.identity.oauth.dcr/src/main/java/org/wso2/carbon/identity/oauth/dcr/service/DCRMService.java
+++ b/components/org.wso2.carbon.identity.oauth.dcr/src/main/java/org/wso2/carbon/identity/oauth/dcr/service/DCRMService.java
@@ -64,6 +64,7 @@
import org.wso2.carbon.identity.oauth2.OAuth2Constants;
import org.wso2.carbon.identity.oauth2.util.JWTSignatureValidationUtils;
import org.wso2.carbon.identity.oauth2.util.OAuth2Util;
+import org.wso2.carbon.identity.organization.management.service.exception.OrganizationManagementException;
import org.wso2.carbon.user.api.UserStoreException;
import java.lang.reflect.InvocationTargetException;
@@ -105,12 +106,12 @@ public class DCRMService {
*/
public Application getApplication(String clientId) throws DCRMException {
- validateRequestTenantDomain(clientId);
+ String tenantDomain = getTenantDomain();
+ validateRequestTenantDomain(clientId, tenantDomain);
OAuthConsumerAppDTO consumerAppDTO = getApplicationById(
- clientId, DCRMUtils.isApplicationRolePermissionRequired());
+ clientId, DCRMUtils.isApplicationRolePermissionRequired(), tenantDomain);
// Get the jwksURI from the service provider.
String applicationName = consumerAppDTO.getApplicationName();
- String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
ServiceProvider serviceProvider = getServiceProvider(applicationName, tenantDomain);
String jwksURI = serviceProvider.getJwksUri();
if (StringUtils.isNotEmpty(jwksURI)) {
@@ -156,7 +157,7 @@ public Application getApplicationByName(String clientName) throws DCRMException
DCRMConstants.ErrorMessages.BAD_REQUEST_INSUFFICIENT_DATA, null);
}
- String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
+ String tenantDomain = getTenantDomain();
if (!isServiceProviderExist(clientName, tenantDomain)) {
throw DCRMUtils.generateClientException(
DCRMConstants.ErrorMessages.NOT_FOUND_APPLICATION_WITH_NAME, clientName);
@@ -203,10 +204,10 @@ public Application registerApplication(ApplicationRegistrationRequest registrati
*/
public void deleteApplication(String clientId) throws DCRMException {
- validateRequestTenantDomain(clientId);
- OAuthConsumerAppDTO appDTO = getApplicationById(clientId);
+ String tenantDomain = getTenantDomain();
+ validateRequestTenantDomain(clientId, tenantDomain);
+ OAuthConsumerAppDTO appDTO = getApplicationById(clientId, tenantDomain);
String applicationOwner = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
- String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
String spName;
try {
spName = DCRDataHolder.getInstance().getApplicationManagementService()
@@ -241,9 +242,9 @@ public void deleteApplication(String clientId) throws DCRMException {
*/
public Application updateApplication(ApplicationUpdateRequest updateRequest, String clientId) throws DCRMException {
- validateRequestTenantDomain(clientId);
- OAuthConsumerAppDTO appDTO = getApplicationById(clientId);
- String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
+ String tenantDomain = getTenantDomain();
+ validateRequestTenantDomain(clientId, tenantDomain);
+ OAuthConsumerAppDTO appDTO = getApplicationById(clientId, tenantDomain);
String applicationOwner = StringUtils.isNotBlank(updateRequest.getExtApplicationOwner()) ?
updateRequest.getExtApplicationOwner() :
PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
@@ -309,13 +310,24 @@ public Application updateApplication(ApplicationUpdateRequest updateRequest, Str
sp.setJwksUri(updateRequest.getJwksURI());
}
// Todo: validate version input. Create a function at app mgt.
- sp.setApplicationVersion(applicationVersion);
- // Need to create a deep clone, since modifying the fields of the original object,
- // will modify the cached SP object.
- ServiceProvider clonedSP = cloneServiceProvider(sp);
+ if (StringUtils.isNotBlank(applicationVersion)) {
+ sp.setApplicationVersion(applicationVersion);
+ }
+ }
+ if (StringUtils.isNotEmpty(updateRequest.getExtAllowedAudience()) &&
+ (updateRequest.getExtAllowedAudience().equalsIgnoreCase(ORG_ROLE_AUDIENCE)
+ || updateRequest.getExtAllowedAudience().equalsIgnoreCase(APP_ROLE_AUDIENCE))) {
+ AssociatedRolesConfig associatedRolesConfig = new AssociatedRolesConfig();
+ associatedRolesConfig.setAllowedAudience(updateRequest.getExtAllowedAudience().toLowerCase());
+ sp.setAssociatedRolesConfig(associatedRolesConfig);
+ }
+ // Need to create a deep clone, since modifying the fields of the original object,
+ // will modify the cached SP object.
+ ServiceProvider clonedSP = cloneServiceProvider(sp);
+ if (StringUtils.isNotEmpty(clientName)) {
clonedSP.setApplicationName(clientName);
- updateServiceProvider(clonedSP, tenantDomain, applicationOwner);
}
+ updateServiceProvider(clonedSP, tenantDomain, applicationOwner);
// Update application
try {
@@ -412,21 +424,13 @@ public Application updateApplication(ApplicationUpdateRequest updateRequest, Str
appDTO.setPkceSupportPlain(updateRequest.isExtPkceSupportPlain());
appDTO.setBypassClientCredentials(updateRequest.isExtPublicClient());
oAuthAdminService.updateConsumerApplication(appDTO);
-
- if (StringUtils.isNotEmpty(updateRequest.getExtAllowedAudience()) &&
- (updateRequest.getExtAllowedAudience().equalsIgnoreCase(ORG_ROLE_AUDIENCE)
- || updateRequest.getExtAllowedAudience().equalsIgnoreCase(APP_ROLE_AUDIENCE))) {
- AssociatedRolesConfig associatedRolesConfig = new AssociatedRolesConfig();
- associatedRolesConfig.setAllowedAudience(updateRequest.getExtAllowedAudience().toLowerCase());
- sp.setAssociatedRolesConfig(associatedRolesConfig);
- }
} catch (IdentityOAuthClientException e) {
throw new DCRMClientException(DCRMConstants.ErrorCodes.INVALID_CLIENT_METADATA, e.getMessage(), e);
} catch (IdentityOAuthAdminException e) {
throw DCRMUtils.generateServerException(
DCRMConstants.ErrorMessages.FAILED_TO_UPDATE_APPLICATION, clientId, e);
}
- OAuthConsumerAppDTO oAuthConsumerAppDTO = getApplicationById(clientId);
+ OAuthConsumerAppDTO oAuthConsumerAppDTO = getApplicationById(clientId, tenantDomain);
// Setting the jwksURI to be sent in the response.
oAuthConsumerAppDTO.setJwksURI(updateRequest.getJwksURI());
Application application = buildResponse(oAuthConsumerAppDTO, tenantDomain);
@@ -489,12 +493,13 @@ private String getDisplayNameProperty(ServiceProvider serviceProvider) {
return displayNameProperty.map(ServiceProviderProperty::getValue).orElse(null);
}
- private OAuthConsumerAppDTO getApplicationById(String clientId) throws DCRMException {
+ private OAuthConsumerAppDTO getApplicationById(String clientId, String tenantDomain) throws DCRMException {
- return getApplicationById(clientId, true);
+ return getApplicationById(clientId, true, tenantDomain);
}
- private OAuthConsumerAppDTO getApplicationById(String clientId, boolean isApplicationRolePermissionRequired)
+ private OAuthConsumerAppDTO getApplicationById(String clientId, boolean isApplicationRolePermissionRequired,
+ String tenantDomain)
throws DCRMException {
if (StringUtils.isEmpty(clientId)) {
@@ -504,7 +509,7 @@ private OAuthConsumerAppDTO getApplicationById(String clientId, boolean isApplic
}
try {
- OAuthConsumerAppDTO dto = oAuthAdminService.getOAuthApplicationData(clientId);
+ OAuthConsumerAppDTO dto = oAuthAdminService.getOAuthApplicationData(clientId, tenantDomain);
if (dto == null || StringUtils.isEmpty(dto.getApplicationName())) {
throw DCRMUtils.generateClientException(
DCRMConstants.ErrorMessages.NOT_FOUND_APPLICATION_WITH_ID, clientId);
@@ -529,8 +534,7 @@ private Application createOAuthApplication(ApplicationRegistrationRequest regist
String applicationOwner = StringUtils.isNotBlank(registrationRequest.getExtApplicationOwner()) ?
registrationRequest.getExtApplicationOwner() :
PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
-
- String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
+ String tenantDomain = getTenantDomain();
/*
* ApplicationOwner will be null and a server error is thrown when creating an app, if the api authentication/
@@ -566,7 +570,7 @@ private Application createOAuthApplication(ApplicationRegistrationRequest regist
}
if (StringUtils.isNotEmpty(registrationRequest.getConsumerKey()) && isClientIdExist(
- registrationRequest.getConsumerKey())) {
+ registrationRequest.getConsumerKey(), tenantDomain)) {
throw DCRMUtils.generateClientException(DCRMConstants.ErrorMessages.CONFLICT_EXISTING_CLIENT_ID,
registrationRequest.getConsumerKey());
}
@@ -941,10 +945,10 @@ private boolean isServiceProviderExist(String serviceProviderName, String tenant
* @return true if application exists with the client id.
* @throws DCRMException in case of failure.
*/
- private boolean isClientIdExist(String clientId) throws DCRMException {
+ private boolean isClientIdExist(String clientId, String tenantDomain) throws DCRMException {
try {
- OAuthConsumerAppDTO dto = oAuthAdminService.getOAuthApplicationData(clientId);
+ OAuthConsumerAppDTO dto = oAuthAdminService.getOAuthApplicationData(clientId, tenantDomain);
return dto != null && StringUtils.isNotBlank(dto.getApplicationName());
} catch (IdentityOAuthAdminException e) {
if (e.getCause() instanceof InvalidOAuthClientException) {
@@ -1144,7 +1148,7 @@ private String escapeQueryParamsIfPresent(String redirectURI) {
private boolean isUserAuthorized(String clientId) throws DCRMServerException {
try {
- String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
+ String tenantDomain = getTenantDomain();
String spName = DCRDataHolder.getInstance().getApplicationManagementService()
.getServiceProviderNameByClientId(clientId, DCRMConstants.OAUTH2, tenantDomain);
String threadLocalUserName = CarbonContext.getThreadLocalCarbonContext().getUsername();
@@ -1176,10 +1180,10 @@ private static boolean clientIdMatchesRegex(String clientId, String clientIdVali
* @param clientId Consumer key of application.
* @throws DCRMException DCRMException
*/
- private void validateRequestTenantDomain(String clientId) throws DCRMException {
+ private void validateRequestTenantDomain(String clientId, String tenantDomain) throws DCRMException {
try {
- String tenantDomainOfApp = OAuth2Util.getTenantDomainOfOauthApp(clientId);
+ String tenantDomainOfApp = OAuth2Util.getTenantDomainOfOauthApp(clientId, tenantDomain);
OAuth2Util.validateRequestTenantDomain(tenantDomainOfApp);
} catch (InvalidOAuthClientException e) {
throw new DCRMClientException(DCRMConstants.ErrorMessages.TENANT_DOMAIN_MISMATCH.getErrorCode(),
@@ -1275,4 +1279,21 @@ private void addSPProperties(Map spProperties, ServiceProvider s
}
serviceProvider.setSpProperties(serviceProviderProperties);
}
+
+ private static String getTenantDomain() throws DCRMServerException {
+
+ String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
+ String applicationResidentOrgId = PrivilegedCarbonContext.getThreadLocalCarbonContext()
+ .getApplicationResidentOrganizationId();
+ if (StringUtils.isNotEmpty(applicationResidentOrgId)) {
+ try {
+ tenantDomain = DCRDataHolder.getInstance().getOrganizationManager()
+ .resolveTenantDomain(applicationResidentOrgId);
+ } catch (OrganizationManagementException e) {
+ throw DCRMUtils.generateServerException(
+ DCRMConstants.ErrorMessages.FAILED_TO_RESOLVE_TENANT_DOMAIN, applicationResidentOrgId, e);
+ }
+ }
+ return tenantDomain;
+ }
}
diff --git a/components/org.wso2.carbon.identity.oauth.dcr/src/main/java/org/wso2/carbon/identity/oauth/dcr/util/DCRMUtils.java b/components/org.wso2.carbon.identity.oauth.dcr/src/main/java/org/wso2/carbon/identity/oauth/dcr/util/DCRMUtils.java
index 7e2df76179e..beb611f1de1 100644
--- a/components/org.wso2.carbon.identity.oauth.dcr/src/main/java/org/wso2/carbon/identity/oauth/dcr/util/DCRMUtils.java
+++ b/components/org.wso2.carbon.identity.oauth.dcr/src/main/java/org/wso2/carbon/identity/oauth/dcr/util/DCRMUtils.java
@@ -37,7 +37,6 @@
* This was deprecated as part of deprecating the legacy identity/register DCR endpoint.
* The recommendation is to use /identity/oauth2/dcr/v1.1 instead.
*/
-@Deprecated
public class DCRMUtils {
private static final Log log = LogFactory.getLog(DCRMUtils.class);
diff --git a/components/org.wso2.carbon.identity.oauth.dcr/src/test/java/org/wso2/carbon/identity/oauth/dcr/service/DCRMServiceTest.java b/components/org.wso2.carbon.identity.oauth.dcr/src/test/java/org/wso2/carbon/identity/oauth/dcr/service/DCRMServiceTest.java
index 87c456aaf23..8edaea61d9c 100644
--- a/components/org.wso2.carbon.identity.oauth.dcr/src/test/java/org/wso2/carbon/identity/oauth/dcr/service/DCRMServiceTest.java
+++ b/components/org.wso2.carbon.identity.oauth.dcr/src/test/java/org/wso2/carbon/identity/oauth/dcr/service/DCRMServiceTest.java
@@ -108,6 +108,7 @@ public class DCRMServiceTest {
private String dummyCallbackUrl = "dummyCallbackUrl";
private final String dummyTemplateName = "dummyTemplateName";
private final String dummyBackchannelLogoutUri = "http://backchannel.com/";
+ private static final String ORG_ROLE_AUDIENCE = "organization";
@Mock
private OAuthConsumerAppDTO dto;
@@ -199,12 +200,12 @@ public void getApplicationEmptyClientIdTest() throws DCRMException {
public void getApplicationNullDTOTest(String dtoStatus) throws Exception {
if (dtoStatus == null) {
- when(mockOAuthAdminService.getOAuthApplicationData(dummyConsumerKey)).thenReturn(null);
+ when(mockOAuthAdminService.getOAuthApplicationData(dummyConsumerKey, dummyTenantDomain)).thenReturn(null);
lenient().when(mockOAuthAdminService.getAllOAuthApplicationData()).thenReturn(new OAuthConsumerAppDTO[0]);
} else {
OAuthConsumerAppDTO dto = new OAuthConsumerAppDTO();
dto.setApplicationName("");
- when(mockOAuthAdminService.getOAuthApplicationData(dummyConsumerKey)).thenReturn(dto);
+ when(mockOAuthAdminService.getOAuthApplicationData(dummyConsumerKey, dummyTenantDomain)).thenReturn(dto);
lenient().when(mockOAuthAdminService.getAllOAuthApplicationData())
.thenReturn(new OAuthConsumerAppDTO[]{dto});
}
@@ -222,7 +223,7 @@ public void getApplicationNullDTOTest(String dtoStatus) throws Exception {
public void getApplicationDTOTestWithIOAException() throws Exception {
doThrow(new IdentityOAuthAdminException("")).when(mockOAuthAdminService)
- .getOAuthApplicationData(dummyConsumerKey);
+ .getOAuthApplicationData(dummyConsumerKey, dummyTenantDomain);
lenient().when(mockOAuthAdminService.getAllOAuthApplicationData()).thenReturn(new OAuthConsumerAppDTO[0]);
setInternalState(dcrmService, "oAuthAdminService", mockOAuthAdminService);
@@ -239,7 +240,7 @@ public void getApplicationDTOTestWithIOAException() throws Exception {
public void getApplicationDTOTestWithIOCException() throws Exception {
doThrow(new IdentityOAuthAdminException("", new InvalidOAuthClientException(""))).when(mockOAuthAdminService)
- .getOAuthApplicationData(dummyConsumerKey);
+ .getOAuthApplicationData(dummyConsumerKey, dummyTenantDomain);
lenient().when(mockOAuthAdminService.getAllOAuthApplicationData()).thenReturn(new OAuthConsumerAppDTO[0]);
setInternalState(dcrmService, "oAuthAdminService", mockOAuthAdminService);
@@ -256,7 +257,7 @@ public void getApplicationDTOTestWithIOCException() throws Exception {
public void getApplicationDTOTestUserUnauthorized() throws Exception {
setInternalState(dcrmService, "oAuthAdminService", mockOAuthAdminService);
- when(mockOAuthAdminService.getOAuthApplicationData(dummyConsumerKey)).thenReturn(dto);
+ when(mockOAuthAdminService.getOAuthApplicationData(dummyConsumerKey, dummyTenantDomain)).thenReturn(dto);
when(dto.getApplicationName()).thenReturn(dummyClientName);
try {
@@ -276,7 +277,7 @@ public void isUserAuthorizedTestWithIAMException() throws IdentityOAuthAdminExce
UserStoreException, NoSuchFieldException, IllegalAccessException {
setInternalState(dcrmService, "oAuthAdminService", mockOAuthAdminService);
- when(mockOAuthAdminService.getOAuthApplicationData(dummyConsumerKey)).thenReturn(dto);
+ when(mockOAuthAdminService.getOAuthApplicationData(dummyConsumerKey, dummyTenantDomain)).thenReturn(dto);
when(dto.getApplicationName()).thenReturn(dummyClientName);
try {
@@ -304,7 +305,7 @@ public void getApplicationDTOTest(String roleAudience) throws Exception {
dto.setCallbackUrl(dummyCallbackUrl);
dto.setUsername(dummyUserName.concat("@").concat(dummyTenantDomain));
- when(mockOAuthAdminService.getOAuthApplicationData(dummyConsumerKey)).thenReturn(dto);
+ when(mockOAuthAdminService.getOAuthApplicationData(dummyConsumerKey, dummyTenantDomain)).thenReturn(dto);
setInternalState(dcrmService, "oAuthAdminService", mockOAuthAdminService);
PrivilegedCarbonContext.getThreadLocalCarbonContext().setUserRealm(mockedUserRealm);
when(mockedUserRealm.getUserStoreManager()).thenReturn(mockedUserStoreManager);
@@ -328,7 +329,8 @@ public void getApplicationDTOTest(String roleAudience) throws Exception {
public void validateRequestTenantDomainTestWitInvalidOAuthClientException()
throws IdentityOAuth2Exception, InvalidOAuthClientException {
- when(OAuth2Util.getTenantDomainOfOauthApp(dummyConsumerKey)).thenThrow(new InvalidOAuthClientException(""));
+ when(OAuth2Util.getTenantDomainOfOauthApp(dummyConsumerKey, dummyTenantDomain)).
+ thenThrow(new InvalidOAuthClientException(""));
try {
dcrmService.getApplication(dummyConsumerKey);
} catch (DCRMException ex) {
@@ -343,7 +345,8 @@ public void validateRequestTenantDomainTestWitInvalidOAuthClientException()
public void validateRequestTenantDomainTestWitIdentityOAuth2Exception()
throws IdentityOAuth2Exception, InvalidOAuthClientException {
- when(OAuth2Util.getTenantDomainOfOauthApp(dummyConsumerKey)).thenThrow(new IdentityOAuth2Exception(""));
+ when(OAuth2Util.getTenantDomainOfOauthApp(dummyConsumerKey, dummyTenantDomain)).
+ thenThrow(new IdentityOAuth2Exception(""));
try {
dcrmService.getApplication(dummyConsumerKey);
} catch (DCRMException ex) {
@@ -535,7 +538,7 @@ public void registerApplicationTestWithExistClientId() throws Exception {
applicationRegistrationRequest.setGrantTypes(dummyGrantTypes);
applicationRegistrationRequest.setConsumerKey(dummyConsumerKey);
setInternalState(dcrmService, "oAuthAdminService", mockOAuthAdminService);
- when(mockOAuthAdminService.getOAuthApplicationData(dummyConsumerKey))
+ when(mockOAuthAdminService.getOAuthApplicationData(dummyConsumerKey, dummyTenantDomain))
.thenReturn(dto);
when(dto.getApplicationName()).thenReturn(dummyClientName);
@@ -915,7 +918,8 @@ public void isClientIdExistTestWithIdentityOAuthAdminException() throws Exceptio
setInternalState(dcrmService, "oAuthAdminService", mockOAuthAdminService);
IdentityOAuthAdminException identityOAuthAdminException = mock(IdentityOAuthAdminException.class);
- doThrow(identityOAuthAdminException).when(mockOAuthAdminService).getOAuthApplicationData(dummyConsumerKey);
+ doThrow(identityOAuthAdminException).when(mockOAuthAdminService).getOAuthApplicationData(dummyConsumerKey,
+ dummyTenantDomain);
try {
dcrmService.registerApplication(applicationRegistrationRequest);
} catch (IdentityException ex) {
@@ -974,7 +978,7 @@ private OAuthConsumerAppDTO registerApplicationTestWithFailedToUpdateSP() throws
lenient().when(mockOAuthAdminService
.getOAuthApplicationDataByAppName(dummyClientName)).thenReturn(oAuthConsumerApp);
lenient().when(mockOAuthAdminService
- .getOAuthApplicationData("dummyConsumerKey")).thenReturn(oAuthConsumerApp);
+ .getOAuthApplicationData("dummyConsumerKey", dummyTenantDomain)).thenReturn(oAuthConsumerApp);
lenient().when(mockOAuthAdminService.getAllOAuthApplicationData())
.thenReturn(new OAuthConsumerAppDTO[]{oAuthConsumerApp});
lenient().when(mockOAuthAdminService.registerAndRetrieveOAuthApplicationData(any(OAuthConsumerAppDTO.class))).
@@ -1004,6 +1008,7 @@ public void updateApplicationTest(List redirectUri1, String roleAudience
assertEquals(application.getClientId(), dummyConsumerKey);
assertEquals(application.getClientName(), dummyClientName);
assertEquals(application.getClientSecret(), dummyConsumerSecret);
+ assertEquals(application.getExtAllowedAudience(), roleAudience);
}
@Test
@@ -1107,7 +1112,7 @@ private OAuthConsumerAppDTO updateApplication()
dto.setCallbackUrl(dummyCallbackUrl);
dto.setUsername(dummyUserName.concat("@").concat(dummyTenantDomain));
- when(mockOAuthAdminService.getOAuthApplicationData(dummyConsumerKey)).thenReturn(dto);
+ when(mockOAuthAdminService.getOAuthApplicationData(dummyConsumerKey, dummyTenantDomain)).thenReturn(dto);
setInternalState(dcrmService, "oAuthAdminService", mockOAuthAdminService);
ServiceProvider serviceProvider = new ServiceProvider();
diff --git a/components/org.wso2.carbon.identity.oauth.endpoint/pom.xml b/components/org.wso2.carbon.identity.oauth.endpoint/pom.xml
index da49b25e9b4..907932139ec 100644
--- a/components/org.wso2.carbon.identity.oauth.endpoint/pom.xml
+++ b/components/org.wso2.carbon.identity.oauth.endpoint/pom.xml
@@ -22,7 +22,7 @@
org.wso2.carbon.identity.inbound.auth.oauth2
identity-inbound-auth-oauth
../../pom.xml
- 7.0.191-SNAPSHOT
+ 7.0.214-SNAPSHOT
4.0.0
@@ -146,6 +146,14 @@
org.wso2.carbon.identity.oidc.session
provided
+
+ org.apache.httpcomponents.wso2
+ httpcore
+
+
+ org.wso2.orbit.org.apache.httpcomponents
+ httpclient
+
com.google.code.gson
gson
@@ -161,11 +169,6 @@
org.wso2.carbon.identity.client.attestation.filter
provided
-
- org.springframework
- spring-web
- provided
-
com.fasterxml.jackson.core
jackson-databind
@@ -323,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 fe628a50698..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")
@@ -421,6 +394,36 @@ private void addFederatedTokensToSessionCache(OAuthMessage oAuthMessage,
}
}
+ /**
+ * Add mapped remote claims to session cache.
+ *
+ * @param oAuthMessage The OAuthMessage with the session data cache entry.
+ * @param authenticationResult The authentication result of authorization call.
+ */
+ private void addMappedRemoteClaimsToSessionCache(OAuthMessage oAuthMessage,
+ AuthenticationResult authenticationResult) {
+
+ Optional