revert-70aa11f8
Pasindu 7 years ago
commit f39eed4221

@ -22,13 +22,13 @@
<parent>
<artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.annotations</artifactId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>WSO2 Carbon - API Management Annotations</name>
<description>WSO2 Carbon - API Management Custom Annotation Module</description>

@ -21,12 +21,12 @@
<parent>
<artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<artifactId>org.wso2.carbon.apimgt.application.extension.api</artifactId>
<packaging>war</packaging>
<name>WSO2 Carbon - API Application Management API</name>

@ -22,12 +22,12 @@
<parent>
<artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<artifactId>org.wso2.carbon.apimgt.application.extension</artifactId>
<packaging>bundle</packaging>
<name>WSO2 Carbon - API Application Management</name>

@ -21,13 +21,13 @@
<parent>
<artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.handlers</artifactId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>WSO2 Carbon - API Security Handler Component</name>
<description>WSO2 Carbon - API Management Security Handler Module</description>

@ -13,13 +13,13 @@
<parent>
<artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.integration.client</artifactId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>WSO2 Carbon - API Management Integration Client</name>
<description>WSO2 Carbon - API Management Integration Client</description>

@ -13,13 +13,13 @@
<parent>
<artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.integration.generated.client</artifactId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>WSO2 Carbon - API Management Integration Generated Client</name>
<description>WSO2 Carbon - API Management Integration Client</description>

@ -22,13 +22,13 @@
<parent>
<artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.webapp.publisher</artifactId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>WSO2 Carbon - API Management Webapp Publisher</name>
<description>WSO2 Carbon - API Management Webapp Publisher</description>

@ -22,13 +22,13 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>apimgt-extensions</artifactId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<packaging>pom</packaging>
<name>WSO2 Carbon - API Management Extensions Component</name>
<url>http://wso2.org</url>

@ -22,7 +22,7 @@
<parent>
<artifactId>certificate-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -22,7 +22,7 @@
<parent>
<artifactId>certificate-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -21,13 +21,13 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>certificate-mgt</artifactId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.certificate.mgt.core</artifactId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>WSO2 Carbon - Certificate Management Core</name>
<description>WSO2 Carbon - Certificate Management Core</description>

@ -22,14 +22,14 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>certificate-mgt</artifactId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<packaging>pom</packaging>
<name>WSO2 Carbon - Certificate Management Component</name>
<url>http://wso2.org</url>

@ -22,7 +22,7 @@
<parent>
<artifactId>device-mgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -22,7 +22,7 @@
<parent>
<artifactId>device-mgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -22,7 +22,7 @@
<parent>
<artifactId>device-mgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -22,7 +22,7 @@
<parent>
<artifactId>device-mgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -22,7 +22,7 @@
<parent>
<artifactId>device-mgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -22,7 +22,7 @@
<parent>
<artifactId>device-mgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -22,7 +22,7 @@
<parent>
<artifactId>carbon-devicemgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

@ -3,7 +3,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>device-mgt</artifactId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -22,7 +22,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>device-mgt</artifactId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -22,7 +22,7 @@
<parent>
<artifactId>device-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -21,7 +21,7 @@
<parent>
<artifactId>device-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -22,7 +22,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>device-mgt</artifactId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -22,7 +22,7 @@
<parent>
<artifactId>device-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -22,7 +22,7 @@
<parent>
<artifactId>device-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -82,6 +82,7 @@ $("a#invite-user-link").click(function () {
usernameList,
function () {
modalDialog.header("User invitation email for enrollment was successfully sent.");
modalDialog.content("");
modalDialog.footer('<div class="buttons"><a href="#" id="invite-user-success-link" ' +
'class="btn-operations">Ok </a></div>');
$("a#invite-user-success-link").click(function () {

@ -69,11 +69,11 @@ function showAdvanceOperation(operation, button) {
$(button).addClass('selected');
$(button).siblings().removeClass('selected');
if ($(button).attr("id") == 'allNotifications') {
$("#noNotificationtxt").html('You do not have any unread notifications ');
} else if ($(button).attr("id") == 'unReadNotifications') {
$("#noNotificationtxt").html('You do not have any notifications ');
} else if ($(button).attr("id") == 'unReadNotifications') {
$("#noNotificationtxt").html('You do not have any unread notifications ');
} else {
$("#noNotificationtxt").html('You do not have any notifications ');
$("#noNotificationtxt").html('You do not have any unread notifications ');
}
var hiddenOperation = ".wr-hidden-operations-content > div";
$(hiddenOperation + '[data-operation="' + operation + '"]').show();

@ -6964,3 +6964,7 @@ header.header-default {
padding: 8px 15px !important;
line-height: 0px !important;
}
.header .fw-user{
color: #333 !important;
}

@ -23,7 +23,7 @@
<parent>
<artifactId>device-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -22,7 +22,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

@ -22,7 +22,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>email-sender</artifactId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -22,7 +22,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

@ -1,110 +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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>dynamic-client-registration</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>dynamic-client-web-proxy</artifactId>
<name>WSO2 Carbon - Proxy endpoint of Dynamic Client Registration Web Service</name>
<description>WSO2 Carbon - Dynamic Client Registration Web Proxy</description>
<packaging>war</packaging>
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<warName>${project.artifactId}</warName>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.dynamic.client.registration</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.utils</artifactId>
<scope>provided</scope>
</dependency>
<!--dependency>
<groupId>org.apache.ws.commons.axiom.wso2</groupId>
<artifactId>axiom-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.ws.commons.axiom.wso2</groupId>
<artifactId>axiom-impl</artifactId>
<scope>provided</scope>
</dependency-->
<dependency>
<groupId>org.apache.ws.commons.axiom.wso2</groupId>
<artifactId>axiom</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-bindings-http</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-jaxrs</artifactId>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.core</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

@ -1,72 +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.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<String, String> 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 | 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;
}
}

@ -1,129 +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.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;
}
}

@ -1,52 +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.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";
}
}

@ -1,122 +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.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;
}
}

@ -1,35 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
~ 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.
-->
<!--
This file defines class loading policy of the whole container. But this behaviour can be overridden by individual webapps by putting this file into the META-INF/ directory.
-->
<Classloading xmlns="http://wso2.org/projects/as/classloading">
<!-- Parent-first or child-first. Default behaviour is child-first.-->
<ParentFirst>false</ParentFirst>
<!--
Default environments that contains provides to all the webapps. This can be overridden by individual webapps by specifing required environments
Tomcat environment is the default and every webapps gets it even if they didn't specify it.
e.g. If a webapps requires CXF, they will get both Tomcat and CXF.
-->
<Environments>CXF,Carbon</Environments>
</Classloading>

@ -1,51 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxrs="http://cxf.apache.org/jaxrs"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd">
<import resource="classpath:META-INF/cxf/cxf.xml"/>
<import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
<!-- Registration Service Proxy Endpoint -->
<jaxrs:server id="RegistrationService" address="/register">
<jaxrs:serviceBeans>
<ref bean="RegistrationServiceBean"/>
</jaxrs:serviceBeans>
<jaxrs:providers>
<ref bean="jsonProvider"/>
</jaxrs:providers>
</jaxrs:server>
<!-- OAuth Service Proxy Endpoint -->
<jaxrs:server id="OAuthService" address="/token">
<jaxrs:serviceBeans>
<ref bean="OAuthServiceBean"/>
</jaxrs:serviceBeans>
<jaxrs:providers></jaxrs:providers>
</jaxrs:server>
<bean id="RegistrationServiceBean" class="org.wso2.carbon.dynamic.client.web.proxy.RegistrationProxy"/>
<bean id="OAuthServiceBean" class="org.wso2.carbon.dynamic.client.web.proxy.OAuthEndpointProxy"/>
<bean id="jsonProvider" class="org.codehaus.jackson.jaxrs.JacksonJsonProvider"/>
</beans>

@ -1,37 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
-->
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
<display-name>Dynamic-client-proxy-Webapp</display-name>
<servlet>
<description>Dynamic-client-registration-proxy Endpoint</description>
<display-name>JAX-WS/JAX-RS Servlet</display-name>
<servlet-name>CXFServlet</servlet-name>
<servlet-class>
org.apache.cxf.transport.servlet.CXFServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>CXFServlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>60</session-timeout>
</session-config>
</web-app>

@ -1,125 +0,0 @@
@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;
}

@ -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=INFO, 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

@ -1,23 +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.
-->
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="DCR-Proxy-Tests">
<parameter name="useDefaultListeners" value="false"/>
</suite>

@ -1,186 +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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>dynamic-client-registration</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>dynamic-client-web</artifactId>
<name>WSO2 Carbon - Dynamic Client Registration Web Service</name>
<description>WSO2 Carbon - Dynamic Client Registration Web</description>
<packaging>war</packaging>
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<warName>${project.artifactId}</warName>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18</version>
<configuration>
<systemPropertyVariables>
<log4j.configuration>file:src/test/resources/log4j.properties</log4j.configuration>
</systemPropertyVariables>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!--dependency>
<groupId>org.apache.ws.commons.axiom.wso2</groupId>
<artifactId>axiom-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.ws.commons.axiom.wso2</groupId>
<artifactId>axiom-impl</artifactId>
<scope>provided</scope>
</dependency-->
<dependency>
<groupId>org.apache.ws.commons.axiom.wso2</groupId>
<artifactId>axiom</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-bindings-http</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-extension-providers</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-ws-security</artifactId>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<scope>provided</scope>
</dependency>
<!-- Device management core dependencies -->
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.common</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.core</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.dynamic.client.registration</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.utils</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.wso2.carbon.identity.framework</groupId>
<artifactId>org.wso2.carbon.identity.application.mgt</artifactId>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>org.apache.neethi.wso2</groupId>
<artifactId>neethi</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.neethi</groupId>
<artifactId>neethi</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple.wso2</groupId>
<artifactId>json-simple</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.neethi.wso2</groupId>
<artifactId>neethi</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.neethi</groupId>
<artifactId>neethi</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-jaxrs</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

@ -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 org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.dynamic.client.registration.DynamicClientRegistrationService;
/**
* Holds the utility methods used by Dynamic-Client web bundle.
*/
public class DynamicClientUtil {
public static DynamicClientRegistrationService getDynamicClientRegistrationService() {
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
return (DynamicClientRegistrationService) ctx.getOSGiService(DynamicClientRegistrationService.class, null);
}
}

@ -1,70 +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 com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
import javax.ws.rs.Produces;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.ext.MessageBodyWriter;
import javax.ws.rs.ext.Provider;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
@Provider
@Produces(MediaType.APPLICATION_JSON)
public class FaultMessageBodyWriter implements MessageBodyWriter<FaultResponse> {
private static final String UTF_8 = "UTF-8";
@Override
public boolean isWriteable(Class<?> aClass, Type type, Annotation[] annotations, MediaType mediaType) {
return (FaultResponse.class == type);
}
@Override
public long getSize(FaultResponse faultResponse, Class<?> aClass, Type type, Annotation[] annotations,
MediaType mediaType) {
return -1;
}
@Override
public void writeTo(FaultResponse faultResponse, Class<?> aClass, Type type, Annotation[] annotations,
MediaType mediaType, MultivaluedMap<String, Object> stringObjectMultivaluedMap,
OutputStream outputStream) throws IOException, WebApplicationException {
try (OutputStreamWriter writer = new OutputStreamWriter(outputStream, UTF_8)) {
JsonObject response = new JsonObject();
response.addProperty("error", faultResponse.getCode().getValue());
response.addProperty("error_description", faultResponse.getDescription());
getGson().toJson(response, type, writer);
}
}
private Gson getGson() {
GsonBuilder gsonBuilder = new GsonBuilder();
return gsonBuilder.create();
}
}

@ -1,38 +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;
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;
}
}

@ -1,40 +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.core.MultivaluedMap;
import javax.ws.rs.core.Response;
public abstract class RegistrationResponse extends Response {
@Override
public Object getEntity() {
return null;
}
@Override
public int getStatus() {
return 0;
}
@Override
public MultivaluedMap<String, Object> getMetadata() {
return null;
}
}

@ -1,72 +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 org.wso2.carbon.dynamic.client.registration.profile.RegistrationProfile;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.POST;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
public interface RegistrationService {
enum ErrorCode {
INVALID_URI("invalid_redirect_uri"), INVALID_CLIENT_METADATA("invalid_client_metadata");
private String value;
private ErrorCode(String value) {
this.value = value;
}
public String getValue() {
return value;
}
}
/**
* This method is used to register an Oauth application.
*
* @param profile contains the necessary attributes that are
* needed in order to register an app.
* @return Status 200 if success including consumerKey and consumerSecret.
*/
@POST
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
Response register(RegistrationProfile profile);
/**
* This method is used to remove already registered Oauth application.
*
* @param applicationName name of the application.
* @param userId name of the application owner.
* @param consumerKey provided consumerKey for the registered application.
* @return Status 200 if success.
*/
@DELETE
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
Response unregister(@QueryParam("applicationName") String applicationName,
@QueryParam("userId") String userId,
@QueryParam("consumerKey") String consumerKey);
}

@ -1,106 +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.impl;
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.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;
public class RegistrationServiceImpl implements RegistrationService {
private static final Log log = LogFactory.getLog(RegistrationServiceImpl.class);
@POST
@Override
public Response register(RegistrationProfile profile) {
Response response;
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();
}
response = 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);
response = Response.status(Response.Status.BAD_REQUEST).entity(
new FaultResponse(ErrorCode.INVALID_CLIENT_METADATA, msg)).build();
} finally {
PrivilegedCarbonContext.endTenantFlow();
}
return response;
}
@DELETE
@Override
public Response unregister(@QueryParam("applicationName") String applicationName,
@QueryParam("userId") String userId,
@QueryParam("consumerKey") String consumerKey) {
Response response;
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) {
boolean status = dynamicClientRegistrationService.unregisterOAuthApplication(userId, applicationName,
consumerKey);
if (status) {
return Response.status(Response.Status.OK).build();
}
return Response.status(Response.Status.BAD_REQUEST).build();
}
response = 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);
response = Response.serverError().entity(new FaultResponse(ErrorCode.INVALID_CLIENT_METADATA, msg)).build();
} finally {
PrivilegedCarbonContext.endTenantFlow();
}
return response;
}
}

@ -1,35 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
~ 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.
-->
<!--
This file defines class loading policy of the whole container. But this behaviour can be overridden by individual webapps by putting this file into the META-INF/ directory.
-->
<Classloading xmlns="http://wso2.org/projects/as/classloading">
<!-- Parent-first or child-first. Default behaviour is child-first.-->
<ParentFirst>false</ParentFirst>
<!--
Default environments that contains provides to all the webapps. This can be overridden by individual webapps by specifing required environments
Tomcat environment is the default and every webapps gets it even if they didn't specify it.
e.g. If a webapps requires CXF, they will get both Tomcat and CXF.
-->
<Environments>CXF,Carbon</Environments>
</Classloading>

@ -1,44 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxrs="http://cxf.apache.org/jaxrs"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd">
<import resource="classpath:META-INF/cxf/cxf.xml"/>
<import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
<!-- Registration Service Endpoint -->
<jaxrs:server id="RegistrationService" address="/register">
<jaxrs:serviceBeans>
<ref bean="RegistrationServiceBean"/>
</jaxrs:serviceBeans>
<jaxrs:providers>
<ref bean="jsonProvider"/>
<ref bean="faultResponseWriter"/>
</jaxrs:providers>
</jaxrs:server>
<bean id="RegistrationServiceBean" class="org.wso2.carbon.dynamic.client.web.impl.RegistrationServiceImpl"/>
<bean id="jsonProvider" class="org.codehaus.jackson.jaxrs.JacksonJsonProvider"/>
<bean id="faultResponseWriter" class="org.wso2.carbon.dynamic.client.web.FaultMessageBodyWriter"/>
</beans>

@ -1,39 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ /*
~ * 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.
~ */
-->
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
<display-name>dynamic-client-registration-Webapp</display-name>
<servlet>
<description>Dynamic-client-registration Agent Endpoint</description>
<display-name>JAX-WS/JAX-RS Servlet</display-name>
<servlet-name>CXFServlet</servlet-name>
<servlet-class>
org.apache.cxf.transport.servlet.CXFServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>CXFServlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>60</session-timeout>
</session-config>
</web-app>

@ -1,125 +0,0 @@
@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;
}

@ -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=INFO, 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

@ -1,23 +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.
-->
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="DCR-Tests">
<parameter name="useDefaultListeners" value="false"/>
</suite>

@ -1,117 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>dynamic-client-registration</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.dynamic.client.registration</artifactId>
<version>3.0.12-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>WSO2 Carbon - Dynamic client registration service</name>
<description>WSO2 Carbon - Dynamic Client Registration Service</description>
<url>http://wso2.org</url>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-scr-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>1.4.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Name>${project.artifactId}</Bundle-Name>
<Bundle-Version>${carbon.device.mgt.version}</Bundle-Version>
<Bundle-Description>Dynamic Client Registration Bundle</Bundle-Description>
<Private-Package>org.wso2.carbon.dynamic.client.registration.internal</Private-Package>
<Export-Package>
!org.wso2.carbon.dynamic.client.registration.internal,
org.wso2.carbon.dynamic.client.registration.*
</Export-Package>
<Import-Package>
org.apache.commons.logging,
org.json,
org.json.simple,
org.osgi.framework,
org.osgi.service.component,
org.wso2.carbon.context,
org.wso2.carbon.identity.application.*; version="${carbon.identity.imp.pkg.version}",
org.wso2.carbon.identity.base; version="${carbon.identity.imp.pkg.version}",
org.wso2.carbon.identity.oauth.*; version="${carbon.identity-inbound-auth-oauth.imp.pkg.version}",
org.wso2.carbon.identity.sso.saml.admin,
org.wso2.carbon.identity.sso.saml.dto,
org.wso2.carbon.registry.api,
org.wso2.carbon.registry.core,
org.wso2.carbon.utils.multitenancy
</Import-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.eclipse.osgi</groupId>
<artifactId>org.eclipse.osgi</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.osgi</groupId>
<artifactId>org.eclipse.osgi.services</artifactId>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.utils</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.identity.framework</groupId>
<artifactId>org.wso2.carbon.identity.application.mgt</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.identity.inbound.auth.oauth2</groupId>
<artifactId>org.wso2.carbon.identity.oauth</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.identity.inbound.auth.saml2</groupId>
<artifactId>org.wso2.carbon.identity.sso.saml</artifactId>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple.wso2</groupId>
<artifactId>json-simple</artifactId>
</dependency>
<dependency>
<groupId>org.json.wso2</groupId>
<artifactId>json</artifactId>
</dependency>
</dependencies>
</project>

@ -1,61 +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.registration;
/**
* Custom exception to be thrown inside DynamicClientRegistration related functionality.
*/
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);
}
}

@ -1,64 +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.registration;
import org.wso2.carbon.dynamic.client.registration.profile.RegistrationProfile;
/**
* This class represents the interface to be implemented by DynamicClientRegistrationService which
* is used to support the Dynamic-client-authentication protocol.
*/
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
*
*/
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
*
*/
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
*
*/
boolean isOAuthApplicationAvailable(String applicationName) throws DynamicClientRegistrationException;
}

@ -1,98 +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.registration;
import org.json.simple.JSONObject;
import org.wso2.carbon.dynamic.client.registration.util.DCRConstants;
import java.util.HashMap;
import java.util.Map;
/**
* This class represents an OAuth application populated with necessary data.
*/
public class OAuthApplicationInfo {
private String clientId;
private String clientName;
private String callBackURL;
private String clientSecret;
private Map<String, Object> parameters = new HashMap<String, Object>();
public String getClientId() {
return clientId;
}
public void setClientId(String clientId) {
this.clientId = clientId;
}
public String getClientSecret() {
return clientSecret;
}
public void setClientSecret(String clientSecret) {
this.clientSecret = clientSecret;
}
public void setClientName(String clientName) {
this.clientName = clientName;
}
public void setCallBackURL(String callBackURL) {
this.callBackURL = callBackURL;
}
public void addParameter(String name, Object value) {
parameters.put(name, value);
}
public Object getParameter(String name) {
return parameters.get(name);
}
public String getJsonString() {
return JSONObject.toJSONString(parameters);
}
public String getClientName() {
return clientName;
}
public String getCallBackURL() {
return callBackURL;
}
public void putAll(Map<String, Object> parameters) {
this.parameters.putAll(parameters);
}
public void removeParameter(String key) {
this.parameters.remove(key);
}
public String toString() {
JSONObject obj = new JSONObject();
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();
}
}

@ -1,373 +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.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.context.CarbonContext;
import org.wso2.carbon.context.PrivilegedCarbonContext;
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;
import org.wso2.carbon.identity.base.IdentityException;
import org.wso2.carbon.identity.oauth.IdentityOAuthAdminException;
import org.wso2.carbon.identity.oauth.OAuthAdminService;
import org.wso2.carbon.identity.oauth.dto.OAuthConsumerAppDTO;
import org.wso2.carbon.identity.sso.saml.admin.SAMLSSOConfigAdmin;
import org.wso2.carbon.identity.sso.saml.dto.SAMLSSOServiceProviderDTO;
import org.wso2.carbon.registry.core.Registry;
import org.wso2.carbon.utils.multitenancy.MultitenantUtils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* Implementation of DynamicClientRegistrationService.
*/
public class DynamicClientRegistrationServiceImpl implements DynamicClientRegistrationService {
private static final String TOKEN_SCOPE = "tokenScope";
private static final String MDM = "mdm";
private static final String SAML_SSO = "samlsso";
private static final String BASIC_AUTHENTICATOR = "BasicAuthenticator";
private static final String BASIC = "basic";
private static final String LOCAL = "local";
private static final Log log = LogFactory.getLog(DynamicClientRegistrationService.class);
private static final String AUTH_TYPE_OAUTH_2 = "oauth2";
private static final String OAUTH_CONSUMER_SECRET = "oauthConsumerSecret";
private static final int STEP_ORDER = 1;
private static final String OAUTH_VERSION = "OAuth-2.0";
private static final String APPLICATION_TYPE_WEBAPP = "webapp";
private static final String APPLICATION_TYPE_DEVICE = "device";
@Override
public OAuthApplicationInfo registerOAuthApplication(
RegistrationProfile profile) throws DynamicClientRegistrationException {
OAuthApplicationInfo oAuthApplicationInfo = new OAuthApplicationInfo();
String applicationName = profile.getClientName();
if (log.isDebugEnabled()) {
log.debug("Trying to register OAuth application: '" + applicationName + "'");
}
String tokenScope = profile.getTokenScope();
String tokenScopes[] = new String[1];
tokenScopes[0] = tokenScope;
oAuthApplicationInfo.addParameter(TOKEN_SCOPE, Arrays.toString(tokenScopes));
OAuthApplicationInfo info;
try {
synchronized (DynamicClientRegistrationServiceImpl.class) {
info = this.createOAuthApplication(profile);
}
} catch (DynamicClientRegistrationException | IdentityException e) {
throw new DynamicClientRegistrationException("Can not create OAuth application : " + applicationName, e);
}
if (info == null || info.getJsonString() == null) {
throw new DynamicClientRegistrationException(
"OAuth app does not contain required data: '" + applicationName + "'");
}
oAuthApplicationInfo.setClientName(info.getClientName());
oAuthApplicationInfo.setClientId(info.getClientId());
oAuthApplicationInfo.setCallBackURL(info.getCallBackURL());
oAuthApplicationInfo.setClientSecret(info.getClientSecret());
try {
JSONObject jsonObject = new JSONObject(info.getJsonString());
if (jsonObject.has(DCRConstants.ClientMetadata.OAUTH_REDIRECT_URIS)) {
oAuthApplicationInfo.addParameter(DCRConstants.ClientMetadata.OAUTH_REDIRECT_URIS,
jsonObject
.get(DCRConstants.ClientMetadata.OAUTH_REDIRECT_URIS));
}
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(
"Can not retrieve information of the created OAuth application", e);
}
return oAuthApplicationInfo;
}
private OAuthApplicationInfo createOAuthApplication(
RegistrationProfile profile) throws DynamicClientRegistrationException, IdentityException {
//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;
}
String tenantDomain = MultitenantUtils.getTenantDomain(userId);
String baseUser = CarbonContext.getThreadLocalCarbonContext().getUsername();
String userName = MultitenantUtils.getTenantAwareUsername(userId);
PrivilegedCarbonContext.startTenantFlow();
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenantDomain, true);
// Acting as the provided user. When creating Service Provider/OAuth App,
// username is fetched from CarbonContext
PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(userName);
try {
// Append the username before Application name to make application name unique across two users.
applicationName = replaceInvalidChars(userName) + "_" + applicationName;
// Create the Service Provider
ServiceProvider serviceProvider = new ServiceProvider();
serviceProvider.setApplicationName(applicationName);
User user = new User();
user.setUserName(userName);
user.setTenantDomain(tenantDomain);
serviceProvider.setOwner(user);
serviceProvider.setDescription("Service Provider for application " + applicationName);
ApplicationManagementService appMgtService = DynamicClientRegistrationDataHolder.getInstance().
getApplicationManagementService();
if (appMgtService == null) {
throw new IllegalStateException("Error occurred while retrieving Application Management" + "Service");
}
ServiceProvider existingServiceProvider = appMgtService.getServiceProvider(applicationName, tenantDomain);
if (existingServiceProvider == null) {
appMgtService.createApplication(serviceProvider, tenantDomain, userName);
}
ServiceProvider createdServiceProvider = appMgtService.getServiceProvider(applicationName, tenantDomain);
if (createdServiceProvider == null) {
throw new DynamicClientRegistrationException("Couldn't create Service Provider Application " +
applicationName);
}
//Set SaaS app option
createdServiceProvider.setSaasApp(isSaaSApp);
// Then Create OAuthApp
OAuthAdminService oAuthAdminService = new OAuthAdminService();
OAuthConsumerAppDTO oAuthConsumerApp = new OAuthConsumerAppDTO();
oAuthConsumerApp.setApplicationName(applicationName);
oAuthConsumerApp.setCallbackUrl(callbackUrl);
oAuthConsumerApp.setGrantTypes(grantType);
oAuthConsumerApp.setOAuthVersion(OAUTH_VERSION);
if (log.isDebugEnabled()) {
log.debug("Creating OAuth App " + applicationName);
}
if ((existingServiceProvider == null) || (existingServiceProvider.getInboundAuthenticationConfig().
getInboundAuthenticationRequestConfigs().length == 0)) {
oAuthAdminService.registerOAuthApplicationData(oAuthConsumerApp);
}
if (log.isDebugEnabled()) {
log.debug("Created OAuth App " + applicationName);
}
OAuthConsumerAppDTO createdApp =
oAuthAdminService.getOAuthApplicationDataByAppName(oAuthConsumerApp.getApplicationName());
if (log.isDebugEnabled()) {
log.debug("Retrieved Details for OAuth App " + createdApp.getApplicationName());
}
// Set the OAuthApp in InboundAuthenticationConfig
InboundAuthenticationConfig inboundAuthenticationConfig =
new InboundAuthenticationConfig();
List<InboundAuthenticationRequestConfig> inboundAuthenticationRequestConfigs = new ArrayList<>();
InboundAuthenticationRequestConfig inboundAuthenticationRequestConfig = new
InboundAuthenticationRequestConfig();
inboundAuthenticationRequestConfig.setInboundAuthKey(createdApp.getOauthConsumerKey());
inboundAuthenticationRequestConfig.setInboundAuthType(AUTH_TYPE_OAUTH_2);
String oauthConsumerSecret = createdApp.getOauthConsumerSecret();
if (oauthConsumerSecret != null && !oauthConsumerSecret.isEmpty()) {
Property property = new Property();
property.setName(OAUTH_CONSUMER_SECRET);
property.setValue(oauthConsumerSecret);
Property[] properties = {property};
inboundAuthenticationRequestConfig.setProperties(properties);
}
if (APPLICATION_TYPE_WEBAPP.equals(profile.getApplicationType())) {
SAMLSSOServiceProviderDTO samlssoServiceProviderDTO = new SAMLSSOServiceProviderDTO();
samlssoServiceProviderDTO.setIssuer(applicationName);
SAMLSSOConfigAdmin configAdmin = new SAMLSSOConfigAdmin(getConfigSystemRegistry());
configAdmin.addRelyingPartyServiceProvider(samlssoServiceProviderDTO);
InboundAuthenticationRequestConfig samlAuthenticationRequest = new InboundAuthenticationRequestConfig();
samlAuthenticationRequest.setInboundAuthKey(applicationName);
samlAuthenticationRequest.setInboundAuthType(SAML_SSO);
inboundAuthenticationRequestConfigs.add(samlAuthenticationRequest);
}
LocalAuthenticatorConfig localAuth = new LocalAuthenticatorConfig();
localAuth.setName(BASIC_AUTHENTICATOR);
localAuth.setDisplayName(BASIC);
localAuth.setEnabled(true);
AuthenticationStep authStep = new AuthenticationStep();
authStep.setStepOrder(STEP_ORDER);
authStep.setSubjectStep(true);
authStep.setAttributeStep(true);
authStep.setLocalAuthenticatorConfigs(new LocalAuthenticatorConfig[]{localAuth});
LocalAndOutboundAuthenticationConfig localOutboundAuthConfig = new LocalAndOutboundAuthenticationConfig();
localOutboundAuthConfig.setAuthenticationType(LOCAL);
localOutboundAuthConfig.setAuthenticationSteps(new AuthenticationStep[]{authStep});
createdServiceProvider.setLocalAndOutBoundAuthenticationConfig(localOutboundAuthConfig);
inboundAuthenticationRequestConfigs.add(inboundAuthenticationRequestConfig);
inboundAuthenticationConfig
.setInboundAuthenticationRequestConfigs(inboundAuthenticationRequestConfigs.toArray(
new InboundAuthenticationRequestConfig[inboundAuthenticationRequestConfigs.size()]));
createdServiceProvider.setInboundAuthenticationConfig(inboundAuthenticationConfig);
// Update the Service Provider app to add OAuthApp as an Inbound Authentication Config
appMgtService.updateApplication(createdServiceProvider, tenantDomain, userName);
OAuthApplicationInfo oAuthApplicationInfo = new OAuthApplicationInfo();
oAuthApplicationInfo.setClientId(createdApp.getOauthConsumerKey());
oAuthApplicationInfo.setCallBackURL(createdApp.getCallbackUrl());
oAuthApplicationInfo.setClientSecret(oauthConsumerSecret);
oAuthApplicationInfo.setClientName(createdApp.getApplicationName());
oAuthApplicationInfo.addParameter(
DCRConstants.ClientMetadata.OAUTH_REDIRECT_URIS, createdApp.getCallbackUrl());
oAuthApplicationInfo.addParameter(
DCRConstants.ClientMetadata.OAUTH_CLIENT_GRANT, createdApp.getGrantTypes());
return oAuthApplicationInfo;
} catch (IdentityApplicationManagementException e) {
throw new DynamicClientRegistrationException(
"Error occurred while creating ServiceProvider for app " + applicationName, e);
} catch (Exception e) {
throw new DynamicClientRegistrationException(
"Error occurred while creating OAuthApp " + applicationName, e);
} finally {
PrivilegedCarbonContext.endTenantFlow();
PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(baseUser);
}
}
protected Registry getConfigSystemRegistry() {
return (Registry) PrivilegedCarbonContext.getThreadLocalCarbonContext().getRegistry(RegistryType.
SYSTEM_CONFIGURATION);
}
@Override
public boolean unregisterOAuthApplication(String userId, String applicationName, String consumerKey) throws
DynamicClientRegistrationException {
DynamicClientRegistrationUtil.validateUsername(userId);
DynamicClientRegistrationUtil.validateApplicationName(applicationName);
DynamicClientRegistrationUtil.validateConsumerKey(consumerKey);
boolean status = false;
String tenantDomain = MultitenantUtils.getTenantDomain(userId);
String userName = MultitenantUtils.getTenantAwareUsername(userId);
PrivilegedCarbonContext.startTenantFlow();
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenantDomain, true);
PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(userName);
OAuthAdminService oAuthAdminService;
OAuthConsumerAppDTO oAuthConsumerApp;
try {
oAuthAdminService = new OAuthAdminService();
oAuthConsumerApp = oAuthAdminService.getOAuthApplicationData(consumerKey);
} catch (Exception e) {
//We had to catch Exception here because getOAuthApplicationData can throw exceptions of java.lang.Exception
// class.
throw new DynamicClientRegistrationException("Error occurred while retrieving application data", e);
}
if (oAuthConsumerApp == null) {
throw new DynamicClientRegistrationException(
"No OAuth Consumer Application is associated with the given consumer key: " + consumerKey);
}
try {
oAuthAdminService.removeOAuthApplicationData(consumerKey);
ApplicationManagementService appMgtService = DynamicClientRegistrationDataHolder.getInstance().
getApplicationManagementService();
if (appMgtService == null) {
throw new IllegalStateException(
"Error occurred while retrieving Application Management" +
"Service");
}
ServiceProvider createdServiceProvider = appMgtService.getServiceProvider(applicationName, tenantDomain);
if (createdServiceProvider == null) {
throw new DynamicClientRegistrationException(
"Couldn't retrieve Service Provider Application " + applicationName);
}
appMgtService.deleteApplication(applicationName, tenantDomain, userName);
status = true;
} catch (IdentityApplicationManagementException e) {
throw new DynamicClientRegistrationException(
"Error occurred while removing ServiceProvider for application '" + applicationName + "'", e);
} catch (IdentityOAuthAdminException e) {
throw new DynamicClientRegistrationException("Error occurred while removing application '" +
applicationName + "'", e);
} finally {
PrivilegedCarbonContext.endTenantFlow();
}
return status;
}
@Override
public boolean isOAuthApplicationAvailable(String applicationName) throws DynamicClientRegistrationException {
ApplicationManagementService appMgtService = DynamicClientRegistrationDataHolder.getInstance().
getApplicationManagementService();
if (appMgtService == null) {
throw new IllegalStateException(
"Error occurred while retrieving Application Management" +
"Service");
}
try {
return appMgtService.getServiceProvider(applicationName,
CarbonContext.getThreadLocalCarbonContext().getTenantDomain()) !=
null;
} catch (IdentityApplicationManagementException e) {
throw new DynamicClientRegistrationException(
"Error occurred while retrieving information of OAuthApp " + applicationName, e);
}
}
private String replaceInvalidChars(String username) {
return username.replaceAll("@", "_AT_");
}
}

@ -1,51 +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.registration.internal;
import org.wso2.carbon.identity.application.mgt.ApplicationManagementService;
/**
* DataHolder class of DynamicClientRegistration bundle. This hold a reference to
* ApplicationManagementService.
*/
public class DynamicClientRegistrationDataHolder {
private ApplicationManagementService applicationManagementService;
private static DynamicClientRegistrationDataHolder thisInstance =
new DynamicClientRegistrationDataHolder();
private DynamicClientRegistrationDataHolder() {
}
public static DynamicClientRegistrationDataHolder getInstance() {
return thisInstance;
}
public ApplicationManagementService getApplicationManagementService() {
if (applicationManagementService == null) {
throw new IllegalStateException("ApplicationManagementService is not initialized properly");
}
return applicationManagementService;
}
public void setApplicationManagementService(ApplicationManagementService applicationManagementService) {
this.applicationManagementService = applicationManagementService;
}
}

@ -1,84 +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.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.dynamic.client.registration.impl.DynamicClientRegistrationServiceImpl;
import org.wso2.carbon.identity.application.mgt.ApplicationManagementService;
/**
* @scr.component name="org.wso2.carbon.dynamic.client.registration" immediate="true"
* @scr.reference name="identity.application.management.service"
* interface="org.wso2.carbon.identity.application.mgt.ApplicationManagementService"
* cardinality="1..1"
* policy="dynamic"
* bind="setApplicationManagementService"
* unbind="unsetApplicationManagementService"
*/
public class DynamicClientRegistrationServiceComponent {
private static final Log log = LogFactory.getLog(DynamicClientRegistrationServiceComponent.class);
@SuppressWarnings("unused")
protected void activate(ComponentContext componentContext) {
if(log.isDebugEnabled()){
log.debug("Starting DynamicClientRegistrationServiceComponent");
}
componentContext.getBundleContext().registerService(
DynamicClientRegistrationService.class.getName(), new DynamicClientRegistrationServiceImpl(), null);
}
@SuppressWarnings("unused")
protected void deactivate(ComponentContext componentContext) {
if(log.isDebugEnabled()){
log.debug("Stopping DynamicClientRegistrationServiceComponent");
}
}
/**
* Sets ApplicationManagement Service.
*
* @param applicationManagementService An instance of ApplicationManagementService
*/
protected void setApplicationManagementService(ApplicationManagementService
applicationManagementService) {
if (log.isDebugEnabled()) {
log.debug("Setting ApplicationManagement Service");
}
DynamicClientRegistrationDataHolder.getInstance().
setApplicationManagementService(applicationManagementService);
}
/**
* Unsets ApplicationManagement Service.
*
* @param applicationManagementService An instance of ApplicationManagementService
*/
protected void unsetApplicationManagementService(ApplicationManagementService
applicationManagementService) {
if (log.isDebugEnabled()) {
log.debug("Unsetting ApplicationManagement Service");
}
DynamicClientRegistrationDataHolder.getInstance().setApplicationManagementService(null);
}
}

@ -1,207 +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.registration.profile;
/**
*
* DTO class to be used when registering an OAuth application.
*
* */
public class RegistrationProfile {
private String applicationType;
private String[] redirectUris;
private String clientName;
private String logoUri;
private String subjectType;
private String sectorIdentifierUri;
private String tokenEndpointAuthMethod;
private String jwksUri;
private String userInfoEncryptedResponseAlg;
private String userInfoEncryptedResponseEnc;
private String[] contacts;
private String[] requestUris;
private String owner;
private String callbackUrl;
private String tokenScope;
private String grantType;
private boolean saasApp;
private String audience;
private String recepientValidationURL;
private String assertionConsumerURL;
public String getRecepientValidationURL() {
return recepientValidationURL;
}
public void setRecepientValidationURL(String recepientValidationURL) {
this.recepientValidationURL = recepientValidationURL;
}
public String getAssertionConsumerURL() {
return assertionConsumerURL;
}
public void setAssertionConsumerURL(String assertionConsumerURL) {
this.assertionConsumerURL = assertionConsumerURL;
}
public String getAudience() {
return audience;
}
public void setAudience(String audience) {
this.audience = audience;
}
public boolean isSaasApp() {
return saasApp;
}
public void setSaasApp(boolean saasApp) {
this.saasApp = saasApp;
}
public String getApplicationType() {
return applicationType;
}
public void setApplicationType(String applicationType) {
this.applicationType = applicationType;
}
public String[] getRedirectUris() {
return redirectUris;
}
public void setRedirectUris(String[] redirectUris) {
this.redirectUris = redirectUris;
}
public String getClientName() {
return clientName;
}
public void setClientName(String clientName) {
this.clientName = clientName;
}
public String getLogoUri() {
return logoUri;
}
public void setLogoUri(String logoUri) {
this.logoUri = logoUri;
}
public String getSubjectType() {
return subjectType;
}
public void setSubjectType(String subjectType) {
this.subjectType = subjectType;
}
public String getSectorIdentifierUri() {
return sectorIdentifierUri;
}
public void setSectorIdentifierUri(String sectorIdentifierUri) {
this.sectorIdentifierUri = sectorIdentifierUri;
}
public String getTokenEndpointAuthMethod() {
return tokenEndpointAuthMethod;
}
public void setTokenEndpointAuthMethod(String tokenEndpointAuthMethod) {
this.tokenEndpointAuthMethod = tokenEndpointAuthMethod;
}
public String getJwksUri() {
return jwksUri;
}
public void setJwksUri(String jwksUri) {
this.jwksUri = jwksUri;
}
public String getUserInfoEncryptedResponseAlg() {
return userInfoEncryptedResponseAlg;
}
public void setUserInfoEncryptedResponseAlg(String userInfoEncryptedResponseAlg) {
this.userInfoEncryptedResponseAlg = userInfoEncryptedResponseAlg;
}
public String getUserInfoEncryptedResponseEnc() {
return userInfoEncryptedResponseEnc;
}
public void setUserInfoEncryptedResponseEnc(String userInfoEncryptedResponseEnc) {
this.userInfoEncryptedResponseEnc = userInfoEncryptedResponseEnc;
}
public String[] getContacts() {
return contacts;
}
public void setContacts(String[] contacts) {
this.contacts = contacts;
}
public String[] getRequestUris() {
return requestUris;
}
public void setRequestUris(String[] requestUris) {
this.requestUris = requestUris;
}
public String getOwner() {
return owner;
}
public void setOwner(String owner) {
this.owner = owner;
}
public String getCallbackUrl() {
return callbackUrl;
}
public void setCallbackUrl(String callbackUrl) {
this.callbackUrl = callbackUrl;
}
public String getTokenScope() {
return tokenScope;
}
public void setTokenScope(String tokenScope) {
this.tokenScope = tokenScope;
}
public String getGrantType() {
return grantType;
}
public void setGrantType(String grantType) {
this.grantType = grantType;
}
}

@ -1,58 +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.registration.util;
/**
* This class holds the constants used by DynamicClientRegistration component.
*/
public final class DCRConstants {
public static class ClientMetadata {
private ClientMetadata() {
throw new AssertionError();
}
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";
public static final String OAUTH_CALLBACK_URIS = "callback_url";
public static final String OAUTH_CLIENT_NAME = "client_name";
public static final String OAUTH_CLIENT_TYPE = "client_type";
public static final String APP_KEY_TYPE = "key_type";
public static final String APP_CALLBACK_URL = "callback_url";
public static final String APP_HOME_PAGE = "homepage";
public static final String OAUTH_CLIENT_CONTACT = "contact";
public static final String APP_LOGO_URI = "logo_uri";
public static final String OAUTH_CLIENT_SCOPE = "scope";
public static final String OAUTH_CLIENT_GRANT = "grant_types";
public static final String OAUTH_CLIENT_RESPONSETYPE = "response_types";
public static final String OAUTH_CLIENT_AUTHMETHOD = "token_endpoint_auth_method";
public static final String OAUTH_CLIENT_REGISTRATION_CLIENT_URI = "registration_client_uri";
public static final String OAUTH_CLIENT_REGISTRATION_ACCESSTOKEN = "registration_access_token";
public static final String OAUTH_CLIENT_CONTACTS = "contacts";
public static final String OAUTH_CLIENT_MANUAL = "MANUAL";
public static final String OAUTH_CLIENT_PRODUCTION = "PRODUCTION";
public static final String OAUTH_CLIENT_SANDBOX = "SANDBOX";
public static final String OAUTH_CLIENT_NOACCESSTOKEN = "NO ACCESS TOKEN";
public static final String OAUTH_CLIENT_JSONPARAMSTRING = "jsonParams";
public static final String OAUTH_CLIENT_USERNAME = "username";
public static final String OAUTH_CLIENT_APPLICATION = "application";
public static final String VALIDITY_PERIOD = "validityPeriod";
}
}

@ -1,42 +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.registration.util;
/**
* This class holds the util methods used by DCR component.
*/
public class DynamicClientRegistrationUtil {
public static void validateUsername(String username) {
if (username == null || username.isEmpty()) {
throw new IllegalArgumentException("Username cannot be null or empty");
}
}
public static void validateApplicationName(String applicationName) {
if (applicationName == null || applicationName.isEmpty()) {
throw new IllegalArgumentException("Application name cannot be null or empty");
}
}
public static void validateConsumerKey(String consumerKey) {
if (consumerKey == null || consumerKey.isEmpty()) {
throw new IllegalArgumentException("Consumer Key cannot be null or empty");
}
}
}

@ -1,146 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>dynamic-client-registration</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.dynamic.client.web.app.registration</artifactId>
<version>3.0.12-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>WSO2 Carbon - Dynamic client web app registration</name>
<description>WSO2 Carbon - Dynamic Client Web-app Registration Service</description>
<url>http://wso2.org</url>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-scr-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>1.4.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Name>${project.artifactId}</Bundle-Name>
<Bundle-Version>${carbon.device.mgt.version}</Bundle-Version>
<Bundle-Description>Dynamic Client Web App Registration Bundle</Bundle-Description>
<Private-Package>org.wso2.carbon.dynamic.client.web.app.registration.internal</Private-Package>
<Export-Package>
!org.wso2.carbon.dynamic.client.web.app.registration.internal,
org.wso2.carbon.dynamic.client.web.app.registration.*
</Export-Package>
<Import-Package>
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
</Import-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.eclipse.osgi</groupId>
<artifactId>org.eclipse.osgi</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.osgi</groupId>
<artifactId>org.eclipse.osgi.services</artifactId>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.utils</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.identity.framework</groupId>
<artifactId>org.wso2.carbon.identity.application.mgt</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.identity.inbound.auth.oauth2</groupId>
<artifactId>org.wso2.carbon.identity.oauth</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.identity.framework</groupId>
<artifactId>org.wso2.carbon.identity.core</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.tomcat</groupId>
<artifactId>tomcat</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.tomcat</groupId>
<artifactId>tomcat-servlet-api</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.logging</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.user.core</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.registry.core</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.dynamic.client.registration</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
</dependencies>
</project>

@ -1,179 +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.app.registration;
import org.apache.catalina.core.StandardContext;
import org.apache.commons.collections.iterators.IteratorEnumeration;
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.OAuthApplicationInfo;
import org.wso2.carbon.dynamic.client.registration.profile.RegistrationProfile;
import org.wso2.carbon.dynamic.client.web.app.registration.dto.JaggeryOAuthConfigurationSettings;
import org.wso2.carbon.dynamic.client.web.app.registration.dto.OAuthAppDetails;
import org.wso2.carbon.dynamic.client.web.app.registration.util.DynamicClientWebAppRegistrationConstants;
import org.wso2.carbon.dynamic.client.web.app.registration.util.DynamicClientWebAppRegistrationUtil;
import javax.servlet.ServletContext;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
/**
* This class contains the logic to handle the OAuth application creation process.
*/
public class DynamicClientWebAppRegistrationManager {
private static DynamicClientWebAppRegistrationManager dynamicClientWebAppRegistrationManager;
private static Map<String, ServletContext> webAppContexts = new HashMap<>();
private static final Log log = LogFactory.getLog(DynamicClientWebAppRegistrationManager.class);
private DynamicClientWebAppRegistrationManager() {
}
public static DynamicClientWebAppRegistrationManager getInstance() {
if (dynamicClientWebAppRegistrationManager == null) {
synchronized (DynamicClientWebAppRegistrationManager.class) {
if (dynamicClientWebAppRegistrationManager == null) {
dynamicClientWebAppRegistrationManager = new DynamicClientWebAppRegistrationManager();
}
}
}
return dynamicClientWebAppRegistrationManager;
}
public OAuthAppDetails registerOAuthApplication(RegistrationProfile registrationProfile) {
if (log.isDebugEnabled()) {
log.debug("Registering OAuth application for web app : " + registrationProfile.getClientName());
}
if (DynamicClientWebAppRegistrationUtil.validateRegistrationProfile(registrationProfile)) {
try {
OAuthApplicationInfo oAuthApplicationInfo =
DynamicClientWebAppRegistrationUtil.registerOAuthApplication(registrationProfile);
OAuthAppDetails oAuthAppDetails = new OAuthAppDetails();
oAuthAppDetails.setWebAppName(registrationProfile.getClientName());
oAuthAppDetails.setClientName(oAuthApplicationInfo.getClientName());
oAuthAppDetails.setClientKey(oAuthApplicationInfo.getClientId());
oAuthAppDetails.setClientSecret(oAuthApplicationInfo.getClientSecret());
//store it in registry
if (DynamicClientWebAppRegistrationUtil.putOAuthApplicationData(oAuthAppDetails)) {
return oAuthAppDetails;
} else {
DynamicClientWebAppRegistrationUtil.unregisterOAuthApplication(registrationProfile.getOwner(),
oAuthApplicationInfo.getClientName(),
oAuthApplicationInfo.getClientId());
log.warn("Error occurred while persisting the OAuth application data in registry.");
}
} catch (DynamicClientRegistrationException e) {
log.error("Error occurred while registering the OAuth application : " +
registrationProfile.getClientName(), e);
}
}
return null;
}
public OAuthAppDetails 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 null;
}
public boolean isRegisteredOAuthApplication(String clientName) {
OAuthAppDetails oAuthAppDetails = this.getOAuthApplicationData(clientName);
if (oAuthAppDetails != null && (oAuthAppDetails.getClientKey() != null && oAuthAppDetails.getClientSecret() !=
null)) {
return true;
}
return false;
}
public void saveServletContextToCache(StandardContext context) {
DynamicClientWebAppRegistrationManager.webAppContexts.put(context.getBaseName(),
context.getServletContext());
}
public void initiateDynamicClientRegistration() {
String requiredDynamicClientRegistration, webAppName, serviceProviderName;
ServletContext servletContext;
RegistrationProfile registrationProfile;
OAuthAppDetails oAuthAppDetails;
DynamicClientWebAppRegistrationManager dynamicClientWebAppRegistrationManager =
DynamicClientWebAppRegistrationManager.getInstance();
Enumeration enumeration = new IteratorEnumeration(DynamicClientWebAppRegistrationManager.
webAppContexts.keySet().iterator());
if (log.isDebugEnabled()) {
log.debug("Initiating the DynamicClientRegistration service for web-apps");
}
while (enumeration.hasMoreElements()) {
oAuthAppDetails = new OAuthAppDetails();
webAppName = (String) enumeration.nextElement();
serviceProviderName = DynamicClientWebAppRegistrationUtil.replaceInvalidChars(DynamicClientWebAppRegistrationUtil.getUserName())
+ "_" + webAppName;
servletContext = DynamicClientWebAppRegistrationManager.webAppContexts.get(webAppName);
requiredDynamicClientRegistration = servletContext.getInitParameter(
DynamicClientWebAppRegistrationConstants.DYNAMIC_CLIENT_REQUIRED_FLAG);
//Java web-app section
if ((requiredDynamicClientRegistration != null) && (Boolean.parseBoolean(
requiredDynamicClientRegistration))) {
//Check whether this is an already registered application
if (!dynamicClientWebAppRegistrationManager.isRegisteredOAuthApplication(serviceProviderName)) {
//Construct the RegistrationProfile
registrationProfile = DynamicClientWebAppRegistrationUtil.
constructRegistrationProfile(servletContext, webAppName);
//Register the OAuth application
oAuthAppDetails =
dynamicClientWebAppRegistrationManager.registerOAuthApplication(registrationProfile);
} else {
oAuthAppDetails = dynamicClientWebAppRegistrationManager.getOAuthApplicationData(webAppName);
}
} else if (requiredDynamicClientRegistration == null) {
//Jaggery apps
JaggeryOAuthConfigurationSettings jaggeryOAuthConfigurationSettings =
DynamicClientWebAppRegistrationUtil.getJaggeryAppOAuthSettings(servletContext);
if (jaggeryOAuthConfigurationSettings.isRequireDynamicClientRegistration()) {
if (!dynamicClientWebAppRegistrationManager.isRegisteredOAuthApplication(serviceProviderName)) {
registrationProfile = DynamicClientWebAppRegistrationUtil.
constructRegistrationProfile(jaggeryOAuthConfigurationSettings,
webAppName);
oAuthAppDetails = dynamicClientWebAppRegistrationManager.
registerOAuthApplication(registrationProfile);
} else {
oAuthAppDetails = dynamicClientWebAppRegistrationManager.getOAuthApplicationData(webAppName);
}
}
}
//Add client credentials to the web-context
if ((oAuthAppDetails != null && oAuthAppDetails.getClientKey() != null) &&
!oAuthAppDetails.getClientKey().isEmpty()) {
DynamicClientWebAppRegistrationUtil.addClientCredentialsToWebContext(oAuthAppDetails,
servletContext);
if (log.isDebugEnabled()) {
log.debug("Added OAuth application credentials to webapp context of webapp : " +
webAppName);
}
}
}
}
}

@ -1,38 +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.app.registration;
import org.wso2.carbon.core.ServerStartupObserver;
/**
* ServerStartupObserver implementation to initiate the DynamicClientRegistration process for web
* apps after the Carbon server is up and ready.
*/
public class WebAppRegistrationServerStartupObserver implements ServerStartupObserver {
@Override
public void completingServerStartup() {
}
@Override
public void completedServerStartup() {
DynamicClientWebAppRegistrationManager.getInstance().initiateDynamicClientRegistration();
}
}

@ -1,44 +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.app.registration.dto;
/**
* Represents Configuration setting related to OAuth in authenticators.xml.
*/
public class DynamicClientRegistrationSettings {
private boolean isRemote;
private String host;
public boolean isRemote() {
return isRemote;
}
public void setIsRemote(boolean isRemote) {
this.isRemote = isRemote;
}
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
}

@ -1,110 +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.app.registration.dto;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
/**
* Represents OAuthConfiguration data required to create OAuth service provider for Jaggery apps.
*/
@XmlRootElement(name = "OAuthSettings")
public class JaggeryOAuthConfigurationSettings {
private String grantType;
private boolean saasApp;
private String callbackURL;
private String tokenScope;
private boolean requireDynamicClientRegistration;
private String audience;
private String assertionConsumerURL;
private String recepientValidationURL;
@XmlElement(name = "assertionConsumerURL", required = true)
public String getAssertionConsumerURL() {
return assertionConsumerURL;
}
public void setAssertionConsumerURL(String assertionConsumerURL) {
this.assertionConsumerURL = assertionConsumerURL;
}
@XmlElement(name = "recepientValidationURL", required = true)
public String getRecepientValidationURL() {
return recepientValidationURL;
}
public void setRecepientValidationURL(String recepientValidationURL) {
this.recepientValidationURL = recepientValidationURL;
}
@XmlElement(name = "audience", required = true)
public String getAudience() {
return audience;
}
public void setAudience(String audience) {
this.audience = audience;
}
@XmlElement(name = "saasApp", required = true)
public boolean isSaasApp() {
return saasApp;
}
public void setSaasApp(boolean saasApp) {
this.saasApp = saasApp;
}
@XmlElement(name = "callbackURL", required = false)
public String getCallbackURL() {
return callbackURL;
}
public void setCallbackURL(String callbackURL) {
this.callbackURL = callbackURL;
}
@XmlElement(name = "tokenScope", required = false)
public String getTokenScope() {
return tokenScope;
}
public void setTokenScope(String tokenScope) {
this.tokenScope = tokenScope;
}
@XmlElement(name = "grantType", required = true)
public String getGrantType() {
return grantType;
}
public void setGrantType(String grantType) {
this.grantType = grantType;
}
@XmlElement(name = "requireDynamicClientRegistration", required = true)
public boolean isRequireDynamicClientRegistration() {
return requireDynamicClientRegistration;
}
public void setRequireDynamicClientRegistration(boolean requireDynamicClientRegistration) {
this.requireDynamicClientRegistration = requireDynamicClientRegistration;
}
}

@ -1,70 +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.app.registration.dto;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
/**
* Represents an OAuth application with basic necessary data.
*/
@XmlRootElement(name = "OAuthAppDetails")
public class OAuthAppDetails {
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;
}
}

@ -1,97 +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.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;
import org.wso2.carbon.utils.ConfigurationContextService;
/**
* Dataholder class of DynamicClient Webapp Registration component.
*/
public class DynamicClientWebAppRegistrationDataHolder {
private RealmService realmService;
private RegistryService registryService;
private DynamicClientRegistrationService dynamicClientRegistrationService;
private ConfigurationContextService configurationContextService;
private static DynamicClientWebAppRegistrationDataHolder thisInstance =
new DynamicClientWebAppRegistrationDataHolder();
private DynamicClientWebAppRegistrationDataHolder() {
}
public static DynamicClientWebAppRegistrationDataHolder getInstance() {
return thisInstance;
}
public ConfigurationContextService getConfigurationContextService() {
if (configurationContextService != null) {
return configurationContextService;
} else {
throw new IllegalStateException(
"ConfigurationContext service has not initialized properly");
}
}
public void setConfigurationContextService(
ConfigurationContextService configurationContextService) {
this.configurationContextService = configurationContextService;
}
public DynamicClientRegistrationService getDynamicClientRegistrationService() {
if (dynamicClientRegistrationService != null) {
return dynamicClientRegistrationService;
} else {
throw new IllegalStateException(
"DynamicClientRegistration service has not initialized properly");
}
}
public void setDynamicClientRegistrationService(
DynamicClientRegistrationService dynamicClientRegistrationService) {
this.dynamicClientRegistrationService = dynamicClientRegistrationService;
}
public RealmService getRealmService() {
if (realmService != null) {
return realmService;
} else {
throw new IllegalStateException("RealmService has not initialized properly");
}
}
public void setRealmService(RealmService realmService) {
this.realmService = realmService;
}
public RegistryService getRegistryService() {
if (registryService != null) {
return registryService;
} else {
throw new IllegalStateException("Registry Service has not initialized properly");
}
}
public void setRegistryService(RegistryService registryService) {
this.registryService = registryService;
}
}

@ -1,176 +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.app.registration.internal;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.osgi.service.component.ComponentContext;
import org.osgi.util.tracker.ServiceTracker;
import org.wso2.carbon.core.ServerStartupObserver;
import org.wso2.carbon.dynamic.client.registration.DynamicClientRegistrationService;
import org.wso2.carbon.dynamic.client.web.app.registration.WebAppRegistrationServerStartupObserver;
import org.wso2.carbon.registry.core.service.RegistryService;
import org.wso2.carbon.user.core.service.RealmService;
import org.wso2.carbon.utils.ConfigurationContextService;
/**
* @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"
* @scr.reference name="config.context.service"
* interface="org.wso2.carbon.utils.ConfigurationContextService"
* cardinality="0..1"
* policy="dynamic"
* bind="setConfigurationContextService"
* unbind="unsetConfigurationContextService"
*/
public class DynamicClientWebAppRegistrationServiceComponent {
private static Log log =
LogFactory.getLog(DynamicClientWebAppRegistrationServiceComponent.class);
@SuppressWarnings("unused")
protected void activate(ComponentContext componentContext) {
componentContext.getBundleContext().registerService(ServerStartupObserver.class.getName(),
new WebAppRegistrationServerStartupObserver(), null);
}
@SuppressWarnings("unused")
protected void deactivate(ComponentContext componentContext) {
}
/**
* Sets Realm Service.
*
* @param realmService An instance of RealmService
*/
protected void setRealmService(RealmService realmService) {
if (log.isDebugEnabled()) {
log.debug("Setting Realm Service");
}
DynamicClientWebAppRegistrationDataHolder.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");
}
DynamicClientWebAppRegistrationDataHolder.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");
}
DynamicClientWebAppRegistrationDataHolder.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");
}
DynamicClientWebAppRegistrationDataHolder.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");
}
DynamicClientWebAppRegistrationDataHolder.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");
}
DynamicClientWebAppRegistrationDataHolder.getInstance().setDynamicClientRegistrationService(null);
}
/**
* Sets ConfigurationContext Service.
*
* @param configurationContextService An instance of ConfigurationContextService
*/
protected void setConfigurationContextService(
ConfigurationContextService configurationContextService) {
if (log.isDebugEnabled()) {
log.debug("Setting ConfigurationContextService");
}
DynamicClientWebAppRegistrationDataHolder.getInstance().setConfigurationContextService(
configurationContextService);
}
/**
* Unsets ConfigurationContext Service.
*
* @param configurationContextService An instance of ConfigurationContextService
*/
protected void unsetConfigurationContextService(
ConfigurationContextService configurationContextService) {
if (log.isDebugEnabled()) {
log.debug("Un-setting ConfigurationContextService");
}
DynamicClientWebAppRegistrationDataHolder.getInstance().setConfigurationContextService(null);
}
}

@ -1,46 +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.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.web.app.registration.DynamicClientWebAppRegistrationManager;
/**
* 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();
DynamicClientWebAppRegistrationManager.getInstance().saveServletContextToCache(context);
}
}
}

@ -1,69 +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.app.registration.util;
/**
* Holds the constants to be used in Dynamic client web app registration component.
*/
public class DynamicClientWebAppRegistrationConstants {
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 =
"requireDynamicClientRegistration";
public static final class ContentTypes {
private ContentTypes() {
throw new AssertionError();
}
public static final String CONTENT_TYPE_ANY = "*/*";
public static final String CONTENT_TYPE_XML = "application/xml";
public static final String CONTENT_TYPE_APPLICATION_JSON = "application/json";
}
public static final class CharSets {
private CharSets() {
throw new AssertionError();
}
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";
}
}

@ -1,382 +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.app.registration.util;
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;
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 org.wso2.carbon.utils.ConfigurationContextService;
import org.wso2.carbon.utils.NetworkUtils;
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.*;
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 = "grantType";
private final static String OAUTH_PARAM_TOKEN_SCOPE = "tokenScope";
private final static String OAUTH_PARAM_SAAS_APP = "saasApp";
private final static String OAUTH_PARAM_CALLBACK_URL = "callbackURL";
private final static String AUDIENCE = "audience";
private final static String ASSERTION_CONSUMER_URL = "assertionConsumerURL";
private final static String RECEPIENT_VALIDATION_URL = "recepientValidationURL";
private static final String JAGGERY_APP_OAUTH_CONFIG_PATH =
"config" + File.separator + "service-provider.json";
private static final Log log =
LogFactory.getLog(DynamicClientWebAppRegistrationUtil.class);
private static final String CHARSET_UTF_8 = "UTF-8";
public static Registry getGovernanceRegistry() throws DynamicClientRegistrationException {
try {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
return DynamicClientWebAppRegistrationDataHolder.getInstance().getRegistryService().
getGovernanceSystemRegistry(tenantId);
} catch (RegistryException e) {
throw new DynamicClientRegistrationException(
"Error in retrieving governance registry instance: " +
e.getMessage(), e);
}
}
public static OAuthAppDetails getOAuthApplicationData(String appName)
throws DynamicClientRegistrationException {
Resource resource;
String resourcePath = DynamicClientWebAppRegistrationConstants.OAUTH_APP_DATA_REGISTRY_PATH + "/" + appName;
try {
if (log.isDebugEnabled()) {
log.debug("Retrieving OAuth application " + appName + " data from Registry");
}
resource = DynamicClientWebAppRegistrationUtil.getRegistryResource(resourcePath);
if (resource != null) {
JAXBContext context = JAXBContext.newInstance(OAuthAppDetails.class);
Unmarshaller unmarshaller = context.createUnmarshaller();
return (OAuthAppDetails) unmarshaller.unmarshal(
new StringReader(new String((byte[]) resource.getContent(), Charset.forName(
DynamicClientWebAppRegistrationConstants.CharSets.CHARSET_UTF8))));
}
return new OAuthAppDetails();
} 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(OAuthAppDetails oAuthAppDetails) throws
DynamicClientRegistrationException {
boolean status;
try {
if (log.isDebugEnabled()) {
log.debug("Persisting OAuth application data in Registry");
}
StringWriter writer = new StringWriter();
JAXBContext context = JAXBContext.newInstance(OAuthAppDetails.class);
Marshaller marshaller = context.createMarshaller();
marshaller.marshal(oAuthAppDetails, writer);
Resource resource = DynamicClientWebAppRegistrationUtil.getGovernanceRegistry().newResource();
resource.setContent(writer.toString());
resource.setMediaType(DynamicClientWebAppRegistrationConstants.ContentTypes.CONTENT_TYPE_XML);
String resourcePath = DynamicClientWebAppRegistrationConstants.OAUTH_APP_DATA_REGISTRY_PATH + "/" +
oAuthAppDetails.getClientName();
status = DynamicClientWebAppRegistrationUtil.putRegistryResource(resourcePath, resource);
} catch (RegistryException e) {
throw new DynamicClientRegistrationException(
"Error occurred while persisting OAuth application data : " +
oAuthAppDetails.getClientName(), e);
} catch (JAXBException e) {
throw new DynamicClientRegistrationException(
"Error occurred while parsing the OAuth application data : " +
oAuthAppDetails.getWebAppName(), e);
}
return status;
}
public static boolean putRegistryResource(String path, Resource resource) throws DynamicClientRegistrationException {
try {
Registry governanceRegistry = DynamicClientWebAppRegistrationUtil.getGovernanceRegistry();
governanceRegistry.beginTransaction();
governanceRegistry.put(path, resource);
governanceRegistry.commitTransaction();
return true;
} catch (RegistryException e) {
throw new DynamicClientRegistrationException("Error occurred while persisting registry resource : " +
e.getMessage(), e);
}
}
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 = DynamicClientWebAppRegistrationDataHolder.getInstance().getRealmService();
if (realmService != null) {
username = realmService.getBootstrapRealmConfiguration().getAdminUserName();
}
return username;
}
public static RegistrationProfile constructRegistrationProfile(ServletContext servletContext, String webAppName) {
RegistrationProfile 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());
String callbackURL = servletContext.getInitParameter(
DynamicClientWebAppRegistrationUtil.OAUTH_PARAM_CALLBACK_URL);
if ((callbackURL != null) && !callbackURL.isEmpty()) {
registrationProfile.setCallbackUrl(callbackURL);
} else {
registrationProfile.setCallbackUrl(DynamicClientWebAppRegistrationUtil.getCallbackUrl(webAppName));
}
registrationProfile.setClientName(webAppName);
registrationProfile.setSaasApp(Boolean.parseBoolean(servletContext.getInitParameter(
DynamicClientWebAppRegistrationUtil.OAUTH_PARAM_SAAS_APP)));
return registrationProfile;
}
public static RegistrationProfile constructRegistrationProfile(JaggeryOAuthConfigurationSettings
jaggeryOAuthConfigurationSettings, String webAppName) {
RegistrationProfile registrationProfile = new RegistrationProfile();
if (jaggeryOAuthConfigurationSettings != null) {
registrationProfile.setGrantType(jaggeryOAuthConfigurationSettings.getGrantType());
registrationProfile.setTokenScope(jaggeryOAuthConfigurationSettings.getTokenScope());
registrationProfile.setClientName(webAppName);
registrationProfile.setSaasApp(jaggeryOAuthConfigurationSettings.isSaasApp());
registrationProfile.setOwner(DynamicClientWebAppRegistrationUtil.getUserName());
registrationProfile.setAudience(jaggeryOAuthConfigurationSettings.getAudience());
registrationProfile.setAssertionConsumerURL(jaggeryOAuthConfigurationSettings.getAssertionConsumerURL());
registrationProfile.setRecepientValidationURL(jaggeryOAuthConfigurationSettings.getRecepientValidationURL());
if (jaggeryOAuthConfigurationSettings.getCallbackURL() != null) {
registrationProfile.setCallbackUrl(jaggeryOAuthConfigurationSettings.getCallbackURL());
} else {
registrationProfile.setCallbackUrl(DynamicClientWebAppRegistrationUtil.getCallbackUrl(webAppName));
}
} else {
log.warn("Please configure OAuth settings properly for jaggery app : " + webAppName);
}
return registrationProfile;
}
public static boolean validateRegistrationProfile(RegistrationProfile registrationProfile) {
boolean status = true;
//todo fix this
if (registrationProfile.getGrantType() == null) {
status = false;
log.warn("Required parameter 'grantType' is missing for initiating Dynamic-Client " +
"registration for webapp : " + registrationProfile.getClientName());
}
if (registrationProfile.getTokenScope() == null) {
status = false;
log.warn("Required parameter 'tokenScope' is missing for initiating Dynamic-Client " +
"registration for webapp : " + registrationProfile.getClientName());
}
return status;
}
public static JaggeryOAuthConfigurationSettings getJaggeryAppOAuthSettings(ServletContext servletContext) {
JaggeryOAuthConfigurationSettings jaggeryOAuthConfigurationSettings = new JaggeryOAuthConfigurationSettings();
try {
InputStream inputStream = servletContext.getResourceAsStream(JAGGERY_APP_OAUTH_CONFIG_PATH);
if (inputStream != null) {
JsonReader reader = new JsonReader(new InputStreamReader(inputStream, CHARSET_UTF_8));
reader.beginObject();
while (reader.hasNext()) {
String key = reader.nextName();
switch (key) {
case DynamicClientWebAppRegistrationConstants.DYNAMIC_CLIENT_REQUIRED_FLAG:
jaggeryOAuthConfigurationSettings.setRequireDynamicClientRegistration(reader.nextBoolean());
break;
case DynamicClientWebAppRegistrationUtil.OAUTH_PARAM_GRANT_TYPE:
jaggeryOAuthConfigurationSettings.setGrantType(reader.nextString());
break;
case DynamicClientWebAppRegistrationUtil.OAUTH_PARAM_TOKEN_SCOPE:
jaggeryOAuthConfigurationSettings.setTokenScope(reader.nextString());
break;
case DynamicClientWebAppRegistrationUtil.OAUTH_PARAM_SAAS_APP:
jaggeryOAuthConfigurationSettings.setSaasApp(reader.nextBoolean());
break;
case DynamicClientWebAppRegistrationUtil.OAUTH_PARAM_CALLBACK_URL:
jaggeryOAuthConfigurationSettings.setCallbackURL(reader.nextString());
break;
case DynamicClientWebAppRegistrationUtil.AUDIENCE:
jaggeryOAuthConfigurationSettings.setAudience(reader.nextString());
break;
case DynamicClientWebAppRegistrationUtil.ASSERTION_CONSUMER_URL:
jaggeryOAuthConfigurationSettings.setAssertionConsumerURL(reader.nextString());
break;
case DynamicClientWebAppRegistrationUtil.RECEPIENT_VALIDATION_URL:
jaggeryOAuthConfigurationSettings.setRecepientValidationURL(reader.nextString());
break;
}
}
return jaggeryOAuthConfigurationSettings;
}
} catch (UnsupportedEncodingException e) {
log.error("Error occurred while initializing OAuth settings for the Jaggery app.", e);
} catch (IOException e) {
log.error("Error occurred while initializing OAuth settings for the Jaggery app.", e);
}
return jaggeryOAuthConfigurationSettings;
}
public static String getServerBaseUrl() {
// Hostname
String hostName = "localhost";
try {
hostName = NetworkUtils.getMgtHostName();
} catch (Exception ignored) {
}
// 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 "https://" + hostName + ":" + port;
}
public static String getCallbackUrl(String context) {
return getServerBaseUrl() + "/" + context;
}
public static void addClientCredentialsToWebContext(OAuthAppDetails oAuthAppDetails,
ServletContext servletContext) {
if (oAuthAppDetails != null) {
//Check for client credentials
if ((oAuthAppDetails.getClientKey() != null && !oAuthAppDetails.getClientKey().isEmpty()) &&
(oAuthAppDetails.getClientSecret() != null && !oAuthAppDetails.getClientSecret().isEmpty())) {
servletContext.setAttribute(DynamicClientWebAppRegistrationConstants.OAUTH_CLIENT_KEY,
oAuthAppDetails.getClientKey());
servletContext.setAttribute(DynamicClientWebAppRegistrationConstants.OAUTH_CLIENT_SECRET,
oAuthAppDetails.getClientSecret());
} else {
log.warn("Client credentials not found for web app : " + oAuthAppDetails.getWebAppName());
}
}
}
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;
}
}

@ -1,196 +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.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) {
String msg = "Backend server error occurred while invoking DCR endpoint for " +
"registering service-provider upon web-app : '" + clientName + "'; Server returned response '" +
responseString + "' with HTTP status code '" + status + "'";
throw new DynamicClientRegistrationException(msg);
}
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 {
if (httpClient != null) {
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 {
if (httpClient != null) {
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;
}
}

@ -1,43 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>identity-extensions</artifactId>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>dynamic-client-registration</artifactId>
<version>3.0.12-SNAPSHOT</version>
<packaging>pom</packaging>
<name>WSO2 Carbon - Dynamic client registration</name>
<url>http://wso2.org</url>
<modules>
<module>dynamic-client-web</module>
<module>dynamic-client-web-proxy</module>
<module>org.wso2.carbon.dynamic.client.registration</module>
<module>org.wso2.carbon.dynamic.client.web.app.registration</module>
</modules>
</project>

@ -22,13 +22,13 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>identity-extensions</artifactId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.device.mgt.oauth.extensions</artifactId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>WSO2 Carbon - OAuth Extensions</name>
<url>http://wso2.org</url>

@ -21,7 +21,7 @@
<parent>
<artifactId>identity-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

@ -22,7 +22,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>identity-extensions</artifactId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -22,7 +22,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
@ -30,14 +30,13 @@
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>identity-extensions</artifactId>
<packaging>pom</packaging>
<name>WSO2 Carbon - Dynamic Client Registration Component</name>
<name>WSO2 Carbon - Identity Extensions Component</name>
<url>http://wso2.org</url>
<modules>
<module>org.wso2.carbon.identity.authenticator.backend.oauth</module>
<module>org.wso2.carbon.device.mgt.oauth.extensions</module>
<module>org.wso2.carbon.identity.jwt.client.extension</module>
<module>dynamic-client-registration</module>
</modules>
</project>

@ -22,14 +22,14 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>policy-mgt</artifactId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.complex.policy.decision.point</artifactId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>WSO2 Carbon - Policy Decision Point</name>
<description>WSO2 Carbon - Policy Decision Point</description>

@ -3,14 +3,14 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>policy-mgt</artifactId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.policy.decision.point</artifactId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>WSO2 Carbon - Policy Decision Point</name>
<description>WSO2 Carbon - Policy Decision Point</description>

@ -3,7 +3,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>policy-mgt</artifactId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
@ -11,7 +11,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.policy.information.point</artifactId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>WSO2 Carbon - Policy Information Point</name>
<description>WSO2 Carbon - Policy Information Point</description>

@ -22,14 +22,14 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>policy-mgt</artifactId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.policy.mgt.common</artifactId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>WSO2 Carbon - Policy Management Common</name>
<description>WSO2 Carbon - Policy Management Common</description>

@ -22,14 +22,14 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>policy-mgt</artifactId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.policy.mgt.core</artifactId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>WSO2 Carbon - Policy Management Core</name>
<description>WSO2 Carbon - Policy Management Core</description>

@ -23,13 +23,13 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>policy-mgt</artifactId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<packaging>pom</packaging>
<name>WSO2 Carbon - Policy Management Component</name>
<url>http://wso2.org</url>

@ -21,14 +21,14 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>webapp-authenticator-framework</artifactId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.webapp.authenticator.framework</artifactId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>WSO2 Carbon - Web Application Authenticator Framework Bundle</name>
<description>WSO2 Carbon - Web Application Authenticator Framework Bundle</description>

@ -22,14 +22,14 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>webapp-authenticator-framework</artifactId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<packaging>pom</packaging>
<name>WSO2 Carbon - Webapp Authenticator Framework</name>
<url>http://wso2.org</url>

@ -21,14 +21,14 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>apimgt-extensions-feature</artifactId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.application.extension.feature</artifactId>
<packaging>pom</packaging>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<name>WSO2 Carbon - API Management Application Extension Feature</name>
<url>http://wso2.org</url>
<description>This feature contains an implementation of a api application registration, which takes care of subscription

@ -22,14 +22,14 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>apimgt-extensions-feature</artifactId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.handler.server.feature</artifactId>
<packaging>pom</packaging>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<name>WSO2 Carbon - Device Management - APIM handler Server Feature</name>
<url>http://wso2.org</url>
<description>This feature contains the handler for the api authentications

@ -21,13 +21,13 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>apimgt-extensions-feature</artifactId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.integration.client.feature</artifactId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<packaging>pom</packaging>
<name>WSO2 Carbon - APIM Integration Client Feature</name>
<url>http://wso2.org</url>

@ -21,14 +21,14 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>apimgt-extensions-feature</artifactId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.webapp.publisher.feature</artifactId>
<packaging>pom</packaging>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<name>WSO2 Carbon - API Management Webapp Publisher Feature</name>
<url>http://wso2.org</url>
<description>This feature contains an implementation of a Tomcat lifecycle listener, which takes care of publishing

@ -22,14 +22,14 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>apimgt-extensions-feature</artifactId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<packaging>pom</packaging>
<name>WSO2 Carbon - API Management Extensions Feature</name>
<url>http://wso2.org</url>

@ -22,7 +22,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>certificate-mgt-feature</artifactId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -22,7 +22,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>certificate-mgt-feature</artifactId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -22,14 +22,14 @@
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>certificate-mgt-feature</artifactId>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.certificate.mgt.server.feature</artifactId>
<packaging>pom</packaging>
<version>3.0.12-SNAPSHOT</version>
<version>3.0.14-SNAPSHOT</version>
<name>WSO2 Carbon - Certificate Management Server Feature</name>
<url>http://wso2.org</url>
<description>This feature contains the core bundles required for back-end Certificate Management functionality

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save