From cbf10a8b59f8533a0acac1d54d64bbe089172b25 Mon Sep 17 00:00:00 2001 From: mharindu Date: Wed, 2 Sep 2015 17:35:41 +0530 Subject: [PATCH 1/4] Refactored addOperation method --- .../carbon/device/mgt/core/dao/DeviceDAO.java | 50 ++++++++++++------- .../mgt/core/dao/impl/DeviceDAOImpl.java | 46 +++++++++++++++++ .../operation/mgt/OperationManagerImpl.java | 36 ++++++------- .../DeviceManagementProviderServiceImpl.java | 6 +++ 4 files changed, 98 insertions(+), 40 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAO.java index 3eb1f48ac4..126cfb2941 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAO.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAO.java @@ -34,8 +34,8 @@ public interface DeviceDAO { /** * This method is used to add a device. * - * @param typeId device type id. - * @param device device object. + * @param typeId device type id. + * @param device device object. * @param tenantId tenant id. * @return returns the id of the persisted device record. * @throws DeviceManagementDAOException @@ -45,8 +45,8 @@ public interface DeviceDAO { /** * This method is used to update a given device. * - * @param typeId device type id. - * @param device device object. + * @param typeId device type id. + * @param device device object. * @param tenantId tenant id. * @return returns the id of updated device. * @throws DeviceManagementDAOException @@ -85,7 +85,7 @@ public interface DeviceDAO { /** * This method is used to retrieve all the devices of a given tenant and device type. * - * @param type device type. + * @param type device type. * @param tenantId tenant id. * @return returns list of devices. * @throws DeviceManagementDAOException @@ -94,6 +94,7 @@ public interface DeviceDAO { /** * This method is used to retrieve devices of a given user. + * * @param username user name. * @param tenantId tenant id. * @return returns list of devices. @@ -112,8 +113,9 @@ public interface DeviceDAO { /** * This method is used to retrieve devices of a given device name. + * * @param deviceName device name. - * @param tenantId tenant id. + * @param tenantId tenant id. * @return returns list of devices. * @throws DeviceManagementDAOException */ @@ -122,7 +124,7 @@ public interface DeviceDAO { /** * This method is used to add an enrollment information of a given device. * - * @param device device object. + * @param device device object. * @param tenantId tenant id. * @return returns the id of the enrollment. * @throws DeviceManagementDAOException @@ -132,22 +134,22 @@ public interface DeviceDAO { /** * This method is used to set the current enrollment status of given device and user. * - * @param deviceId device id. + * @param deviceId device id. * @param currentOwner current user name. - * @param status device status. - * @param tenantId tenant id. + * @param status device status. + * @param tenantId tenant id. * @return returns true if success. * @throws DeviceManagementDAOException */ boolean setEnrolmentStatus(DeviceIdentifier deviceId, String currentOwner, Status status, - int tenantId) throws DeviceManagementDAOException; + int tenantId) throws DeviceManagementDAOException; /** * This method is used to get the status of current enrollment of a given user and device. * - * @param deviceId device id. + * @param deviceId device id. * @param currentOwner device owner. - * @param tenantId tenant id. + * @param tenantId tenant id. * @return returns current enrollment status. * @throws DeviceManagementDAOException */ @@ -157,9 +159,9 @@ public interface DeviceDAO { /** * This method is used to retrieve current enrollment of a given device and user. * - * @param deviceId device id. + * @param deviceId device id. * @param currentUser user name. - * @param tenantId tenant id. + * @param tenantId tenant id. * @return returns EnrolmentInfo object. * @throws DeviceManagementDAOException */ @@ -169,7 +171,7 @@ public interface DeviceDAO { /** * This method is used to retrieve devices of a given enrollment status. * - * @param status enrollment status. + * @param status enrollment status. * @param tenantId tenant id. * @return returns list of devices. * @throws DeviceManagementDAOException @@ -180,12 +182,24 @@ public interface DeviceDAO { * This method is used to retrieve the enrollment id of a given device and status. * * @param deviceId device id. - * @param status enrollment status. + * @param status enrollment status. * @param tenantId tenant id. * @return returns the id of current enrollment. * @throws DeviceManagementDAOException */ int getEnrolmentByStatus(DeviceIdentifier deviceId, Status status, - int tenantId) throws DeviceManagementDAOException; + int tenantId) throws DeviceManagementDAOException; + + /** + * This method is used to retrieve the enrollment info of a given list of devices and status. + * + * @param deviceIds A list of device identifiers. + * @param status enrollment status. + * @param tenantId tenant id. + * @return returns a list of enrolment info objects. + * @throws DeviceManagementDAOException + */ + List getEnrolmentsByStatus(List deviceIds, Status status, + int tenantId) throws DeviceManagementDAOException; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceDAOImpl.java index 75e916589d..58de082c66 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceDAOImpl.java @@ -30,6 +30,7 @@ import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil; import java.sql.*; import java.util.ArrayList; import java.util.Date; +import java.util.Iterator; import java.util.List; public class DeviceDAOImpl implements DeviceDAO { @@ -455,6 +456,51 @@ public class DeviceDAOImpl implements DeviceDAO { } } + public List getEnrolmentsByStatus(List deviceIds, Status status, + int tenantId) throws DeviceManagementDAOException { + Connection conn; + PreparedStatement stmt = null; + ResultSet rs = null; + List enrolments = new ArrayList<>(); + try { + conn = this.getConnection(); + StringBuilder sql = new StringBuilder(); + sql.append("SELECT e.ID AS ENROLMENT_ID, e.OWNER, e.OWNERSHIP, e.DATE_OF_ENROLMENT, e.DATE_OF_LAST_UPDATE, " + + "e.STATUS FROM DM_ENROLMENT e WHERE e.DEVICE_ID IN (SELECT d.ID FROM DM_DEVICE d " + + "WHERE d.DEVICE_IDENTIFICATION IN ("); + + // adding arguments to the sql query + Iterator iterator = deviceIds.iterator(); + while (iterator.hasNext()) { + iterator.next(); + sql.append(" ?"); + if (iterator.hasNext()) { + sql.append(","); + } + } + sql.append(") AND d.TENANT_ID = ?) AND e.STATUS = ? AND e.TENANT_ID = ?"); + + stmt = conn.prepareStatement(sql.toString()); + int index = 1; + for (DeviceIdentifier id : deviceIds) { + stmt.setString(index++, id.getId()); + } + stmt.setInt(index++, tenantId); + stmt.setString(index++, status.toString()); + stmt.setInt(index, tenantId); + rs = stmt.executeQuery(); + if (rs.next()) { + enrolments.add(this.loadEnrolment(rs)); + } + return enrolments; + } catch (SQLException e) { + throw new DeviceManagementDAOException("Error occurred while retrieving the enrolment " + + "ids of devices", e); + } finally { + DeviceManagementDAOUtil.cleanupResources(stmt, rs); + } + } + private Device loadDevice(ResultSet rs) throws SQLException { Device device = new Device(); device.setId(rs.getInt("DEVICE_ID")); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java index c26eea0de4..9044720294 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java @@ -80,34 +80,26 @@ public class OperationManagerImpl implements OperationManager { } } try { - OperationManagementDAOFactory.beginTransaction(); + int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); + List enrolments; + try { + DeviceManagementDAOFactory.openConnection(); + enrolments = deviceDAO.getEnrolmentsByStatus(deviceIds, EnrolmentInfo.Status.ACTIVE, tenantId); + } catch (SQLException e) { + throw new OperationManagementException("Error occurred while opening a connection the data " + + "source", e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + OperationManagementDAOFactory.beginTransaction(); org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation operationDto = OperationDAOUtil.convertOperation(operation); int operationId = this.lookupOperationDAO(operation).addOperation(operationDto); - int enrolmentId; - int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); - for (DeviceIdentifier deviceId : deviceIds) { - try { - DeviceManagementDAOFactory.openConnection(); - enrolmentId = deviceDAO.getEnrolmentByStatus(deviceId, EnrolmentInfo.Status.ACTIVE, tenantId); - } catch (SQLException e) { - throw new OperationManagementException("Error occurred while opening a connection the data " + - "source", e); - } finally { - DeviceManagementDAOFactory.closeConnection(); - } - - if (enrolmentId < 0) { - String errorMsg = "The operation not added for device.The device not found for " + - "device Identifier type -'" + deviceId.getType() + "' and device Id '" + - deviceId.getId(); - log.error(errorMsg); - } else { - operationMappingDAO.addOperationMapping(operationId, enrolmentId); - } + for (EnrolmentInfo enrolmentInfo : enrolments) { + operationMappingDAO.addOperationMapping(operationId, enrolmentInfo.getId()); } OperationManagementDAOFactory.commitTransaction(); return operationId; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index d5000da889..1489b474d8 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -245,6 +245,12 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv DeviceManagementDAOFactory.beginTransaction(); Device device = deviceDAO.getDevice(deviceId, tenantId); + if (device == null) { + if (log.isDebugEnabled()) { + log.debug("Device not found for id '" + deviceId.getId() + "'"); + } + throw new DeviceManagementException("Device not found"); + } DeviceType deviceType = deviceTypeDAO.getDeviceType(device.getType()); device.getEnrolmentInfo().setDateOfLastUpdate(new Date().getTime()); From fbd697edb011df4c5ebf234dfc1612396c6f8a42 Mon Sep 17 00:00:00 2001 From: mharindu Date: Tue, 8 Sep 2015 11:27:29 +0530 Subject: [PATCH 2/4] Fixed issue in policy delegation executor --- .../policy/mgt/core/impl/PolicyAdministratorPointImpl.java | 3 +-- .../wso2/carbon/policy/mgt/core/PolicyEvaluationTestCase.java | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/PolicyAdministratorPointImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/PolicyAdministratorPointImpl.java index c536987bd4..5e63355f95 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/PolicyAdministratorPointImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/PolicyAdministratorPointImpl.java @@ -133,8 +133,7 @@ public class PolicyAdministratorPointImpl implements PolicyAdministratorPoint { TaskInfo.TriggerInfo triggerInfo = new TaskInfo.TriggerInfo(); - triggerInfo.setIntervalMillis(0); - triggerInfo.setRepeatCount(1); + triggerInfo.setRepeatCount(0); Map properties = new HashMap<>(); properties.put(PolicyManagementConstants.TENANT_ID, String.valueOf(tenantId)); diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/java/org/wso2/carbon/policy/mgt/core/PolicyEvaluationTestCase.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/java/org/wso2/carbon/policy/mgt/core/PolicyEvaluationTestCase.java index e1ebc13e9d..a74e85bf3e 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/java/org/wso2/carbon/policy/mgt/core/PolicyEvaluationTestCase.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/java/org/wso2/carbon/policy/mgt/core/PolicyEvaluationTestCase.java @@ -107,12 +107,12 @@ public class PolicyEvaluationTestCase extends BasePolicyManagementDAOTest { log.debug("Re-enforcing policy started...!"); - int sixe = policies.size(); + int size = policies.size(); sortPolicies(policies); int x = 0; for (Policy policy : policies) { - policy.setPriorityId(sixe - x); + policy.setPriorityId(size - x); x++; } From 9920f2919a38fc267aa47eb6bd02f5243bb858f7 Mon Sep 17 00:00:00 2001 From: mharindu Date: Wed, 9 Sep 2015 20:00:10 +0530 Subject: [PATCH 3/4] Fixed spelling mistakes of policy component --- .../carbon/policy/mgt/common/monitor/ComplianceFeature.java | 2 +- .../wso2/carbon/policy/mgt/core/dao/impl/MonitoringDAOImpl.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/monitor/ComplianceFeature.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/monitor/ComplianceFeature.java index 0e3e9a9536..ddc238c1ff 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/monitor/ComplianceFeature.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/monitor/ComplianceFeature.java @@ -45,7 +45,7 @@ public class ComplianceFeature { this.featureCode = featureCode; } - public boolean isCompliance() { + public boolean isCompliant() { return compliance; } diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/MonitoringDAOImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/MonitoringDAOImpl.java index b7d58353d5..54d0ff0198 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/MonitoringDAOImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/MonitoringDAOImpl.java @@ -219,7 +219,7 @@ public class MonitoringDAOImpl implements MonitoringDAO { for (ComplianceFeature feature : complianceFeatures) { stmt.setInt(1, policyComplianceStatusId); stmt.setString(2, feature.getFeatureCode()); - if (feature.isCompliance()) { + if (feature.isCompliant()) { stmt.setInt(3, 1); } else { stmt.setInt(3, 0); From b8720917e1fe23168a483bb4d10f24fd180254fd Mon Sep 17 00:00:00 2001 From: harshanl Date: Fri, 11 Sep 2015 20:53:19 +0530 Subject: [PATCH 4/4] Added Dynamic-client-registration module --- .../config/permission/PermissionManager.java | 2 + .../mgt/PermissionManagerConfigTests.java | 22 ++ .../dynamic-client-web}/pom.xml | 40 ++-- .../client/web/ConfigurationService.java | 33 +++ .../dynamic/client/web/DynamicClientUtil.java | 36 ++++ .../client/web}/FaultMessageBodyWriter.java | 25 ++- .../dynamic/client/web/FaultResponse.java | 38 ++++ .../client/web/RegistrationResponse.java | 40 ++++ .../client/web}/RegistrationService.java | 27 ++- .../web/impl/ConfigurationServiceImpl.java | 32 +++ .../web/impl/RegistrationServiceImpl.java | 103 +++++++++ .../webapp/META-INF/webapp-classloading.xml | 0 .../src/main/webapp/WEB-INF/cxf-servlet.xml | 26 +-- .../src/main/webapp/WEB-INF/web.xml | 0 .../src/main/webapp/servicelist.css | 0 .../src/test/resources/log4j.properties | 0 .../src/test/resources/testng.xml | 0 .../pom.xml | 108 ++++++++++ .../registration}/ApplicationConstants.java | 28 +-- .../DynamicClientRegistrationException.java | 61 ++++++ .../DynamicClientRegistrationService.java | 61 ++++++ .../registration}/OAuthApplicationInfo.java | 43 ++-- .../impl/DynamicClientRegistrationImpl.java} | 168 ++++++++++----- ...amicClientRegistrationBundleActivator.java | 44 ++++ .../profile/RegistrationProfile.java | 39 ++-- .../pom.xml | 127 ++++++++++++ .../DynamicRegistrationManager.java | 90 ++++++++ .../client/web/app/registration/OAuthApp.java | 70 +++++++ .../DynamicClientRegistrationDataHolder.java | 66 ++++++ ...entWebAppRegistrationServiceComponent.java | 136 ++++++++++++ ...ientWebAppDeploymentLifecycleListener.java | 70 +++++++ .../DynamicClientRegistrationConstants.java | 49 +++++ .../DynamicClientWebAppRegistrationUtil.java | 196 ++++++++++++++++++ .../pom.xml | 40 ++-- .../oauth/extension/ConfigurationService.java | 34 --- .../oauth/extension/FaultResponse.java | 39 ---- .../oauth/extension/RegistrationResponse.java | 41 ---- .../impl/ConfigurationServiceImpl.java | 33 --- .../impl/RegistrationServiceImpl.java | 82 -------- .../main/resources/device-info-response.xml | 102 --------- .../src/main/resources/properties.xml | 25 --- .../syncml-session-ending-response.xml | 41 ---- .../main/resources/syncml-test-message.xml | 1 - .../src/main/resources/wap-provisioning.xml | 87 -------- .../src/main/resources/wso2mdm.jks | Bin 9485 -> 0 bytes .../src/test/resources/log4j.properties | 32 --- .../src/test/resources/testng.xml | 41 ---- .../authenticator/JWTAuthenticator.java | 10 +- .../pom.xml | 50 ++++- .../src/main/resources/p2.inf | 2 + .../pom.xml | 6 +- .../src/main/resources/p2.inf | 2 - pom.xml | 26 ++- 53 files changed, 1711 insertions(+), 763 deletions(-) create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/permission/mgt/PermissionManagerConfigTests.java rename components/{oauth-extensions/dynamic-client-manager => dynamic-client-registration/dynamic-client-web}/pom.xml (82%) create mode 100644 components/dynamic-client-registration/dynamic-client-web/src/main/java/org/wso2/carbon/dynamic/client/web/ConfigurationService.java create mode 100644 components/dynamic-client-registration/dynamic-client-web/src/main/java/org/wso2/carbon/dynamic/client/web/DynamicClientUtil.java rename components/{oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension => dynamic-client-registration/dynamic-client-web/src/main/java/org/wso2/carbon/dynamic/client/web}/FaultMessageBodyWriter.java (73%) create mode 100644 components/dynamic-client-registration/dynamic-client-web/src/main/java/org/wso2/carbon/dynamic/client/web/FaultResponse.java create mode 100644 components/dynamic-client-registration/dynamic-client-web/src/main/java/org/wso2/carbon/dynamic/client/web/RegistrationResponse.java rename components/{oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension => dynamic-client-registration/dynamic-client-web/src/main/java/org/wso2/carbon/dynamic/client/web}/RegistrationService.java (68%) create mode 100644 components/dynamic-client-registration/dynamic-client-web/src/main/java/org/wso2/carbon/dynamic/client/web/impl/ConfigurationServiceImpl.java create mode 100644 components/dynamic-client-registration/dynamic-client-web/src/main/java/org/wso2/carbon/dynamic/client/web/impl/RegistrationServiceImpl.java rename components/{oauth-extensions/dynamic-client-manager => dynamic-client-registration/dynamic-client-web}/src/main/webapp/META-INF/webapp-classloading.xml (100%) rename components/{oauth-extensions/dynamic-client-manager => dynamic-client-registration/dynamic-client-web}/src/main/webapp/WEB-INF/cxf-servlet.xml (57%) rename components/{oauth-extensions/dynamic-client-manager => dynamic-client-registration/dynamic-client-web}/src/main/webapp/WEB-INF/web.xml (100%) rename components/{oauth-extensions/dynamic-client-manager => dynamic-client-registration/dynamic-client-web}/src/main/webapp/servicelist.css (100%) rename components/{oauth-extensions/dynamic-client-manager => dynamic-client-registration/dynamic-client-web}/src/test/resources/log4j.properties (100%) rename components/{oauth-extensions/dynamic-client-manager => dynamic-client-registration/dynamic-client-web}/src/test/resources/testng.xml (100%) create mode 100644 components/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/pom.xml rename components/{oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension => dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration}/ApplicationConstants.java (74%) create mode 100644 components/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/DynamicClientRegistrationException.java create mode 100644 components/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/DynamicClientRegistrationService.java rename components/{oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension => dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration}/OAuthApplicationInfo.java (55%) rename components/{oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/DynamicClientRegistrationUtil.java => dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/impl/DynamicClientRegistrationImpl.java} (58%) create mode 100644 components/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/internal/DynamicClientRegistrationBundleActivator.java rename components/{oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension => dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration}/profile/RegistrationProfile.java (79%) create mode 100644 components/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/pom.xml create mode 100644 components/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/src/main/java/org/wso2/carbon/dynamic/client/web/app/registration/DynamicRegistrationManager.java create mode 100644 components/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/src/main/java/org/wso2/carbon/dynamic/client/web/app/registration/OAuthApp.java create mode 100644 components/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/src/main/java/org/wso2/carbon/dynamic/client/web/app/registration/internal/DynamicClientRegistrationDataHolder.java create mode 100644 components/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/src/main/java/org/wso2/carbon/dynamic/client/web/app/registration/internal/DynamicClientWebAppRegistrationServiceComponent.java create mode 100644 components/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/src/main/java/org/wso2/carbon/dynamic/client/web/app/registration/listner/DynamicClientWebAppDeploymentLifecycleListener.java create mode 100644 components/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/src/main/java/org/wso2/carbon/dynamic/client/web/app/registration/util/DynamicClientRegistrationConstants.java create mode 100644 components/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/src/main/java/org/wso2/carbon/dynamic/client/web/app/registration/util/DynamicClientWebAppRegistrationUtil.java rename components/{oauth-extensions => dynamic-client-registration}/pom.xml (57%) delete mode 100644 components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/ConfigurationService.java delete mode 100644 components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/FaultResponse.java delete mode 100644 components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/RegistrationResponse.java delete mode 100644 components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/impl/ConfigurationServiceImpl.java delete mode 100644 components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/impl/RegistrationServiceImpl.java delete mode 100644 components/oauth-extensions/dynamic-client-manager/src/main/resources/device-info-response.xml delete mode 100644 components/oauth-extensions/dynamic-client-manager/src/main/resources/properties.xml delete mode 100644 components/oauth-extensions/dynamic-client-manager/src/main/resources/syncml-session-ending-response.xml delete mode 100644 components/oauth-extensions/dynamic-client-manager/src/main/resources/syncml-test-message.xml delete mode 100644 components/oauth-extensions/dynamic-client-manager/src/main/resources/wap-provisioning.xml delete mode 100644 components/oauth-extensions/dynamic-client-manager/src/main/resources/wso2mdm.jks delete mode 100644 components/oauth-extensions/org.wso2.carbon.device.mgt.oauth.extension/src/test/resources/log4j.properties delete mode 100644 components/oauth-extensions/org.wso2.carbon.device.mgt.oauth.extension/src/test/resources/testng.xml rename features/{oauth-extensions/org.wso2.carbon.oauth.extensions.server.feature => dynamic-client-registration/org.wso2.carbon.dynamic.client.registration.server.feature}/pom.xml (69%) create mode 100644 features/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration.server.feature/src/main/resources/p2.inf rename features/{oauth-extensions => dynamic-client-registration}/pom.xml (86%) delete mode 100644 features/oauth-extensions/org.wso2.carbon.oauth.extensions.server.feature/src/main/resources/p2.inf diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/permission/PermissionManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/permission/PermissionManager.java index 0e370b3825..4cdf10ad77 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/permission/PermissionManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/permission/PermissionManager.java @@ -33,6 +33,8 @@ public class PermissionManager { private static PermissionManager permissionManager; + private PermissionManager(){}; + public static PermissionManager getInstance() { if (permissionManager == null) { synchronized (PermissionManager.class) { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/permission/mgt/PermissionManagerConfigTests.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/permission/mgt/PermissionManagerConfigTests.java new file mode 100644 index 0000000000..97ac0721b5 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/permission/mgt/PermissionManagerConfigTests.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2015, 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.device.mgt.core.permission.mgt; + +public class PermissionManagerConfigTests { +} diff --git a/components/oauth-extensions/dynamic-client-manager/pom.xml b/components/dynamic-client-registration/dynamic-client-web/pom.xml similarity index 82% rename from components/oauth-extensions/dynamic-client-manager/pom.xml rename to components/dynamic-client-registration/dynamic-client-web/pom.xml index 80af542393..927f8e1f77 100644 --- a/components/oauth-extensions/dynamic-client-manager/pom.xml +++ b/components/dynamic-client-registration/dynamic-client-web/pom.xml @@ -4,9 +4,9 @@ ~ 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 + ~ you may obtain a copy of the License at ~ - ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ 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 @@ -14,24 +14,25 @@ ~ KIND, either express or implied. See the License for the ~ specific language governing permissions and limitations ~ under the License. ---> + --> + dynamic-client-registration org.wso2.carbon.devicemgt - oauth-extensions 0.9.2-SNAPSHOT ../pom.xml 4.0.0 org.wso2.mdm - dynamic-client-manager - WSO2 Carbon - Dynamic Client Registration Impl - WSO2 Carbon - Dynamic Client Registration Impl + dynamic-client-web + 0.9.2-SNAPSHOT + WSO2 Carbon - Dynamic Client Registration Web Service + WSO2 Carbon - Dynamic Client Registration Web war @@ -119,33 +120,18 @@ provided - org.wso2.carbon - org.wso2.carbon.utils - provided - - - org.wso2.carbon.identity - org.wso2.carbon.identity.application.mgt - provided - - - org.wso2.carbon.apimgt - org.wso2.carbon.apimgt.api - provided - - - org.wso2.carbon.apimgt - org.wso2.carbon.apimgt.impl + org.wso2.carbon.devicemgt + org.wso2.carbon.dynamic.client.registration provided - org.wso2.carbon.apimgt - org.wso2.carbon.apimgt.keymgt.client + org.wso2.carbon + org.wso2.carbon.utils provided org.wso2.carbon.identity - org.wso2.carbon.identity.oauth + org.wso2.carbon.identity.application.mgt provided diff --git a/components/dynamic-client-registration/dynamic-client-web/src/main/java/org/wso2/carbon/dynamic/client/web/ConfigurationService.java b/components/dynamic-client-registration/dynamic-client-web/src/main/java/org/wso2/carbon/dynamic/client/web/ConfigurationService.java new file mode 100644 index 0000000000..0d97308f54 --- /dev/null +++ b/components/dynamic-client-registration/dynamic-client-web/src/main/java/org/wso2/carbon/dynamic/client/web/ConfigurationService.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2015, 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.dynamic.client.web; + +import javax.ws.rs.*; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +@Path("/connect") +public interface ConfigurationService { + + @GET + @Path("/register") + Response getProfile(@PathParam("client_id") String clientId); + +} diff --git a/components/dynamic-client-registration/dynamic-client-web/src/main/java/org/wso2/carbon/dynamic/client/web/DynamicClientUtil.java b/components/dynamic-client-registration/dynamic-client-web/src/main/java/org/wso2/carbon/dynamic/client/web/DynamicClientUtil.java new file mode 100644 index 0000000000..21f2aec018 --- /dev/null +++ b/components/dynamic-client-registration/dynamic-client-web/src/main/java/org/wso2/carbon/dynamic/client/web/DynamicClientUtil.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2015, 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.dynamic.client.web; + +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.dynamic.client.registration.DynamicClientRegistrationService; + +/** + * Created by harshan on 9/8/15. + */ +public class DynamicClientUtil { + + public static DynamicClientRegistrationService getDynamicClientRegistrationService() { + DynamicClientRegistrationService dynamicClientRegistrationService; + PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + dynamicClientRegistrationService = + (DynamicClientRegistrationService) ctx.getOSGiService(DynamicClientRegistrationService.class, null); + return dynamicClientRegistrationService; + } +} diff --git a/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/FaultMessageBodyWriter.java b/components/dynamic-client-registration/dynamic-client-web/src/main/java/org/wso2/carbon/dynamic/client/web/FaultMessageBodyWriter.java similarity index 73% rename from components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/FaultMessageBodyWriter.java rename to components/dynamic-client-registration/dynamic-client-web/src/main/java/org/wso2/carbon/dynamic/client/web/FaultMessageBodyWriter.java index ff43d4aad9..39f3c6dfb0 100644 --- a/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/FaultMessageBodyWriter.java +++ b/components/dynamic-client-registration/dynamic-client-web/src/main/java/org/wso2/carbon/dynamic/client/web/FaultMessageBodyWriter.java @@ -1,22 +1,21 @@ /* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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. - * + * 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.extension; +package org.wso2.carbon.dynamic.client.web; import com.google.gson.Gson; import com.google.gson.GsonBuilder; diff --git a/components/dynamic-client-registration/dynamic-client-web/src/main/java/org/wso2/carbon/dynamic/client/web/FaultResponse.java b/components/dynamic-client-registration/dynamic-client-web/src/main/java/org/wso2/carbon/dynamic/client/web/FaultResponse.java new file mode 100644 index 0000000000..395673e565 --- /dev/null +++ b/components/dynamic-client-registration/dynamic-client-web/src/main/java/org/wso2/carbon/dynamic/client/web/FaultResponse.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2015, 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.dynamic.client.web; + +public class FaultResponse { + + private RegistrationService.ErrorCode code; + private String description; + + public FaultResponse(RegistrationService.ErrorCode code, String description) { + this.code = code; + this.description = description; + } + + public RegistrationService.ErrorCode getCode() { + return code; + } + + public String getDescription() { + return description; + } + +} diff --git a/components/dynamic-client-registration/dynamic-client-web/src/main/java/org/wso2/carbon/dynamic/client/web/RegistrationResponse.java b/components/dynamic-client-registration/dynamic-client-web/src/main/java/org/wso2/carbon/dynamic/client/web/RegistrationResponse.java new file mode 100644 index 0000000000..889e43ea81 --- /dev/null +++ b/components/dynamic-client-registration/dynamic-client-web/src/main/java/org/wso2/carbon/dynamic/client/web/RegistrationResponse.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2015, 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.dynamic.client.web; + +import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.core.Response; + +public class RegistrationResponse extends Response { + + @Override + public Object getEntity() { + return null; + } + + @Override + public int getStatus() { + return 0; + } + + @Override + public MultivaluedMap getMetadata() { + return null; + } + +} diff --git a/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/RegistrationService.java b/components/dynamic-client-registration/dynamic-client-web/src/main/java/org/wso2/carbon/dynamic/client/web/RegistrationService.java similarity index 68% rename from components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/RegistrationService.java rename to components/dynamic-client-registration/dynamic-client-web/src/main/java/org/wso2/carbon/dynamic/client/web/RegistrationService.java index 962b721091..194d5e966d 100644 --- a/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/RegistrationService.java +++ b/components/dynamic-client-registration/dynamic-client-web/src/main/java/org/wso2/carbon/dynamic/client/web/RegistrationService.java @@ -1,24 +1,23 @@ /* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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. - * + * 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.extension; +package org.wso2.carbon.dynamic.client.web; -import org.wso2.carbon.identity.oauth.extension.profile.RegistrationProfile; +import org.wso2.carbon.dynamic.client.registration.profile.RegistrationProfile; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; diff --git a/components/dynamic-client-registration/dynamic-client-web/src/main/java/org/wso2/carbon/dynamic/client/web/impl/ConfigurationServiceImpl.java b/components/dynamic-client-registration/dynamic-client-web/src/main/java/org/wso2/carbon/dynamic/client/web/impl/ConfigurationServiceImpl.java new file mode 100644 index 0000000000..7fcf7fa075 --- /dev/null +++ b/components/dynamic-client-registration/dynamic-client-web/src/main/java/org/wso2/carbon/dynamic/client/web/impl/ConfigurationServiceImpl.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2015, 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.dynamic.client.web.impl; + +import org.wso2.carbon.dynamic.client.web.ConfigurationService; + +import javax.ws.rs.PathParam; +import javax.ws.rs.core.Response; + +public class ConfigurationServiceImpl implements ConfigurationService { + + @Override + public Response getProfile(@PathParam("client_id") String clientId) { + return null; + } + +} \ No newline at end of file diff --git a/components/dynamic-client-registration/dynamic-client-web/src/main/java/org/wso2/carbon/dynamic/client/web/impl/RegistrationServiceImpl.java b/components/dynamic-client-registration/dynamic-client-web/src/main/java/org/wso2/carbon/dynamic/client/web/impl/RegistrationServiceImpl.java new file mode 100644 index 0000000000..0640943479 --- /dev/null +++ b/components/dynamic-client-registration/dynamic-client-web/src/main/java/org/wso2/carbon/dynamic/client/web/impl/RegistrationServiceImpl.java @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2015, 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.dynamic.client.web.impl; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.apimgt.api.APIManagementException; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.dynamic.client.registration.DynamicClientRegistrationException; +import org.wso2.carbon.dynamic.client.registration.DynamicClientRegistrationService; +import org.wso2.carbon.dynamic.client.registration.OAuthApplicationInfo; +import org.wso2.carbon.dynamic.client.registration.profile.RegistrationProfile; +import org.wso2.carbon.dynamic.client.web.DynamicClientUtil; +import org.wso2.carbon.dynamic.client.web.FaultResponse; +import org.wso2.carbon.dynamic.client.web.RegistrationService; +import org.wso2.carbon.utils.multitenancy.MultitenantConstants; + +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.POST; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.QueryParam; + +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +public class RegistrationServiceImpl implements RegistrationService { + + private static final Log log = LogFactory.getLog(RegistrationServiceImpl.class); + + @POST + @Override + public Response register(RegistrationProfile profile) { + try { + PrivilegedCarbonContext.startTenantFlow(); + PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain( + MultitenantConstants.SUPER_TENANT_DOMAIN_NAME); + PrivilegedCarbonContext.getThreadLocalCarbonContext(). + setTenantId(MultitenantConstants.SUPER_TENANT_ID); + + DynamicClientRegistrationService dynamicClientRegistrationService = DynamicClientUtil. + getDynamicClientRegistrationService(); + if(dynamicClientRegistrationService != null){ + OAuthApplicationInfo info = dynamicClientRegistrationService. + registerOAuthApplication(profile); + return Response.status(Response.Status.CREATED).entity(info.toString()).build(); + } + return Response.status(Response.Status.INTERNAL_SERVER_ERROR). + entity("Dynamic Client Registration Service not available.").build(); + } catch (DynamicClientRegistrationException e) { + String msg = "Error occurred while registering client '" + profile.getClientName() + "'"; + log.error(msg, e); + return Response.status(Response.Status.BAD_REQUEST).entity( + new FaultResponse(ErrorCode.INVALID_CLIENT_METADATA, msg)).build(); + } finally { + PrivilegedCarbonContext.endTenantFlow(); + } + } + + @DELETE + @Override + public Response unregister(@QueryParam("applicationName") String applicationName, + @QueryParam("userId") String userId, + @QueryParam("consumerKey") String consumerKey) { + try { + DynamicClientRegistrationService dynamicClientRegistrationService = DynamicClientUtil. + getDynamicClientRegistrationService(); + if(dynamicClientRegistrationService != null){ + boolean status = dynamicClientRegistrationService.unregisterOAuthApplication(userId, + applicationName, + consumerKey); + if(status){ + return Response.status(Response.Status.ACCEPTED).build(); + } + return Response.status(Response.Status.BAD_REQUEST).build(); + } + return Response.status(Response.Status.INTERNAL_SERVER_ERROR). + entity("Dynamic Client Registration Service not available.").build(); + } catch (DynamicClientRegistrationException e) { + String msg = "Error occurred while un-registering client '" + applicationName + "'"; + log.error(msg, e); + return Response.serverError(). + entity(new FaultResponse(ErrorCode.INVALID_CLIENT_METADATA, msg)).build(); + } + } + +} diff --git a/components/oauth-extensions/dynamic-client-manager/src/main/webapp/META-INF/webapp-classloading.xml b/components/dynamic-client-registration/dynamic-client-web/src/main/webapp/META-INF/webapp-classloading.xml similarity index 100% rename from components/oauth-extensions/dynamic-client-manager/src/main/webapp/META-INF/webapp-classloading.xml rename to components/dynamic-client-registration/dynamic-client-web/src/main/webapp/META-INF/webapp-classloading.xml diff --git a/components/oauth-extensions/dynamic-client-manager/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/dynamic-client-registration/dynamic-client-web/src/main/webapp/WEB-INF/cxf-servlet.xml similarity index 57% rename from components/oauth-extensions/dynamic-client-manager/src/main/webapp/WEB-INF/cxf-servlet.xml rename to components/dynamic-client-registration/dynamic-client-web/src/main/webapp/WEB-INF/cxf-servlet.xml index 78ccf40375..3d7ec54290 100644 --- a/components/oauth-extensions/dynamic-client-manager/src/main/webapp/WEB-INF/cxf-servlet.xml +++ b/components/dynamic-client-registration/dynamic-client-web/src/main/webapp/WEB-INF/cxf-servlet.xml @@ -2,19 +2,19 @@ - + - + diff --git a/components/oauth-extensions/dynamic-client-manager/src/main/webapp/WEB-INF/web.xml b/components/dynamic-client-registration/dynamic-client-web/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from components/oauth-extensions/dynamic-client-manager/src/main/webapp/WEB-INF/web.xml rename to components/dynamic-client-registration/dynamic-client-web/src/main/webapp/WEB-INF/web.xml diff --git a/components/oauth-extensions/dynamic-client-manager/src/main/webapp/servicelist.css b/components/dynamic-client-registration/dynamic-client-web/src/main/webapp/servicelist.css similarity index 100% rename from components/oauth-extensions/dynamic-client-manager/src/main/webapp/servicelist.css rename to components/dynamic-client-registration/dynamic-client-web/src/main/webapp/servicelist.css diff --git a/components/oauth-extensions/dynamic-client-manager/src/test/resources/log4j.properties b/components/dynamic-client-registration/dynamic-client-web/src/test/resources/log4j.properties similarity index 100% rename from components/oauth-extensions/dynamic-client-manager/src/test/resources/log4j.properties rename to components/dynamic-client-registration/dynamic-client-web/src/test/resources/log4j.properties diff --git a/components/oauth-extensions/dynamic-client-manager/src/test/resources/testng.xml b/components/dynamic-client-registration/dynamic-client-web/src/test/resources/testng.xml similarity index 100% rename from components/oauth-extensions/dynamic-client-manager/src/test/resources/testng.xml rename to components/dynamic-client-registration/dynamic-client-web/src/test/resources/testng.xml diff --git a/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/pom.xml b/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/pom.xml new file mode 100644 index 0000000000..e1aa38e3f6 --- /dev/null +++ b/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/pom.xml @@ -0,0 +1,108 @@ + + + + + + dynamic-client-registration + org.wso2.carbon.devicemgt + 0.9.2-SNAPSHOT + ../pom.xml + + + 4.0.0 + org.wso2.carbon.dynamic.client.registration + 0.9.2-SNAPSHOT + bundle + WSO2 Carbon - Dynamic client registration service + WSO2 Carbon - Dynamic Client Registration Service + http://wso2.org + + + + + org.apache.felix + maven-bundle-plugin + 1.4.0 + true + + + ${project.artifactId} + ${project.artifactId} + ${carbon.device.mgt.version} + Dynamic Client Registration Bundle + org.wso2.carbon.dynamic.client.registration.internal.DynamicClientRegistrationBundleActivator + org.wso2.carbon.dynamic.client.registration.internal + + !org.wso2.carbon.dynamic.client.registration.internal, + org.wso2.carbon.dynamic.client.registration.* + + * + + + + + + + + org.eclipse.osgi + org.eclipse.osgi + + + org.eclipse.osgi + org.eclipse.osgi.services + + + org.testng + testng + + + org.wso2.carbon + org.wso2.carbon.utils + + + org.wso2.carbon.identity + org.wso2.carbon.identity.application.mgt + + + org.wso2.carbon.apimgt + org.wso2.carbon.apimgt.api + + + org.wso2.carbon.apimgt + org.wso2.carbon.apimgt.impl + + + org.wso2.carbon.apimgt + org.wso2.carbon.apimgt.keymgt.client + + + org.wso2.carbon.identity + org.wso2.carbon.identity.oauth + + + com.googlecode.json-simple.wso2 + json-simple + + + org.json.wso2 + json + + + \ No newline at end of file diff --git a/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/ApplicationConstants.java b/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/ApplicationConstants.java similarity index 74% rename from components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/ApplicationConstants.java rename to components/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/ApplicationConstants.java index ad160b6ff3..c326ee6af8 100644 --- a/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/ApplicationConstants.java +++ b/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/ApplicationConstants.java @@ -1,23 +1,25 @@ /* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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. - * + * 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.extension; +package org.wso2.carbon.dynamic.client.registration; +/** + * This class holds the constants used by DynamicClientRegistration component. + */ public final class ApplicationConstants { public static class ClientMetadata { diff --git a/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/DynamicClientRegistrationException.java b/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/DynamicClientRegistrationException.java new file mode 100644 index 0000000000..f01d817d71 --- /dev/null +++ b/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/DynamicClientRegistrationException.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2015, 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.dynamic.client.registration; + +/** + * Custom exception to be thrown inside DynamicClientRegistration related functionalities. + */ +public class DynamicClientRegistrationException extends Exception { + + private static final long serialVersionUID = -3151279311929070297L; + + private String errorMessage; + + public String getErrorMessage() { + return errorMessage; + } + + public void setErrorMessage(String errorMessage) { + this.errorMessage = errorMessage; + } + + public DynamicClientRegistrationException(String msg, Exception nestedEx) { + super(msg, nestedEx); + setErrorMessage(msg); + } + + public DynamicClientRegistrationException(String message, Throwable cause) { + super(message, cause); + setErrorMessage(message); + } + + public DynamicClientRegistrationException(String msg) { + super(msg); + setErrorMessage(msg); + } + + public DynamicClientRegistrationException() { + super(); + } + + public DynamicClientRegistrationException(Throwable cause) { + super(cause); + } + +} diff --git a/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/DynamicClientRegistrationService.java b/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/DynamicClientRegistrationService.java new file mode 100644 index 0000000000..e6aea31a71 --- /dev/null +++ b/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/DynamicClientRegistrationService.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2015, 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.dynamic.client.registration; + +import org.wso2.carbon.dynamic.client.registration.profile.RegistrationProfile; + +/** + * This class represents the interface to be implemented by DynamicClientRegistrationService. + */ +public interface DynamicClientRegistrationService { + + /** + * This method will register a new OAuth application using the data provided by + * RegistrationProfile. + * + * @param profile - RegistrationProfile of the OAuth application to be created. + * @return OAuthApplicationInfo object which holds the necessary data of created OAuth app. + * @throws DynamicClientRegistrationException + */ + public OAuthApplicationInfo registerOAuthApplication(RegistrationProfile profile) throws + DynamicClientRegistrationException; + + /** + * This method will unregister a created OAuth application. + * + * @param userName - Username of the owner + * @param applicationName - OAuth application name + * @param consumerKey - ConsumerKey of the OAuth application + * @return The status of the operation + * @throws DynamicClientRegistrationException + */ + public boolean unregisterOAuthApplication(String userName, String applicationName, + String consumerKey) throws DynamicClientRegistrationException; + + /** + * This method will check the existence of an OAuth application provided application-name. + * + * @param applicationName - OAuth application name + * @return The status of the operation + * @throws DynamicClientRegistrationException + */ + public boolean isOAuthApplicationExists(String applicationName) + throws DynamicClientRegistrationException; + +} diff --git a/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/OAuthApplicationInfo.java b/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/OAuthApplicationInfo.java similarity index 55% rename from components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/OAuthApplicationInfo.java rename to components/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/OAuthApplicationInfo.java index 3457b60d38..2eb570cb59 100644 --- a/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/OAuthApplicationInfo.java +++ b/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/OAuthApplicationInfo.java @@ -1,30 +1,30 @@ /* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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. - * + * 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.extension; +package org.wso2.carbon.dynamic.client.registration; -import org.codehaus.jackson.map.ObjectMapper; import org.json.simple.JSONObject; -import java.io.IOException; import java.util.HashMap; import java.util.Map; +/** + * This class represents an OAuth application populated with necessary data. + */ public class OAuthApplicationInfo { private String clientId; @@ -86,12 +86,13 @@ public class OAuthApplicationInfo { } public String toString() { - ObjectMapper mapper = new ObjectMapper(); - try { - return mapper.writeValueAsString(this); - } catch (IOException e) { - throw new RuntimeException("Error occurred while serializing OAuthApplicationInfo bean"); - } + JSONObject obj = new JSONObject(); + obj.put(ApplicationConstants.ClientMetadata.OAUTH_CLIENT_ID, this.getClientId()); + obj.put(ApplicationConstants.ClientMetadata.OAUTH_CLIENT_NAME, this.getClientName()); + obj.put(ApplicationConstants.ClientMetadata.OAUTH_CALLBACK_URIS, this.getCallBackURL()); + obj.put(ApplicationConstants.ClientMetadata.OAUTH_CLIENT_SECRET, this.getClientSecret()); + obj.put("parameters", this.getJsonString()); + return obj.toString(); } } diff --git a/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/DynamicClientRegistrationUtil.java b/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/impl/DynamicClientRegistrationImpl.java similarity index 58% rename from components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/DynamicClientRegistrationUtil.java rename to components/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/impl/DynamicClientRegistrationImpl.java index c823323364..599619cfc1 100644 --- a/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/DynamicClientRegistrationUtil.java +++ b/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/impl/DynamicClientRegistrationImpl.java @@ -1,31 +1,34 @@ /* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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. - * + * 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.extension; + +package org.wso2.carbon.dynamic.client.registration.impl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.json.JSONException; import org.json.JSONObject; -import org.wso2.carbon.apimgt.api.APIManagementException; -import org.wso2.carbon.apimgt.impl.utils.APIUtil; import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.dynamic.client.registration.ApplicationConstants; +import org.wso2.carbon.dynamic.client.registration.DynamicClientRegistrationException; +import org.wso2.carbon.dynamic.client.registration.DynamicClientRegistrationService; +import org.wso2.carbon.dynamic.client.registration.OAuthApplicationInfo; +import org.wso2.carbon.dynamic.client.registration.profile.RegistrationProfile; import org.wso2.carbon.identity.application.common.IdentityApplicationManagementException; import org.wso2.carbon.identity.application.common.model.InboundAuthenticationConfig; import org.wso2.carbon.identity.application.common.model.InboundAuthenticationRequestConfig; @@ -37,22 +40,25 @@ import org.wso2.carbon.identity.oauth.OAuthAdminService; import org.wso2.carbon.identity.oauth.dto.OAuthConsumerAppDTO; import org.wso2.carbon.utils.multitenancy.MultitenantUtils; -import org.wso2.carbon.identity.oauth.extension.profile.RegistrationProfile; - import java.util.Arrays; -public class DynamicClientRegistrationUtil { +/** + * Implementation of DynamicClientRegistrationService. + */ +public class DynamicClientRegistrationImpl implements DynamicClientRegistrationService { private static final String TOKEN_SCOPE = "tokenScope"; - private static final Log log = LogFactory.getLog(DynamicClientRegistrationUtil.class); + private static final Log log = LogFactory.getLog(DynamicClientRegistrationService.class); - public static OAuthApplicationInfo registerApplication(RegistrationProfile profile) throws APIManagementException { + @Override + public OAuthApplicationInfo registerOAuthApplication(RegistrationProfile profile) + throws DynamicClientRegistrationException { OAuthApplicationInfo oAuthApplicationInfo = new OAuthApplicationInfo(); String applicationName = profile.getClientName(); if (log.isDebugEnabled()) { - log.debug("Trying to create OAuth application: '" + applicationName + "'"); + log.debug("Trying to register OAuth application: '" + applicationName + "'"); } String tokenScope = profile.getTokenScope(); @@ -62,13 +68,15 @@ public class DynamicClientRegistrationUtil { oAuthApplicationInfo.addParameter(TOKEN_SCOPE, Arrays.toString(tokenScopes)); OAuthApplicationInfo info; try { - info = createOAuthApplication(profile); + info = this.createOAuthApplication(profile); } catch (Exception e) { - throw new APIManagementException("Can not create OAuth application : " + applicationName, e); + throw new DynamicClientRegistrationException( + "Can not create OAuth application : " + applicationName, e); } if (info == null || info.getJsonString() == null) { - throw new APIManagementException("OAuth app does not contain required data: '" + applicationName + "'"); + throw new DynamicClientRegistrationException( + "OAuth app does not contain required data: '" + applicationName + "'"); } oAuthApplicationInfo.setClientName(info.getClientName()); @@ -79,29 +87,37 @@ public class DynamicClientRegistrationUtil { try { JSONObject jsonObject = new JSONObject(info.getJsonString()); if (jsonObject.has(ApplicationConstants.ClientMetadata.OAUTH_REDIRECT_URIS)) { - oAuthApplicationInfo.addParameter(ApplicationConstants.ClientMetadata.OAUTH_REDIRECT_URIS, - jsonObject.get(ApplicationConstants.ClientMetadata.OAUTH_REDIRECT_URIS)); + oAuthApplicationInfo + .addParameter(ApplicationConstants.ClientMetadata.OAUTH_REDIRECT_URIS, + jsonObject + .get(ApplicationConstants.ClientMetadata. + OAUTH_REDIRECT_URIS)); } if (jsonObject.has(ApplicationConstants.ClientMetadata.OAUTH_CLIENT_GRANT)) { oAuthApplicationInfo.addParameter(ApplicationConstants.ClientMetadata. - OAUTH_CLIENT_GRANT, jsonObject.get(ApplicationConstants.ClientMetadata.OAUTH_CLIENT_GRANT)); + OAUTH_CLIENT_GRANT, jsonObject + .get(ApplicationConstants.ClientMetadata. + OAUTH_CLIENT_GRANT)); } } catch (JSONException e) { - throw new APIManagementException("Can not retrieve information of the created OAuth application", e); + throw new DynamicClientRegistrationException( + "Can not retrieve information of the created OAuth application", e); } return oAuthApplicationInfo; } - public static OAuthApplicationInfo createOAuthApplication( + private OAuthApplicationInfo createOAuthApplication( RegistrationProfile profile) - throws APIManagementException, IdentityException { + throws DynamicClientRegistrationException, IdentityException { - //Subscriber's name should be passed as a parameter, since it's under the subscriber the OAuth App is created. + //Subscriber's name should be passed as a parameter, since it's under the subscriber + //the OAuth App is created. String userId = profile.getOwner(); String applicationName = profile.getClientName(); String grantType = profile.getGrantType(); String callbackUrl = profile.getCallbackUrl(); + boolean isSaaSApp = profile.isSaasApp(); if (userId == null || userId.isEmpty()) { return null; @@ -125,20 +141,24 @@ public class DynamicClientRegistrationUtil { // Create the Service Provider ServiceProvider serviceProvider = new ServiceProvider(); serviceProvider.setApplicationName(applicationName); + serviceProvider.setDescription("Service Provider for application " + applicationName); ApplicationManagementService appMgtService = ApplicationManagementService.getInstance(); if (appMgtService == null) { - throw new IllegalStateException("Error occurred while retrieving Application Management" + + throw new IllegalStateException( + "Error occurred while retrieving Application Management" + "Service"); } appMgtService.createApplication(serviceProvider); ServiceProvider createdServiceProvider = appMgtService.getApplication(applicationName); if (createdServiceProvider == null) { - throw new APIManagementException("Couldn't create Service Provider Application " + applicationName); + throw new DynamicClientRegistrationException( + "Couldn't create Service Provider Application " + applicationName); } - + //Set SaaS app option + createdServiceProvider.setSaasApp(isSaaSApp); // Then Create OAuthApp OAuthAdminService oAuthAdminService = new OAuthAdminService(); @@ -155,13 +175,15 @@ public class DynamicClientRegistrationUtil { log.debug("Created OAuth App " + applicationName); } - OAuthConsumerAppDTO createdApp = oAuthAdminService.getOAuthApplicationDataByAppName(oAuthConsumerAppDTO - .getApplicationName()); + OAuthConsumerAppDTO createdApp = + oAuthAdminService.getOAuthApplicationDataByAppName(oAuthConsumerAppDTO + .getApplicationName()); if (log.isDebugEnabled()) { log.debug("Retrieved Details for OAuth App " + createdApp.getApplicationName()); } // Set the OAuthApp in InboundAuthenticationConfig - InboundAuthenticationConfig inboundAuthenticationConfig = new InboundAuthenticationConfig(); + InboundAuthenticationConfig inboundAuthenticationConfig = + new InboundAuthenticationConfig(); InboundAuthenticationRequestConfig[] inboundAuthenticationRequestConfigs = new InboundAuthenticationRequestConfig[1]; InboundAuthenticationRequestConfig inboundAuthenticationRequestConfig = new @@ -170,16 +192,18 @@ public class DynamicClientRegistrationUtil { inboundAuthenticationRequestConfig.setInboundAuthKey(createdApp.getOauthConsumerKey()); inboundAuthenticationRequestConfig.setInboundAuthType("oauth2"); if (createdApp.getOauthConsumerSecret() != null && !createdApp. - getOauthConsumerSecret().isEmpty()) { + getOauthConsumerSecret() + .isEmpty()) { Property property = new Property(); property.setName("oauthConsumerSecret"); property.setValue(createdApp.getOauthConsumerSecret()); - Property[] properties = {property}; + Property[] properties = { property }; inboundAuthenticationRequestConfig.setProperties(properties); } inboundAuthenticationRequestConfigs[0] = inboundAuthenticationRequestConfig; - inboundAuthenticationConfig.setInboundAuthenticationRequestConfigs(inboundAuthenticationRequestConfigs); + inboundAuthenticationConfig + .setInboundAuthenticationRequestConfigs(inboundAuthenticationRequestConfigs); createdServiceProvider.setInboundAuthenticationConfig(inboundAuthenticationConfig); // Update the Service Provider app to add OAuthApp as an Inbound Authentication Config @@ -192,23 +216,29 @@ public class DynamicClientRegistrationUtil { oAuthApplicationInfo.setClientName(createdApp.getApplicationName()); oAuthApplicationInfo.addParameter( - ApplicationConstants.ClientMetadata.OAUTH_REDIRECT_URIS, createdApp.getCallbackUrl()); + ApplicationConstants.ClientMetadata.OAUTH_REDIRECT_URIS, + createdApp.getCallbackUrl()); oAuthApplicationInfo.addParameter( - ApplicationConstants.ClientMetadata.OAUTH_CLIENT_GRANT, createdApp.getGrantTypes()); + ApplicationConstants.ClientMetadata.OAUTH_CLIENT_GRANT, + createdApp.getGrantTypes()); return oAuthApplicationInfo; } catch (IdentityApplicationManagementException e) { - APIUtil.handleException("Error occurred while creating ServiceProvider for app " + applicationName, e); + throw new DynamicClientRegistrationException( + "Error occurred while creating ServiceProvider for app " + applicationName, e); } catch (Exception e) { - APIUtil.handleException("Error occurred while creating OAuthApp " + applicationName, e); + throw new DynamicClientRegistrationException( + "Error occurred while creating OAuthApp " + applicationName, e); } finally { PrivilegedCarbonContext.endTenantFlow(); PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(baseUser); } - return null; } - public static void unregisterApplication(String userId, String applicationName, - String consumerKey) throws APIManagementException { + @Override + public boolean unregisterOAuthApplication(String userId, String applicationName, + String consumerKey) + throws DynamicClientRegistrationException { + boolean status = false; String tenantDomain = MultitenantUtils.getTenantDomain(userId); String baseUser = CarbonContext.getThreadLocalCarbonContext().getUsername(); String userName = MultitenantUtils.getTenantAwareUsername(userId); @@ -218,15 +248,18 @@ public class DynamicClientRegistrationUtil { PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(userName); if (userId == null || userId.isEmpty()) { - throw new APIManagementException("Error occurred while unregistering Application: userId cannot " + + throw new DynamicClientRegistrationException( + "Error occurred while unregistering Application: userId cannot " + "be null/empty"); } try { OAuthAdminService oAuthAdminService = new OAuthAdminService(); - OAuthConsumerAppDTO oAuthConsumerAppDTO = oAuthAdminService.getOAuthApplicationData(consumerKey); + OAuthConsumerAppDTO oAuthConsumerAppDTO = + oAuthAdminService.getOAuthApplicationData(consumerKey); if (oAuthConsumerAppDTO == null) { - throw new APIManagementException("Couldn't retrieve OAuth Consumer Application associated with the " + + throw new DynamicClientRegistrationException( + "Couldn't retrieve OAuth Consumer Application associated with the " + "given consumer key: " + consumerKey); } oAuthAdminService.removeOAuthApplicationData(consumerKey); @@ -234,24 +267,49 @@ public class DynamicClientRegistrationUtil { ApplicationManagementService appMgtService = ApplicationManagementService.getInstance(); if (appMgtService == null) { - throw new IllegalStateException("Error occurred while retrieving Application Management" + + throw new IllegalStateException( + "Error occurred while retrieving Application Management" + "Service"); } ServiceProvider createdServiceProvider = appMgtService.getApplication(applicationName); if (createdServiceProvider == null) { - throw new APIManagementException("Couldn't retrieve Service Provider Application " + applicationName); + throw new DynamicClientRegistrationException( + "Couldn't retrieve Service Provider Application " + applicationName); } appMgtService.deleteApplication(applicationName); - + status = true; } catch (IdentityApplicationManagementException e) { - APIUtil.handleException("Error occurred while removing ServiceProvider for app " + applicationName, e); + throw new DynamicClientRegistrationException( + "Error occurred while removing ServiceProvider for app " + applicationName, e); } catch (Exception e) { - APIUtil.handleException("Error occurred while removing OAuthApp " + applicationName, e); + throw new DynamicClientRegistrationException( + "Error occurred while removing OAuthApp " + applicationName, e); } finally { PrivilegedCarbonContext.endTenantFlow(); PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(baseUser); } + return status; } + @Override + public boolean isOAuthApplicationExists(String applicationName) + throws DynamicClientRegistrationException { + ApplicationManagementService appMgtService = ApplicationManagementService.getInstance(); + if (appMgtService == null) { + throw new IllegalStateException( + "Error occurred while retrieving Application Management" + + "Service"); + } + try { + if (appMgtService.getApplication(applicationName) != null) { + return true; + } + } catch (IdentityApplicationManagementException e) { + throw new DynamicClientRegistrationException( + "Error occurred while retrieving information of OAuthApp " + applicationName, + e); + } + return false; + } } diff --git a/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/internal/DynamicClientRegistrationBundleActivator.java b/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/internal/DynamicClientRegistrationBundleActivator.java new file mode 100644 index 0000000000..e3ae13e4df --- /dev/null +++ b/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/internal/DynamicClientRegistrationBundleActivator.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2015, 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.dynamic.client.registration.internal; + +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; +import org.wso2.carbon.dynamic.client.registration.DynamicClientRegistrationService; +import org.wso2.carbon.dynamic.client.registration.impl.DynamicClientRegistrationImpl; + +/** + * BundleActivator class of DynamicClientRegistration component. + */ +public class DynamicClientRegistrationBundleActivator implements BundleActivator{ + + @Override + public void start(BundleContext bundleContext) throws Exception { + DynamicClientRegistrationService dynamicClientRegistrationService = + new DynamicClientRegistrationImpl(); + bundleContext.registerService(DynamicClientRegistrationService.class.getName(), + dynamicClientRegistrationService, null); + } + + @Override + public void stop(BundleContext bundleContext) throws Exception { + + } + +} diff --git a/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/profile/RegistrationProfile.java b/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/profile/RegistrationProfile.java similarity index 79% rename from components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/profile/RegistrationProfile.java rename to components/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/profile/RegistrationProfile.java index 25a760ab25..8f8286ba68 100644 --- a/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/profile/RegistrationProfile.java +++ b/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/profile/RegistrationProfile.java @@ -1,23 +1,27 @@ /* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, 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 + * 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. - * + * 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.extension.profile; +package org.wso2.carbon.dynamic.client.registration.profile; +/** + * + * DTO class to be used when registering a OAuth application. + * +* */ public class RegistrationProfile { private String applicationType; @@ -36,6 +40,15 @@ public class RegistrationProfile { private String callbackUrl; private String tokenScope; private String grantType; + private boolean saasApp; + + public boolean isSaasApp() { + return saasApp; + } + + public void setSaasApp(boolean saasApp) { + this.saasApp = saasApp; + } public String getApplicationType() { return applicationType; diff --git a/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/pom.xml b/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/pom.xml new file mode 100644 index 0000000000..1e5d699887 --- /dev/null +++ b/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/pom.xml @@ -0,0 +1,127 @@ + + + + + + dynamic-client-registration + org.wso2.carbon.devicemgt + 0.9.2-SNAPSHOT + ../pom.xml + + + 4.0.0 + org.wso2.carbon.dynamic.client.web.app.registration + 0.9.2-SNAPSHOT + bundle + WSO2 Carbon - Dynamic client web app registration + WSO2 Carbon - Dynamic Client Web-app Registration Service + http://wso2.org + + + + + org.apache.felix + maven-scr-plugin + + + org.apache.felix + maven-bundle-plugin + 1.4.0 + true + + + ${project.artifactId} + ${project.artifactId} + ${carbon.device.mgt.version} + Dynamic Client Web App Registration Bundle + org.wso2.carbon.dynamic.client.web.app.registration.internal + + !org.wso2.carbon.dynamic.client.web.app.registration.internal, + org.wso2.carbon.dynamic.client.web.app.registration.* + + * + + + + + + + + org.eclipse.osgi + org.eclipse.osgi + + + org.eclipse.osgi + org.eclipse.osgi.services + + + org.testng + testng + + + org.wso2.carbon + org.wso2.carbon.utils + + + org.wso2.carbon.identity + org.wso2.carbon.identity.application.mgt + + + org.wso2.carbon.apimgt + org.wso2.carbon.apimgt.api + + + org.wso2.carbon.apimgt + org.wso2.carbon.apimgt.impl + + + org.wso2.carbon.apimgt + org.wso2.carbon.apimgt.keymgt.client + + + org.wso2.carbon.identity + org.wso2.carbon.identity.oauth + + + org.wso2.tomcat + tomcat + + + org.wso2.tomcat + tomcat-servlet-api + + + org.wso2.carbon + org.wso2.carbon.logging + + + org.wso2.carbon + org.wso2.carbon.user.core + + + org.wso2.carbon + org.wso2.carbon.registry.core + + + org.wso2.carbon.devicemgt + org.wso2.carbon.dynamic.client.registration + + + \ No newline at end of file diff --git a/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/src/main/java/org/wso2/carbon/dynamic/client/web/app/registration/DynamicRegistrationManager.java b/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/src/main/java/org/wso2/carbon/dynamic/client/web/app/registration/DynamicRegistrationManager.java new file mode 100644 index 0000000000..cbe973aae3 --- /dev/null +++ b/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/src/main/java/org/wso2/carbon/dynamic/client/web/app/registration/DynamicRegistrationManager.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2015, 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.dynamic.client.web.app.registration; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.dynamic.client.registration.DynamicClientRegistrationException; +import org.wso2.carbon.dynamic.client.registration.DynamicClientRegistrationService; +import org.wso2.carbon.dynamic.client.registration.OAuthApplicationInfo; +import org.wso2.carbon.dynamic.client.registration.profile.RegistrationProfile; +import org.wso2.carbon.dynamic.client.web.app.registration.internal.DynamicClientRegistrationDataHolder; +import org.wso2.carbon.dynamic.client.web.app.registration.util.DynamicClientWebAppRegistrationUtil; + +/** + * This class contains the logic to handle the OAuth application creation process. + */ +public class DynamicRegistrationManager { + + private static DynamicRegistrationManager dynamicRegistrationManager; + private static final Log log = + LogFactory.getLog(DynamicRegistrationManager.class); + + private DynamicRegistrationManager() { + } + + public static DynamicRegistrationManager getInstance() { + if (dynamicRegistrationManager == null) { + synchronized (DynamicRegistrationManager.class) { + if (dynamicRegistrationManager == null) { + dynamicRegistrationManager = new DynamicRegistrationManager(); + } + } + } + return dynamicRegistrationManager; + } + + public boolean registerOAuthApplication(RegistrationProfile registrationProfile) { + DynamicClientRegistrationService dynamicClientRegistrationService = + DynamicClientRegistrationDataHolder.getInstance() + .getDynamicClientRegistrationService(); + try { + OAuthApplicationInfo oAuthApplicationInfo = + dynamicClientRegistrationService.registerOAuthApplication(registrationProfile); + OAuthApp oAuthApp = new OAuthApp(); + oAuthApp.setWebAppName(registrationProfile.getClientName()); + oAuthApp.setClientName(oAuthApplicationInfo.getClientName()); + oAuthApp.setClientKey(oAuthApplicationInfo.getClientId()); + oAuthApp.setClientSecret(oAuthApplicationInfo.getClientSecret()); + //store it in registry + return DynamicClientWebAppRegistrationUtil.putOAuthApplicationData(oAuthApp); + } catch (DynamicClientRegistrationException e) { + log.error("Error occurred while registering the OAuth application.",e); + } + return false; + } + + public OAuthApp getOAuthApplicationData(String clientName) { + try { + return DynamicClientWebAppRegistrationUtil.getOAuthApplicationData(clientName); + } catch (DynamicClientRegistrationException e) { + log.error("Error occurred while fetching the OAuth application data for web app : " + clientName, e); + } + return new OAuthApp(); + } + + public boolean isRegisteredOAuthApplication(String clientName) { + OAuthApp oAuthApp = this.getOAuthApplicationData(clientName); + if (oAuthApp.getClientKey() != null && oAuthApp.getClientSecret() != null) { + return true; + } + return false; + } + +} diff --git a/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/src/main/java/org/wso2/carbon/dynamic/client/web/app/registration/OAuthApp.java b/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/src/main/java/org/wso2/carbon/dynamic/client/web/app/registration/OAuthApp.java new file mode 100644 index 0000000000..ec8ea8e762 --- /dev/null +++ b/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/src/main/java/org/wso2/carbon/dynamic/client/web/app/registration/OAuthApp.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2015, 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.dynamic.client.web.app.registration; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * Represents a OAuth application with basic data. + */ +@XmlRootElement(name = "OAuthApp") +public class OAuthApp { + + private String clientName; + private String clientKey; + private String clientSecret; + private String webAppName; + + @XmlElement(name = "clientName", required = true) + public String getClientName() { + return clientName; + } + + public void setClientName(String clientName) { + this.clientName = clientName; + } + + @XmlElement(name = "clientKey", required = false) + public String getClientKey() { + return clientKey; + } + + public void setClientKey(String clientKey) { + this.clientKey = clientKey; + } + + @XmlElement(name = "clientSecret", required = false) + public String getClientSecret() { + return clientSecret; + } + + public void setClientSecret(String clientSecret) { + this.clientSecret = clientSecret; + } + + @XmlElement(name = "webAppName", required = true) + public String getWebAppName() { + return webAppName; + } + + public void setWebAppName(String webAppName) { + this.webAppName = webAppName; + } +} diff --git a/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/src/main/java/org/wso2/carbon/dynamic/client/web/app/registration/internal/DynamicClientRegistrationDataHolder.java b/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/src/main/java/org/wso2/carbon/dynamic/client/web/app/registration/internal/DynamicClientRegistrationDataHolder.java new file mode 100644 index 0000000000..5d8cf806cd --- /dev/null +++ b/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/src/main/java/org/wso2/carbon/dynamic/client/web/app/registration/internal/DynamicClientRegistrationDataHolder.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2015, 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.dynamic.client.web.app.registration.internal; + +import org.wso2.carbon.dynamic.client.registration.DynamicClientRegistrationService; +import org.wso2.carbon.registry.core.service.RegistryService; +import org.wso2.carbon.user.core.service.RealmService; + +/** + * Dataholder class of DynamicClient Webapp Registration component. + */ +public class DynamicClientRegistrationDataHolder { + + private RealmService realmService; + private RegistryService registryService; + private DynamicClientRegistrationService dynamicClientRegistrationService; + + public DynamicClientRegistrationService getDynamicClientRegistrationService() { + return dynamicClientRegistrationService; + } + + public void setDynamicClientRegistrationService( + DynamicClientRegistrationService dynamicClientRegistrationService) { + this.dynamicClientRegistrationService = dynamicClientRegistrationService; + } + + private static DynamicClientRegistrationDataHolder thisInstance = new DynamicClientRegistrationDataHolder(); + + private DynamicClientRegistrationDataHolder() {} + + public static DynamicClientRegistrationDataHolder getInstance() { + return thisInstance; + } + + public RealmService getRealmService() { + return realmService; + } + + public void setRealmService(RealmService realmService) { + this.realmService = realmService; + } + + public RegistryService getRegistryService() { + return registryService; + } + + public void setRegistryService(RegistryService registryService) { + this.registryService = registryService; + } +} diff --git a/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/src/main/java/org/wso2/carbon/dynamic/client/web/app/registration/internal/DynamicClientWebAppRegistrationServiceComponent.java b/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/src/main/java/org/wso2/carbon/dynamic/client/web/app/registration/internal/DynamicClientWebAppRegistrationServiceComponent.java new file mode 100644 index 0000000000..84572e93cb --- /dev/null +++ b/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/src/main/java/org/wso2/carbon/dynamic/client/web/app/registration/internal/DynamicClientWebAppRegistrationServiceComponent.java @@ -0,0 +1,136 @@ +/* + * Copyright (c) 2015, 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.dynamic.client.web.app.registration.internal; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.osgi.service.component.ComponentContext; +import org.wso2.carbon.dynamic.client.registration.DynamicClientRegistrationService; +import org.wso2.carbon.registry.core.service.RegistryService; +import org.wso2.carbon.user.core.service.RealmService; + +/** + * @scr.component name="org.wso2.carbon.device.manager" immediate="true" + * @scr.reference name="user.realmservice.default" + * interface="org.wso2.carbon.user.core.service.RealmService" + * cardinality="1..1" + * policy="dynamic" + * bind="setRealmService" + * unbind="unsetRealmService" + * @scr.reference name="registry.service" + * interface="org.wso2.carbon.registry.core.service.RegistryService" + * cardinality="1..1" + * policy="dynamic" + * bind="setRegistryService" + * unbind="unsetRegistryService" + * @scr.reference name="dynamic.client.service" + * interface="org.wso2.carbon.dynamic.client.registration.DynamicClientRegistrationService" + * cardinality="1..1" + * policy="dynamic" + * bind="setDynamicClientService" + * unbind="unsetDynamicClientService" + */ +public class DynamicClientWebAppRegistrationServiceComponent { + + private static Log log = LogFactory.getLog(DynamicClientWebAppRegistrationServiceComponent.class); + + @SuppressWarnings("unused") + protected void activate(ComponentContext componentContext) { + + } + + @SuppressWarnings("unused") + protected void deactivate(ComponentContext componentContext) { + //do nothing + } + + /** + * Sets Realm Service. + * + * @param realmService An instance of RealmService + */ + protected void setRealmService(RealmService realmService) { + if (log.isDebugEnabled()) { + log.debug("Setting Realm Service"); + } + DynamicClientRegistrationDataHolder.getInstance().setRealmService(realmService); + } + + /** + * Unsets Realm Service. + * + * @param realmService An instance of RealmService + */ + protected void unsetRealmService(RealmService realmService) { + if (log.isDebugEnabled()) { + log.debug("Unsetting Realm Service"); + } + DynamicClientRegistrationDataHolder.getInstance().setRealmService(null); + } + + /** + * Sets Registry Service. + * + * @param registryService An instance of RegistryService + */ + protected void setRegistryService(RegistryService registryService) { + if (log.isDebugEnabled()) { + log.debug("Setting Registry Service"); + } + DynamicClientRegistrationDataHolder.getInstance().setRegistryService(registryService); + } + + /** + * Unsets Registry Service. + * + * @param registryService An instance of RegistryService + */ + protected void unsetRegistryService(RegistryService registryService) { + if (log.isDebugEnabled()) { + log.debug("Un setting Registry Service"); + } + DynamicClientRegistrationDataHolder.getInstance().setRegistryService(null); + } + + /** + * Sets Dynamic Client Registration Service. + * + * @param dynamicClientRegistrationService An instance of DynamicClientRegistrationService + */ + protected void setDynamicClientService(DynamicClientRegistrationService dynamicClientRegistrationService) { + if (log.isDebugEnabled()) { + log.debug("Setting Dynamic Client Registration Service"); + } + DynamicClientRegistrationDataHolder.getInstance().setDynamicClientRegistrationService( + dynamicClientRegistrationService); + } + + /** + * Unsets Dynamic Client Registration Service. + * + * @param dynamicClientRegistrationService An instance of DynamicClientRegistrationService + */ + protected void unsetDynamicClientService(DynamicClientRegistrationService dynamicClientRegistrationService) { + if (log.isDebugEnabled()) { + log.debug("Un setting Dynamic Client Registration Service"); + } + DynamicClientRegistrationDataHolder.getInstance().setDynamicClientRegistrationService(null); + } + +} diff --git a/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/src/main/java/org/wso2/carbon/dynamic/client/web/app/registration/listner/DynamicClientWebAppDeploymentLifecycleListener.java b/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/src/main/java/org/wso2/carbon/dynamic/client/web/app/registration/listner/DynamicClientWebAppDeploymentLifecycleListener.java new file mode 100644 index 0000000000..32c3d1c382 --- /dev/null +++ b/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/src/main/java/org/wso2/carbon/dynamic/client/web/app/registration/listner/DynamicClientWebAppDeploymentLifecycleListener.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2015, 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.dynamic.client.web.app.registration.listner; + +import org.apache.catalina.Lifecycle; +import org.apache.catalina.LifecycleEvent; +import org.apache.catalina.LifecycleListener; +import org.apache.catalina.core.StandardContext; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.dynamic.client.registration.DynamicClientRegistrationException; +import org.wso2.carbon.dynamic.client.registration.profile.RegistrationProfile; +import org.wso2.carbon.dynamic.client.web.app.registration.DynamicRegistrationManager; +import org.wso2.carbon.dynamic.client.web.app.registration.util.DynamicClientRegistrationConstants; +import org.wso2.carbon.dynamic.client.web.app.registration.util.DynamicClientWebAppRegistrationUtil; + +import javax.servlet.ServletContext; + +/** + * This class initiates the dynamic client registration flow for Web applications upon on deployment + * of the web application. + */ +@SuppressWarnings("unused") +public class DynamicClientWebAppDeploymentLifecycleListener implements LifecycleListener { + + private static final Log log = + LogFactory.getLog(DynamicClientWebAppDeploymentLifecycleListener.class); + + @Override + public void lifecycleEvent(LifecycleEvent lifecycleEvent) { + if (Lifecycle.AFTER_START_EVENT.equals(lifecycleEvent.getType())) { + StandardContext context = (StandardContext) lifecycleEvent.getLifecycle(); + ServletContext servletContext = context.getServletContext(); + String requiredDynamicClientRegistration = servletContext.getInitParameter( + DynamicClientRegistrationConstants.DYNAMIC_CLIENT_REQUIRED_FLAG_PARAM); + if ((requiredDynamicClientRegistration != null) && + (Boolean.parseBoolean(requiredDynamicClientRegistration))) { + DynamicRegistrationManager dynamicRegistrationManager = + DynamicRegistrationManager.getInstance(); + //Get the application name from web-context + String webAppName = context.getBaseName(); + if (!dynamicRegistrationManager.isRegisteredOAuthApplication(webAppName)) { + RegistrationProfile registrationProfile = DynamicClientWebAppRegistrationUtil + .constructRegistrationProfile(servletContext, webAppName); + if(DynamicClientWebAppRegistrationUtil.validateRegistrationProfile(registrationProfile)){ + dynamicRegistrationManager.registerOAuthApplication(registrationProfile); + } + } + } else { + //TODO: Need to have the necessary logic to handle jaggery webapp scenario + } + } + } +} diff --git a/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/src/main/java/org/wso2/carbon/dynamic/client/web/app/registration/util/DynamicClientRegistrationConstants.java b/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/src/main/java/org/wso2/carbon/dynamic/client/web/app/registration/util/DynamicClientRegistrationConstants.java new file mode 100644 index 0000000000..7b8169d486 --- /dev/null +++ b/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/src/main/java/org/wso2/carbon/dynamic/client/web/app/registration/util/DynamicClientRegistrationConstants.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2015, 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.dynamic.client.web.app.registration.util; + +/** + * Holds the constants to be used in Dynamic client web app registration component. + */ +public class DynamicClientRegistrationConstants { + + public final static String OAUTH_APP_DATA_REGISTRY_PATH = "/OAuth"; + public final static String OAUTH_APP_NAME = "appName"; + public final static String OAUTH_CLIENT_KEY = "clientKey"; + public final static String OAUTH_CLIENT_SECRET = "clientSecret"; + public final static String DYNAMIC_CLIENT_REQUIRED_FLAG_PARAM = + "require-dynamic-client-registration"; + + public static final class ContentTypes { + private ContentTypes() { + throw new AssertionError(); + } + + public static final String CONTENT_TYPE_ANY = "*/*"; + public static final String MEDIA_TYPE_XML = "application/xml"; + } + + public static final class CharSets { + private CharSets() { + throw new AssertionError(); + } + + public static final String CHARSET_UTF8 = "UTF8"; + } +} diff --git a/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/src/main/java/org/wso2/carbon/dynamic/client/web/app/registration/util/DynamicClientWebAppRegistrationUtil.java b/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/src/main/java/org/wso2/carbon/dynamic/client/web/app/registration/util/DynamicClientWebAppRegistrationUtil.java new file mode 100644 index 0000000000..8977faefee --- /dev/null +++ b/components/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/src/main/java/org/wso2/carbon/dynamic/client/web/app/registration/util/DynamicClientWebAppRegistrationUtil.java @@ -0,0 +1,196 @@ +/* + * Copyright (c) 2015, 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.dynamic.client.web.app.registration.util; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.dynamic.client.registration.DynamicClientRegistrationException; +import org.wso2.carbon.dynamic.client.registration.profile.RegistrationProfile; +import org.wso2.carbon.dynamic.client.web.app.registration.OAuthApp; +import org.wso2.carbon.dynamic.client.web.app.registration.internal.DynamicClientRegistrationDataHolder; +import org.wso2.carbon.registry.api.RegistryException; +import org.wso2.carbon.registry.api.Resource; +import org.wso2.carbon.registry.core.Registry; +import org.wso2.carbon.user.core.service.RealmService; +import org.wso2.carbon.utils.CarbonUtils; + +import javax.servlet.ServletContext; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; +import javax.xml.bind.Unmarshaller; +import java.io.StringReader; +import java.io.StringWriter; +import java.nio.charset.Charset; + +/** + * Holds the utility methods to be used in Dynamic client web app registration component. + */ +public class DynamicClientWebAppRegistrationUtil { + + private final static String OAUTH_PARAM_GRANT_TYPE = "grant-type"; + private final static String OAUTH_PARAM_TOKEN_SCOPE = "token-scope"; + private final static String SP_PARAM_SAAS_APP = "saas-app"; + + private static final Log log = + LogFactory.getLog(DynamicClientWebAppRegistrationUtil.class); + + public static Registry getGovernanceRegistry() throws DynamicClientRegistrationException { + try { + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + return DynamicClientRegistrationDataHolder.getInstance().getRegistryService() + .getGovernanceSystemRegistry( + tenantId); + } catch (RegistryException e) { + throw new DynamicClientRegistrationException( + "Error in retrieving governance registry instance: " + + e.getMessage(), e); + } + } + + public static OAuthApp getOAuthApplicationData(String appName) + throws DynamicClientRegistrationException { + Resource resource; + String resourcePath = DynamicClientRegistrationConstants.OAUTH_APP_DATA_REGISTRY_PATH + "/" + appName; + try { + resource = DynamicClientWebAppRegistrationUtil.getRegistryResource(resourcePath); + if (resource != null) { + JAXBContext context = JAXBContext.newInstance(OAuthApp.class); + Unmarshaller unmarshaller = context.createUnmarshaller(); + return (OAuthApp) unmarshaller.unmarshal( + new StringReader(new String((byte[]) resource.getContent(), Charset + .forName( + DynamicClientRegistrationConstants.CharSets.CHARSET_UTF8)))); + } + return new OAuthApp(); + } catch (JAXBException e) { + throw new DynamicClientRegistrationException( + "Error occurred while parsing the OAuth application data : " + appName, e); + } catch (RegistryException e) { + throw new DynamicClientRegistrationException( + "Error occurred while retrieving the Registry resource of OAuth application : " + + appName, e); + } + } + + public static boolean putOAuthApplicationData(OAuthApp oAuthApp) + throws DynamicClientRegistrationException { + boolean status = false; + try { + if (log.isDebugEnabled()) { + log.debug("Persisting OAuth application data in Registry"); + } + StringWriter writer = new StringWriter(); + JAXBContext context = JAXBContext.newInstance(OAuthApp.class); + Marshaller marshaller = context.createMarshaller(); + marshaller.marshal(oAuthApp, writer); + + Resource resource = DynamicClientWebAppRegistrationUtil.getGovernanceRegistry().newResource(); + resource.setContent(writer.toString()); + resource.setMediaType(DynamicClientRegistrationConstants.ContentTypes.MEDIA_TYPE_XML); + String resourcePath = + DynamicClientRegistrationConstants.OAUTH_APP_DATA_REGISTRY_PATH + "/" + + oAuthApp.getWebAppName(); + status = DynamicClientWebAppRegistrationUtil.putRegistryResource(resourcePath, resource); + } catch (RegistryException e) { + throw new DynamicClientRegistrationException( + "Error occurred while persisting OAuth application data : " + + oAuthApp.getClientName(), e); + } catch (JAXBException e) { + e.printStackTrace(); + } + return status; + } + + public static boolean putRegistryResource(String path, + Resource resource) + throws DynamicClientRegistrationException { + boolean status; + try { + Registry governanceRegistry = DynamicClientWebAppRegistrationUtil + .getGovernanceRegistry(); + governanceRegistry.beginTransaction(); + governanceRegistry.put(path, resource); + governanceRegistry.commitTransaction(); + status = true; + } catch (RegistryException e) { + throw new DynamicClientRegistrationException( + "Error occurred while persisting registry resource : " + + e.getMessage(), e); + } + return status; + } + + public static Resource getRegistryResource(String path) + throws DynamicClientRegistrationException { + try { + Registry governanceRegistry = DynamicClientWebAppRegistrationUtil + .getGovernanceRegistry(); + if (governanceRegistry.resourceExists(path)) { + return governanceRegistry.get(path); + } + return null; + } catch (RegistryException e) { + throw new DynamicClientRegistrationException( + "Error in retrieving registry resource : " + + e.getMessage(), e); + } + } + + public static String getUserName(){ + String username = ""; + RealmService realmService = + DynamicClientRegistrationDataHolder.getInstance().getRealmService(); + if(realmService != null){ + username = realmService.getBootstrapRealmConfiguration().getAdminUserName(); + } + return username; + } + + public static RegistrationProfile constructRegistrationProfile(ServletContext servletContext, String webAppName) { + RegistrationProfile registrationProfile = new RegistrationProfile(); + registrationProfile.setGrantType(servletContext.getInitParameter( + DynamicClientWebAppRegistrationUtil.OAUTH_PARAM_GRANT_TYPE)); + registrationProfile.setTokenScope(servletContext.getInitParameter( + DynamicClientWebAppRegistrationUtil.OAUTH_PARAM_TOKEN_SCOPE)); + registrationProfile.setOwner(DynamicClientWebAppRegistrationUtil.getUserName()); + //TODO : Need to get the hostname properly + registrationProfile.setCallbackUrl("http://localhost:9763/" + webAppName); + registrationProfile.setClientName(webAppName); + registrationProfile.setSaasApp(Boolean.parseBoolean(servletContext.getInitParameter( + DynamicClientWebAppRegistrationUtil.SP_PARAM_SAAS_APP))); + return registrationProfile; + } + + public static boolean validateRegistrationProfile(RegistrationProfile registrationProfile) { + boolean status = true; + if(registrationProfile.getGrantType() == null){ + status = false; + log.warn("Required parameter 'grant-type' is missing for initiating Dynamic-Client " + + "registration for webapp : " + registrationProfile.getClientName()); + } + if(registrationProfile.getTokenScope() == null){ + status = false; + log.warn("Required parameter 'token-scope' is missing for initiating Dynamic-Client " + + "registration for webapp : " + registrationProfile.getClientName()); + } + return status; + } +} diff --git a/components/oauth-extensions/pom.xml b/components/dynamic-client-registration/pom.xml similarity index 57% rename from components/oauth-extensions/pom.xml rename to components/dynamic-client-registration/pom.xml index 7b9aa75794..95cd219a42 100644 --- a/components/oauth-extensions/pom.xml +++ b/components/dynamic-client-registration/pom.xml @@ -1,21 +1,21 @@ + ~ Copyright (c) 2015, 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. + --> @@ -28,14 +28,16 @@ 4.0.0 org.wso2.carbon.devicemgt - oauth-extensions + dynamic-client-registration 0.9.2-SNAPSHOT pom - WSO2 Carbon - OAuth Extensions + WSO2 Carbon - Dynamic Client Registration Component http://wso2.org - dynamic-client-manager + org.wso2.carbon.dynamic.client.registration + org.wso2.carbon.dynamic.client.web.app.registration + dynamic-client-web diff --git a/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/ConfigurationService.java b/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/ConfigurationService.java deleted file mode 100644 index 032f090a1d..0000000000 --- a/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/ConfigurationService.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2015, 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.extension; - -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) -@Path("/connect") -public interface ConfigurationService { - - @GET - @Path("/register") - Response getProfile(@PathParam("client_id") String clientId); - -} diff --git a/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/FaultResponse.java b/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/FaultResponse.java deleted file mode 100644 index 5e71a41237..0000000000 --- a/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/FaultResponse.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2015, 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.extension; - -public class FaultResponse { - - private RegistrationService.ErrorCode code; - private String description; - - public FaultResponse(RegistrationService.ErrorCode code, String description) { - this.code = code; - this.description = description; - } - - public RegistrationService.ErrorCode getCode() { - return code; - } - - public String getDescription() { - return description; - } - -} diff --git a/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/RegistrationResponse.java b/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/RegistrationResponse.java deleted file mode 100644 index 23d60a8f11..0000000000 --- a/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/RegistrationResponse.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2015, 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.extension; - -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.core.Response; - -public class RegistrationResponse extends Response { - - @Override - public Object getEntity() { - return null; - } - - @Override - public int getStatus() { - return 0; - } - - @Override - public MultivaluedMap getMetadata() { - return null; - } - -} diff --git a/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/impl/ConfigurationServiceImpl.java b/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/impl/ConfigurationServiceImpl.java deleted file mode 100644 index 840e0ee935..0000000000 --- a/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/impl/ConfigurationServiceImpl.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2015, 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.extension.impl; - -import org.wso2.carbon.identity.oauth.extension.ConfigurationService; - -import javax.ws.rs.PathParam; -import javax.ws.rs.core.Response; - -public class ConfigurationServiceImpl implements ConfigurationService { - - @Override - public Response getProfile(@PathParam("client_id") String clientId) { - return null; - } - -} \ No newline at end of file diff --git a/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/impl/RegistrationServiceImpl.java b/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/impl/RegistrationServiceImpl.java deleted file mode 100644 index 2fdb539988..0000000000 --- a/components/oauth-extensions/dynamic-client-manager/src/main/java/org/wso2/carbon/identity/oauth/extension/impl/RegistrationServiceImpl.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2015, 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.extension.impl; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.apimgt.api.APIManagementException; -import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.identity.oauth.extension.DynamicClientRegistrationUtil; -import org.wso2.carbon.identity.oauth.extension.FaultResponse; -import org.wso2.carbon.identity.oauth.extension.OAuthApplicationInfo; -import org.wso2.carbon.identity.oauth.extension.RegistrationService; -import org.wso2.carbon.identity.oauth.extension.profile.RegistrationProfile; -import org.wso2.carbon.utils.multitenancy.MultitenantConstants; - -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.POST; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.QueryParam; - -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) -public class RegistrationServiceImpl implements RegistrationService { - - private static final Log log = LogFactory.getLog(RegistrationServiceImpl.class); - - @POST - @Override - public Response register(RegistrationProfile profile) { - try { - PrivilegedCarbonContext.startTenantFlow(); - PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain( - MultitenantConstants.SUPER_TENANT_DOMAIN_NAME); - PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(MultitenantConstants.SUPER_TENANT_ID); - - OAuthApplicationInfo info = DynamicClientRegistrationUtil.registerApplication(profile); - return Response.status(Response.Status.ACCEPTED).entity(info.toString()).build(); - } catch (APIManagementException e) { - String msg = "Error occurred while registering client '" + profile.getClientName() + "'"; - log.error(msg, e); - return Response.status(Response.Status.BAD_REQUEST).entity( - new FaultResponse(ErrorCode.INVALID_CLIENT_METADATA, msg)).build(); - } finally { - PrivilegedCarbonContext.endTenantFlow(); - } - } - - @DELETE - @Override - public Response unregister(@QueryParam("applicationName") String applicationName, - @QueryParam("userId") String userId, - @QueryParam("consumerKey") String consumerKey) { - try { - DynamicClientRegistrationUtil.unregisterApplication(userId, applicationName, consumerKey); - return Response.status(Response.Status.ACCEPTED).build(); - } catch (APIManagementException e) { - String msg = "Error occurred while un-registering client '" + applicationName + "'"; - log.error(msg, e); - return Response.serverError().entity(new FaultResponse(ErrorCode.INVALID_CLIENT_METADATA, msg)).build(); - } - } - -} diff --git a/components/oauth-extensions/dynamic-client-manager/src/main/resources/device-info-response.xml b/components/oauth-extensions/dynamic-client-manager/src/main/resources/device-info-response.xml deleted file mode 100644 index 7468d847ba..0000000000 --- a/components/oauth-extensions/dynamic-client-manager/src/main/resources/device-info-response.xml +++ /dev/null @@ -1,102 +0,0 @@ - - - - 1.2 - DM/1.2 - 1 - 1 - - TARGET_URI - - - SOURCE_URI - - - - - 1 - 1 - 0 - SyncHdr - TARGET_URI - 212 - - - 2 - 1 - 2 - Alert - 200 - - - 3 - 1 - 3 - Replace - ./devinf12 - 200 - - - 75 - - - ./DevDetail/SwV - - - - - ./Vendor/MSFT/DeviceInstanceService/Identity/Identity1/IMSI - - - - - ./Vendor/MSFT/DeviceInstanceService/Identity/Identity1/IMEI - - - - - ./DevInfo/DevId - - - - - ./DevInfo/Man - - - - - ./DevInfo/Mod - - - - - ./DevInfo/Lang - - - - - 5 - - - ./Vendor/MSFT/RemoteRing/Ring - - - - - \ No newline at end of file diff --git a/components/oauth-extensions/dynamic-client-manager/src/main/resources/properties.xml b/components/oauth-extensions/dynamic-client-manager/src/main/resources/properties.xml deleted file mode 100644 index 63b0686e0e..0000000000 --- a/components/oauth-extensions/dynamic-client-manager/src/main/resources/properties.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - Federated - wso2carbon - cacert - CN=mdmcn - 3 - 300 - \ No newline at end of file diff --git a/components/oauth-extensions/dynamic-client-manager/src/main/resources/syncml-session-ending-response.xml b/components/oauth-extensions/dynamic-client-manager/src/main/resources/syncml-session-ending-response.xml deleted file mode 100644 index ae3f93bb87..0000000000 --- a/components/oauth-extensions/dynamic-client-manager/src/main/resources/syncml-session-ending-response.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - 1.2 - DM/1.2 - 1 - 2 - - TARGET_URI - - - SOURCE_URI - - - - - 1 - 1 - 0 - SyncHdr - TARGET_URI - 212 - - - \ No newline at end of file diff --git a/components/oauth-extensions/dynamic-client-manager/src/main/resources/syncml-test-message.xml b/components/oauth-extensions/dynamic-client-manager/src/main/resources/syncml-test-message.xml deleted file mode 100644 index 1e015d436d..0000000000 --- a/components/oauth-extensions/dynamic-client-manager/src/main/resources/syncml-test-message.xml +++ /dev/null @@ -1 +0,0 @@ -1.2DM/1.211https://EnterpriseEnrollment.wso2.com/Synchml/initialqueryurn:uuid:FAEFB2D5-1771-5446-A635-797AFC474895dummyb64syncml:auth-md5Zp3sdCvijPGIQ6JxuIJHlQ==212013175./DevDetail/SwV8.10.12397.8953./DevInfo/DevIdurn:uuid:FAEFB2D5-1771-5446-A635-797AFC474895./DevInfo/ManNOKIA./DevInfo/ModLumia 630./DevInfo/DmV1.3./DevInfo/Langen-GB \ No newline at end of file diff --git a/components/oauth-extensions/dynamic-client-manager/src/main/resources/wap-provisioning.xml b/components/oauth-extensions/dynamic-client-manager/src/main/resources/wap-provisioning.xml deleted file mode 100644 index 896b451255..0000000000 --- a/components/oauth-extensions/dynamic-client-manager/src/main/resources/wap-provisioning.xml +++ /dev/null @@ -1,87 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/components/oauth-extensions/dynamic-client-manager/src/main/resources/wso2mdm.jks b/components/oauth-extensions/dynamic-client-manager/src/main/resources/wso2mdm.jks deleted file mode 100644 index 66b68ea395562b9716c8c579b944ae19b5dbf296..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 9485 zcmeI0Wl&w)vZxnp;qDOJHNaZ921|l#aM!SKSU_-hhXjYaV=w!TJodvNX)5@y$C(Eal-oE*D&eo^0t{pOY-V zbcGZ0d&?$YDTsCykH?gl-%FM@)ly@HsqGpFz zm0n!yI!|MVb@+Dm^)ivatUxvlxTtmKU306nH_nWr6f%=|t#!j~-`e3DyLYMyK{5c+ z$&`ezw-pd8B+HVdy12cO3Y1bT(6#JA`x2Q2b=j=4BBuJ_DT^Ix4)Q9MQgSW{AhLEJ zkn<3{IlT2;Pj9-&E5dUK?gT1Y&AWG{*y>(GqnEa)_%#q#y<mzJ({)&`>$E>+_R!sz`~$JD>Us=5=Q3c_ zdgq*t;ZtGR&Ro#3_;DN=vgNfa?mSG`99KL|cjzM|eI zOXK8ofKHLO#+Dl?GE~UfmZYe;P~B&Um%>z{LaudHWblH@GlhH@^dIMb7sOHx5JMJRyI z^`cA@u3$3-Ik+9A_9qHgKsHt)7dpP!wAr{jB3bX_!SN1vp!8U~_Amk|VgccnM+;GR zQGS4FQa_ob?Ixwwe!@2M%q!!EZpZ7kT^eElj42J*^6_3Y1jXx|p6+vTcZe&q?7q$T zEFSU4sn5=O_aS5AxU+&X6F;{g#eOGSl4n;4*dJsYN^JQt- z8-T_V!n!pP3ngmQQktdNz{enG?0Csb9$e(1>%yG`^C;B_J`0Z@LY6nY z*6RBai6Ea5<4XrRg2(2KhRNczP$Qt~A=knJW8=di{6Pp?>6~WPkC2%RZwig%oi^^1 zP#dxwixJHJPK4;axC)LN0er?WvC`I4hnDNcMxctk^XDKTR!FaJR5yABi4@Zk26Kcb zLR8ueaSuNJH{|}Z8S%Y4TT=%fnH0m9j1^oz#FMy&DW%}L$H$|YCFUzEw4nAJqa@KU zR`ba15JuAdtj#u^1q^9DO_cl|s_{k?;1rsp_A0vSzF1?rp`>z_v;p?syf_N2sU=C> zp`sK+Y8>t6#%Sc)yBV@^<4jqt6vjQ1yXuXw zC@V+kfal0E6%h1UnPkZK<0+h~CR~xNQa@`se|`N}T5$Dmi_dfhncdp+-O&18NjIY= z0TZKYv%Ae)Z|8;Mpc`{5lTEaU?BN5s{ zhlDnh;%eq&nSXm~7riN==IU9&cLxtPYX{JDJNMD=_y%E(u>Pnqcr!_=2#w@K*-H_D{` zov&yxduCypq8qf;KF6Ra-xX4i8)DBRf(gpzS$ElxF7lr(Uf*5T2lt4huzLB%*@`dw zu6T8E#tgh%Nf0|9jgdjk?aQim+N&Y5;_WmN!y`Ito)Yy}MQ91>-sZDZ%_7Q3I^(q2 zG2{h+0}XLzy6XI{G$?|KhY0F-na_m#P~^yoX#Nsk!;s}tHO_oR;?i9FLP&2-c}JOf z;AQwb9VfwpNVn2k_QzS@ms1B+!Y^4?M7_}WXlMZz2~{-w_0Y|;@(TRx+je?oLcW-0 zR-BI(mr1dmNnek%eZBKV-3Dzy40f)aN*6CYh-#BvPdEFSaqn27)8drQzhU>C|GH2b z$0q-^a~`TuqKP>Y!`9xzrW7P4(lULyhyPMVBxIo1#EyFmVM4w}oxKiYmGetdPHhol zBRxw#!-7RGLxp${#K)`c# zaSf8KC(c)4L;9VtprVMrV@%zcx39U01YPZ43kVz`^9>cwc~ELz$V~7O@*fNsV7VKL z%J{;>;>fpw9V>)mbw2K!0{IDb!)W&$8C%9bxfeS!g!(z|xs=U%a$_^<^QPSsdDHQG zqN2*Ptg3dnJcty|CoXs@Lw*GZd}PZF%p)rZod#jWbIEKa;n<E9Ko&kA=cC78uO z-9|%)S9`wNKaT^U169Q#q~I5S^$i_nEN1I&53~5wwE!T^Uw_+kT?+~TVgbMbKvZA= z5Du_#J}vT!g4@CNQv@2Ds4B*yJ=S5O@Yn&l?J7c7iPYisSm#OWHY%?{3}b_EWe()5 zGLui?bkPo%2&LVdIVzN1xJ@vqj`fqI1V{3A?rQU}dO63CqJA>=Bi<@=1SxteZkgn5 z?KY(nYj|(+z2ZKVqdpJM{<`y2%d{sh%OrEe)LIILs-|u5`e$axNLmDzhBFMPA+qy3 zPXmceb4d}tkyCzV+#2nvblefFO0vzXH{@_gEvLSX^TgB-{XIpRiN6i_U&d}`<#_PE zl8P2YLj5#%*v)fwd8%JcQDBztnYkTm@^xu2;DAw<`e!6_D-3>~JB>T?g?uvnf{OzR zEQkoPpkEzdjz{)=jX6<#*y!XV_5G-I#0P-r1OL*by>wu$o-shtM{7xlg^wqTd z)=96N9a>d}UQm?$d*|unpRW0|JRJZalRT-zJgGo0uANZE&`Q!~vjdJ^Q+AJ0x>~+* zx~pT&T``o2!|nwjn47!Kr|JW}cvd0TOoD9}H+nzL8ej2rCUI%-D3fF_;v$8SBS{(H zeUI!E+A^_zHKd_6W8NXY&-zHdPdLYi&t3+UdX3Fai%swQmZcP3`4)$VbB&4?2!aE^ z<&lF)!RXI%PmTwV00zOqJ^h&_lTL&C3@^<$#v8)= z7P%6aBjD+$CLasU*Z@o$Xei2fF!Qr)Y~zQD65s2Z5c7&lJ{XdF)#M1vng@xlYmthEN5}+qZB9GVfNZy+2}LnUNmJ5ilimK~ zzx|EgF`BB#m1aVK`l%--)I@}a3nCmYem;7PsKY%Qn!{y~%&oBA(kwH| zfF2_AAw65%euXZ5Z>dPc{PcuFYZhcxgt2p*_m5+Me_{Ia8PliFm|pmAOrrqmO;z24 zXc?FPEo}Y+aSi6@;e!bL3)lY;|8pGupWxk=etNF_?pvao_D>YG!^C(14FW+5Wx@`R zXC=E`1{UW9^J^!$Q#4|UaXEZ&92> z^_FcRagY1}HdY2kXwzYSzV2*)qgPZMZVD(HhOVUagWvZA4(6*ISWGr{rW3fOca zg!n|ou~J|$mtQU@+OlTcIymg#+OhO41h?LL(bzGwgUA{ny4EXPev5)6<=|63x!MQGbm*y0t(SvWhxFiy>&UBW3c= zlA%AV4>_>Pu;D9{-M?X(Y8iak674Nzz~sF*nGpv?jB%&#RJ(J({6%e0d@_MuODQ1p z=J>l|k320WTJK}pyeviEHw#}vL?Kn)2|3!G?d>(@&;*{w$qqqzO6wpx1x0AI!Y58j zOpg;TOQYT4aM00p@hxjGszTsSUOK@QSsM4vPf8qz>6Dy%lK^%i9&l&ThhiRyc%ET))2FJ~ZzZJ*RE07KsLWv`@Id z2Q(7pZ-m*X36Rl-y>~PQxjk}5{~O*$U;{AuAMnP6Cxpj${7!M|ZS-!j`egIb;drOw z8Y9yMO!>z$Ej%%p(C`1f0qalrKZF1O=09A>za{dY{3oGEbZ|tSXGqkFev`sj#5t)Q)OKBYwuPiV#BBWfIrE^m zx{`CH*41681+S{Zhu9n5j$c#~F585eV^y)U>vmhUM%8*%m`bB(k_$V7F5X%t5GYJ5 zJiREtNv|6CuAA8R=@pu7_^PJCg>F*0{yZsRFuk*`8laZFOf@$C%Ucj2ruep;7MvH%_p_g zDvdufy0*wObzIo$2nX!AVPo8px&csT*vwNR`!w`8t&k{X`MooD4op5WdVNX(zS+k? z7fI7x(zSV1mlMe|izxwO2~2UtWLG9Ug;RI_7?G~bsb-=p@8ULlGp^@ncXUw)8ls9V z$KJZ-^|i-Y7ONWE`?3%Mn}`8zGFK^kuYUuYc7j#4d=&J^9irD9ZEtpg4ph-mxu)-> zSQQyk7bDRU4f@pQ=G*p{)CL)x)VJ?T$Oe!HCsznCwhoB6x17^F8|+Y>lnY!S56SGM zHEbUGsP-*I6*~PV4(t~g#^iy!Vuo7~;ZDNmQvG?7YWkN+Dh}NLZ<6X|=WxnxkLa^b zAJGw!@`~UQoGm>tSoxaJprO3Mxk{~uVCP#h_YG1(Z?Vg`vBnm6Pk2LJ9dql!?>D?! z*UNQp_@MSG6aEJq4=c>JFxU45SRE*kj1?D#a`98{<<>C|<~37HSH$l$&PBB@TXTT~ zPQNKEKwhX4K8j4<(YXyO8KVUGx(G#`r{}DEb4z<4bGxIgkmlu1+$(z3o$2$4-V<@8 zdI(R{oRm#Kq!Q;ECxq_@&0W403>IyPSMI-ZvIn!&oE_wAUTny@=ft9Dn6r+pOY}1& zcH8a09{^Qpd$Yn&1*y_?smaypFR1W1W0(?^N4NCanL}5>B`0Bdgd-unRKE^XaLxxl zC#C1lA~b&3AV5uc()}G6qkHtO(y|{%h<}Awf7*}*wA}t8H-G;f?U0qi;5731S8>Jp zgXGCC(EM?qbo@Az_htlcPyU~`i;0Itj%4e>q%=SQSB^oW)0lPQ`XGLka>b%Wr7K-) z;Rh7`cl2D{Ltg?Sgu}6LduF=t0x`}l=knybfCFc;p5NdWeXBn2Tvq9qk=^K_@L zptoExAw=#*(A9u@@+K~7>?q5#d7wA+_Y|burNl-Z+0&p~*A}1QhT%GIxmDA-bh16~ z%-n2k0Gz|seXapaL$X@P>L zHDM$eTOF6T$BMsc+O!tfVx}g;M&$~V<&kD23~GmKT;WvTf1A76L#N|O2cJYqap^|T z|9ysC5HrJI;Z$Ck0%;{xQ$pq;t=3+x81pwhhFt+&YN&18=^@*z+WO0qLDkA;H9WIr zi-UN=T0TV-Y85_T`lk5C=AgXgw1s57wtdZ*kyY76a7A!-idafqn9gn^>udgUG;If; z(0AVNzc$A#6*w-oa&8!^+Bh7kZV=%GQhobG^~41A3#^6467O!vxg}ha?Hw5!VD5+p zr2jf3@!HjWlS9_DgcOTlr3cKUf=Q3~;K`fn7MD@K-Bw z*oRQk7j&W@6nnS}LOQqS#8JwuInmBjX>0O6{!rtx_a1nODsp7S5mEs~No_zpM9&vAFYHro~Alum{@rEC4xPE9l&c_@9bxilSla0!PsVKi67l$_W zqq09di8(;BdGY4o$l~mD;;h{$a)L*K&aep@=ncxm6s?J-4`pt@)6>rYydq*`EX zCtc7~p**^NpWUsqIX!ymKS>*uo0x1cN$Z@esf;$|+q>pqRV>Wx_7>-<<0}g=Up-eb z5lFT=+(8BI7_#ve_kM8SEfGDcn%=MlG3e>#G%YT^ax*E&xk|YhW~k00!iwIy%r2Mi z&J7-}*_+ZT!`cjRtUBLw-(>6+vjnAo*duVCrV4FI(>sk6onp#v?K@IpR={`+I$l zEyvuv8skT+*j+3_5S3m@7GHJYV2eT67dwgs)rYHK`>{Gi#*9VXn}i>ZWTJ0@R9QJa z7H+ohmTM5X<@EVgzj8w3e(bu}fALUO8V|!nHKR=t5UJN3SEu4n715gAB{?*^R&|TZ z{BE5{A1~VN?<@nd9u#m_-%R&8&wZd<-+MDP+82ZLIStxydkijN{K}-xm%z3<)*EqB zG+HO6E7U-T*sEK`@<7`AV~NYd5Ims4$}iJ1T;12o7#%1=(IJ;O7vqTTiQwUI{GC%= zhZsZr;Of@);gz4O*KXWN5UMHbD5qCvLtFLM84q;<>IvJ6UuhoOrJ4t^yky~bX1*?B zZ6~*E8dGpFOLY8IatkMQSW%^!{k~u75P(K!p3%J$%y?H#~RtQ})zBkY$zMlQnJYAA zhg%-7iWGfgen^cP6Q-X(+%GdlVAxPA2T07+F>b`qlIV$x7J|J?1}psN>u8#eZ%ICc zz71vCwi!@!W%|ZKE>}E0zVSLfj(E6=@%8;luv3&$!cnR(;ViNuWduxHn_?!?4nBA2 zy7~!1u?kT#{s{Q|qq6K5|Glfdq7gf2AM|F9C(lM$F_7X1`*pm4U#8+Qtk7CcJr5!1 zU}^M&(B~t#R$^mI>UHZbQ_gV{{JrR+^kUl9ms(*Gkd2PMcZIqBq2{`JapGn11}O^E zj3To|10Rxzk&%#2=#hUgHJRQjD2&?%z%#Mk9eeYcx ziPE4`w`j6ZOU}2(USHp`;JB2jC+6m(F_k{(@FIDopnxf{Fqn$N%kQ^{ z7S(V5lwk#kn^jV^xAd&)Uk>KAX%rXRN1ccbaU(IQ18~9uPLI+IHbVRG<|K4^HI7Y{ zgfD)LXRq*?HMg%%=O5B_R`;yccl=qN{oSIg!~buOe*bRK|8CL$Zqfg4(f( W`0v%-2|WuF22km0Do6xx&3^&4V5S-X diff --git a/components/oauth-extensions/org.wso2.carbon.device.mgt.oauth.extension/src/test/resources/log4j.properties b/components/oauth-extensions/org.wso2.carbon.device.mgt.oauth.extension/src/test/resources/log4j.properties deleted file mode 100644 index 7da6d6c9e1..0000000000 --- a/components/oauth-extensions/org.wso2.carbon.device.mgt.oauth.extension/src/test/resources/log4j.properties +++ /dev/null @@ -1,32 +0,0 @@ -# -# Copyright 2009 WSO2, Inc. (http://wso2.com) -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# -# This is the log4j configuration file used by WSO2 Carbon -# -# IMPORTANT : Please do not remove or change the names of any -# of the Appenders defined here. The layout pattern & log file -# can be changed using the WSO2 Carbon Management Console, and those -# settings will override the settings in this file. -# - -log4j.rootLogger=DEBUG, STD_OUT - -# Redirect log messages to console -log4j.appender.STD_OUT=org.apache.log4j.ConsoleAppender -log4j.appender.STD_OUT.Target=System.out -log4j.appender.STD_OUT.layout=org.apache.log4j.PatternLayout -log4j.appender.STD_OUT.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n diff --git a/components/oauth-extensions/org.wso2.carbon.device.mgt.oauth.extension/src/test/resources/testng.xml b/components/oauth-extensions/org.wso2.carbon.device.mgt.oauth.extension/src/test/resources/testng.xml deleted file mode 100644 index 4da53d1247..0000000000 --- a/components/oauth-extensions/org.wso2.carbon.device.mgt.oauth.extension/src/test/resources/testng.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/authenticator/JWTAuthenticator.java b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/authenticator/JWTAuthenticator.java index 974480fd5a..e359375eb3 100644 --- a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/authenticator/JWTAuthenticator.java +++ b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/authenticator/JWTAuthenticator.java @@ -28,6 +28,8 @@ import org.apache.catalina.connector.Request; import org.apache.catalina.connector.Response; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.tomcat.util.buf.ByteChunk; +import org.apache.tomcat.util.buf.MessageBytes; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.core.util.KeyStoreManager; import org.wso2.carbon.user.api.TenantManager; @@ -35,11 +37,13 @@ import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.user.api.UserStoreManager; import org.wso2.carbon.utils.multitenancy.MultitenantConstants; import org.wso2.carbon.utils.multitenancy.MultitenantUtils; +import org.wso2.carbon.webapp.authenticator.framework.Constants; import org.wso2.carbon.webapp.authenticator.framework.DataHolder; import java.security.interfaces.RSAPublicKey; import java.text.ParseException; import java.util.StringTokenizer; +import java.util.regex.Matcher; /** * This authenticator authenticates HTTP requests using JWT header. @@ -52,7 +56,11 @@ public class JWTAuthenticator implements WebappAuthenticator { @Override public boolean canHandle(Request request) { - return false; + String authorizationHeader = request.getHeader(HTTPConstants.HEADER_AUTHORIZATION); + if(decodeAuthorizationHeader(authorizationHeader) != null){ + return true; + } + return false; } @Override diff --git a/features/oauth-extensions/org.wso2.carbon.oauth.extensions.server.feature/pom.xml b/features/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration.server.feature/pom.xml similarity index 69% rename from features/oauth-extensions/org.wso2.carbon.oauth.extensions.server.feature/pom.xml rename to features/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration.server.feature/pom.xml index eae36b42e9..3f55389989 100644 --- a/features/oauth-extensions/org.wso2.carbon.oauth.extensions.server.feature/pom.xml +++ b/features/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration.server.feature/pom.xml @@ -23,19 +23,37 @@ org.wso2.carbon.devicemgt - oauth-extentions-feature + dynamic-client-registration-feature 0.9.2-SNAPSHOT ../pom.xml 4.0.0 - org.wso2.carbon.oauth.extensions.server.feature + org.wso2.carbon.dynamic.client.registration.server.feature pom 0.9.2-SNAPSHOT - WSO2 Carbon - Oauth Extensions Server Feature + WSO2 Carbon - Dynamic Client Registration Server Feature http://wso2.org - This feature contains oauth functionality - + This feature contains dynamic client registration features + + + + org.wso2.carbon.devicemgt + org.wso2.carbon.dynamic.client.registration + + + org.wso2.carbon.devicemgt + org.wso2.carbon.dynamic.client.web.app.registration + + + com.googlecode.json-simple.wso2 + json-simple + + + org.json.wso2 + json + + @@ -80,12 +98,12 @@ org.wso2.mdm - dynamic-client-manager - ${project.version} + dynamic-client-web + ${carbon.device.mgt.version} war true ${basedir}/src/main/resources/ - dynamic-client-manager.war + dynamic-client-web.war @@ -105,7 +123,7 @@ p2-feature-gen - org.wso2.carbon.oauth.extensions.server + org.wso2.carbon.dynamic.client.registration.server ../../../features/etc/feature.properties @@ -113,6 +131,20 @@ org.eclipse.equinox.p2.type.group:false + + + org.wso2.carbon.devicemgt:org.wso2.carbon.dynamic.client.registration:${carbon.device.mgt.version} + + + org.wso2.carbon.devicemgt:org.wso2.carbon.dynamic.client.web.app.registration:${carbon.device.mgt.version} + + + com.googlecode.json-simple.wso2:json-simple:${json-simple.version} + + + org.json.wso2:json:${json.wso2.version} + + org.wso2.carbon.core.server:${carbon.kernel.version} diff --git a/features/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration.server.feature/src/main/resources/p2.inf b/features/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration.server.feature/src/main/resources/p2.inf new file mode 100644 index 0000000000..0f2ca3fd11 --- /dev/null +++ b/features/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration.server.feature/src/main/resources/p2.inf @@ -0,0 +1,2 @@ +instructions.configure = \ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.dynamic.client.registration.server_${feature.version}/dynamic-client-web.war,target:${installFolder}/../../deployment/server/webapps/dynamic-client-web.war,overwrite:true);\ \ No newline at end of file diff --git a/features/oauth-extensions/pom.xml b/features/dynamic-client-registration/pom.xml similarity index 86% rename from features/oauth-extensions/pom.xml rename to features/dynamic-client-registration/pom.xml index 87ed9a7ef0..2df634c5b2 100644 --- a/features/oauth-extensions/pom.xml +++ b/features/dynamic-client-registration/pom.xml @@ -29,14 +29,14 @@ 4.0.0 org.wso2.carbon.devicemgt - oauth-extentions-feature + dynamic-client-registration-feature 0.9.2-SNAPSHOT pom - WSO2 Carbon - Policy Management Feature + WSO2 Carbon - Dynamic Client Registration Feature http://wso2.org - org.wso2.carbon.oauth.extensions.server.feature + org.wso2.carbon.dynamic.client.registration.server.feature diff --git a/features/oauth-extensions/org.wso2.carbon.oauth.extensions.server.feature/src/main/resources/p2.inf b/features/oauth-extensions/org.wso2.carbon.oauth.extensions.server.feature/src/main/resources/p2.inf deleted file mode 100644 index 3143c5e9df..0000000000 --- a/features/oauth-extensions/org.wso2.carbon.oauth.extensions.server.feature/src/main/resources/p2.inf +++ /dev/null @@ -1,2 +0,0 @@ -instructions.configure = \ -org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.oauth.extensions.server_${feature.version}/dynamic-client-manager.war,target:${installFolder}/../../deployment/server/webapps/dynamic-client-manager.war,overwrite:true);\ \ No newline at end of file diff --git a/pom.xml b/pom.xml index a3f508df4f..ce2f4a193f 100644 --- a/pom.xml +++ b/pom.xml @@ -41,13 +41,13 @@ components/policy-mgt components/certificate-mgt components/webapp-authenticator-framework - components/oauth-extensions + components/dynamic-client-registration features/device-mgt features/apimgt-extensions features/policy-mgt features/webapp-authenticator-framework - features/oauth-extensions features/certificate-mgt + features/dynamic-client-registration @@ -170,6 +170,21 @@ org.wso2.carbon.apimgt.webapp.publisher ${carbon.device.mgt.version} + + org.wso2.carbon.devicemgt + org.wso2.carbon.dynamic.client.registration + ${carbon.device.mgt.version} + + + org.wso2.carbon.devicemgt + org.wso2.carbon.dynamic.client.web.app.registration + ${carbon.device.mgt.version} + + + org.wso2.mdm + dynamic-client-web + ${carbon.device.mgt.version} + @@ -981,6 +996,11 @@ commons-lang ${version.commons.lang} + + org.json.wso2 + json + ${json.wso2.version} + @@ -1259,6 +1279,8 @@ 2.26.1.wso2v3 + + 2.0.0.wso2v1