diff --git a/components/identity-extensions/dynamic-client-registration/dynamic-client-web-proxy/pom.xml b/components/identity-extensions/dynamic-client-registration/dynamic-client-web-proxy/pom.xml
new file mode 100644
index 0000000000..2b03b808fb
--- /dev/null
+++ b/components/identity-extensions/dynamic-client-registration/dynamic-client-web-proxy/pom.xml
@@ -0,0 +1,114 @@
+
+
+
+
+
+ dynamic-client-registration
+ org.wso2.carbon.devicemgt
+ 0.9.2-SNAPSHOT
+ ../pom.xml
+
+
+ 4.0.0
+ org.wso2.mdm
+ dynamic-client-web-proxy
+ 0.9.2-SNAPSHOT
+ WSO2 Carbon - Proxy endpoint of Dynamic Client Registration Web Service
+ WSO2 Carbon - Dynamic Client Registration Web Proxy
+ war
+
+
+
+
+ maven-war-plugin
+ 2.2
+
+ ${project.artifactId}
+
+
+
+
+
+
+ org.wso2.carbon.devicemgt
+ org.wso2.carbon.dynamic.client.registration
+ provided
+
+
+ org.wso2.carbon
+ org.wso2.carbon.utils
+ provided
+
+
+ org.apache.ws.commons.axiom
+ axiom-api
+ provided
+
+
+ org.apache.ws.commons.axiom
+ axiom-impl
+ provided
+
+
+ org.apache.ws.commons.axiom.wso2
+ axiom
+ provided
+
+
+ org.apache.cxf
+ cxf-rt-frontend-jaxrs
+ provided
+
+
+ org.apache.cxf
+ cxf-rt-transports-http
+ provided
+
+
+ org.apache.cxf
+ cxf-rt-bindings-http
+ provided
+
+
+ org.codehaus.jackson
+ jackson-jaxrs
+
+
+ commons-logging
+ commons-logging
+ provided
+
+
+ org.apache.httpcomponents
+ httpclient
+
+
+ com.google.code.gson
+ gson
+ provided
+
+
+ org.wso2.carbon
+ org.wso2.carbon.core
+ provided
+
+
+
\ No newline at end of file
diff --git a/components/identity-extensions/dynamic-client-registration/dynamic-client-web-proxy/src/main/java/org/wso2/carbon/dynamic/client/web/proxy/OAuthEndpointProxy.java b/components/identity-extensions/dynamic-client-registration/dynamic-client-web-proxy/src/main/java/org/wso2/carbon/dynamic/client/web/proxy/OAuthEndpointProxy.java
new file mode 100644
index 0000000000..c738d8aec1
--- /dev/null
+++ b/components/identity-extensions/dynamic-client-registration/dynamic-client-web-proxy/src/main/java/org/wso2/carbon/dynamic/client/web/proxy/OAuthEndpointProxy.java
@@ -0,0 +1,80 @@
+/*
+ * 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.proxy;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpHost;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.utils.URIBuilder;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.util.EntityUtils;
+import org.wso2.carbon.dynamic.client.web.proxy.util.Constants;
+import org.wso2.carbon.dynamic.client.web.proxy.util.DCRProxyUtils;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.POST;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Response;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+public class OAuthEndpointProxy {
+
+ private static final Log log = LogFactory.getLog(OAuthEndpointProxy.class);
+
+ @POST
+ @Consumes("application/x-www-form-urlencoded")
+ @Produces("application/json")
+ public Response issueAccessToken(MultivaluedMap paramMap) {
+ DefaultHttpClient httpClient = DCRProxyUtils.getHttpsClient();
+ String host = DCRProxyUtils.getKeyManagerHost();
+ Response response;
+ try {
+ URI uri = new URIBuilder().setScheme(Constants.RemoteServiceProperties.
+ DYNAMIC_CLIENT_SERVICE_PROTOCOL).setHost(host).setPath(
+ Constants.RemoteServiceProperties.OAUTH2_TOKEN_ENDPOINT).build();
+ HttpHost httpHost = new HttpHost(uri.toString());
+ CloseableHttpResponse serverResponse = httpClient.execute(httpHost, null);
+ HttpEntity responseData = serverResponse.getEntity();
+ int status = serverResponse.getStatusLine().getStatusCode();
+ String resp = EntityUtils.toString(responseData, Constants.CharSets.CHARSET_UTF_8);
+ response = Response.status(DCRProxyUtils.getResponseStatus(status)).entity(resp).build();
+ } catch (URISyntaxException e) {
+ String msg = "Service invoke error occurred while registering client";
+ log.error(msg, e);
+ response = Response.status(javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
+ } catch (UnsupportedEncodingException e) {
+ String msg = "Service invoke error occurred while registering client";
+ log.error(msg, e);
+ response = Response.status(javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
+ } catch (IOException e) {
+ String msg = "Service invoke error occurred while registering client";
+ log.error(msg, e);
+ response = Response.status(javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
+ } finally {
+ httpClient.close();
+ }
+ return response;
+ }
+}
diff --git a/components/identity-extensions/dynamic-client-registration/dynamic-client-web-proxy/src/main/java/org/wso2/carbon/dynamic/client/web/proxy/RegistrationProxy.java b/components/identity-extensions/dynamic-client-registration/dynamic-client-web-proxy/src/main/java/org/wso2/carbon/dynamic/client/web/proxy/RegistrationProxy.java
new file mode 100644
index 0000000000..885530df77
--- /dev/null
+++ b/components/identity-extensions/dynamic-client-registration/dynamic-client-web-proxy/src/main/java/org/wso2/carbon/dynamic/client/web/proxy/RegistrationProxy.java
@@ -0,0 +1,129 @@
+/*
+ * 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.proxy;
+
+import com.google.gson.Gson;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.http.HttpEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpDelete;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.utils.URIBuilder;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.util.EntityUtils;
+import org.wso2.carbon.dynamic.client.registration.profile.RegistrationProfile;
+import org.wso2.carbon.dynamic.client.web.proxy.util.Constants;
+import org.wso2.carbon.dynamic.client.web.proxy.util.DCRProxyUtils;
+
+import javax.ws.rs.*;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+/**
+ * This class implements the proxy-endpoint for Dynamic-client-registration web service endpoints.
+ */
+public class RegistrationProxy {
+
+ private static final Log log = LogFactory.getLog(RegistrationProxy.class);
+
+ @POST
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response register(RegistrationProfile registrationProfile) {
+ DefaultHttpClient httpClient = DCRProxyUtils.getHttpsClient();
+ String host = DCRProxyUtils.getKeyManagerHost();
+ Response response;
+ try {
+ URI uri = new URIBuilder().setScheme(Constants.RemoteServiceProperties.
+ DYNAMIC_CLIENT_SERVICE_PROTOCOL).setHost(host).setPath(
+ Constants.RemoteServiceProperties.DYNAMIC_CLIENT_SERVICE_ENDPOINT).build();
+ Gson gson = new Gson();
+ StringEntity entity = new StringEntity(gson.toJson(registrationProfile), MediaType.APPLICATION_JSON,
+ Constants.CharSets.CHARSET_UTF_8);
+ HttpPost httpPost = new HttpPost(uri);
+ httpPost.setEntity(entity);
+ CloseableHttpResponse serverResponse = httpClient.execute(httpPost);
+ HttpEntity responseData = serverResponse.getEntity();
+ int status = serverResponse.getStatusLine().getStatusCode();
+ String resp = EntityUtils.toString(responseData, Constants.CharSets.CHARSET_UTF_8);
+ response = Response.status(DCRProxyUtils.getResponseStatus(status)).entity(resp).build();
+ } catch (URISyntaxException e) {
+ String msg = "Server error occurred while registering client '" + registrationProfile.getClientName() + "'";
+ log.error(msg, e);
+ response = Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
+ } catch (UnsupportedEncodingException e) {
+ String msg = "Request data encoding error occurred while registering client '" + registrationProfile.
+ getClientName() + "'";
+ log.error(msg, e);
+ response = Response.status(Response.Status.UNSUPPORTED_MEDIA_TYPE).entity(msg).build();
+ } catch (IOException e) {
+ String msg = "Service invoke error occurred while registering client.";
+ log.error(msg, e);
+ response = Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
+ } finally {
+ httpClient.close();
+ }
+ return response;
+ }
+
+ @DELETE
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response unregister(@QueryParam("applicationName") String applicationName,
+ @QueryParam("userId") String userId,
+ @QueryParam("consumerKey") String consumerKey) {
+ Response response;
+ DefaultHttpClient httpClient = DCRProxyUtils.getHttpsClient();
+ String host = DCRProxyUtils.getKeyManagerHost();
+ try {
+ URI uri = new URIBuilder().setScheme(Constants.RemoteServiceProperties.
+ DYNAMIC_CLIENT_SERVICE_PROTOCOL).setHost(host).setPath(
+ Constants.RemoteServiceProperties.DYNAMIC_CLIENT_SERVICE_ENDPOINT)
+ .setParameter("applicationName", applicationName)
+ .setParameter("userId", userId)
+ .setParameter("consumerKey", consumerKey).build();
+ HttpDelete httpDelete = new HttpDelete(uri);
+ CloseableHttpResponse serverResponse = httpClient.execute(httpDelete);
+ HttpEntity responseData = serverResponse.getEntity();
+ int status = serverResponse.getStatusLine().getStatusCode();
+ String resp = EntityUtils.toString(responseData, Constants.CharSets.CHARSET_UTF_8);
+ response = Response.status(DCRProxyUtils.getResponseStatus(status)).entity(resp).build();
+ } catch (URISyntaxException e) {
+ String msg = "Server error occurred while deleting the client '" + applicationName + "'";
+ log.error(msg, e);
+ response = Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
+ } catch (UnsupportedEncodingException e) {
+ String msg = "Request data encoding error occurred while deleting the client '" + applicationName + "'";
+ log.error(msg, e);
+ response = Response.status(Response.Status.UNSUPPORTED_MEDIA_TYPE).entity(msg).build();
+ } catch (IOException e) {
+ String msg = "Service invoke error occurred while deleting the client '" + applicationName + "'";
+ log.error(msg, e);
+ response = Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
+ } finally {
+ httpClient.close();
+ }
+ return response;
+ }
+}
\ No newline at end of file
diff --git a/components/identity-extensions/dynamic-client-registration/dynamic-client-web-proxy/src/main/java/org/wso2/carbon/dynamic/client/web/proxy/util/Constants.java b/components/identity-extensions/dynamic-client-registration/dynamic-client-web-proxy/src/main/java/org/wso2/carbon/dynamic/client/web/proxy/util/Constants.java
new file mode 100644
index 0000000000..a63a530edb
--- /dev/null
+++ b/components/identity-extensions/dynamic-client-registration/dynamic-client-web-proxy/src/main/java/org/wso2/carbon/dynamic/client/web/proxy/util/Constants.java
@@ -0,0 +1,52 @@
+/*
+ * 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.proxy.util;
+
+/**
+ * Holds the constants used by DCR proxy app.
+ */
+public class Constants {
+
+ public static final class CharSets {
+ private CharSets() {
+ throw new AssertionError();
+ }
+
+ public static final String CHARSET_UTF_8 = "UTF-8";
+ }
+
+ public static class ConfigurationProperties {
+ private ConfigurationProperties() {
+ throw new AssertionError();
+ }
+
+ public static final String AUTHENTICATOR_NAME = "OAuthAuthenticator";
+ public static final String AUTHENTICATOR_CONFIG_HOST_URL = "hostURL";
+ }
+
+ public static class RemoteServiceProperties {
+ private RemoteServiceProperties() {
+ throw new AssertionError();
+ }
+
+ public static final String DYNAMIC_CLIENT_SERVICE_ENDPOINT = "/dynamic-client-web/register";
+ public static final String OAUTH2_TOKEN_ENDPOINT = "/oauth2/token";
+ public static final String DYNAMIC_CLIENT_SERVICE_PROTOCOL = "https";
+ }
+}
diff --git a/components/identity-extensions/dynamic-client-registration/dynamic-client-web-proxy/src/main/java/org/wso2/carbon/dynamic/client/web/proxy/util/DCRProxyUtils.java b/components/identity-extensions/dynamic-client-registration/dynamic-client-web-proxy/src/main/java/org/wso2/carbon/dynamic/client/web/proxy/util/DCRProxyUtils.java
new file mode 100644
index 0000000000..d9d1e549b2
--- /dev/null
+++ b/components/identity-extensions/dynamic-client-registration/dynamic-client-web-proxy/src/main/java/org/wso2/carbon/dynamic/client/web/proxy/util/DCRProxyUtils.java
@@ -0,0 +1,122 @@
+/*
+ * 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.proxy.util;
+
+import org.apache.http.HttpHost;
+import org.apache.http.client.utils.URIBuilder;
+import org.apache.http.conn.scheme.Scheme;
+import org.apache.http.conn.scheme.SchemeRegistry;
+import org.apache.http.conn.ssl.SSLSocketFactory;
+import org.apache.http.conn.ssl.X509HostnameVerifier;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.impl.conn.SingleClientConnManager;
+import org.wso2.carbon.context.PrivilegedCarbonContext;
+import org.wso2.carbon.core.security.AuthenticatorsConfiguration;
+import org.wso2.carbon.utils.CarbonUtils;
+import org.wso2.carbon.utils.ConfigurationContextService;
+
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.HttpsURLConnection;
+import javax.ws.rs.core.Response;
+
+/**
+ * Holds the utility methods used by DCR proxy app.
+ */
+public class DCRProxyUtils {
+
+ public static ConfigurationContextService getConfigurationContextService() {
+ PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
+ return (ConfigurationContextService) ctx.getOSGiService(ConfigurationContextService.class, null);
+ }
+
+ public static DefaultHttpClient getHttpsClient() {
+ DefaultHttpClient httpClient = new DefaultHttpClient();
+ // Setup the HTTPS settings to accept any certificate.
+ HostnameVerifier hostnameVerifier = org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER;
+
+ SchemeRegistry registry = new SchemeRegistry();
+ SSLSocketFactory socketFactory = SSLSocketFactory.getSocketFactory();
+ socketFactory.setHostnameVerifier((X509HostnameVerifier) hostnameVerifier);
+ registry.register(new Scheme(Constants.RemoteServiceProperties.
+ DYNAMIC_CLIENT_SERVICE_PROTOCOL, socketFactory, DCRProxyUtils.getServerHTTPSPort()));
+ SingleClientConnManager mgr = new SingleClientConnManager(httpClient.getParams(), registry);
+ httpClient = new DefaultHttpClient(mgr, httpClient.getParams());
+
+ // Set verifier
+ HttpsURLConnection.setDefaultHostnameVerifier(hostnameVerifier);
+ return httpClient;
+ }
+
+ public static Response.Status getResponseStatus(int statusCode) {
+ switch (statusCode) {
+ case 200 :
+ return Response.Status.OK;
+ case 201 :
+ return Response.Status.CREATED;
+ case 400 :
+ return Response.Status.BAD_REQUEST;
+ case 415 :
+ return Response.Status.UNSUPPORTED_MEDIA_TYPE;
+ case 500 :
+ return Response.Status.INTERNAL_SERVER_ERROR;
+ }
+ return Response.Status.ACCEPTED;
+ }
+
+ public static String getKeyManagerHost()
+ throws IllegalArgumentException {
+ AuthenticatorsConfiguration authenticatorsConfiguration = AuthenticatorsConfiguration.getInstance();
+ AuthenticatorsConfiguration.AuthenticatorConfig authenticatorConfig = authenticatorsConfiguration.
+ getAuthenticatorConfig(
+ Constants.ConfigurationProperties.AUTHENTICATOR_NAME);
+ if (authenticatorConfig != null && authenticatorConfig.getParameters() != null) {
+ return getHostName(authenticatorConfig.getParameters().get(Constants.ConfigurationProperties.
+ AUTHENTICATOR_CONFIG_HOST_URL));
+
+ }else{
+ throw new IllegalArgumentException("Configuration parameters need to be defined in Authenticators.xml.");
+ }
+ }
+
+ private static String getHostName(String host) {
+ if (host != null && !host.isEmpty()) {
+ if (host.contains("https://")) {
+ return host.replace("https://","");
+ }
+ } else {
+ throw new IllegalArgumentException("Remote Host parameter must defined in Authenticators.xml.");
+ }
+ return null;
+ }
+
+
+ public static int getServerHTTPSPort() {
+ // HTTPS port
+ String mgtConsoleTransport = CarbonUtils.getManagementTransport();
+ ConfigurationContextService configContextService = DCRProxyUtils.getConfigurationContextService();
+ int port = CarbonUtils.getTransportPort(configContextService, mgtConsoleTransport);
+ int httpsProxyPort =
+ CarbonUtils.getTransportProxyPort(configContextService.getServerConfigContext(),
+ mgtConsoleTransport);
+ if (httpsProxyPort > 0) {
+ port = httpsProxyPort;
+ }
+ return port;
+ }
+}
diff --git a/components/identity-extensions/dynamic-client-registration/dynamic-client-web-proxy/src/main/webapp/META-INF/webapp-classloading.xml b/components/identity-extensions/dynamic-client-registration/dynamic-client-web-proxy/src/main/webapp/META-INF/webapp-classloading.xml
new file mode 100644
index 0000000000..38ac535842
--- /dev/null
+++ b/components/identity-extensions/dynamic-client-registration/dynamic-client-web-proxy/src/main/webapp/META-INF/webapp-classloading.xml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+ false
+
+
+ CXF,Carbon
+
diff --git a/components/identity-extensions/dynamic-client-registration/dynamic-client-web-proxy/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/identity-extensions/dynamic-client-registration/dynamic-client-web-proxy/src/main/webapp/WEB-INF/cxf-servlet.xml
new file mode 100644
index 0000000000..e057aebcd2
--- /dev/null
+++ b/components/identity-extensions/dynamic-client-registration/dynamic-client-web-proxy/src/main/webapp/WEB-INF/cxf-servlet.xml
@@ -0,0 +1,51 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/components/identity-extensions/dynamic-client-registration/dynamic-client-web-proxy/src/main/webapp/WEB-INF/web.xml b/components/identity-extensions/dynamic-client-registration/dynamic-client-web-proxy/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..091413931d
--- /dev/null
+++ b/components/identity-extensions/dynamic-client-registration/dynamic-client-web-proxy/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,37 @@
+
+
+
+ Dynamic-client-proxy-Webapp
+
+ Dynamic-client-registration-proxy Endpoint
+ JAX-WS/JAX-RS Servlet
+ CXFServlet
+
+ org.apache.cxf.transport.servlet.CXFServlet
+
+ 1
+
+
+ CXFServlet
+ /*
+
+
+ 60
+
+
\ No newline at end of file
diff --git a/components/identity-extensions/dynamic-client-registration/dynamic-client-web-proxy/src/main/webapp/servicelist.css b/components/identity-extensions/dynamic-client-registration/dynamic-client-web-proxy/src/main/webapp/servicelist.css
new file mode 100644
index 0000000000..e6eacadbb0
--- /dev/null
+++ b/components/identity-extensions/dynamic-client-registration/dynamic-client-web-proxy/src/main/webapp/servicelist.css
@@ -0,0 +1,125 @@
+@CHARSET "ISO-8859-1";
+
+/* http://meyerweb.com/eric/tools/css/reset/
+ v2.0 | 20110126
+ License: none (public domain)
+*/
+
+html, body, div, span, applet, object, iframe,
+h1, h2, h3, h4, h5, h6, p, blockquote, pre,
+a, abbr, acronym, address, big, cite, code,
+del, dfn, em, img, ins, kbd, q, s, samp,
+small, strike, strong, sub, sup, tt, var,
+b, u, i, center,
+dl, dt, dd, ol, ul, li,
+fieldset, form, label, legend,
+table, caption, tbody, tfoot, thead, tr, th, td,
+article, aside, canvas, details, embed,
+figure, figcaption, footer, header, hgroup,
+menu, nav, output, ruby, section, summary,
+time, mark, audio, video {
+ margin: 0;
+ padding: 0;
+ border: 0;
+ font-size: 100%;
+ font: inherit;
+ vertical-align: baseline;
+}
+
+/* HTML5 display-role reset for older browsers */
+article, aside, details, figcaption, figure,
+footer, header, hgroup, menu, nav, section {
+ display: block;
+}
+
+html {
+ background: #efefef;
+}
+
+body {
+ line-height: 1;
+ width: 960px;
+ margin: auto;
+ background: white;
+ padding: 10px;
+ box-shadow: 0px 0px 5px #CCC;
+ font-family: "Lucida Grande", "Lucida Sans", "Microsoft Sans Serif", "Lucida Sans Unicode", "Verdana", "Sans-serif", "trebuchet ms" !important;
+
+}
+
+ol, ul {
+ list-style: none;
+}
+
+blockquote, q {
+ quotes: none;
+}
+
+blockquote:before, blockquote:after,
+q:before, q:after {
+ content: '';
+ content: none;
+}
+
+table {
+ border-collapse: collapse;
+ border-spacing: 0;
+ width: 960px;
+ border: solid 1px #ccc;
+}
+
+table a {
+ font-size: 12px;
+ color: #1e90ff;
+ padding: 7px;
+ float: left;;
+}
+
+.heading {
+ font-size: 18px;
+ margin-top: 20px;
+ float: left;
+ color: #0067B1;
+ margin-bottom: 20px;
+ padding-top: 20px;
+}
+
+.field {
+ font-weight: normal;
+ width: 120px;
+ font-size: 12px;
+ float: left;
+ padding: 7px;
+ clear: left;
+}
+
+.value {
+ font-weight: bold;
+ font-size: 12px;
+ float: left;
+ padding: 7px;
+ clear: right;
+}
+
+.porttypename {
+ font-weight: bold;
+ font-size: 14px;
+}
+
+UL {
+ margin-top: 0;
+}
+
+LI {
+ font-weight: normal;
+ font-size: 12px;
+ margin-top: 10px;
+}
+
+TD {
+ border: 1px solid #ccc;
+ vertical-align: text-top;
+ padding: 5px;
+}
+
+
diff --git a/components/identity-extensions/dynamic-client-registration/dynamic-client-web-proxy/src/test/resources/log4j.properties b/components/identity-extensions/dynamic-client-registration/dynamic-client-web-proxy/src/test/resources/log4j.properties
new file mode 100644
index 0000000000..7da6d6c9e1
--- /dev/null
+++ b/components/identity-extensions/dynamic-client-registration/dynamic-client-web-proxy/src/test/resources/log4j.properties
@@ -0,0 +1,32 @@
+#
+# 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/identity-extensions/dynamic-client-registration/dynamic-client-web-proxy/src/test/resources/testng.xml b/components/identity-extensions/dynamic-client-registration/dynamic-client-web-proxy/src/test/resources/testng.xml
new file mode 100644
index 0000000000..c0c21a40c3
--- /dev/null
+++ b/components/identity-extensions/dynamic-client-registration/dynamic-client-web-proxy/src/test/resources/testng.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/components/identity-extensions/dynamic-client-registration/dynamic-client-web/pom.xml b/components/identity-extensions/dynamic-client-registration/dynamic-client-web/pom.xml
index 9df732403c..1df2b45ea1 100644
--- a/components/identity-extensions/dynamic-client-registration/dynamic-client-web/pom.xml
+++ b/components/identity-extensions/dynamic-client-registration/dynamic-client-web/pom.xml
@@ -87,11 +87,6 @@
cxf-rt-transports-http
provided
-
- org.apache.cxf
- cxf-rt-bindings-soap
- compile
-
org.apache.cxf
cxf-rt-bindings-http
diff --git a/components/identity-extensions/dynamic-client-registration/dynamic-client-web/src/main/java/org/wso2/carbon/dynamic/client/web/ConfigurationService.java b/components/identity-extensions/dynamic-client-registration/dynamic-client-web/src/main/java/org/wso2/carbon/dynamic/client/web/ConfigurationService.java
deleted file mode 100644
index 0d97308f54..0000000000
--- a/components/identity-extensions/dynamic-client-registration/dynamic-client-web/src/main/java/org/wso2/carbon/dynamic/client/web/ConfigurationService.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.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/identity-extensions/dynamic-client-registration/dynamic-client-web/src/main/java/org/wso2/carbon/dynamic/client/web/RegistrationService.java b/components/identity-extensions/dynamic-client-registration/dynamic-client-web/src/main/java/org/wso2/carbon/dynamic/client/web/RegistrationService.java
index 194d5e966d..ee5fa0ce74 100644
--- a/components/identity-extensions/dynamic-client-registration/dynamic-client-web/src/main/java/org/wso2/carbon/dynamic/client/web/RegistrationService.java
+++ b/components/identity-extensions/dynamic-client-registration/dynamic-client-web/src/main/java/org/wso2/carbon/dynamic/client/web/RegistrationService.java
@@ -27,8 +27,6 @@ import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-@Produces(MediaType.APPLICATION_JSON)
-@Consumes(MediaType.APPLICATION_JSON)
public interface RegistrationService {
enum ErrorCode {
@@ -52,6 +50,8 @@ public interface RegistrationService {
* @return Status 200 if success including consumerKey and consumerSecret.
*/
@POST
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
Response register(RegistrationProfile profile);
/**
@@ -63,7 +63,9 @@ public interface RegistrationService {
* @return Status 200 if success.
*/
@DELETE
- public Response unregister(@QueryParam("applicationName") String applicationName,
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ Response unregister(@QueryParam("applicationName") String applicationName,
@QueryParam("userId") String userId,
@QueryParam("consumerKey") String consumerKey);
diff --git a/components/identity-extensions/dynamic-client-registration/dynamic-client-web/src/main/java/org/wso2/carbon/dynamic/client/web/impl/RegistrationServiceImpl.java b/components/identity-extensions/dynamic-client-registration/dynamic-client-web/src/main/java/org/wso2/carbon/dynamic/client/web/impl/RegistrationServiceImpl.java
index 5d8e7bc5fb..59539b7279 100644
--- a/components/identity-extensions/dynamic-client-registration/dynamic-client-web/src/main/java/org/wso2/carbon/dynamic/client/web/impl/RegistrationServiceImpl.java
+++ b/components/identity-extensions/dynamic-client-registration/dynamic-client-web/src/main/java/org/wso2/carbon/dynamic/client/web/impl/RegistrationServiceImpl.java
@@ -37,8 +37,6 @@ 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);
@@ -89,7 +87,7 @@ public class RegistrationServiceImpl implements RegistrationService {
boolean status = dynamicClientRegistrationService.unregisterOAuthApplication(userId, applicationName,
consumerKey);
if (status) {
- return Response.status(Response.Status.ACCEPTED).build();
+ return Response.status(Response.Status.OK).build();
}
return Response.status(Response.Status.BAD_REQUEST).build();
}
diff --git a/components/identity-extensions/dynamic-client-registration/dynamic-client-web/src/main/webapp/WEB-INF/web.xml b/components/identity-extensions/dynamic-client-registration/dynamic-client-web/src/main/webapp/WEB-INF/web.xml
index a89397675a..57eb77536b 100644
--- a/components/identity-extensions/dynamic-client-registration/dynamic-client-web/src/main/webapp/WEB-INF/web.xml
+++ b/components/identity-extensions/dynamic-client-registration/dynamic-client-web/src/main/webapp/WEB-INF/web.xml
@@ -19,9 +19,9 @@
~ */
-->
- Admin-Webapp
+ dynamic-client-registration-Webapp
- JAX-WS/JAX-RS Device Registration Agent Endpoint
+ Dynamic-client-registration Agent Endpoint
JAX-WS/JAX-RS Servlet
CXFServlet
diff --git a/components/identity-extensions/dynamic-client-registration/dynamic-client-web/src/test/resources/testng.xml b/components/identity-extensions/dynamic-client-registration/dynamic-client-web/src/test/resources/testng.xml
index de65e3005d..c25631e70a 100644
--- a/components/identity-extensions/dynamic-client-registration/dynamic-client-web/src/test/resources/testng.xml
+++ b/components/identity-extensions/dynamic-client-registration/dynamic-client-web/src/test/resources/testng.xml
@@ -18,11 +18,6 @@
-
+
-
-
-
-
-
\ No newline at end of file
diff --git a/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/pom.xml b/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/pom.xml
index 9b44329b6b..4d01bd8697 100644
--- a/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/pom.xml
+++ b/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/pom.xml
@@ -66,6 +66,7 @@
org.wso2.carbon.identity.application.common,
org.wso2.carbon.identity.application.common.model,
org.wso2.carbon.identity.application.mgt,
+ org.wso2.carbon.identity.application.mgt.stub,
org.wso2.carbon.identity.base,
org.wso2.carbon.identity.oauth,
org.wso2.carbon.identity.oauth.dto,
diff --git a/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/OAuthApplicationInfo.java b/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/OAuthApplicationInfo.java
index 547844869a..5fdb049aaf 100644
--- a/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/OAuthApplicationInfo.java
+++ b/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/OAuthApplicationInfo.java
@@ -18,6 +18,7 @@
package org.wso2.carbon.dynamic.client.registration;
import org.json.simple.JSONObject;
+import org.wso2.carbon.dynamic.client.registration.util.DCRConstants;
import java.util.HashMap;
import java.util.Map;
@@ -87,10 +88,10 @@ public class OAuthApplicationInfo {
public String toString() {
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(DCRConstants.ClientMetadata.OAUTH_CLIENT_ID, this.getClientId());
+ obj.put(DCRConstants.ClientMetadata.OAUTH_CLIENT_NAME, this.getClientName());
+ obj.put(DCRConstants.ClientMetadata.OAUTH_CALLBACK_URIS, this.getCallBackURL());
+ obj.put(DCRConstants.ClientMetadata.OAUTH_CLIENT_SECRET, this.getClientSecret());
return obj.toString();
}
diff --git a/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/impl/DynamicClientRegistrationServiceImpl.java b/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/impl/DynamicClientRegistrationServiceImpl.java
index a5640b97ea..7938ba355a 100644
--- a/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/impl/DynamicClientRegistrationServiceImpl.java
+++ b/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/impl/DynamicClientRegistrationServiceImpl.java
@@ -27,6 +27,8 @@ import org.wso2.carbon.context.RegistryType;
import org.wso2.carbon.dynamic.client.registration.*;
import org.wso2.carbon.dynamic.client.registration.internal.DynamicClientRegistrationDataHolder;
import org.wso2.carbon.dynamic.client.registration.profile.RegistrationProfile;
+import org.wso2.carbon.dynamic.client.registration.util.DCRConstants;
+import org.wso2.carbon.dynamic.client.registration.util.DynamicClientRegistrationUtil;
import org.wso2.carbon.identity.application.common.IdentityApplicationManagementException;
import org.wso2.carbon.identity.application.common.model.*;
import org.wso2.carbon.identity.application.mgt.ApplicationManagementService;
@@ -94,15 +96,15 @@ public class DynamicClientRegistrationServiceImpl implements DynamicClientRegist
try {
JSONObject jsonObject = new JSONObject(info.getJsonString());
- if (jsonObject.has(ApplicationConstants.ClientMetadata.OAUTH_REDIRECT_URIS)) {
- oAuthApplicationInfo.addParameter(ApplicationConstants.ClientMetadata.OAUTH_REDIRECT_URIS,
+ if (jsonObject.has(DCRConstants.ClientMetadata.OAUTH_REDIRECT_URIS)) {
+ oAuthApplicationInfo.addParameter(DCRConstants.ClientMetadata.OAUTH_REDIRECT_URIS,
jsonObject
- .get(ApplicationConstants.ClientMetadata.OAUTH_REDIRECT_URIS));
+ .get(DCRConstants.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));
+ if (jsonObject.has(DCRConstants.ClientMetadata.OAUTH_CLIENT_GRANT)) {
+ oAuthApplicationInfo.addParameter(DCRConstants.ClientMetadata.OAUTH_CLIENT_GRANT, jsonObject
+ .get(DCRConstants.ClientMetadata.OAUTH_CLIENT_GRANT));
}
} catch (JSONException e) {
throw new DynamicClientRegistrationException(
@@ -160,7 +162,6 @@ public class DynamicClientRegistrationServiceImpl implements DynamicClientRegist
}
ServiceProvider existingServiceProvider = appMgtService.getServiceProvider(applicationName, tenantDomain);
-
if (existingServiceProvider == null) {
appMgtService.createApplication(serviceProvider, tenantDomain, userName);
}
@@ -267,9 +268,9 @@ public class DynamicClientRegistrationServiceImpl implements DynamicClientRegist
oAuthApplicationInfo.setClientName(createdApp.getApplicationName());
oAuthApplicationInfo.addParameter(
- ApplicationConstants.ClientMetadata.OAUTH_REDIRECT_URIS, createdApp.getCallbackUrl());
+ DCRConstants.ClientMetadata.OAUTH_REDIRECT_URIS, createdApp.getCallbackUrl());
oAuthApplicationInfo.addParameter(
- ApplicationConstants.ClientMetadata.OAUTH_CLIENT_GRANT, createdApp.getGrantTypes());
+ DCRConstants.ClientMetadata.OAUTH_CLIENT_GRANT, createdApp.getGrantTypes());
return oAuthApplicationInfo;
} catch (IdentityApplicationManagementException e) {
diff --git a/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/internal/DynamicClientRegistrationServiceComponent.java b/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/internal/DynamicClientRegistrationServiceComponent.java
index 6717742ac3..4a1ee1a641 100644
--- a/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/internal/DynamicClientRegistrationServiceComponent.java
+++ b/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/internal/DynamicClientRegistrationServiceComponent.java
@@ -20,7 +20,6 @@ package org.wso2.carbon.dynamic.client.registration.internal;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.osgi.framework.ServiceRegistration;
import org.osgi.service.component.ComponentContext;
import org.wso2.carbon.dynamic.client.registration.DynamicClientRegistrationService;
import org.wso2.carbon.dynamic.client.registration.impl.DynamicClientRegistrationServiceImpl;
@@ -44,10 +43,8 @@ public class DynamicClientRegistrationServiceComponent {
if(log.isDebugEnabled()){
log.debug("Starting DynamicClientRegistrationServiceComponent");
}
- DynamicClientRegistrationService dynamicClientRegistrationService =
- new DynamicClientRegistrationServiceImpl();
componentContext.getBundleContext().registerService(
- DynamicClientRegistrationService.class.getName(), dynamicClientRegistrationService, null);
+ DynamicClientRegistrationService.class.getName(), new DynamicClientRegistrationServiceImpl(), null);
}
@SuppressWarnings("unused")
diff --git a/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/ApplicationConstants.java b/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/util/DCRConstants.java
similarity index 95%
rename from components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/ApplicationConstants.java
rename to components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/util/DCRConstants.java
index d9f26334c3..12c59e2de1 100644
--- a/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/ApplicationConstants.java
+++ b/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/util/DCRConstants.java
@@ -15,18 +15,18 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.wso2.carbon.dynamic.client.registration;
+package org.wso2.carbon.dynamic.client.registration.util;
/**
* This class holds the constants used by DynamicClientRegistration component.
*/
-public final class ApplicationConstants {
+public final class DCRConstants {
public static class ClientMetadata {
private ClientMetadata() {
throw new AssertionError();
}
- //todo refactor names
+
public static final String OAUTH_CLIENT_ID = "client_id"; //this means consumer key
public static final String OAUTH_CLIENT_SECRET = "client_secret";
public static final String OAUTH_REDIRECT_URIS = "redirect_uris";
@@ -55,4 +55,4 @@ public final class ApplicationConstants {
public static final String VALIDITY_PERIOD = "validityPeriod";
}
-}
+}
\ No newline at end of file
diff --git a/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/DynamicClientRegistrationUtil.java b/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/util/DynamicClientRegistrationUtil.java
similarity index 91%
rename from components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/DynamicClientRegistrationUtil.java
rename to components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/util/DynamicClientRegistrationUtil.java
index dd835dad97..b4e53c797b 100644
--- a/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/DynamicClientRegistrationUtil.java
+++ b/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/util/DynamicClientRegistrationUtil.java
@@ -15,8 +15,11 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.wso2.carbon.dynamic.client.registration;
+package org.wso2.carbon.dynamic.client.registration.util;
+/**
+ * This class holds the util methods used by DCR component.
+ */
public class DynamicClientRegistrationUtil {
public static void validateUsername(String username) {
@@ -36,5 +39,4 @@ public class DynamicClientRegistrationUtil {
throw new IllegalArgumentException("Consumer Key cannot be null or empty");
}
}
-
-}
+}
\ No newline at end of file
diff --git a/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/pom.xml b/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/pom.xml
index 438dbcefd9..4acc1ee85a 100644
--- a/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/pom.xml
+++ b/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/pom.xml
@@ -56,7 +56,27 @@
!org.wso2.carbon.dynamic.client.web.app.registration.internal,
org.wso2.carbon.dynamic.client.web.app.registration.*
- *
+
+ javax.xml.bind.*,
+ com.google.*,
+ javax.net.ssl,
+ javax.servlet,
+ org.apache.axis2.context,
+ org.apache.catalina,
+ org.apache.catalina.core,
+ org.apache.commons.*,
+ org.apache.http,
+ org.apache.http.*,
+ org.osgi.framework,
+ org.osgi.service.component,
+ org.wso2.carbon.context,
+ org.wso2.carbon.core,
+ org.wso2.carbon.core.security,
+ org.wso2.carbon.dynamic.client.*,
+ org.wso2.carbon.registry.*,
+ org.wso2.carbon.user.*,
+ org.wso2.carbon.utils
+
@@ -115,5 +135,13 @@
org.wso2.carbon.devicemgt
org.wso2.carbon.dynamic.client.registration
+
+ org.apache.httpcomponents
+ httpclient
+
+
+ com.google.code.gson
+ gson
+
\ No newline at end of file
diff --git a/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/src/main/java/org/wso2/carbon/dynamic/client/web/app/registration/DynamicClientWebAppRegistrationManager.java b/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/src/main/java/org/wso2/carbon/dynamic/client/web/app/registration/DynamicClientWebAppRegistrationManager.java
index 3d9e0083cd..ef8f643c88 100644
--- a/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/src/main/java/org/wso2/carbon/dynamic/client/web/app/registration/DynamicClientWebAppRegistrationManager.java
+++ b/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/src/main/java/org/wso2/carbon/dynamic/client/web/app/registration/DynamicClientWebAppRegistrationManager.java
@@ -52,8 +52,7 @@ public class DynamicClientWebAppRegistrationManager {
if (dynamicClientWebAppRegistrationManager == null) {
synchronized (DynamicClientWebAppRegistrationManager.class) {
if (dynamicClientWebAppRegistrationManager == null) {
- dynamicClientWebAppRegistrationManager =
- new DynamicClientWebAppRegistrationManager();
+ dynamicClientWebAppRegistrationManager = new DynamicClientWebAppRegistrationManager();
}
}
}
@@ -65,11 +64,9 @@ public class DynamicClientWebAppRegistrationManager {
log.debug("Registering OAuth application for web app : " + registrationProfile.getClientName());
}
if (DynamicClientWebAppRegistrationUtil.validateRegistrationProfile(registrationProfile)) {
- DynamicClientRegistrationService dynamicClientRegistrationService =
- DynamicClientWebAppRegistrationDataHolder.getInstance().getDynamicClientRegistrationService();
try {
OAuthApplicationInfo oAuthApplicationInfo =
- dynamicClientRegistrationService.registerOAuthApplication(registrationProfile);
+ DynamicClientWebAppRegistrationUtil.registerOAuthApplication(registrationProfile);
OAuthAppDetails oAuthAppDetails = new OAuthAppDetails();
oAuthAppDetails.setWebAppName(registrationProfile.getClientName());
oAuthAppDetails.setClientName(oAuthApplicationInfo.getClientName());
@@ -79,7 +76,7 @@ public class DynamicClientWebAppRegistrationManager {
if (DynamicClientWebAppRegistrationUtil.putOAuthApplicationData(oAuthAppDetails)) {
return oAuthAppDetails;
} else {
- dynamicClientRegistrationService.unregisterOAuthApplication(registrationProfile.getOwner(),
+ DynamicClientWebAppRegistrationUtil.unregisterOAuthApplication(registrationProfile.getOwner(),
oAuthApplicationInfo.getClientName(),
oAuthApplicationInfo.getClientId());
log.warn("Error occurred while persisting the OAuth application data in registry.");
diff --git a/components/identity-extensions/dynamic-client-registration/dynamic-client-web/src/main/java/org/wso2/carbon/dynamic/client/web/impl/ConfigurationServiceImpl.java b/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/src/main/java/org/wso2/carbon/dynamic/client/web/app/registration/dto/DynamicClientRegistrationSettings.java
similarity index 56%
rename from components/identity-extensions/dynamic-client-registration/dynamic-client-web/src/main/java/org/wso2/carbon/dynamic/client/web/impl/ConfigurationServiceImpl.java
rename to components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/src/main/java/org/wso2/carbon/dynamic/client/web/app/registration/dto/DynamicClientRegistrationSettings.java
index 7fcf7fa075..6bbe47eb5a 100644
--- a/components/identity-extensions/dynamic-client-registration/dynamic-client-web/src/main/java/org/wso2/carbon/dynamic/client/web/impl/ConfigurationServiceImpl.java
+++ b/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/src/main/java/org/wso2/carbon/dynamic/client/web/app/registration/dto/DynamicClientRegistrationSettings.java
@@ -15,18 +15,30 @@
* 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;
+package org.wso2.carbon.dynamic.client.web.app.registration.dto;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.core.Response;
+/**
+ * Represents Configuration setting related to OAuth in authenticators.xml.
+ */
+public class DynamicClientRegistrationSettings {
+
+ private boolean isRemote;
+ private String host;
+
+ public boolean isRemote() {
+ return isRemote;
+ }
-public class ConfigurationServiceImpl implements ConfigurationService {
+ public void setIsRemote(boolean isRemote) {
+ this.isRemote = isRemote;
+ }
- @Override
- public Response getProfile(@PathParam("client_id") String clientId) {
- return null;
+ public String getHost() {
+ return host;
}
-}
\ No newline at end of file
+ public void setHost(String host) {
+ this.host = host;
+ }
+}
diff --git a/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/src/main/java/org/wso2/carbon/dynamic/client/web/app/registration/util/DynamicClientWebAppRegistrationConstants.java b/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/src/main/java/org/wso2/carbon/dynamic/client/web/app/registration/util/DynamicClientWebAppRegistrationConstants.java
index 778063b722..ca5e9a0eb6 100644
--- a/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/src/main/java/org/wso2/carbon/dynamic/client/web/app/registration/util/DynamicClientWebAppRegistrationConstants.java
+++ b/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/src/main/java/org/wso2/carbon/dynamic/client/web/app/registration/util/DynamicClientWebAppRegistrationConstants.java
@@ -36,7 +36,8 @@ public class DynamicClientWebAppRegistrationConstants {
}
public static final String CONTENT_TYPE_ANY = "*/*";
- public static final String MEDIA_TYPE_XML = "application/xml";
+ public static final String CONTENT_TYPE_XML = "application/xml";
+ public static final String CONTENT_TYPE_APPLICATION_JSON = "application/json";
}
public static final class CharSets {
@@ -46,4 +47,23 @@ public class DynamicClientWebAppRegistrationConstants {
public static final String CHARSET_UTF8 = "UTF8";
}
-}
+
+ public static class ConfigurationProperties {
+ private ConfigurationProperties() {
+ throw new AssertionError();
+ }
+
+ public static final String AUTHENTICATOR_NAME = "OAuthAuthenticator";
+ public static final String AUTHENTICATOR_CONFIG_IS_REMOTE = "isRemote";
+ public static final String AUTHENTICATOR_CONFIG_HOST_URL = "hostURL";
+ }
+
+ public static class RemoteServiceProperties {
+ private RemoteServiceProperties() {
+ throw new AssertionError();
+ }
+
+ public static final String DYNAMIC_CLIENT_SERVICE_ENDPOINT = "/dynamic-client-web/register";
+ public static final String DYNAMIC_CLIENT_SERVICE_PROTOCOL = "https";
+ }
+}
\ No newline at end of file
diff --git a/components/identity-extensions/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/identity-extensions/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
index 03550d9896..ce6eaa50ee 100644
--- a/components/identity-extensions/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/identity-extensions/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
@@ -22,8 +22,11 @@ import com.google.gson.stream.JsonReader;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.context.PrivilegedCarbonContext;
+import org.wso2.carbon.core.security.AuthenticatorsConfiguration;
import org.wso2.carbon.dynamic.client.registration.DynamicClientRegistrationException;
+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.dto.DynamicClientRegistrationSettings;
import org.wso2.carbon.dynamic.client.web.app.registration.dto.OAuthAppDetails;
import org.wso2.carbon.dynamic.client.web.app.registration.dto.JaggeryOAuthConfigurationSettings;
import org.wso2.carbon.dynamic.client.web.app.registration.internal.DynamicClientWebAppRegistrationDataHolder;
@@ -114,7 +117,7 @@ public class DynamicClientWebAppRegistrationUtil {
Resource resource = DynamicClientWebAppRegistrationUtil.getGovernanceRegistry().newResource();
resource.setContent(writer.toString());
- resource.setMediaType(DynamicClientWebAppRegistrationConstants.ContentTypes.MEDIA_TYPE_XML);
+ resource.setMediaType(DynamicClientWebAppRegistrationConstants.ContentTypes.CONTENT_TYPE_XML);
String resourcePath = DynamicClientWebAppRegistrationConstants.OAUTH_APP_DATA_REGISTRY_PATH + "/" +
oAuthAppDetails.getClientName();
status = DynamicClientWebAppRegistrationUtil.putRegistryResource(resourcePath, resource);
@@ -315,4 +318,65 @@ public class DynamicClientWebAppRegistrationUtil {
public static String replaceInvalidChars(String username) {
return username.replaceAll("@","_AT_");
}
+
+ private static DynamicClientRegistrationSettings getDynamicClientRegistrationSettings()
+ throws IllegalArgumentException {
+ AuthenticatorsConfiguration authenticatorsConfiguration = AuthenticatorsConfiguration.getInstance();
+ AuthenticatorsConfiguration.AuthenticatorConfig authenticatorConfig = authenticatorsConfiguration.
+ getAuthenticatorConfig(DynamicClientWebAppRegistrationConstants.
+ ConfigurationProperties.AUTHENTICATOR_NAME);
+ DynamicClientRegistrationSettings dynamicClientRegistrationSettings = new DynamicClientRegistrationSettings();
+ if (authenticatorConfig != null && authenticatorConfig.getParameters() != null) {
+ dynamicClientRegistrationSettings.setIsRemote(Boolean.parseBoolean(
+ authenticatorConfig.getParameters().get(
+ DynamicClientWebAppRegistrationConstants.ConfigurationProperties.
+ AUTHENTICATOR_CONFIG_IS_REMOTE)));
+ dynamicClientRegistrationSettings.setHost(authenticatorConfig.getParameters().
+ get(DynamicClientWebAppRegistrationConstants.ConfigurationProperties.AUTHENTICATOR_CONFIG_HOST_URL));
+
+ }else{
+ throw new IllegalArgumentException("Configuration parameters need to be defined in Authenticators.xml.");
+ }
+ return dynamicClientRegistrationSettings;
+ }
+
+ //This method will choose the best DynamicClientRegistrationService based on server configurations and
+ //registers OAuth client.
+ public static OAuthApplicationInfo registerOAuthApplication(RegistrationProfile registrationProfile)
+ throws DynamicClientRegistrationException {
+ DynamicClientRegistrationSettings dynamicClientRegistrationSettings = getDynamicClientRegistrationSettings();
+ if (dynamicClientRegistrationSettings.isRemote()) {
+ return RemoteDCRClient.createOAuthApplication(registrationProfile,
+ getHostName(dynamicClientRegistrationSettings.getHost()));
+ } else {
+ return DynamicClientWebAppRegistrationDataHolder.getInstance().
+ getDynamicClientRegistrationService().registerOAuthApplication(registrationProfile);
+ }
+ }
+
+ //This method will choose the best DynamicClientRegistrationService based on server configurations and
+ //unregisters OAuth client.
+ public static boolean unregisterOAuthApplication(String owner, String clientName, String clientId)
+ throws DynamicClientRegistrationException {
+ DynamicClientRegistrationSettings dynamicClientRegistrationSettings = getDynamicClientRegistrationSettings();
+ if (dynamicClientRegistrationSettings.isRemote()) {
+ return RemoteDCRClient.deleteOAuthApplication(owner, clientName, clientId,
+ getHostName(dynamicClientRegistrationSettings.getHost()));
+ } else {
+ return DynamicClientWebAppRegistrationDataHolder.getInstance().
+ getDynamicClientRegistrationService().unregisterOAuthApplication(owner, clientName, clientId);
+ }
+ }
+
+ private static String getHostName(String host) {
+ if (host != null && !host.isEmpty()) {
+ if (host.contains("https://")) {
+ return host.replace("https://","");
+ }
+ } else {
+ throw new IllegalArgumentException("Remote Host parameter must defined in Authenticators.xml.");
+ }
+ return null;
+ }
+
}
\ No newline at end of file
diff --git a/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/src/main/java/org/wso2/carbon/dynamic/client/web/app/registration/util/RemoteDCRClient.java b/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/src/main/java/org/wso2/carbon/dynamic/client/web/app/registration/util/RemoteDCRClient.java
new file mode 100644
index 0000000000..9d5926db77
--- /dev/null
+++ b/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/src/main/java/org/wso2/carbon/dynamic/client/web/app/registration/util/RemoteDCRClient.java
@@ -0,0 +1,191 @@
+/*
+ * 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 com.google.gson.Gson;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpDelete;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.utils.URIBuilder;
+import org.apache.http.conn.scheme.Scheme;
+import org.apache.http.conn.scheme.SchemeRegistry;
+import org.apache.http.conn.ssl.SSLSocketFactory;
+import org.apache.http.conn.ssl.X509HostnameVerifier;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.impl.conn.SingleClientConnManager;
+import org.apache.http.util.EntityUtils;
+import org.wso2.carbon.dynamic.client.registration.DynamicClientRegistrationException;
+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.DynamicClientWebAppRegistrationDataHolder;
+import org.wso2.carbon.utils.CarbonUtils;
+import org.wso2.carbon.utils.ConfigurationContextService;
+
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.HttpsURLConnection;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+/**
+ * This class holds the necessary logic to create and delete service-providers by invoking the
+ * dynamic-client-registration endpoint.
+ */
+public class RemoteDCRClient {
+
+ private static final Log log = LogFactory.getLog(RemoteDCRClient.class);
+
+ public static OAuthApplicationInfo createOAuthApplication(RegistrationProfile registrationProfile, String host)
+ throws DynamicClientRegistrationException {
+ if (log.isDebugEnabled()) {
+ log.debug("Invoking DCR service to create OAuth application for web app : " + registrationProfile.
+ getClientName());
+ }
+ DefaultHttpClient httpClient = getHTTPSClient();
+ String clientName = registrationProfile.getClientName();
+ try {
+ URI uri = new URIBuilder().setScheme(DynamicClientWebAppRegistrationConstants.RemoteServiceProperties.
+ DYNAMIC_CLIENT_SERVICE_PROTOCOL).setHost(host).setPath(
+ DynamicClientWebAppRegistrationConstants.RemoteServiceProperties.DYNAMIC_CLIENT_SERVICE_ENDPOINT)
+ .build();
+ Gson gson = new Gson();
+ StringEntity entity = new StringEntity(gson.toJson(registrationProfile),
+ DynamicClientWebAppRegistrationConstants.ContentTypes.CONTENT_TYPE_APPLICATION_JSON,
+ DynamicClientWebAppRegistrationConstants.CharSets.CHARSET_UTF8);
+ HttpPost httpPost = new HttpPost(uri);
+ httpPost.setEntity(entity);
+ HttpResponse response = httpClient.execute(httpPost);
+ int status = response.getStatusLine().getStatusCode();
+ HttpEntity responseData = response.getEntity();
+ String responseString = EntityUtils.toString(responseData, DynamicClientWebAppRegistrationConstants.
+ CharSets.CHARSET_UTF8);
+ if (status != 201) {
+ throw new DynamicClientRegistrationException(
+ "Backend server error occurred while invoking DCR endpoint for " +
+ "registering service-provider for web-app : " + clientName);
+ }
+ return getOAuthApplicationInfo(gson.fromJson(responseString, JsonElement.class));
+ } catch (URISyntaxException e) {
+ throw new DynamicClientRegistrationException("Exception occurred while constructing the URI for invoking " +
+ "DCR endpoint for registering service-provider for web-app : "
+ + clientName, e);
+ } catch (UnsupportedEncodingException e) {
+ throw new DynamicClientRegistrationException(
+ "Exception occurred while constructing the payload for invoking " +
+ "DCR endpoint for registering service-provider for web-app : "
+ + clientName, e);
+ } catch (IOException e) {
+ throw new DynamicClientRegistrationException("Connection error occurred while invoking DCR endpoint for" +
+ " registering service-provider for web-app : " + clientName,
+ e);
+ } finally {
+ httpClient.close();
+ }
+ }
+
+ public static boolean deleteOAuthApplication(String user, String appName, String clientid, String host)
+ throws DynamicClientRegistrationException {
+ if (log.isDebugEnabled()) {
+ log.debug("Invoking DCR service to remove OAuth application created for web app : " + appName);
+ }
+ DefaultHttpClient httpClient = getHTTPSClient();
+ try {
+ URI uri = new URIBuilder().setScheme(DynamicClientWebAppRegistrationConstants.RemoteServiceProperties.
+ DYNAMIC_CLIENT_SERVICE_PROTOCOL).setHost(host).setPath(
+ DynamicClientWebAppRegistrationConstants.RemoteServiceProperties.DYNAMIC_CLIENT_SERVICE_ENDPOINT)
+ .setParameter("applicationName", appName)
+ .setParameter("userId", user)
+ .setParameter("consumerKey", clientid).build();
+ HttpDelete httpDelete = new HttpDelete(uri);
+ HttpResponse response = httpClient.execute(httpDelete);
+ int status = response.getStatusLine().getStatusCode();
+ if (status == 200) {
+ return true;
+ }
+ } catch (IOException e) {
+ throw new DynamicClientRegistrationException(
+ "Connection error occurred while constructing the payload for " +
+ "invoking DCR endpoint for unregistering the web-app : " + appName, e);
+ } catch (URISyntaxException e) {
+ throw new DynamicClientRegistrationException("Exception occurred while constructing the URI for invoking " +
+ "DCR endpoint for unregistering the web-app : " + appName, e);
+ } finally {
+ httpClient.close();
+ }
+ return false;
+ }
+
+ private static int getServerHTTPSPort() {
+ // HTTPS port
+ String mgtConsoleTransport = CarbonUtils.getManagementTransport();
+ ConfigurationContextService configContextService =
+ DynamicClientWebAppRegistrationDataHolder.getInstance().getConfigurationContextService();
+ int port = CarbonUtils.getTransportPort(configContextService, mgtConsoleTransport);
+ int httpsProxyPort =
+ CarbonUtils.getTransportProxyPort(configContextService.getServerConfigContext(),
+ mgtConsoleTransport);
+ if (httpsProxyPort > 0) {
+ port = httpsProxyPort;
+ }
+ return port;
+ }
+
+ private static OAuthApplicationInfo getOAuthApplicationInfo(JsonElement jsonData) {
+ JsonObject jsonObject = jsonData.getAsJsonObject();
+ OAuthApplicationInfo oAuthApplicationInfo = new OAuthApplicationInfo();
+ JsonElement property = jsonObject.get("client_id");
+ if (property != null) {
+ oAuthApplicationInfo.setClientId(property.getAsString());
+ }
+ property = jsonObject.get("client_name");
+ if (property != null) {
+ oAuthApplicationInfo.setClientName(property.getAsString());
+ }
+ property = jsonObject.get("client_secret");
+ if (property != null) {
+ oAuthApplicationInfo.setClientSecret(property.getAsString());
+ }
+ return oAuthApplicationInfo;
+ }
+
+ private static DefaultHttpClient getHTTPSClient() {
+ DefaultHttpClient httpClient = new DefaultHttpClient();
+ // Setup the HTTPS settings to accept any certificate.
+ HostnameVerifier hostnameVerifier = org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER;
+
+ SchemeRegistry registry = new SchemeRegistry();
+ SSLSocketFactory socketFactory = SSLSocketFactory.getSocketFactory();
+ socketFactory.setHostnameVerifier((X509HostnameVerifier) hostnameVerifier);
+ registry.register(new Scheme(DynamicClientWebAppRegistrationConstants.RemoteServiceProperties.
+ DYNAMIC_CLIENT_SERVICE_PROTOCOL, socketFactory, getServerHTTPSPort()));
+ SingleClientConnManager mgr = new SingleClientConnManager(httpClient.getParams(), registry);
+ httpClient = new DefaultHttpClient(mgr, httpClient.getParams());
+
+ // Set verifier
+ HttpsURLConnection.setDefaultHostnameVerifier(hostnameVerifier);
+ return httpClient;
+ }
+}
diff --git a/components/identity-extensions/dynamic-client-registration/pom.xml b/components/identity-extensions/dynamic-client-registration/pom.xml
index e568ea5e88..54e68022ac 100644
--- a/components/identity-extensions/dynamic-client-registration/pom.xml
+++ b/components/identity-extensions/dynamic-client-registration/pom.xml
@@ -36,6 +36,7 @@
dynamic-client-web
+ dynamic-client-web-proxy
org.wso2.carbon.dynamic.client.registration
org.wso2.carbon.dynamic.client.web.app.registration
diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/MonitoringManagerImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/MonitoringManagerImpl.java
index 1eb91150b8..54b284dcb2 100644
--- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/MonitoringManagerImpl.java
+++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/MonitoringManagerImpl.java
@@ -106,6 +106,9 @@ public class MonitoringManagerImpl implements MonitoringManager {
complianceData.setPolicyId(policy.getId());
} catch (SQLException e) {
throw new PolicyComplianceException("Error occurred while opening a data source connection", e);
+ } catch (MonitoringDAOException e) {
+ throw new PolicyComplianceException("Unable to add the none compliance features to database for device " +
+ deviceIdentifier.getId() + " - " + deviceIdentifier.getType(), e);
} finally {
PolicyManagementDAOFactory.closeConnection();
}
@@ -124,6 +127,10 @@ public class MonitoringManagerImpl implements MonitoringManager {
complianceFeatures);
PolicyManagementDAOFactory.commitTransaction();
+ } catch (MonitoringDAOException e) {
+ PolicyManagementDAOFactory.rollbackTransaction();
+ throw new PolicyComplianceException("Unable to add the none compliance features to database for device " +
+ deviceIdentifier.getId() + " - " + deviceIdentifier.getType(), e);
} finally {
PolicyManagementDAOFactory.closeConnection();
}
@@ -143,6 +150,10 @@ public class MonitoringManagerImpl implements MonitoringManager {
.getId());
monitoringDAO.deleteNoneComplianceData(complianceData.getId());
PolicyManagementDAOFactory.commitTransaction();
+ } catch (MonitoringDAOException e) {
+ PolicyManagementDAOFactory.rollbackTransaction();
+ throw new PolicyComplianceException("Unable to remove the none compliance features from database for device " +
+ deviceIdentifier.getId() + " - " + deviceIdentifier.getType(), e);
} finally {
PolicyManagementDAOFactory.closeConnection();
}
@@ -153,17 +164,11 @@ public class MonitoringManagerImpl implements MonitoringManager {
}
}
} catch (DeviceManagementException e) {
- PolicyManagementDAOFactory.rollbackTransaction();
throw new PolicyComplianceException("Unable tor retrieve device data from DB for " +
deviceIdentifier.getId() + " - " + deviceIdentifier.getType(), e);
} catch (PolicyManagerDAOException | PolicyManagementException e) {
- PolicyManagementDAOFactory.rollbackTransaction();
throw new PolicyComplianceException("Unable tor retrieve policy data from DB for device " +
deviceIdentifier.getId() + " - " + deviceIdentifier.getType(), e);
- } catch (MonitoringDAOException e) {
- PolicyManagementDAOFactory.rollbackTransaction();
- throw new PolicyComplianceException("Unable to add the none compliance features to database for device " +
- deviceIdentifier.getId() + " - " + deviceIdentifier.getType(), e);
}
return complianceFeatures;
}
diff --git a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/authenticator/OAuthAuthenticator.java b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/authenticator/OAuthAuthenticator.java
index 497fa3b3e2..c82a57646b 100644
--- a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/authenticator/OAuthAuthenticator.java
+++ b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/authenticator/OAuthAuthenticator.java
@@ -99,13 +99,14 @@ public class OAuthAuthenticator implements WebappAuthenticator {
if (oAuthValidationResponse.isValid()) {
String username = oAuthValidationResponse.getUserName();
+ String tenantDomain = oAuthValidationResponse.getTenantDomain();
//Remove the userstore domain from username
/*if (username.contains("/")) {
username = username.substring(username.indexOf('/') + 1);
}*/
authenticationInfo.setUsername(username);
- authenticationInfo.setTenantDomain(oAuthValidationResponse.getTenantDomain());
- authenticationInfo.setTenantId(Utils.getTenantIdOFUser(username));
+ authenticationInfo.setTenantDomain(tenantDomain);
+ authenticationInfo.setTenantId(Utils.getTenantIdOFUser(username + "@" + tenantDomain));
if (oAuthValidationResponse.isValid()) {
authenticationInfo.setStatus(Status.CONTINUE);
}
diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/oracle.sql b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/oracle.sql
index dd6fa2c621..10e92f5047 100644
--- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/oracle.sql
+++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/oracle.sql
@@ -23,11 +23,11 @@ CREATE TABLE DM_DEVICE_CERTIFICATE (
SERIAL_NUMBER VARCHAR2(500) DEFAULT NULL,
CERTIFICATE BLOB DEFAULT NULL,
PRIMARY KEY (ID)
-);
-
+)
+/
-- Generate ID using sequence and trigger
-CREATE SEQUENCE DM_DEVICE_CERTIFICATE_seq START WITH 1 INCREMENT BY 1;
-
+CREATE SEQUENCE DM_DEVICE_CERTIFICATE_seq START WITH 1 INCREMENT BY 1 NOCACHE
+/
CREATE OR REPLACE TRIGGER DM_DEVICE_CERTIFICATE_seq_tr
BEFORE INSERT ON DM_DEVICE_CERTIFICATE FOR EACH ROW
WHEN (NEW.ID IS NULL)
diff --git a/pom.xml b/pom.xml
index 408d066248..e812fdfa0a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1247,9 +1247,12 @@
gson
${google.gson.version}
-
-
-
+
+ org.apache.httpcomponents
+ httpclient
+ ${apache.http.version}
+
+
org.apache.neethi.wso2
neethi
@@ -1448,16 +1451,6 @@
false
-
- wso2-staging
- WSO2 internal Repository
- http://maven.wso2.org/nexus/content/repositories/orgwso2carbonidentity-165/
-
- true
- daily
- ignore
-
-
@@ -1504,7 +1497,7 @@
4.6.0
- 5.0.3-SNAPSHOT
+ 5.0.3
4.5.0
@@ -1555,6 +1548,7 @@
2.3.1
1.1.1
1.2
+ 4.5.1
2.0.4