diff --git a/product/modules/distribution/pom.xml b/product/modules/distribution/pom.xml
index 45758abc6..6db365a13 100644
--- a/product/modules/distribution/pom.xml
+++ b/product/modules/distribution/pom.xml
@@ -29,10 +29,10 @@
4.0.0
- wso2cdm
+ wso2mdmjar
- WSO2 Connected Device Manager (CDM) - Distribution
- WSO2 Connected Device Manager (CDM) Distribution
+ WSO2 Mobile Device Manager (MDM) - Distribution
+ WSO2 Mobile Device Manager (MDM) Distribution
@@ -213,18 +213,18 @@
-
-
-
+
+
+
-
+
+ dir="${tempdir}/wso2mdm-${project.version}/repository/components">
target/site
- wso2cdm-${project.version}/docs
+ wso2mdm-${project.version}/docs755
@@ -109,7 +109,7 @@
src/repository/conf
- wso2cdm-${project.version}/repository/conf
+ wso2mdm-${project.version}/repository/conf**/api-manager.xml**/sso-idp-config.xml
@@ -120,7 +120,7 @@
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/security/
- wso2cdm-${project.version}/repository/conf/security/
+ wso2mdm-${project.version}/repository/conf/security/**/entitlement.properties**/trusted-idp-config.xml
@@ -131,12 +131,12 @@
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/resources/rxts/
- wso2cdm-${project.version}/repository/resources/rxts/
+ wso2mdm-${project.version}/repository/resources/rxts/src/repository/conf/datasources
- wso2cdm-${project.version}/repository/conf/datasources
+ wso2mdm-${project.version}/repository/conf/datasources
**/master-datasources.xml
@@ -145,7 +145,7 @@
src/repository/resources
- wso2cdm-${project.version}/repository/resources
+ wso2mdm-${project.version}/repository/resources*/**
@@ -153,7 +153,7 @@
src/repository/conf/data-bridge
- wso2cdm-${project.version}/repository/conf/data-bridge
+ wso2mdm-${project.version}/repository/conf/data-bridge
755
@@ -161,7 +161,7 @@
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/lib/runtimes
- wso2cdm-${project.version}/lib/runtimes/
+ wso2mdm-${project.version}/lib/runtimes/*/**
@@ -170,7 +170,7 @@
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/dbscripts/service-provider
- wso2cdm-${project.version}/dbscripts/service-provider
+ wso2mdm-${project.version}/dbscripts/service-provider*/**
@@ -181,7 +181,7 @@
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/dbscripts/identity
- wso2cdm-${project.version}/dbscripts/identity
+ wso2mdm-${project.version}/dbscripts/identity*/**
@@ -192,7 +192,7 @@
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/dbscripts/apimgt
- wso2cdm-${project.version}/dbscripts/apimgt
+ wso2mdm-${project.version}/dbscripts/apimgt*/**
@@ -202,7 +202,7 @@
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/modules
- wso2cdm-${project.version}/modules/
+ wso2mdm-${project.version}/modules/*/**
@@ -211,7 +211,7 @@
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/dbscripts/cdm
- wso2cdm-${project.version}/dbscripts/cdm
+ wso2mdm-${project.version}/dbscripts/cdm*/**
@@ -226,7 +226,7 @@
src/repository/jaggeryapps
- wso2cdm-${project.version}/repository/deployment/server/jaggeryapps
+ wso2mdm-${project.version}/repository/deployment/server/jaggeryapps
755
@@ -234,13 +234,13 @@
- wso2cdm-${project.version}/lib/endorsed
+ wso2mdm-${project.version}/lib/endorsedjavax.el:el-api:jar
- wso2cdm-${project.version}/repository/deployment/client/modules
+ wso2mdm-${project.version}/repository/deployment/client/modules
org.hibernate.wso2:hibernate:jar
@@ -252,13 +252,13 @@
- wso2cdm-${pom.version}/repository/deployment/server/webapps
+ wso2mdm-${pom.version}/repository/deployment/server/webapps
755
- wso2cdm-${pom.version}/repository/deployment/server/webapps
+ wso2mdm-${pom.version}/repository/deployment/server/webapps
755
@@ -280,7 +280,7 @@
-->
- wso2cdm-${project.version}/repository/conf/tomcat
+ wso2mdm-${project.version}/repository/conf/tomcattrue644
@@ -294,37 +294,37 @@
- wso2cdm-${project.version}
+ wso2mdm-${project.version}true644
- wso2cdm-${project.version}
+ wso2mdm-${project.version}true644
- wso2cdm-${project.version}
+ wso2mdm-${project.version}true644
- wso2cdm-${project.version}
+ wso2mdm-${project.version}true644
- wso2cdm-${project.version}/bin/
+ wso2mdm-${project.version}/bin/true644
- wso2cdm-${project.version}/bin/
+ wso2mdm-${project.version}/bin/true644
@@ -334,7 +334,7 @@
- wso2cdm-${project.version}/repository/conf/etc
+ wso2mdm-${project.version}/repository/conf/etctrue644
@@ -344,7 +344,7 @@
- wso2cdm-${project.version}/repository/conf
+ wso2mdm-${project.version}/repository/conftrue644
@@ -354,7 +354,7 @@
- wso2cdm-${project.version}/repository/conf/security
+ wso2mdm-${project.version}/repository/conf/securitytrue644
@@ -364,14 +364,14 @@
- wso2cdm-${project.version}/repository/conf
+ wso2mdm-${project.version}/repository/conftrue644
- wso2cdm-${project.version}/repository/conf/multitenancy/
+ wso2mdm-${project.version}/repository/conf/multitenancy/
true
@@ -383,19 +383,19 @@
-->
- wso2cdm-${project.version}/repository/conf/security/
+ wso2mdm-${project.version}/repository/conf/security/true644
- wso2cdm-${project.version}/repository/conf/
+ wso2mdm-${project.version}/repository/conf/true644
- wso2cdm-${project.version}/repository/conf
+ wso2mdm-${project.version}/repository/conf644
diff --git a/product/modules/distribution/src/assembly/dist.xml b/product/modules/distribution/src/assembly/dist.xml
index d0a9a55a8..beff31824 100644
--- a/product/modules/distribution/src/assembly/dist.xml
+++ b/product/modules/distribution/src/assembly/dist.xml
@@ -26,7 +26,7 @@
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/components
- wso2cdm-${project.version}/repository/components
+ wso2mdm-${project.version}/repository/components**/eclipse.ini**/*.lock
diff --git a/product/modules/distribution/src/assembly/filter.properties b/product/modules/distribution/src/assembly/filter.properties
index a0ebf6302..19404cf6e 100644
--- a/product/modules/distribution/src/assembly/filter.properties
+++ b/product/modules/distribution/src/assembly/filter.properties
@@ -1,7 +1,7 @@
-product.name=WSO2 Connected Device Manager
-product.version=2.0.0-SNAPSHOT
-product.key=CDM
+product.name=WSO2 Mobile Device Manager
+product.version=1.0.0-SNAPSHOT
+product.key=MDM
hotdeployment=true
hotupdate=true
carbon.version=4.3.0
-default.server.role=CDMPlatform
+default.server.role=MDMPlatform
diff --git a/product/modules/mobileservices/agents/windows/jax-rs/build.xml b/product/modules/mobileservices/agents/windows/jax-rs/build.xml
deleted file mode 100644
index fe8e11092..000000000
--- a/product/modules/mobileservices/agents/windows/jax-rs/build.xml
+++ /dev/null
@@ -1,75 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/product/modules/mobileservices/agents/windows/jax-rs/pom.xml b/product/modules/mobileservices/agents/windows/jax-rs/pom.xml
index a713de08a..1f54fe821 100644
--- a/product/modules/mobileservices/agents/windows/jax-rs/pom.xml
+++ b/product/modules/mobileservices/agents/windows/jax-rs/pom.xml
@@ -1,18 +1,20 @@
+ ~ 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.
+-->
junit
test
-
- commons-httpclient
- commons-httpclient
- 3.1
- provided
- javax.ws.rsjsr311-api
- 1.1.1provided
-
- com.google.code.gson
- gson
- 2.2.4
- org.wso2.carbonorg.wso2.carbon.utils
@@ -165,9 +155,9 @@
provided
- log4j
- log4j
- 1.2.17
+ org.apache.wss4j
+ wss4j-ws-security-common
+ 2.0.0org.bouncycastle
@@ -179,10 +169,24 @@
bcprov-jdk15on1.49
+
+ org.codehaus.plexus
+ plexus-utils
+ 3.0.21
+
+
+ com.madgag.spongycastle
+ pkix
+ 1.51.0.0
+
+
+ org.apache.cxf
+ cxf-rt-ws-security
+ 2.6.1
+
+
+ org.codehaus.jackson
+ jackson-jaxrs
+
-
- 2.6.1
- 4.8.2
-
-
diff --git a/product/modules/mobileservices/agents/windows/jax-rs/run-client.bat b/product/modules/mobileservices/agents/windows/jax-rs/run-client.bat
deleted file mode 100644
index 9bd370256..000000000
--- a/product/modules/mobileservices/agents/windows/jax-rs/run-client.bat
+++ /dev/null
@@ -1,81 +0,0 @@
-@echo off
-REM ---------------------------------------------------------------------------
-REM Copyright 2005,2006 WSO2, Inc. http://www.wso2.org
-REM
-REM Licensed under the Apache License, Version 2.0 (the "License");
-REM you may not use this file except in compliance with the License.
-REM You may obtain a copy of the License at
-REM
-REM http://www.apache.org/licenses/LICENSE-2.0
-REM
-REM Unless required by applicable law or agreed to in writing, software
-REM distributed under the License is distributed on an "AS IS" BASIS,
-REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-REM See the License for the specific language governing permissions and
-REM limitations under the License.
-
-rem ---------------------------------------------------------------------------
-rem Client script for the Jaxws-Jaxrs/jaxrs_basic Sample
-rem
-rem Environment Variable Prequisites
-rem
-rem WSO2AppServer_HOME Must point at your WSO2 AppServer directory
-rem
-rem JAVA_HOME Must point at your Java Development Kit installation.
-rem
-rem JAVA_OPTS (Optional) Java runtime options
-rem ---------------------------------------------------------------------------
-set CURRENT_DIR=%cd%
-
-rem Make sure prerequisite environment variables are set
-if not "%JAVA_HOME%" == "" goto gotJavaHome
-echo The JAVA_HOME environment variable is not defined
-echo This environment variable is needed to run this program
-goto end
-:gotJavaHome
-if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHome
-goto okJavaHome
-:noJavaHome
-echo The JAVA_HOME environment variable is not defined correctly
-echo This environment variable is needed to run this program
-echo NB: JAVA_HOME should point to a JDK/JRE
-goto end
-:okJavaHome
-
-rem check the WSO2AppServer_HOME environment variable
-if not "%WSO2AppServer_HOME%" == "" goto gotHome
-set WSO2AppServer_HOME=%CURRENT_DIR%
-if exist "%WSO2AppServer_HOME\bin\version.txt" goto okHome
-
-rem guess the home. Jump two directories up to check if that is the home
-cd ..\..\..
-set WSO2AppServer_HOME=%cd%
-cd %CURRENT_DIR%
-
-:gotHome
-if exist "%WSO2AppServer_HOME%\bin\version.txt" goto okHome
-
-set WSO2AppServer_HOME=%~dp0..\..
-if exist "%WSO2AppServer_HOME%\bin\version.txt" goto okHome
-
-echo The WSO2AppServer_HOME environment variable is not defined correctly
-echo This environment variable is needed to run this program
-goto end
-
-:okHome
-rem set the classes
-setlocal EnableDelayedExpansion
-rem loop through the libs and add them to the class path
-cd %WSO2AppServer_HOME%\samples\Jaxws-Jaxrs\jaxrs_basic
-set CLIENT_CLASSPATH=.\conf;.\build\classes
-FOR %%C in (.\build\lib\*.jar) DO set CLIENT_CLASSPATH=!CLIENT_CLASSPATH!;.\build\lib\%%~nC%%~xC
-
-rem ----- Execute The Requested Command ---------------------------------------
-echo Using WSO2AppServer_HOME: %WSO2AppServer_HOME%
-echo Using JAVA_HOME: %JAVA_HOME%
-set _RUNJAVA="%JAVA_HOME%\bin\java"
-
-%_RUNJAVA% %JAVA_OPTS% -Dwso2appserver.home="%WSO2AppServer_HOME%" -cp "%CLIENT_CLASSPATH%" -Djava.endorsed.dirs="%WSO2AppServer_HOME%\lib\endorsed";"%JAVA_HOME%\jre\lib\endorsed";"%JAVA_HOME%\lib\endorsed" demo.jaxrs.client.Client http://localhost:9763/jaxrs_basic/services/customers/customerservice %*
-cd %CURRENT_DIR%
-endlocal
-:end
diff --git a/product/modules/mobileservices/agents/windows/jax-rs/run-client.sh b/product/modules/mobileservices/agents/windows/jax-rs/run-client.sh
deleted file mode 100755
index 279d5023c..000000000
--- a/product/modules/mobileservices/agents/windows/jax-rs/run-client.sh
+++ /dev/null
@@ -1,90 +0,0 @@
-#!/bin/sh
-# -----------------------------------------------------------------------------
-#
-# Environment Variable Prequisites
-#
-# CARBON_HOME Home of WSO2 AppServer installation. If not set I will try
-# to figure it out.
-#
-# JAVA_HOME Must point at your Java Development Kit installation.
-#
-# NOTE: Borrowed generously from Apache Tomcat startup scripts.
-
-# if JAVA_HOME is not set we're not happy
-if [ -z "$JAVA_HOME" ]; then
- echo "You must set the JAVA_HOME variable before running WSO2 AppServer."
- exit 1
-fi
-
-# OS specific support. $var _must_ be set to either true or false.
-cygwin=false
-os400=false
-case "`uname`" in
-CYGWIN*) cygwin=true;;
-OS400*) os400=true;;
-esac
-
-# resolve links - $0 may be a softlink
-PRG="$0"
-
-while [ -h "$PRG" ]; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '.*/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`/"$link"
- fi
-done
-
-# Get standard environment variables
-PRGDIR=`dirname "$PRG"`
-
-# Only set WSO2AppServer_HOME if not already set
-[ -z "$CARBON_HOME" ] && CARBON_HOME=`cd "$PRGDIR/../../.." ; pwd`
-
-# For Cygwin, ensure paths are in UNIX format before anything is touched
-if $cygwin; then
- [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
- [ -n "$CARBON_HOME" ] && WSO2AppServer_HOME=`cygpath --unix "$CARBON_HOME"`
- [ -n "$CLASSPATH" ] && CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
-fi
-
-# For OS400
-if $os400; then
- # Set job priority to standard for interactive (interactive - 6) by using
- # the interactive priority - 6, the helper threads that respond to requests
- # will be running at the same priority as interactive jobs.
- COMMAND='chgjob job('$JOBNAME') runpty(6)'
- system $COMMAND
-
- # Enable multi threading
- QIBM_MULTI_THREADED=Y
- export QIBM_MULTI_THREADED
-fi
-
-# update classpath
-CLIENT_CLASSPATH=""
-for f in "$CARBON_HOME"/samples/Jaxws-Jaxrs/jaxrs_basic/build/lib/*.jar
-do
- CLIENT_CLASSPATH=$CLIENT_CLASSPATH:$f
-done
-CLIENT_CLASSPATH=$CLIENT_CLASSPATH:$CLASSPATH
-
-
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin; then
- JAVA_HOME=`cygpath --absolute --windows "$JAVA_HOME"`
- CARBON_HOME=`cygpath --absolute --windows "$CARBON_HOME"`
- CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
- JAVA_ENDORSED_DIRS=`cygpath --path --windows "$JAVA_ENDORSED_DIRS"`
-fi
-
-echo Using CARBON_HOME: $CARBON_HOME
-echo Using JAVA_HOME : $JAVA_HOME
-
-CLIENT_CLASSPATH="$CARBON_HOME/samples/Jaxws-Jaxrs/jaxrs_basic/build/classes":$CLIENT_CLASSPATH
-
-$JAVA_HOME/bin/java -Dwso2appserver.home="$CARBON_HOME" -classpath "$CLIENT_CLASSPATH" \
--Djava.endorsed.dirs="$CARBON_HOME/lib/endorsed":"$JAVA_HOME/jre/lib/endorsed":"$JAVA_HOME/lib/endorsed" \
-demo.jaxrs.client.Client http://localhost:9763/jaxrs_basic/services/customers/customerservice$*
diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/DiscoveryService.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/DiscoveryService.java
deleted file mode 100644
index 64cd0e8ec..000000000
--- a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/DiscoveryService.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2014, 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 cdm.api.windows;
-
-import javax.ws.rs.*;
-import javax.ws.rs.core.Response;
-import java.io.InputStream;
-
-@Path("/EnrollmentServer")
-public interface DiscoveryService {
-
- @Path("/Discovery.svc")
- @POST
- @Consumes({ "application/soap+xml;charset=utf-8", "application/xml" })
- @Produces("application/soap+xml;charset=utf-8")
- Response getDiscoveryResponse(
- InputStream discoveryRequest);
-
- @Path("/Discovery.svc")
- @GET
- @Consumes("text/html")
- @Produces("text/html")
- Response getDiscoveryOKRequest();
-
- @Path("/Discovery.svc")
- @GET
- @Consumes({ "application/soap+xml;charset=utf-8", "application/xml" })
- @Produces("text/html")
- Response getDiscoveryOKRequestWithBody(InputStream discoveryRequest);
-
-}
diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/DiscoveryService/DiscoveryServiceGet.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/DiscoveryService/DiscoveryServiceGet.java
new file mode 100644
index 000000000..5395251a1
--- /dev/null
+++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/DiscoveryService/DiscoveryServiceGet.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2014, 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 cdm.api.windows.DiscoveryService;
+
+
+import cdm.api.windows.DiscoveryService.beans.in.DiscoveryRequest;
+import cdm.api.windows.DiscoveryService.beans.out.Message;
+
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebResult;
+import javax.jws.WebService;
+import javax.ws.rs.*;
+import javax.ws.rs.core.Response;
+import javax.xml.ws.BindingType;
+import javax.xml.ws.RequestWrapper;
+import javax.xml.ws.ResponseWrapper;
+import javax.xml.ws.soap.SOAPBinding;
+
+@WebService(targetNamespace = "http://schemas.microsoft.com/windows/management/2012/01/enrollment", name = "IDiscoveryService")
+@BindingType(value = SOAPBinding.SOAP12HTTP_BINDING)
+public interface DiscoveryServiceGet {
+
+ @POST
+ @WebMethod(operationName = "Discover")
+ @RequestWrapper(targetNamespace = "http://schemas.microsoft.com/windows/management/2012/01/enrollment")
+ @ResponseWrapper(targetNamespace = "http://schemas.microsoft.com/windows/management/2012/01/enrollment")
+ @WebResult(name = "DiscoverResult") Message Discover(
+ @WebParam(name = "request")
+ DiscoveryRequest request);
+
+ @GET
+ @WebMethod
+ @WebResult() Response DiscoverGet();
+
+}
\ No newline at end of file
diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/DiscoveryService/beans/in/DiscoveryRequest.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/DiscoveryService/beans/in/DiscoveryRequest.java
new file mode 100644
index 000000000..825f51a37
--- /dev/null
+++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/DiscoveryService/beans/in/DiscoveryRequest.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2014, 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 cdm.api.windows.DiscoveryService.beans.in;
+
+
+import javax.xml.bind.annotation.*;
+import java.io.Serializable;
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.FIELD)
+public class DiscoveryRequest implements Serializable {
+
+ @XmlElement(name = "EmailAddress")
+ private String emailId;
+
+ @XmlElement(name = "RequestVersion")
+ private String version;
+
+ @XmlElement(name = "DeviceType")
+ private String deviceType;
+
+ public String getEmailId() {
+ return emailId;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setEmailId(String emailId) {
+ this.emailId = emailId;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public String getDeviceType() {
+ return deviceType;
+ }
+
+ public void setDeviceType(String deviceType) {
+ this.deviceType = deviceType;
+ }
+}
\ No newline at end of file
diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/DiscoveryService/beans/in/package-info.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/DiscoveryService/beans/in/package-info.java
new file mode 100644
index 000000000..7f21ab9ee
--- /dev/null
+++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/DiscoveryService/beans/in/package-info.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2014, 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.
+ */
+
+
+
+
+
+@javax.xml.bind.annotation.XmlSchema(namespace = "http://schemas.microsoft.com/windows/pki/2009/01/enrollment", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
+package cdm.api.windows.DiscoveryService.beans.in;
diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/DiscoveryService/beans/out/Message.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/DiscoveryService/beans/out/Message.java
new file mode 100644
index 000000000..8cc1d8f7a
--- /dev/null
+++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/DiscoveryService/beans/out/Message.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2014, 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 cdm.api.windows.DiscoveryService.beans.out;
+
+import javax.xml.bind.annotation.*;
+import java.io.Serializable;
+
+
+@XmlRootElement
+public class Message implements Serializable {
+
+ private String authPolicy;
+ private String enrollmentPolicyServiceUrl;
+ private String enrollmentServiceUrl;
+
+ @XmlElement(name = "AuthPolicy", namespace = "http://schemas.microsoft.com/windows/management/2012/01/enrollment")
+ public String getAuthPolicy() {
+ return authPolicy;
+ }
+
+ @XmlElement(name = "EnrollmentPolicyServiceUrl", namespace = "http://schemas.microsoft.com/windows/management/2012/01/enrollment")
+ public String getEnrollmentPolicyServiceUrl() {
+ return enrollmentPolicyServiceUrl;
+ }
+
+ @XmlElement(name = "EnrollmentServiceUrl", namespace = "http://schemas.microsoft.com/windows/management/2012/01/enrollment")
+ public String getEnrollmentServiceUrl() {
+ return enrollmentServiceUrl;
+ }
+
+ public void setAuthPolicy(String authPolicy) {
+ this.authPolicy = authPolicy;
+ }
+
+ public void setEnrollmentPolicyServiceUrl(String enrollmentPolicyServiceUrl) {
+ this.enrollmentPolicyServiceUrl = enrollmentPolicyServiceUrl;
+ }
+
+ public void setEnrollmentServiceUrl(String enrollmentServiceUrl) {
+ this.enrollmentServiceUrl = enrollmentServiceUrl;
+ }
+}
\ No newline at end of file
diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/DiscoveryService/impl/DiscoveryServiceGetImpl.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/DiscoveryService/impl/DiscoveryServiceGetImpl.java
new file mode 100644
index 000000000..70c6e79ef
--- /dev/null
+++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/DiscoveryService/impl/DiscoveryServiceGetImpl.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2014, 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 cdm.api.windows.DiscoveryService.impl;
+
+import cdm.api.windows.DiscoveryService.beans.in.DiscoveryRequest;
+import cdm.api.windows.DiscoveryService.DiscoveryServiceGet;
+import cdm.api.windows.DiscoveryService.beans.out.Message;
+import org.apache.log4j.Logger;
+import javax.jws.WebService;
+import javax.ws.rs.core.Response;
+import javax.xml.ws.BindingType;
+import javax.xml.ws.soap.Addressing;
+import javax.xml.ws.soap.SOAPBinding;
+
+@WebService(endpointInterface = "cdm.api.windows.DiscoveryService.DiscoveryServiceGet", targetNamespace = "http://schemas.microsoft.com/windows/management/2012/01/enrollment")
+@Addressing(enabled = true, required = true)
+@BindingType(value = SOAPBinding.SOAP12HTTP_BINDING)
+public class DiscoveryServiceGetImpl implements DiscoveryServiceGet {
+
+ private Logger LOGGER = Logger.getLogger(DiscoveryServiceGetImpl.class);
+
+ @Override
+ public Message Discover(DiscoveryRequest disRequest) {
+
+ System.out.println("CHECK_SECOND_POST");
+
+ Message message = new Message();
+ message.setAuthPolicy("OnPremise");
+
+ message.setEnrollmentPolicyServiceUrl(
+ "https://EnterpriseEnrollment.wso2.com/ENROLLMENTSERVER/PolicyEnrollmentWebservice.svc");
+ message.setEnrollmentServiceUrl(
+ "https://EnterpriseEnrollment.wso2.com/ENROLLMENTSERVER/DeviceEnrollmentWebservice.svc");
+
+ LOGGER.info("Received Discovery Service Request");
+
+ return message;
+ }
+
+ @Override
+ public Response DiscoverGet() {
+
+ System.out.println("CHECK_FIRST_GET");
+
+ return Response.ok().build();
+ }
+
+}
diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/EnrolmentService.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/EnrolmentService.java
deleted file mode 100644
index 9a61a3c61..000000000
--- a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/EnrolmentService.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (c) 2014, 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 cdm.api.windows;
-
-import javax.swing.text.Document;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.Response;
-
-@Path("/ENROLLMENTSERVER")
-public interface EnrolmentService {
-
- @Path("/PolicyEnrollmentWebservice.svc")
- @POST
- @Consumes("application/soap+xml;charset=utf-8")
- @Produces("application/soap+xml;charset=utf-8")
- Response getPolicies(Document request);
-
- @Path("/DeviceEnrollmentWebservice.svc")
- @POST
- @Consumes("application/soap+xml;charset=utf-8")
- @Produces("application/soap+xml;charset=utf-8")
- Response enrollUser(Document request);
-
-}
diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/impl/DiscoveryServiceImpl.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/impl/DiscoveryServiceImpl.java
deleted file mode 100644
index 59de66ae0..000000000
--- a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/impl/DiscoveryServiceImpl.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 2014, 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 cdm.api.windows.impl;
-
-import cdm.api.windows.DiscoveryService;
-
-import javax.ws.rs.core.Response;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-
-import org.apache.log4j.Logger;
-
-public class DiscoveryServiceImpl implements DiscoveryService {
-
- private Logger LOGGER = Logger.getLogger(DiscoveryServiceImpl.class);
-
- public Response getDiscoveryResponse(InputStream discoveryRequest) {
- LOGGER.info("Received Discovery Service POST Request [{}]");
-
- String response = null;
- File file = null;
- FileInputStream fis = null;
- byte[] data = null;
-
- try {
-
- file = new File("./conf/discover-service.xml");
- fis = new FileInputStream(file);
- data = new byte[(int) file.length()];
- fis.read(data);
- fis.close();
- response = new String(data, "UTF-8");
-
- } catch (IOException e) {
- LOGGER.error("An Unexpected Error has occurred while processing the request ", e);
- }
- LOGGER.info("Sending Discovery Response");
-
- return Response.ok().entity(response).build();
- }
-
- public Response getDiscoveryOKRequest() {
- LOGGER.info("Received a GET Request without body");
- return Response.ok().build();
- }
-
- public Response getDiscoveryOKRequestWithBody(InputStream discoveryRequest) {
- LOGGER.info("Received a GET Request with body [{}]");
- return Response.ok().build();
- }
-
-
-}
diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/impl/EnrolmentServiceImpl.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/impl/EnrolmentServiceImpl.java
deleted file mode 100644
index c3acde838..000000000
--- a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/impl/EnrolmentServiceImpl.java
+++ /dev/null
@@ -1,305 +0,0 @@
-/*
- * Copyright (c) 2014, 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 cdm.api.windows.impl;
-
-import cdm.api.windows.EnrolmentService;
-import org.apache.log4j.Logger;
-import org.bouncycastle.jce.provider.BouncyCastleProvider;
-import org.bouncycastle.pkcs.PKCS10CertificationRequest;
-import org.bouncycastle.pkcs.jcajce.JcaPKCS10CertificationRequest;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import sun.misc.BASE64Decoder;
-import sun.misc.BASE64Encoder;
-import javax.swing.text.Document;
-import javax.ws.rs.core.Response;
-import javax.xml.namespace.NamespaceContext;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.xpath.XPath;
-import javax.xml.xpath.XPathConstants;
-import javax.xml.xpath.XPathFactory;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.StringWriter;
-import java.security.KeyFactory;
-import java.security.PrivateKey;
-import java.security.Security;
-import java.security.cert.CertificateFactory;
-import java.security.cert.X509Certificate;
-import java.security.spec.PKCS8EncodedKeySpec;
-import java.util.Iterator;
-
-import cdm.api.windows.util.CertificateSigningService;
-
-public class EnrolmentServiceImpl implements EnrolmentService {
-
- private Logger LOGGER = Logger.getLogger(EnrolmentServiceImpl.class);
-
- static {
- Security.addProvider(new BouncyCastleProvider());
- }
-
- private String enrollmentResponseFile;
-
- private String wapProvisioningXmlFile;
-
- private String privatePemKeyFilePath;
-
- private String caCertificateFilePath;
-
- PrivateKey privateKey;
-
- X509Certificate rooCACertificate;
-
- public void init() {
-
- try {
- FileInputStream in = new FileInputStream(privatePemKeyFilePath);
- byte[] keyBytes = new byte[in.available()];
- in.read(keyBytes);
- in.close();
-
- String key = new String(keyBytes, "UTF-8");
- key = key.replaceAll(
- "(-+BEGIN RSA PRIVATE KEY-+\\r?\\n|-+END RSA PRIVATE KEY-+\\r?\\n?)", "");
-
- // don't use this for real projects!
- BASE64Decoder decoder = new BASE64Decoder();
- keyBytes = decoder.decodeBuffer(key);
-
- // generate private key
-
- PKCS8EncodedKeySpec spec = new PKCS8EncodedKeySpec(keyBytes);
- KeyFactory keyFactory = KeyFactory.getInstance("RSA");
-
- privateKey = keyFactory.generatePrivate(spec);
-
- LOGGER.info("Private Key Algorithm : " + privateKey.getAlgorithm());
- } catch (Exception e) {
- LOGGER.error("An unexpected Error has occurred while reading CA Private Key, ", e);
- }
-
- try {
- FileInputStream fr = new FileInputStream(caCertificateFilePath);
- CertificateFactory cf = CertificateFactory.getInstance("X509");
- rooCACertificate = (X509Certificate) cf.generateCertificate(fr);
-
- rooCACertificate.verify(rooCACertificate.getPublicKey());
-
- LOGGER.info("CA Certificate Expiration Date : " + rooCACertificate.getNotAfter());
-
- } catch (Exception e) {
- LOGGER.error("An unexpected Error has occurred while reading CA Root Certificate, ", e);
- }
-
- /*try {
- KeyPairGenerator gen = KeyPairGenerator.getInstance("RSA");
- gen.initialize(2048);
- key = gen.generateKeyPair();
- PrivateKey privateKey = key.getPrivate();
- PublicKey publicKey = key.getPublic();
-
-
- *//**
- * Following details need to be provided
- *
- * Serial number
- * Signature algorithm
- * Issuer Name.
- * Subject Name -- or a Subject Alternative Name (SAN).
- * Date range (not before, not after).
- * Subject Public Key.
- *//*
-
- X509V3CertificateGenerator v3CertGen = new X509V3CertificateGenerator();
- v3CertGen.setSerialNumber(BigInteger.valueOf(new SecureRandom().nextInt(Integer.MAX_VALUE)));
- v3CertGen.setIssuerDN(new X509Principal("CN=wso2.com"));
- //v3CertGen.setIssuerDN(new X509Principal("CN=wso2.com, OU=Mobile, O=wso2 L=Colombo, C=LK"));
- v3CertGen.setNotBefore(new Date(System.currentTimeMillis() - 1000L * 60 * 60 * 24 * 30));
- v3CertGen.setNotAfter(new Date(System.currentTimeMillis() + (1000L * 60 * 60 * 24 * 365*10)));
- v3CertGen.setSubjectDN(new X509Principal("CN=wso2.com"));
- v3CertGen.setPublicKey(publicKey);
- v3CertGen.setSignatureAlgorithm("SHA1withRSA");
-
- rooCACertificate = v3CertGen.generateX509Certificate(privateKey);
-
- } catch (Exception e) {
- e.printStackTrace();
- }*/
- }
-
- public Response getPolicies(Document request) {
- LOGGER.info("Received Get Policies Request");
-
- String response = null;
- File file = null;
- FileInputStream fis = null;
- byte[] data = null;
-
- try {
-
- file = new File("./conf/policy-service.xml");
- fis = new FileInputStream(file);
- data = new byte[(int) file.length()];
- fis.read(data);
- fis.close();
- response = new String(data, "UTF-8");
-
- } catch (IOException e) {
- LOGGER.error("An Unexpected Error has occurred while processing the request ", e);
- }
-
- LOGGER.info("Sending Get Policy Response");
- return Response.ok().entity(response).build();
- }
-
- public Response enrollUser(Document request) {
- LOGGER.info("Received User Enrollment Request");
-
- XPath xPath = XPathFactory.newInstance().newXPath();
- xPath.setNamespaceContext(new MyNamespaceContext());
- String response = null;
-
- DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
-
- try {
- NodeList nl = (NodeList) xPath.evaluate(
- "/s:Envelope/s:Body/wst:RequestSecurityToken/wsse:BinarySecurityToken", request,
- XPathConstants.NODESET);
- Node node = nl.item(0);
- String certificateDataString = node.getTextContent();
- byte[] derByteArray =
- javax.xml.bind.DatatypeConverter.parseBase64Binary(certificateDataString);
-
- PKCS10CertificationRequest certificationRequest =
- new PKCS10CertificationRequest(derByteArray);
- JcaPKCS10CertificationRequest csrReq =
- new JcaPKCS10CertificationRequest(certificationRequest);
-
- LOGGER.info("Public Key of CSR : " + csrReq.getPublicKey());
-
- X509Certificate signedCert =
- CertificateSigningService.signCSR(csrReq, privateKey, rooCACertificate);
-
- LOGGER.info("Verifying Signed Certificate with CSR's public key : " +
- signedCert.getPublicKey());
-
- BASE64Encoder base64Encoder = new BASE64Encoder();
- String rootCertEncodedString = base64Encoder.encode(rooCACertificate.getEncoded());
- String signedCertEncoded = base64Encoder.encode(signedCert.getEncoded());
-
- DocumentBuilder builder = domFactory.newDocumentBuilder();
- org.w3c.dom.Document dDoc = builder.parse(wapProvisioningXmlFile);
-
- NodeList wapParm = dDoc.getElementsByTagName("parm");
-
- NamedNodeMap rootCertAttributes = wapParm.item(0).getAttributes();
- Node b64Encoded = rootCertAttributes.getNamedItem("value");
- b64Encoded.setTextContent(rootCertEncodedString);
-
- NamedNodeMap clientCertAttributes = wapParm.item(1).getAttributes();
- Node b64CliendEncoded = clientCertAttributes.getNamedItem("value");
- b64CliendEncoded.setTextContent(signedCertEncoded);
-
- String wapProvisioning = convertDocumentToString(dDoc);
- String encodedWap = base64Encoder.encode(wapProvisioning.getBytes());
-
- org.w3c.dom.Document responseXml = builder.parse(enrollmentResponseFile);
- NodeList token = responseXml.getElementsByTagName("BinarySecurityToken");
-
- Node firstToken = token.item(0);
- firstToken.setTextContent(encodedWap);
-
- response = convertDocumentToString(responseXml);
- } catch (Exception e) {
- LOGGER.error("An Unexpected Error has occurred while processing the request ", e);
- }
-
- LOGGER.info("Sending User Enrollment Response");
- return Response.ok().entity(response).build();
- }
-
- private String convertDocumentToString(org.w3c.dom.Document document) throws Exception {
- DOMSource domSource = new DOMSource(document);
- StringWriter writer = new StringWriter();
- StreamResult result = new StreamResult(writer);
- TransformerFactory tf = TransformerFactory.newInstance();
- Transformer transformer = tf.newTransformer();
- transformer.transform(domSource, result);
- String wapProvisioning = writer.toString();
-
- return wapProvisioning;
-
- }
-
- public void setEnrollmentResponseFile(String enrollmentResponseFile) {
- this.enrollmentResponseFile = enrollmentResponseFile;
- }
-
- public void setWapProvisioningXmlFile(String wapProvisioningXmlFile) {
- this.wapProvisioningXmlFile = wapProvisioningXmlFile;
- }
-
- public void setPrivatePemKeyFilePath(String privatePemKeyFilePath) {
- this.privatePemKeyFilePath = privatePemKeyFilePath;
- }
-
- public void setCaCertificateFilePath(String caCertificateFilePath) {
- this.caCertificateFilePath = caCertificateFilePath;
- }
-
- public void setPrivateKey(PrivateKey privateKey) {
- this.privateKey = privateKey;
- }
-
- public void setRooCACertificate(X509Certificate rooCACertificate) {
- this.rooCACertificate = rooCACertificate;
- }
-
- private static class MyNamespaceContext implements NamespaceContext {
-
- public String getNamespaceURI(String prefix) {
-
- if ("s".equals(prefix)) {
- return "http://www.w3.org/2003/05/soap-envelope";
- } else if ("wst".equals(prefix)) {
- return "http://docs.oasis-open.org/ws-sx/ws-trust/200512";
- } else if ("wsse".equals(prefix)) {
- return "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";
- }
- return null;
-
- }
-
- public String getPrefix(String namespaceURI) {
- return null;
- }
-
- public Iterator getPrefixes(String namespaceURI) {
- return null;
- }
- }
-}
diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/util/CertificateSigningService.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/util/CertificateSigningService.java
deleted file mode 100644
index 6b0069409..000000000
--- a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/util/CertificateSigningService.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (c) 2014, 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 cdm.api.windows.util;
-
-import org.apache.log4j.Logger;
-import org.bouncycastle.asn1.x500.X500Name;
-import org.bouncycastle.cert.X509v3CertificateBuilder;
-import org.bouncycastle.cert.jcajce.JcaX509CertificateConverter;
-import org.bouncycastle.cert.jcajce.JcaX509ExtensionUtils;
-import org.bouncycastle.cert.jcajce.JcaX509v3CertificateBuilder;
-import org.bouncycastle.operator.ContentSigner;
-import org.bouncycastle.operator.jcajce.JcaContentSignerBuilder;
-import org.bouncycastle.pkcs.jcajce.JcaPKCS10CertificationRequest;
-
-import java.math.BigInteger;
-import java.security.PrivateKey;
-import java.security.SecureRandom;
-import java.security.cert.X509Certificate;
-import java.util.Date;
-
-public class CertificateSigningService {
-
- private static Logger LOGGER = Logger.getLogger(CertificateSigningService.class);
-
- public static X509Certificate signCSR(JcaPKCS10CertificationRequest jcaRequest,
- PrivateKey privateKey, X509Certificate caCert)
- throws Exception {
- try {
-
- X509v3CertificateBuilder certificateBuilder = new JcaX509v3CertificateBuilder(caCert,
- BigInteger
- .valueOf(
- new SecureRandom()
- .nextInt(
- Integer.MAX_VALUE)),
- new Date(
- System.currentTimeMillis() -
- 1000L *
- 60 *
- 60 *
- 24 *
- 30),
- new Date(
- System.currentTimeMillis() +
- (1000L *
- 60 *
- 60 *
- 24 *
- 365 *
- 10)),
- new X500Name(
- "CN=abimaran"),
- jcaRequest
- .getPublicKey());
-
- JcaX509ExtensionUtils extUtils = new JcaX509ExtensionUtils();
-
- ContentSigner signer =
- new JcaContentSignerBuilder("SHA1withRSA").setProvider("BC").build(privateKey);
-
- X509Certificate theCert =
- new JcaX509CertificateConverter().setProvider("BC").getCertificate(
- certificateBuilder.build(signer));
-
- LOGGER.info("Signed Certificate CN : " + theCert.getSubjectDN().getName());
-
- LOGGER.info("Signed CSR's public key : " + theCert.getPublicKey());
-
- return theCert;
-
- } catch (Exception e) {
- throw new Exception("Error in signing the certificate", e);
- }
- }
-
-}
diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/util/WindowsAPIUtil.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/util/WindowsAPIUtil.java
deleted file mode 100644
index ca784e189..000000000
--- a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/util/WindowsAPIUtil.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * 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.
- */
-
-package cdm.api.windows.util;
-
-
-import com.google.gson.JsonObject;
-import org.wso2.carbon.device.mgt.common.Device;
-import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
-import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
-
-
-/**
- * WindowsAPIUtil class provides utility function used by Android REST-API classes.
- */
-public class WindowsAPIUtil {
-
- public static Device convertToDeviceObject(JsonObject json){
- Device device = new Device();
- device.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
- device.setName("Test Device");
- device.setOwner("harshan");
- return device;
- }
-
- public static DeviceIdentifier convertToDeviceIdentifierObject(String deviceId){
- DeviceIdentifier identifier = new DeviceIdentifier();
- identifier.setId(deviceId);
- identifier.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
- return identifier;
- }
-}
diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/CertificateEnrollmentService.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/CertificateEnrollmentService.java
new file mode 100644
index 000000000..9fb6eb629
--- /dev/null
+++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/CertificateEnrollmentService.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2014, 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 cdm.api.windows.wstep;
+
+import cdm.api.windows.wstep.beans.RequestSecurityTokenResponse;
+
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebResult;
+import javax.jws.WebService;
+import javax.ws.rs.*;
+import javax.xml.bind.annotation.XmlSeeAlso;
+import javax.xml.ws.Action;
+import javax.xml.ws.RequestWrapper;
+import javax.xml.ws.ResponseWrapper;
+import javax.xml.ws.soap.SOAPBinding;
+import javax.xml.ws.BindingType;
+
+@WebService(targetNamespace = "http://schemas.microsoft.com/windows/pki/2009/01/enrollment/RSTRC", name = "wstep")
+@BindingType(value = SOAPBinding.SOAP12HTTP_BINDING)
+public interface CertificateEnrollmentService {
+
+ @RequestWrapper(localName = "RequestSecurityToken", targetNamespace = "http://docs.oasis-open.org/ws-sx/ws-trust/200512")
+ @WebMethod(operationName = "RequestSecurityToken")
+ @ResponseWrapper(localName = "RequestSecurityTokenResponseCollection", targetNamespace = "http://docs.oasis-open.org/ws-sx/ws-trust/200512")
+ public void RequestSecurityToken(
+ @WebParam(name = "TokenType", targetNamespace = "http://docs.oasis-open.org/ws-sx/ws-trust/200512")
+ String TokenType,
+ @WebParam(name = "RequestType", targetNamespace = "http://docs.oasis-open.org/ws-sx/ws-trust/200512")
+ String RequestType,
+ @WebParam(name = "BinarySecurityToken", targetNamespace = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd")
+ String BinarySecurityToken,
+ @WebParam(name = "AdditionalContext", targetNamespace = "http://schemas.xmlsoap.org/ws/2006/12/authorization")
+ cdm.api.windows.wstep.beans.AdditionalContext AdditionalContext,
+ @WebParam(mode = WebParam.Mode.OUT, name = "RequestSecurityTokenResponse", targetNamespace = "http://docs.oasis-open.org/ws-sx/ws-trust/200512")
+ javax.xml.ws.Holder response
+ );
+
+}
\ No newline at end of file
diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/beans/AdditionalContext.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/beans/AdditionalContext.java
new file mode 100644
index 000000000..8ffc134ff
--- /dev/null
+++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/beans/AdditionalContext.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2014, 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 cdm.api.windows.wstep.beans;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "OIDCollection", namespace = "http://schemas.xmlsoap.org/ws/2006/12/authorization", propOrder = {
+ "contextitem"
+})
+public class AdditionalContext {
+
+ @XmlElement(name = "ContextItem", required = true)
+ protected List contextitem;
+
+ public List getcontextitem() {
+ if (contextitem == null) {
+ contextitem = new ArrayList();
+ }
+ return this.contextitem;
+ }
+
+}
+
diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/beans/BinarySecurityToken.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/beans/BinarySecurityToken.java
new file mode 100644
index 000000000..9f84e905e
--- /dev/null
+++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/beans/BinarySecurityToken.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2014, 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 cdm.api.windows.wstep.beans;
+
+import javax.xml.bind.annotation.*;
+
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "BinarySecurityToken", namespace = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd")
+public class BinarySecurityToken {
+
+ @XmlAttribute(name = "ValueType")
+ protected String ValueType;
+ @XmlAttribute(name = "EncodingType")
+ protected String EncodingType;
+
+ @XmlValue
+ protected String Token;
+
+ public void setValueType(String valuetype) {
+ this.ValueType = valuetype;
+ }
+
+ public String getValueType() {
+ return this.ValueType;
+ }
+
+ public void setEncodingType(String encodingtype) {
+ this.EncodingType = encodingtype;
+ }
+
+ public String getEncodingType() {
+ return this.EncodingType;
+ }
+
+ public void setToken(String token) {
+ this.Token = token;
+ }
+
+ public String getToken() {
+ return this.Token;
+ }
+
+}
+
diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/beans/ContextItem.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/beans/ContextItem.java
new file mode 100644
index 000000000..84df97062
--- /dev/null
+++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/beans/ContextItem.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2014, 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 cdm.api.windows.wstep.beans;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "ContextItem", namespace = "http://schemas.xmlsoap.org/ws/2006/12/authorization", propOrder = {
+ "Value"
+})
+public class ContextItem {
+
+ @XmlElement(required = true)
+ protected String Value;
+
+ public String getValue() {
+ return Value;
+ }
+
+ public void setValue(String value) {
+ Value = value;
+ }
+
+}
diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/beans/RequestSecurityToken.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/beans/RequestSecurityToken.java
new file mode 100644
index 000000000..e964e6f57
--- /dev/null
+++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/beans/RequestSecurityToken.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2014, 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 cdm.api.windows.wstep.beans;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "RequestedSecurityToken", namespace = "http://docs.oasis-open.org/ws-sx/ws-trust/200512", propOrder = {
+ "binarySecurityToken"
+})
+public class RequestSecurityToken {
+
+ @XmlElement(name = "BinarySecurityToken", required = true, namespace = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd")
+
+ protected BinarySecurityToken binarySecurityToken;
+
+ public void setBinarySecurityToken(BinarySecurityToken binarysecuritytoken) {
+ this.binarySecurityToken = binarysecuritytoken;
+ }
+
+}
\ No newline at end of file
diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/beans/RequestSecurityTokenResponse.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/beans/RequestSecurityTokenResponse.java
new file mode 100644
index 000000000..48d3a95d0
--- /dev/null
+++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/beans/RequestSecurityTokenResponse.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2014, 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 cdm.api.windows.wstep.beans;
+
+import cdm.api.windows.wstep.beans.AdditionalContext;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "RequestSecurityTokenResponse", namespace = "http://docs.oasis-open.org/ws-sx/ws-trust/200512", propOrder = {
+ "TokenType",
+ "RequestedSecurityToken",
+ "RequestID"
+})
+public class RequestSecurityTokenResponse implements Serializable {
+
+ @XmlElement(name = "TokenType", namespace = "http://docs.oasis-open.org/ws-sx/ws-trust/200512")
+ private String TokenType;
+
+ @XmlElement(name = "RequestedSecurityToken", required = true, namespace = "http://docs.oasis-open.org/ws-sx/ws-trust/200512")
+ private RequestedSecurityToken RequestedSecurityToken;
+
+ @XmlElement(name = "RequestID", namespace = "http://docs.oasis-open.org/ws-sx/ws-trust/200512")
+ private int RequestID;
+
+ public String getTokenType() {
+ return TokenType;
+ }
+
+ public void setTokenType(String tokenType) {
+ TokenType = tokenType;
+ }
+
+ public RequestedSecurityToken getRequestedSecurityToken() {
+ return RequestedSecurityToken;
+ }
+
+ public void setRequestedSecurityToken(RequestedSecurityToken requestedSecurityToken) {
+ RequestedSecurityToken = requestedSecurityToken;
+ }
+
+ public int getRequestID() {
+ return RequestID;
+ }
+
+ public void setRequestID(int requestID) {
+ RequestID = requestID;
+ }
+}
\ No newline at end of file
diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/beans/RequestedSecurityToken.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/beans/RequestedSecurityToken.java
new file mode 100644
index 000000000..b85ae85aa
--- /dev/null
+++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/beans/RequestedSecurityToken.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2014, 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 cdm.api.windows.wstep.beans;
+
+import cdm.api.windows.wstep.beans.ContextItem;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+import java.util.ArrayList;
+import java.util.List;
+
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "RequestedSecurityToken", namespace = "http://docs.oasis-open.org/ws-sx/ws-trust/200512", propOrder = {
+ "binarySecurityToken"
+})
+public class RequestedSecurityToken {
+
+ @XmlElement(name = "BinarySecurityToken", required = true, namespace = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd")
+
+ protected BinarySecurityToken binarySecurityToken;
+
+ public void setBinarySecurityToken(BinarySecurityToken binarysecuritytoken) {
+ this.binarySecurityToken = binarysecuritytoken;
+ }
+
+}
+
diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/beans/package-info.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/beans/package-info.java
new file mode 100644
index 000000000..453eefdd2
--- /dev/null
+++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/beans/package-info.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2014, 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.
+ */
+
+@XmlSchema(namespace = "http://www.w3.org/2003/05/soap-envelope",
+ xmlns = {
+ @XmlNs(prefix = "", namespaceURI = "http://www.w3.org/2003/05/soap-envelope"),
+ }, elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
+
+package com.ex.wstep;
+
+import javax.xml.bind.annotation.XmlNs;
+import javax.xml.bind.annotation.XmlSchema;
\ No newline at end of file
diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/impl/CertificateEnrollmentServiceImpl.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/impl/CertificateEnrollmentServiceImpl.java
new file mode 100644
index 000000000..32f8c35dc
--- /dev/null
+++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/impl/CertificateEnrollmentServiceImpl.java
@@ -0,0 +1,195 @@
+/*
+ * Copyright (c) 2014, 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 cdm.api.windows.wstep.impl;
+
+import cdm.api.windows.wstep.beans.AdditionalContext;
+import cdm.api.windows.wstep.CertificateEnrollmentService;
+import cdm.api.windows.wstep.beans.BinarySecurityToken;
+import javax.jws.WebService;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.ws.BindingType;
+import javax.xml.ws.Holder;
+import javax.xml.ws.soap.Addressing;
+import javax.xml.ws.soap.SOAPBinding;
+import org.apache.commons.codec.digest.DigestUtils;
+import cdm.api.windows.wstep.beans.RequestSecurityTokenResponse;
+import cdm.api.windows.wstep.beans.RequestedSecurityToken;
+import cdm.api.windows.wstep.util.CertificateSigningService;
+import cdm.api.windows.wstep.util.KeyStoreGenerator;
+import org.apache.log4j.Logger;
+import org.bouncycastle.pkcs.PKCS10CertificationRequest;
+import org.bouncycastle.pkcs.jcajce.JcaPKCS10CertificationRequest;
+import org.w3c.dom.Document;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import sun.misc.BASE64Encoder;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.StringWriter;
+import java.security.KeyStore;
+import java.security.PrivateKey;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateFactory;
+import java.security.cert.X509Certificate;
+
+@WebService(endpointInterface = "cdm.api.windows.wstep.CertificateEnrollmentService", targetNamespace = "http://schemas.microsoft.com/windows/pki/2009/01/enrollment/RSTRC")
+@Addressing(enabled = true, required = true)
+@BindingType(value = SOAPBinding.SOAP12HTTP_BINDING)
+public class CertificateEnrollmentServiceImpl implements CertificateEnrollmentService {
+
+ private Logger LOGGER = Logger.getLogger(CertificateEnrollmentServiceImpl.class);
+
+ PrivateKey privateKey;
+ X509Certificate rooCACertificate;
+ JcaPKCS10CertificationRequest csrReq;
+ PKCS10CertificationRequest certificationRequest;
+
+ String wapProvisioningXmlFile;
+ DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
+
+ @Override public void RequestSecurityToken(String TokenType, String RequestType,
+ String BinarySecurityToken,
+ AdditionalContext AdditionalContext,
+ Holder response) {
+
+ certificateSign();
+ //////////
+ System.out.println("\n\n\n"+"REQUEST_CSR:"+BinarySecurityToken+"\n\n\n");
+ //////////
+
+ File file = new File(getClass().getClassLoader().getResource("wap-provisioning.xml").getFile());
+ wapProvisioningXmlFile = file.getPath();
+
+ String encodedWap="Initial_test";
+
+ RequestSecurityTokenResponse rs = new RequestSecurityTokenResponse();
+ rs.setTokenType(
+ "http://schemas.microsoft.com/5.0.0.0/ConfigurationManager/Enrollment/DeviceEnrollmentToken");
+
+ try {
+ byte[] derByteArray = javax.xml.bind.DatatypeConverter.parseBase64Binary(BinarySecurityToken);
+ certificationRequest = new PKCS10CertificationRequest(derByteArray);
+ csrReq = new JcaPKCS10CertificationRequest(certificationRequest);
+
+ X509Certificate signedCert = CertificateSigningService.signCSR(csrReq, privateKey, rooCACertificate);
+
+ System.out.println("PUBLIC KEY OF SIGNED CERT :"+signedCert.getPublicKey()+"\n\n\n");
+ System.out.println("PUBLIC KEY OF CSR :"+csrReq.getPublicKey()+"\n\n\n");
+
+
+
+ BASE64Encoder base64Encoder = new BASE64Encoder();
+ String rootCertEncodedString = base64Encoder.encode(rooCACertificate.getEncoded());
+ String signedCertEncoded = base64Encoder.encode(signedCert.getEncoded());
+
+ DocumentBuilder builder = domFactory.newDocumentBuilder();
+ Document dDoc = builder.parse(wapProvisioningXmlFile);
+
+ NodeList wapParm = dDoc.getElementsByTagName("parm");
+ /////////
+ wapParm.item(0).getParentNode().getAttributes().getNamedItem("type").setTextContent(String.valueOf(
+ DigestUtils.sha1Hex(rooCACertificate.getEncoded())));
+ /////////
+ NamedNodeMap rootCertAttributes = wapParm.item(0).getAttributes();
+ Node b64Encoded = rootCertAttributes.getNamedItem("value");
+ rootCertEncodedString=rootCertEncodedString.replaceAll("\n","");
+ b64Encoded.setTextContent(rootCertEncodedString);
+ System.out.println("COPY_ROOT_CERT:"+rootCertEncodedString);
+
+ /////////
+ wapParm.item(1).getParentNode().getAttributes().getNamedItem("type").setTextContent(String.valueOf(DigestUtils.sha1Hex(signedCert.getEncoded())));
+ /////////
+
+
+
+ NamedNodeMap clientCertAttributes = wapParm.item(1).getAttributes();
+ Node b64CliendEncoded = clientCertAttributes.getNamedItem("value");
+ signedCertEncoded=signedCertEncoded.replaceAll("\n","");
+ b64CliendEncoded.setTextContent(signedCertEncoded);
+ System.out.println("COPY_SIGNED_CERT:"+signedCertEncoded);
+
+
+ String wapProvisioning = convertDocumentToString(dDoc);
+
+ ///////
+ System.out.println("WAP_XML:"+wapProvisioning+"\n\n\n");
+ ///////
+
+ encodedWap = base64Encoder.encode(wapProvisioning.getBytes());
+
+ } catch (Exception e) {
+ //throw
+ }
+
+ RequestedSecurityToken rst = new RequestedSecurityToken();
+ BinarySecurityToken BinarySecToken=new BinarySecurityToken();
+ BinarySecToken.setValueType("http://schemas.microsoft.com/5.0.0.0/ConfigurationManager/Enrollment/DeviceEnrollmentProvisionDoc");
+ BinarySecToken.setEncodingType(
+ "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd#base64binary");
+ BinarySecToken.setToken(encodedWap);
+ rst.setBinarySecurityToken(BinarySecToken);
+
+ rs.setRequestedSecurityToken(rst);
+ rs.setRequestID(0);
+ response.value = rs;
+
+ }
+
+ private String convertDocumentToString(Document document) throws Exception {
+ DOMSource domSource = new DOMSource(document);
+ StringWriter writer = new StringWriter();
+ StreamResult result = new StreamResult(writer);
+ TransformerFactory tf = TransformerFactory.newInstance();
+ Transformer transformer = tf.newTransformer();
+ transformer.transform(domSource, result);
+ String wapProvisioning = writer.toString();
+
+ return wapProvisioning;
+
+ }
+
+ public void certificateSign() {
+
+ try {
+ KeyStore securityJks = KeyStoreGenerator.getKeyStore();
+ String pass = "wso2carbon";
+ KeyStoreGenerator.loadToStore(securityJks, pass.toCharArray(), "/Users/asok/Downloads/wso2as-5.2.1/repository/resources/security/wso2carbon.jks");
+ PrivateKey privateKeyCA = (PrivateKey) securityJks.getKey("wso2carbon", pass.toCharArray());
+
+ privateKey=privateKeyCA;
+
+ Certificate cartificateCA = securityJks.getCertificate(pass);
+ CertificateFactory cf = CertificateFactory.getInstance("X.509");
+ ByteArrayInputStream bais = new ByteArrayInputStream(cartificateCA.getEncoded());
+ X509Certificate cartificateCAX509 = (X509Certificate) cf.generateCertificate(bais);
+
+ rooCACertificate=cartificateCAX509;
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+}
diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/util/ApkGenerationException.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/util/ApkGenerationException.java
new file mode 100644
index 000000000..0c7d2768f
--- /dev/null
+++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/util/ApkGenerationException.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2014, 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 cdm.api.windows.wstep.util;
+
+
+/**
+ * Custom exception handling class, to handle the issue that come up during
+ * execution of Apk and certificate generation.
+ */
+public class ApkGenerationException extends Exception {
+
+ public ApkGenerationException(String message) {
+ super(message);
+ }
+
+ public ApkGenerationException(String message, Throwable e) {
+ super(message, e);
+ }
+
+}
diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/util/CertificateSigningService.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/util/CertificateSigningService.java
new file mode 100644
index 000000000..75d45c5e8
--- /dev/null
+++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/util/CertificateSigningService.java
@@ -0,0 +1,104 @@
+package cdm.api.windows.wstep.util;
+
+//REMOVE THIS LATER
+
+import org.apache.log4j.Logger;
+import org.bouncycastle.asn1.x500.X500Name;
+import org.bouncycastle.asn1.x509.*;
+import org.bouncycastle.cert.X509CertificateHolder;
+import org.bouncycastle.cert.X509v3CertificateBuilder;
+import org.bouncycastle.cert.jcajce.JcaX509CertificateConverter;
+import org.bouncycastle.cert.jcajce.JcaX509ExtensionUtils;
+import org.bouncycastle.cert.jcajce.JcaX509v3CertificateBuilder;
+import org.bouncycastle.crypto.params.AsymmetricKeyParameter;
+import org.bouncycastle.crypto.util.PrivateKeyFactory;
+import org.bouncycastle.jce.PKCS10CertificationRequest;
+import org.bouncycastle.operator.ContentSigner;
+import org.bouncycastle.operator.DefaultDigestAlgorithmIdentifierFinder;
+import org.bouncycastle.operator.DefaultSignatureAlgorithmIdentifierFinder;
+import org.bouncycastle.operator.OperatorCreationException;
+import org.bouncycastle.operator.bc.BcRSAContentSignerBuilder;
+import org.bouncycastle.operator.jcajce.JcaContentSignerBuilder;
+//import org.bouncycastle.pkcs.PKCS10CertificationRequestHolder;
+import org.bouncycastle.pkcs.jcajce.JcaPKCS10CertificationRequest;
+
+
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.math.BigInteger;
+import java.security.*;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateFactory;
+import java.security.cert.X509Certificate;
+import java.util.Date;
+
+public class CertificateSigningService {
+
+ private static Logger LOGGER = Logger.getLogger(CertificateSigningService.class);
+
+ /*public static X509Certificate sign(PKCS10CertificationRequest inputCSR, PrivateKey caPrivate, X509Certificate caCertificate)
+ throws InvalidKeyException, NoSuchAlgorithmException,NoSuchProviderException, SignatureException, IOException,
+ OperatorCreationException, CertificateException {
+
+ AlgorithmIdentifier sigAlgId = new DefaultSignatureAlgorithmIdentifierFinder().find("SHA1withRSA");
+ AlgorithmIdentifier digAlgId = new DefaultDigestAlgorithmIdentifierFinder().find(sigAlgId);
+
+ AsymmetricKeyParameter foo = PrivateKeyFactory.createKey(caPrivate.getEncoded());
+
+ //SubjectPublicKeyInfo keyInfo = SubjectPublicKeyInfo.getInstance(pair.getPublic().getEncoded());
+
+ PKCS10CertificationRequestHolder pk10Holder = new PKCS10CertificationRequestHolder(inputCSR);
+ SubjectPublicKeyInfo csrKeyInfo = pk10Holder.getSubjectPublicKeyInfo();
+
+ LOGGER.info("CN of the Device's CSR : " + pk10Holder.getSubject().toString());
+
+
+ X509v3CertificateBuilder myCertificateGenerator = new X509v3CertificateBuilder(
+ new X500Name(caCertificate.getIssuerX500Principal().getName()), BigInteger.valueOf(new SecureRandom().nextInt(Integer.MAX_VALUE)), new Date(System.currentTimeMillis() - 1000L * 60 * 60 * 24 * 30),
+ new Date(System.currentTimeMillis() + (1000L * 60 * 60 * 24 * 365*10)), new X500Name("CN=abimaran"), csrKeyInfo);
+
+ ContentSigner sigGen = new BcRSAContentSignerBuilder(sigAlgId, digAlgId).build(foo);
+
+ X509CertificateHolder holder = myCertificateGenerator.build(sigGen);
+ X509CertificateStructure eeX509CertificateStructure = holder.toASN1Structure();
+
+ CertificateFactory cf = CertificateFactory.getInstance("X.509", "BC");
+
+ // Read Certificate
+ InputStream is1 = new ByteArrayInputStream(eeX509CertificateStructure.getEncoded());
+ X509Certificate theCert = (X509Certificate) cf.generateCertificate(is1);
+
+ LOGGER.info("Signed Certificate CN : " + theCert.getSubjectDN().getName());
+
+ LOGGER.info("Signed CSR's public key : " + theCert.getPublicKey());
+
+ is1.close();
+ return theCert;
+ }*/
+
+ public static X509Certificate signCSR(JcaPKCS10CertificationRequest jcaRequest, PrivateKey privateKey, X509Certificate caCert) throws Exception{
+ try {
+
+ X509v3CertificateBuilder certificateBuilder = new JcaX509v3CertificateBuilder(caCert,
+ BigInteger.valueOf(new SecureRandom().nextInt(Integer.MAX_VALUE)), new Date(System.currentTimeMillis() - 1000L * 60 * 60 * 24 * 30),
+ new Date(System.currentTimeMillis() + (1000L * 60 * 60 * 24 * 365*10)), new X500Name("CN=abimaran"), jcaRequest.getPublicKey());
+
+ JcaX509ExtensionUtils extUtils = new JcaX509ExtensionUtils();
+
+ ContentSigner signer = new JcaContentSignerBuilder("SHA1withRSA").setProvider("BC").build(privateKey);
+
+ X509Certificate theCert = new JcaX509CertificateConverter().setProvider("BC").getCertificate(certificateBuilder.build(signer));
+
+ LOGGER.info("Signed Certificate CN : " + theCert.getSubjectDN().getName());
+
+ LOGGER.info("Signed CSR's public key : " + theCert.getPublicKey());
+
+ return theCert;
+
+ } catch (Exception e) {
+ throw new Exception("Error in signing the certificate", e);
+ }
+ }
+}
diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/util/CertificateUtil.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/util/CertificateUtil.java
new file mode 100644
index 000000000..1c3424e57
--- /dev/null
+++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/util/CertificateUtil.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2014, 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 cdm.api.windows.wstep.util;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+
+import java.math.BigInteger;
+
+import java.security.PrivateKey;
+import java.security.PublicKey;
+import java.security.SecureRandom;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+import java.util.Date;
+import org.spongycastle.asn1.x500.X500Name;
+import org.spongycastle.cert.X509v3CertificateBuilder;
+import org.spongycastle.cert.jcajce.JcaX509CertificateConverter;
+import org.spongycastle.cert.jcajce.JcaX509v3CertificateBuilder;
+import org.spongycastle.operator.ContentSigner;
+import org.spongycastle.operator.OperatorCreationException;
+import org.spongycastle.operator.jcajce.JcaContentSignerBuilder;
+
+/**
+ * Generate X509 V3 certificates. CA, RA and SSL can be generated, where
+ * intermediate certificates are signed from the root certificate to generate
+ * the chain.
+ */
+public class CertificateUtil {
+ private static final Log LOG = LogFactory.getLog(CertificateUtil.class);
+
+
+
+
+ public static X509Certificate signCSR(PublicKey publicKeyToBeSigned, PrivateKey caPrivateKey, X509Certificate caCert) throws Exception{
+ try {
+ X509v3CertificateBuilder certificateBuilder = new JcaX509v3CertificateBuilder(caCert,
+ BigInteger
+ .valueOf(new SecureRandom().nextInt(Integer.MAX_VALUE)),
+ new Date(System.currentTimeMillis()),
+ new Date(System.currentTimeMillis() + (1000L * 60 * 60 * 24 * 365*10)),
+ new X500Name("CN=abimaran"),
+ publicKeyToBeSigned);
+ ContentSigner signer = new JcaContentSignerBuilder("SHA1withRSA").setProvider("SC").build(caPrivateKey);
+ X509Certificate theCert = new JcaX509CertificateConverter().setProvider("SC").getCertificate(certificateBuilder.build(signer));
+ return theCert;
+
+ } catch (OperatorCreationException e) {
+ String message = "Error creating ContentSigner with JcaContentSignerBuilder"
+ + " with the private key provided.";
+ LOG.error(message, e);
+ throw new ApkGenerationException(message, e);
+ } catch (CertificateException e) {
+ String message = "Error building certificate.";
+ LOG.error(message, e);
+ throw new ApkGenerationException(message, e);
+ }
+ }
+
+}
diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/util/Constants.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/util/Constants.java
new file mode 100644
index 000000000..78ab76f4f
--- /dev/null
+++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/util/Constants.java
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2014, 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 cdm.api.windows.wstep.util;
+
+
+import java.io.File;
+
+/**
+ * Constants used throughout the project
+ */
+public class Constants {
+ public static class FilePath {
+ private FilePath() {
+ throw new AssertionError();
+ }
+
+ public static final String BKS_FILE = "emm_truststore.bks";
+ public static final String ANDROID_AGENT = "emm-agent-android";
+ public static final String WSO2CARBON_JKS = "wso2carbon.jks";
+ public static final String CLIENT_TRUST_JKS = "client-truststore.jks";
+
+ public static final String COMMON_UTIL = ANDROID_AGENT + File.separator + "src" +
+ File.separator + "org" + File.separator + "wso2" +
+ File.separator + "emm" + File.separator + "agent" +
+ File.separator + "utils" + File.separator +
+ "CommonUtilities.java";
+ public static final String WSO2EMM_JKS = "wso2emm.jks";
+ public static final String ANDROID_AGENT_RAW = ANDROID_AGENT + File.separator + "res" +
+ File.separator + "raw" + File.separator;
+ public static final String ANDROID_AGENT_APK = ANDROID_AGENT + File.separator + "target" +
+ File.separator + "emm_agent.apk";
+ public static final String APK_FOLDER = "Apk";
+ public static final String JKS_FOLDER = "jks";
+ public static final String BIN_PATH = File.separator + "bin" + File.separator + "mvn";
+ public static final String WORKING_DIR = "workingDir";
+ public static final String ZIP_PATH = "zipPath";
+ }
+
+ public static final String ALGORITHM = "RSA";
+ public static final String PROVIDER = "SC";
+ public static final String ENCRYPTION = "SHA1withRSA";
+ public static final String REGISTRATION_AUTHORITY = "RA";
+ public static final String BKS = "BKS";
+ public static final String BKS_ALIAS = "cert-alias";
+ public static final String JKS = "JKS";
+ public static final String SSL = "SSL";
+ public static final String ENVIRONMENT_VARIABLE = "MAVEN_HOME";
+ public static final String ARCHIVE_TYPE = ".zip";
+ public static final String ACTION = "clean";
+ public static final String GOAL = "package";
+ public static final String SERVER_IP_ANDROID = "String SERVER_IP = \"";
+ public static final String TRUST_STORE_BKS = "String TRUSTSTORE_PASSWORD = \"";
+
+ public static class CSRDataKeys {
+ private CSRDataKeys() {
+ throw new AssertionError();
+ }
+
+ public static final String COUNTRY_CA = "countryCA";
+ public static final String STATE_CA = "stateCA";
+ public static final String LOCALITY_CA = "localityCA";
+ public static final String ORGANIZATION_CA = "organizationCA";
+ public static final String ORGANIZATION_UNIT_CA = "organizationUCA";
+ public static final String DAYS_CA = "daysCA";
+ public static final String COMMON_NAME_CA = "commonNameCA";
+ public static final String COUNTRY_RA = "countryRA";
+ public static final String STATE_RA = "stateRA";
+ public static final String LOCALITY_RA = "localityRA";
+ public static final String ORGANIZATION_RA = "organizationRA";
+ public static final String ORGANIZATION_UNIT_RA = "organizationURA";
+ public static final String DAYS_RA = "daysRA";
+ public static final String COMMON_NAME_RA = "commonNameRA";
+ public static final String COUNTRY_SSL = "countrySSL";
+ public static final String STATE_SSL = "stateSSL";
+ public static final String LOCALITY_SSL = "localitySSL";
+ public static final String ORGANIZATION_SSL = "organizationSSL";
+ public static final String ORGANIZATION_UNIT_SSL = "organizationUSSL";
+ public static final String DAYS_SSL = "daysSSL";
+ public static final String SERVER_IP = "serverIp";
+ public static final String PASSWORD = "password";
+ public static final String USERSNAME = "usersname";
+ public static final String COMPANY = "company";
+
+ }
+
+ public static class TruststoreKeys {
+ private TruststoreKeys() {
+ throw new AssertionError();
+ }
+
+ public static final String PASSWORD_PK12_CA = "passwordPK12CA";
+ public static final String PASSWORD_PK12_RA = "passwordPK12RA";
+ public static final String ALIAS_PK12_CA = "aliasPK12CA";
+ public static final String ALIAS_PK12_RA = "aliasPK12RA";
+ public static final String PASSWORD_WSO2_EMM_JKS = "passwordWSO2EMMJKS";
+ public static final String ALIAS__CLIENT_TRUSTSTORE = "aliasClientTruststore";
+ public static final String PASSWORD_CLIENT_TRUSTSTORE = "passwordClientTruststore";
+ public static final String ALIAS_WSO2_CARBON = "aliasWSO2Carbon";
+ public static final String PASSWORD_WSO2_CARBON = "passwordWSO2Carbon";
+ }
+}
diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/util/FileOperator.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/util/FileOperator.java
new file mode 100644
index 000000000..94c58163a
--- /dev/null
+++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/util/FileOperator.java
@@ -0,0 +1,195 @@
+/*
+ * Copyright (c) 2014, 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 cdm.api.windows.wstep.util;
+
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codehaus.plexus.util.FileUtils;
+
+import java.io.*;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+/**
+ * Common file operations such as read, write PEM files and .zip file creation
+ * are handled by this class. These methods are added to improve reusability of
+ * commonly used file operations.
+ */
+public class FileOperator {
+
+ private static final Log LOG = LogFactory.getLog(FileOperator.class);
+
+ /**
+ * Copy file from the source path to a destination.
+ *
+ * @param source source file path
+ * @param destination destination file path
+ * @throws ApkGenerationException
+ */
+ public static void copyFile(String source, String destination)
+ throws ApkGenerationException {
+ try {
+ FileUtils.copyFile(new File(source), new File(destination));
+ } catch (IOException e) {
+ String message =
+ "Cannot find one of the files, while trying to copy file :" + source +
+ ", to its destination: " + destination;
+ LOG.error(message, e);
+ throw new ApkGenerationException(message, e);
+ }
+ }
+
+ /**
+ * Read a file and returns its content as a {@link String}
+ *
+ * @param path of the file to be read.
+ * @return the content of the file
+ * @throws ApkGenerationException
+ */
+ public static String readFile(String path) throws ApkGenerationException {
+ try {
+ return FileUtils.fileRead(new File(path));
+ } catch (IOException e) {
+ String message = "Error reading file " + path;
+ LOG.error(message, e);
+ throw new ApkGenerationException(message, e);
+ }
+ }
+
+ /**
+ * Write content to a physical file
+ *
+ * @param path the destination file path
+ * @param content data to be saved
+ * @throws ApkGenerationException
+ */
+ public static void fileWrite(String path, String content) throws ApkGenerationException {
+ try {
+ FileUtils.fileWrite(path, content);
+ } catch (IOException e) {
+ String message = "Error writing to file " + path;
+ LOG.error(message, e);
+ throw new ApkGenerationException(message, e);
+ }
+ }
+
+ /**
+ * Creates a zip file from a list of files provided.
+ *
+ * @param zipFilePath the path of the final zip file to be created.
+ * @param files An array of file paths that needs to be added to the zip
+ * @throws ApkGenerationException
+ */
+ public static void createZip(String zipFilePath, String[] files)
+ throws ApkGenerationException {
+ FileOutputStream fileOut;
+ File fileToCopy;
+ ZipOutputStream zipOutStream = null;
+ FileInputStream inputStream = null;
+ byte[] bytes = new byte[1024];
+ int count;
+ int x = 0;
+
+ try {
+ fileOut = new FileOutputStream(zipFilePath);
+ } catch (FileNotFoundException e) {
+ String message = "Error opening file " + zipFilePath;
+ LOG.error(message, e);
+ throw new ApkGenerationException(message, e);
+ }
+
+ try {
+ zipOutStream = new ZipOutputStream(fileOut);
+ for (x = 0; x < files.length; x++) {
+ fileToCopy = new File(files[x]);
+ inputStream = new FileInputStream(files[x]);
+ zipOutStream.putNextEntry(new ZipEntry(fileToCopy.getName()));
+
+ while ((count = inputStream.read(bytes)) > 0) {
+ zipOutStream.write(bytes, 0, count);
+ }
+ }
+ } catch (FileNotFoundException e) {
+ String message = "Cannot open the file ," + files[x] + " to add to zip.";
+ LOG.error(message, e);
+ throw new ApkGenerationException(message, e);
+ } catch (IOException e) {
+ String message = "Cannot write file ," + files[x] + " to zip.";
+ LOG.error(message, e);
+ throw new ApkGenerationException(message, e);
+ } finally {
+ if (inputStream != null) {
+ try {
+ inputStream.close();
+ } catch (IOException e) {
+ String message = "File error while closing the file, " + files[x];
+ LOG.warn(message, e);
+ }
+ }
+ if (zipOutStream != null) {
+ try {
+ zipOutStream.close();
+ } catch (IOException e) {
+ String message = "File error while closing the file, " + zipFilePath;
+ LOG.warn(message, e);
+ }
+ }
+ }
+ }
+
+ /**
+ * Get a file input stream when the file name is provided.
+ *
+ * @param sourceFile Name of the source file.
+ * @return the file input stream.
+ * @throws ApkGenerationException
+ */
+ public static FileInputStream getFileInputStream(String sourceFile)
+ throws ApkGenerationException {
+ try {
+ return new FileInputStream(sourceFile);
+ } catch (FileNotFoundException e) {
+ String message = "Cannot open the file ," + sourceFile;
+ LOG.error(message, e);
+ throw new ApkGenerationException(message, e);
+ }
+ }
+
+ /**
+ * Generates a new folder if it doesn't exist when the path is given.
+ *
+ * @param path the folder path that needs to be created
+ * @throws ApkGenerationException
+ */
+ public static void makeFolder(String path) throws ApkGenerationException {
+ try {
+ File file=new File(path);
+ if(!file.mkdirs()){
+ String message = "Error when creating directory " + path;
+ LOG.error(message);
+ throw new ApkGenerationException(message);
+ }
+ } catch (SecurityException e) {
+ String message = "Error when creating directory " + path;
+ LOG.error(message, e);
+ throw new ApkGenerationException(message, e);
+ }
+ }
+}
diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/util/KeyStoreGenerator.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/util/KeyStoreGenerator.java
new file mode 100644
index 000000000..0e88177d5
--- /dev/null
+++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/util/KeyStoreGenerator.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2014, 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 cdm.api.windows.wstep.util;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.security.*;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+
+/**
+ * Creation of key stores and injecting certificates to the key stores is
+ * handled here.
+ */
+public class KeyStoreGenerator {
+
+ private static final Log LOG = LogFactory.getLog(KeyStoreGenerator.class);
+
+ /**
+ * Load/initiate a key store from a provided file.
+ *
+ * @param keyStore The destination key store which needs to be loaded.
+ * @param storePass Password of the key store.
+ * @param resultFile The source key store file.
+ * @throws ApkGenerationException
+ */
+ public static void loadToStore(KeyStore keyStore, char[] storePass, String resultFile)
+ throws ApkGenerationException {
+ FileInputStream fileInputStream = null;
+
+ try {
+ if (resultFile != null) {
+ fileInputStream = FileOperator.getFileInputStream(resultFile);
+ keyStore.load(fileInputStream, storePass);
+ }
+ } catch (NoSuchAlgorithmException e) {
+ String message = Constants.ALGORITHM + " cryptographic algorithm is requested but" +
+ " it is not available in the environment.";
+ LOG.error(message, e);
+ throw new ApkGenerationException(message, e);
+ } catch (CertificateException e) {
+ String message = "Error working with certificate related to, " + resultFile;
+ LOG.error(message, e);
+ throw new ApkGenerationException(message, e);
+ } catch (IOException e) {
+ String message = "File error while working with file, " + resultFile;
+ LOG.error(message, e);
+ throw new ApkGenerationException(message, e);
+ } finally {
+ try {
+ if (fileInputStream != null) {
+ fileInputStream.close();
+ }
+ } catch (IOException e) {
+ String message = "File error while closing the file, " + resultFile;
+ LOG.error(message, e);
+ }
+ }
+ }
+
+ public static KeyStore getKeyStore() throws ApkGenerationException {
+ try {
+ return KeyStore.getInstance(Constants.JKS);
+ } catch (KeyStoreException e) {
+ String message = "KeyStore error while creating new JKS.";
+ LOG.error(message, e);
+ throw new ApkGenerationException(message, e);
+ }
+
+ }
+
+
+}
diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/util/PPSRSOApMessageHandler.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/util/PPSRSOApMessageHandler.java
new file mode 100644
index 000000000..62897db30
--- /dev/null
+++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/util/PPSRSOApMessageHandler.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2014, 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 cdm.api.windows.wstep.util;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.handler.soap.SOAPHandler;
+import javax.xml.ws.handler.soap.SOAPMessageContext;
+import java.util.HashSet;
+import java.util.Set;
+
+public class PPSRSOApMessageHandler implements SOAPHandler {
+
+ @Override
+ public Set getHeaders() {
+ final QName securityHeader = new QName(
+ "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd",
+ "Security",
+ "wsse");
+
+ final HashSet headers = new HashSet();
+ headers.add(securityHeader);
+
+ System.out.println("CHECKED_HEADER");
+
+ return headers;
+ }
+
+ @Override public boolean handleMessage(SOAPMessageContext context) {
+ return true;
+ }
+
+ @Override public boolean handleFault(SOAPMessageContext context) {
+ return true;
+ }
+
+ @Override public void close(MessageContext context) {
+
+ }
+
+}
diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/util/PasswordCallbackHandler.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/util/PasswordCallbackHandler.java
new file mode 100644
index 000000000..859ac4676
--- /dev/null
+++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/util/PasswordCallbackHandler.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2014, 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 cdm.api.windows.wstep.util;
+
+import org.apache.ws.security.WSPasswordCallback;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.UnsupportedCallbackException;
+import java.io.IOException;
+
+public class PasswordCallbackHandler implements CallbackHandler {
+
+ @Override public void handle(Callback[] callbacks)
+ throws IOException, UnsupportedCallbackException {
+ WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
+
+ System.out.println("CHECKED_BEFORE_IF_SECURITY");
+
+ if ("asok@wso2.com".equals(pc.getIdentifier())) {
+ System.out.println("CHECKED_IF_SECURITY" + pc.getIdentifier());
+ pc.setPassword("admin");
+ return;
+ }
+ }
+}
\ No newline at end of file
diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/IPolicy.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/IPolicy.java
new file mode 100644
index 000000000..923d15655
--- /dev/null
+++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/IPolicy.java
@@ -0,0 +1,48 @@
+package cdm.api.windows.xcep;
+
+import cdm.api.windows.xcep.beans.CACollection;
+import cdm.api.windows.xcep.beans.OIDCollection;
+import cdm.api.windows.xcep.beans.ObjectFactory;
+import cdm.api.windows.xcep.beans.Response;
+
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebResult;
+import javax.jws.WebService;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.POST;
+import javax.ws.rs.Produces;
+import javax.xml.bind.annotation.XmlSeeAlso;
+import javax.xml.ws.Action;
+import javax.xml.ws.BindingType;
+import javax.xml.ws.RequestWrapper;
+import javax.xml.ws.ResponseWrapper;
+import javax.xml.ws.soap.SOAPBinding;
+
+/**
+ * This class was generated by Apache CXF 2.7.3
+ * 2015-01-11T12:55:46.432+05:30
+ * Generated source version: 2.7.3
+ */
+@WebService(targetNamespace = "http://schemas.microsoft.com/windows/pki/2009/01/enrollmentpolicy", name = "IPolicy")
+@BindingType(value = SOAPBinding.SOAP12HTTP_BINDING)
+@XmlSeeAlso({ ObjectFactory.class })
+public interface IPolicy {
+
+ @RequestWrapper(localName = "GetPolicies", targetNamespace = "http://schemas.microsoft.com/windows/pki/2009/01/enrollmentpolicy", className = "com.microsoft.schemas.windows.pki._2009._01.enrollmentpolicy.GetPolicies")
+ @WebMethod(operationName = "GetPolicies")
+ @ResponseWrapper(localName = "GetPoliciesResponse", targetNamespace = "http://schemas.microsoft.com/windows/pki/2009/01/enrollmentpolicy", className = "com.microsoft.schemas.windows.pki._2009._01.enrollmentpolicy.GetPoliciesResponse")
+ public void getPolicies(
+ @WebParam(name = "client", targetNamespace = "http://schemas.microsoft.com/windows/pki/2009/01/enrollmentpolicy")
+ cdm.api.windows.xcep.beans.Client client,
+ @WebParam(name = "requestFilter", targetNamespace = "http://schemas.microsoft.com/windows/pki/2009/01/enrollmentpolicy")
+ cdm.api.windows.xcep.beans.RequestFilter requestFilter,
+ @WebParam(mode = WebParam.Mode.OUT, name = "response", targetNamespace = "http://schemas.microsoft.com/windows/pki/2009/01/enrollmentpolicy")
+ javax.xml.ws.Holder response,
+ @WebParam(mode = WebParam.Mode.OUT, name = "cAs", targetNamespace = "http://schemas.microsoft.com/windows/pki/2009/01/enrollmentpolicy")
+ javax.xml.ws.Holder cAs,
+ @WebParam(mode = WebParam.Mode.OUT, name = "oIDs", targetNamespace = "http://schemas.microsoft.com/windows/pki/2009/01/enrollmentpolicy")
+ javax.xml.ws.Holder oIDs
+ );
+
+}
diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/Attributes.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/Attributes.java
new file mode 100644
index 000000000..a7e141635
--- /dev/null
+++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/Attributes.java
@@ -0,0 +1,489 @@
+
+package cdm.api.windows.xcep.beans;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAnyElement;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlSchemaType;
+import javax.xml.bind.annotation.XmlType;
+import org.w3c.dom.Element;
+
+
+/**
+ *
Java class for Attributes complex type.
+ *
+ *
The following schema fragment specifies the expected content contained within this class.
+ *
+ *