From eb52073e37c4becbf354442b8cdcdebacd57a4f6 Mon Sep 17 00:00:00 2001 From: asok Date: Wed, 21 Jan 2015 16:29:24 +0530 Subject: [PATCH 01/12] commiting windows plugin --- .../agents/windows/jax-rs/build.xml | 75 ----- .../agents/windows/jax-rs/pom.xml | 62 ++-- .../agents/windows/jax-rs/run-client.bat | 81 ----- .../agents/windows/jax-rs/run-client.sh | 90 ------ .../cdm/api/windows/DiscoveryService.java | 47 --- .../cdm/api/windows/EnrolmentService.java | 43 --- .../windows/impl/DiscoveryServiceImpl.java | 72 ----- .../windows/impl/EnrolmentServiceImpl.java | 305 ------------------ .../util/CertificateSigningService.java | 92 ------ .../cdm/api/windows/util/WindowsAPIUtil.java | 45 --- .../src/main/resources/applicationContext.xml | 52 --- .../jax-rs/src/main/resources/ca_cert.pem | 20 -- .../jax-rs/src/main/resources/ca_private.key | 27 -- .../src/main/resources/discover-service.xml | 27 -- .../src/main/resources/enrollment-service.xml | 27 -- .../jax-rs/src/main/resources/log4j.xml | 50 --- .../src/main/resources/policy-service.xml | 15 - .../src/main/resources/wap-provisioning.xml | 18 ++ .../resources/windows-mdm-server.properties | 8 - .../src/main/webapp/WEB-INF/cxf-servlet.xml | 109 +++++-- .../jax-rs/src/main/webapp/WEB-INF/web.xml | 14 +- .../jax-rs/src/main/webapp/servicelist.css | 117 ------- 22 files changed, 133 insertions(+), 1263 deletions(-) delete mode 100644 product/modules/mobileservices/agents/windows/jax-rs/build.xml delete mode 100644 product/modules/mobileservices/agents/windows/jax-rs/run-client.bat delete mode 100755 product/modules/mobileservices/agents/windows/jax-rs/run-client.sh delete mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/DiscoveryService.java delete mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/EnrolmentService.java delete mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/impl/DiscoveryServiceImpl.java delete mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/impl/EnrolmentServiceImpl.java delete mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/util/CertificateSigningService.java delete mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/util/WindowsAPIUtil.java delete mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/resources/applicationContext.xml delete mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/resources/ca_cert.pem delete mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/resources/ca_private.key delete mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/resources/discover-service.xml delete mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/resources/enrollment-service.xml delete mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/resources/log4j.xml delete mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/resources/policy-service.xml delete mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/resources/windows-mdm-server.properties delete mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/webapp/servicelist.css 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 fe8e11092d..0000000000 --- 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 e0c51bde96..8f9ab89a7a 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. +--> 4.0.0 org.wso2.carbon - cdm-windows-api - JAX-RS Windows API - JAX-RS Windows API + cdm-android-api + JAX-RS Android API + JAX-RS Android API war @@ -127,23 +129,11 @@ junit test - - commons-httpclient - commons-httpclient - 3.1 - provided - javax.ws.rs jsr311-api - 1.1.1 provided - - com.google.code.gson - gson - 2.2.4 - org.wso2.carbon org.wso2.carbon.utils @@ -152,13 +142,11 @@ org.wso2.carbon org.wso2.carbon.device.mgt.common - 2.0.0-SNAPSHOT provided org.wso2.carbon org.wso2.carbon.device.mgt.core - 2.0.0-SNAPSHOT provided @@ -167,24 +155,18 @@ provided - log4j - log4j - 1.2.17 + org.apache.wss4j + wss4j-ws-security-common + 2.0.0 - org.bouncycastle - bcpkix-jdk15on - 1.49 + org.apache.cxf + cxf-rt-ws-security + 2.6.1 - org.bouncycastle - bcprov-jdk15on - 1.49 + 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 9bd370256d..0000000000 --- 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 279d5023c0..0000000000 --- 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 64cd0e8ecb..0000000000 --- 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/EnrolmentService.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/EnrolmentService.java deleted file mode 100644 index 9a61a3c61d..0000000000 --- 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 59de66ae0f..0000000000 --- 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 c3acde8387..0000000000 --- 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 6b00694097..0000000000 --- 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 ca784e1895..0000000000 --- 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/resources/applicationContext.xml b/product/modules/mobileservices/agents/windows/jax-rs/src/main/resources/applicationContext.xml deleted file mode 100644 index 5dd63f2c88..0000000000 --- a/product/modules/mobileservices/agents/windows/jax-rs/src/main/resources/applicationContext.xml +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/resources/ca_cert.pem b/product/modules/mobileservices/agents/windows/jax-rs/src/main/resources/ca_cert.pem deleted file mode 100644 index 6eaad0f570..0000000000 --- a/product/modules/mobileservices/agents/windows/jax-rs/src/main/resources/ca_cert.pem +++ /dev/null @@ -1,20 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDXDCCAkQCCQDWxw0vNF9H8DANBgkqhkiG9w0BAQUFADBwMQswCQYDVQQGEwJM -SzEQMA4GA1UECBMHQ29sb21ibzEQMA4GA1UEBxMHQ29sb21ibzENMAsGA1UEChME -d3NvMjEPMA0GA1UECxMGbW9iaWxlMR0wGwYDVQQDFBRjYV93c28yV2luZG93c01v -YmlsZTAeFw0xNDA3MDcxMDE4MDhaFw0xNTA3MDcxMDE4MDhaMHAxCzAJBgNVBAYT -AkxLMRAwDgYDVQQIEwdDb2xvbWJvMRAwDgYDVQQHEwdDb2xvbWJvMQ0wCwYDVQQK -EwR3c28yMQ8wDQYDVQQLEwZtb2JpbGUxHTAbBgNVBAMUFGNhX3dzbzJXaW5kb3dz -TW9iaWxlMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAz+w93X1S8nOM -VM3ScGP8XY9+PnoUaFZgKaD3d9Z6cj4HPKjIzv8iTMx9JBfDjSsLiks5nJqxm1in -juck7n0tl/CZ5L2j/3DhsA4D0Ngp5JsH5ZF+Vu2T+z8wUq8UwGD6qsn/EP9jBbj/ -WN0TtOPcfhOhfJVxaNOrt+9htYad9WOeU8Rh+CIb5oQrigEd417e5d5j4wcU8QLj -sVQQ8WRCYDrnKKof834ZnViBYX4UAdLtXkWFtKcD0RM/cB2LdjydwP3HEj6pkwjT -hRLGHdVF21VCbKOF6mnQagvuseT/ynioBNY60TXb283BQ6YrDfMytvRuzguEQ/7/ -AsTPclNZxQIDAQABMA0GCSqGSIb3DQEBBQUAA4IBAQB3cwy5pibn009WvAYzmw9B -oB77bt21GQO4gFLJlNkvIRrneE5SinjoO6ezWOgY3+8t9ViNeD874momq4kuE6Hb -XDZE1qqinJlqfMJQuEaFkDZKg55kO66wy5+8ioFhA9V8SpeM+SYy3ENBucxiDLQE -ZhM7RKJCpSIq0rRHJyBRbs6GoW7cOB5QQcFDfSW+/CajicWzeD/OJMIfjJezCsZ8 -GNXJpyAS/Te+ysHlfmrKMb1VMZphFNiTmpEx8OI8F/kbhmdwePaZ3SOw2kJp8e3v -Ke4/zPwB95wjz8luzU+PbqNO2K4ZKtXHk6rx5yybR1UBpYINvUEjsRI3hgy1IoE+ ------END CERTIFICATE----- diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/resources/ca_private.key b/product/modules/mobileservices/agents/windows/jax-rs/src/main/resources/ca_private.key deleted file mode 100644 index 764b316630..0000000000 --- a/product/modules/mobileservices/agents/windows/jax-rs/src/main/resources/ca_private.key +++ /dev/null @@ -1,27 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIIEpAIBAAKCAQEAz+w93X1S8nOMVM3ScGP8XY9+PnoUaFZgKaD3d9Z6cj4HPKjI -zv8iTMx9JBfDjSsLiks5nJqxm1injuck7n0tl/CZ5L2j/3DhsA4D0Ngp5JsH5ZF+ -Vu2T+z8wUq8UwGD6qsn/EP9jBbj/WN0TtOPcfhOhfJVxaNOrt+9htYad9WOeU8Rh -+CIb5oQrigEd417e5d5j4wcU8QLjsVQQ8WRCYDrnKKof834ZnViBYX4UAdLtXkWF -tKcD0RM/cB2LdjydwP3HEj6pkwjThRLGHdVF21VCbKOF6mnQagvuseT/ynioBNY6 -0TXb283BQ6YrDfMytvRuzguEQ/7/AsTPclNZxQIDAQABAoIBAQCrNz+Od1fpnOrv -Hnnu4Pb82F+99Ot/K7mOLiX6Qdyc3KU690Y85m2JTk6yfPsj8VFUdTOg2OXuJWf9 -TivkU6JK3u7rJJq6i2rdffz4aji9Lkina1LdJFBacaNKQzBUZsekAiiPB660FK34 -sDw9FfIIxAOTwsAb8UoTcgVE5PCIEx7R7YdAI0/mMnd98kTc2YdcnAmGwrDFQNer -eOLhq8H/6SxUADyos3s6Tgw3/yIo9BnBpe8uPNoakEPgYJLh263uF2rJ2h0+yLDV -9F9by+yFCqyVqS8P06NI+NMe8WsYJo99RGQsLZ7PsI5jiJSTRYgOF4ROQfAcCZiK -UWKCwcwhAoGBAPOg32J8AZX64FFDqyruN/1Q6hJfkVAVM+B3dxNAYIpccLuuxJ7x -JMIWkAFfBlOoaXZzxaDIXmXrd3h5qxRTd6W/gAR9nRko7YHaK7NszpEPA8hVOjjx -kkTNs/KjlELrLspRWL+iDqR5Nscw0V9y2D6tyYuGp475wK4PmKbgcKAdAoGBANp7 -M9nFEAUTeHzdo9csbrGy6wUuCRlixFvXKOH+1ezeuNvxh0XtbJPj7FrPT4nuCKEV -Wud1w3/IRaeCYeKXaHk6eF8zN1gVkN0MAQJ+9KtfZ0QnmQSsluJfrUBGej6UYO0z -DUv5CLNYLPwOVGTb/jb5n+lY2IzjKmA+aWZRML/JAoGBAJSfUycVVzJTdXydt1Hd -OTLDpcfHnTIpfRg2SOHpp/tAIVWdbD06Bp6QfREZExb96jhkr+9BzLSITL2mG4Ou -15K5nDMhHjE3Eozgt0Ah5HIBouEXfQk39W8bvecLe2rHZifuMCHXju8vMweY9GEy -AlFaW1VOs/E40x5cTVegG5TRAoGANLxmUJtTeZYwkBtDr+2GrpfcSLzK73i6otx1 -fs9vPaSpBFXxa/yaJ7xtUaIWtdlh9dfcwF/Zl590yLEdBX+8dP6bDYekRTu3YtPB -7qNMVY1KtNXGBq3OIcgsXoZkfXR9TOP0wrDS289d1F11G39KhmSMp9uNMbynfuGx -uUPBu5kCgYA1UUtQkVPbkKaaopSrDkqAJDlsUnNVkvXH5yWqdAYI2Frw1iOwhED3 -cKmwAejf8nl1HPwfDTGQMRB5PCDkK7mWJ5w9W4MUbJ7ZiNPHloZutUTcw3Nz58cn -OZMZGR/Trtn+YLoj2526NPwKqlw0bRB27UR0KOdgPOHynI3uYPnwgQ== ------END RSA PRIVATE KEY----- diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/resources/discover-service.xml b/product/modules/mobileservices/agents/windows/jax-rs/src/main/resources/discover-service.xml deleted file mode 100644 index 05f8f939b9..0000000000 --- a/product/modules/mobileservices/agents/windows/jax-rs/src/main/resources/discover-service.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - http://schemas.microsoft.com/windows/management/2012/01/enrollment/IDiscoveryService/DiscoverResponse - - - d9eb2fdd-e38a-46ee-bd93-aea9dc86a3b8 - - urn:uuid: 748132ec-a575-4329-b01b-6171a9cf8478 - - - - - OnPremise - - https://EnterpriseEnrollment.wso2.com/ENROLLMENTSERVER/PolicyEnrollmentWebservice.svc - - - https://EnterpriseEnrollment.wso2.com/ENROLLMENTSERVER/DeviceEnrollmentWebservice.svc - - - - - \ No newline at end of file diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/resources/enrollment-service.xml b/product/modules/mobileservices/agents/windows/jax-rs/src/main/resources/enrollment-service.xml deleted file mode 100644 index 4be6e477ac..0000000000 --- a/product/modules/mobileservices/agents/windows/jax-rs/src/main/resources/enrollment-service.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - http://schemas.microsoft.com/windows/pki/2009/01/enrollment/RSTRC/wstep - urn:uuid:81a5419a-496b-474f-a627-5cdd33eed8ab - - - 2012-08-02T00:32:59.420Z - 2014-08-02T00:37:59.420Z - - - - - - - http://schemas.microsoft.com/5.0.0.0/ConfigurationManager/Enrollment/DeviceEnrollmentToken - - - - - 0 - - - - \ No newline at end of file diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/resources/log4j.xml b/product/modules/mobileservices/agents/windows/jax-rs/src/main/resources/log4j.xml deleted file mode 100644 index 7cd7d64125..0000000000 --- a/product/modules/mobileservices/agents/windows/jax-rs/src/main/resources/log4j.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/resources/policy-service.xml b/product/modules/mobileservices/agents/windows/jax-rs/src/main/resources/policy-service.xml deleted file mode 100644 index e38440d6bd..0000000000 --- a/product/modules/mobileservices/agents/windows/jax-rs/src/main/resources/policy-service.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - http://schemas.microsoft.com/windows/pki/2009/01/enrollmentpolicy/IPolicy/GetPoliciesResponse - - - - - - - - \ No newline at end of file diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/resources/wap-provisioning.xml b/product/modules/mobileservices/agents/windows/jax-rs/src/main/resources/wap-provisioning.xml index d51958a715..7683a22c1e 100644 --- a/product/modules/mobileservices/agents/windows/jax-rs/src/main/resources/wap-provisioning.xml +++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/resources/wap-provisioning.xml @@ -1,3 +1,21 @@ + + diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/resources/windows-mdm-server.properties b/product/modules/mobileservices/agents/windows/jax-rs/src/main/resources/windows-mdm-server.properties deleted file mode 100644 index 6f092e31fb..0000000000 --- a/product/modules/mobileservices/agents/windows/jax-rs/src/main/resources/windows-mdm-server.properties +++ /dev/null @@ -1,8 +0,0 @@ -service.url=http://0.0.0.0:9090 - - -discovery.service.file.location=./conf/discover-service.xml -policy.certificate.file.location=./conf/policy-service.xml -enrollment.service.file.location=./conf/enrollment-service.xml - -enrollment.service.wap.provisioning.file.location=./conf/wap-provisioning.xml \ No newline at end of file diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/webapp/WEB-INF/cxf-servlet.xml b/product/modules/mobileservices/agents/windows/jax-rs/src/main/webapp/WEB-INF/cxf-servlet.xml index 165c967047..532caed718 100644 --- a/product/modules/mobileservices/agents/windows/jax-rs/src/main/webapp/WEB-INF/cxf-servlet.xml +++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/webapp/WEB-INF/cxf-servlet.xml @@ -1,44 +1,101 @@ - - - - - - + + + - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/webapp/WEB-INF/web.xml b/product/modules/mobileservices/agents/windows/jax-rs/src/main/webapp/WEB-INF/web.xml index 777ee8a709..c36bac34d5 100644 --- a/product/modules/mobileservices/agents/windows/jax-rs/src/main/webapp/WEB-INF/web.xml +++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/webapp/WEB-INF/web.xml @@ -20,10 +20,16 @@ --> CDM-Windows-API + + + contextConfigLocation + /WEB-INF/cxf-servlet.xml + + - JAX-WS/JAX-RS Endpoint - JAX-WS/JAX-RS Servlet - JAXServlet + JAX-WS/JAX-RS-windows Endpoint + JAX-WS/JAX-RS-windows Servlet + JAXServlet-windows org.apache.cxf.transport.servlet.CXFServlet @@ -34,7 +40,7 @@ 1 - JAXServlet + JAXServlet-windows /* diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/webapp/servicelist.css b/product/modules/mobileservices/agents/windows/jax-rs/src/main/webapp/servicelist.css deleted file mode 100644 index bbc4987c0a..0000000000 --- a/product/modules/mobileservices/agents/windows/jax-rs/src/main/webapp/servicelist.css +++ /dev/null @@ -1,117 +0,0 @@ -@CHARSET "ISO-8859-1"; - -/* http://meyerweb.com/eric/tools/css/reset/ - v2.0 | 20110126 - License: none (public domain) -*/ - -html, body, div, span, applet, object, iframe, -h1, h2, h3, h4, h5, h6, p, blockquote, pre, -a, abbr, acronym, address, big, cite, code, -del, dfn, em, img, ins, kbd, q, s, samp, -small, strike, strong, sub, sup, tt, var, -b, u, i, center, -dl, dt, dd, ol, ul, li, -fieldset, form, label, legend, -table, caption, tbody, tfoot, thead, tr, th, td, -article, aside, canvas, details, embed, -figure, figcaption, footer, header, hgroup, -menu, nav, output, ruby, section, summary, -time, mark, audio, video { - margin: 0; - padding: 0; - border: 0; - font-size: 100%; - font: inherit; - vertical-align: baseline; -} -/* HTML5 display-role reset for older browsers */ -article, aside, details, figcaption, figure, -footer, header, hgroup, menu, nav, section { - display: block; -} - -html { - background: #efefef; -} - -body { - line-height: 1; - width:960px; - margin:auto; - background:white; - padding:10px; - box-shadow:0px 0px 5px #CCC; - font-family:"Lucida Grande","Lucida Sans","Microsoft Sans Serif", "Lucida Sans Unicode","Verdana","Sans-serif","trebuchet ms" !important; - -} -ol, ul { - list-style: none; -} -blockquote, q { - quotes: none; -} -blockquote:before, blockquote:after, -q:before, q:after { - content: ''; - content: none; -} -table { - border-collapse: collapse; - border-spacing: 0; - width:960px; - border:solid 1px #ccc; -} - -table a { - font-size:12px; - color:#1e90ff; - padding:7px; -float:left; -; -} - -.heading { - font-size: 18px; - margin-top: 20px; - float:left; - color:#0067B1; - margin-bottom:20px; - padding-top:20px; -} - -.field { - font-weight: normal; - width:120px; - font-size:12px; - float:left; - padding:7px; - clear:left; -} -.value { - font-weight: bold; - font-size:12px; - float:left; - padding:7px; - clear:right; -} -.porttypename { - font-weight: bold; - font-size:14px; -} -UL { - margin-top: 0; -} -LI { - font-weight: normal; - font-size:12px; - margin-top:10px; -} - -TD { - border:1px solid #ccc; - vertical-align: text-top; - padding: 5px; -} - - From ebe0aa2663d476bbfcfa6fa1615b62729d17f895 Mon Sep 17 00:00:00 2001 From: asok Date: Wed, 21 Jan 2015 16:34:03 +0530 Subject: [PATCH 02/12] commiting windows plugin --- .../DiscoveryService/DiscoveryServiceGet.java | 52 ++ .../beans/in/DiscoveryRequest.java | 61 +++ .../beans/in/package-info.java | 24 + .../DiscoveryService/beans/out/Message.java | 58 +++ .../impl/DiscoveryServiceGetImpl.java | 64 +++ .../wstep/CertificateEnrollmentService.java | 54 ++ .../wstep/beans/AdditionalContext.java | 45 ++ .../wstep/beans/BinarySecurityToken.java | 60 +++ .../api/windows/wstep/beans/ContextItem.java | 43 ++ .../wstep/beans/RequestSecurityToken.java | 40 ++ .../beans/RequestSecurityTokenResponse.java | 71 +++ .../wstep/beans/RequestedSecurityToken.java | 45 ++ .../api/windows/wstep/beans/package-info.java | 27 + .../CertificateEnrollmentServiceImpl.java | 195 +++++++ .../wstep/util/ApkGenerationException.java | 36 ++ .../wstep/util/CertificateSigningService.java | 104 ++++ .../windows/wstep/util/CertificateUtil.java | 77 +++ .../cdm/api/windows/wstep/util/Constants.java | 117 +++++ .../api/windows/wstep/util/FileOperator.java | 195 +++++++ .../windows/wstep/util/KeyStoreGenerator.java | 94 ++++ .../wstep/util/PPSRSOApMessageHandler.java | 57 ++ .../wstep/util/PasswordCallbackHandler.java | 42 ++ .../java/cdm/api/windows/xcep/IPolicy.java | 48 ++ .../api/windows/xcep/beans/Attributes.java | 489 ++++++++++++++++++ .../java/cdm/api/windows/xcep/beans/CA.java | 165 ++++++ .../api/windows/xcep/beans/CACollection.java | 69 +++ .../xcep/beans/CAReferenceCollection.java | 69 +++ .../cdm/api/windows/xcep/beans/CAURI.java | 170 ++++++ .../windows/xcep/beans/CAURICollection.java | 69 +++ .../beans/CertificateEnrollmentPolicy.java | 147 ++++++ .../xcep/beans/CertificateValidity.java | 94 ++++ .../cdm/api/windows/xcep/beans/Client.java | 135 +++++ .../windows/xcep/beans/CryptoProviders.java | 69 +++ .../xcep/beans/EnrollmentPermission.java | 71 +++ .../cdm/api/windows/xcep/beans/Extension.java | 99 ++++ .../xcep/beans/ExtensionCollection.java | 69 +++ .../xcep/beans/FilterOIDCollection.java | 69 +++ .../api/windows/xcep/beans/GetPolicies.java | 92 ++++ .../xcep/beans/GetPoliciesResponse.java | 120 +++++ .../xcep/beans/KeyArchivalAttributes.java | 73 +++ .../java/cdm/api/windows/xcep/beans/OID.java | 169 ++++++ .../api/windows/xcep/beans/OIDCollection.java | 69 +++ .../xcep/beans/OIDReferenceCollection.java | 69 +++ .../api/windows/xcep/beans/ObjectFactory.java | 261 ++++++++++ .../windows/xcep/beans/PolicyCollection.java | 69 +++ .../xcep/beans/PrivateKeyAttributes.java | 197 +++++++ .../windows/xcep/beans/RARequirements.java | 112 ++++ .../api/windows/xcep/beans/RequestFilter.java | 100 ++++ .../cdm/api/windows/xcep/beans/Response.java | 214 ++++++++ .../cdm/api/windows/xcep/beans/Revision.java | 74 +++ .../xcep/beans/SupersededPolicies.java | 69 +++ .../api/windows/xcep/beans/package-info.java | 2 + .../cdm/api/windows/xcep/impl/xcepimpl.java | 79 +++ .../xcep/util/PPSRSOApMessageHandler.java | 58 +++ .../xcep/util/ServerPasswordCallback.java | 40 ++ 55 files changed, 5260 insertions(+) create mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/DiscoveryService/DiscoveryServiceGet.java create mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/DiscoveryService/beans/in/DiscoveryRequest.java create mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/DiscoveryService/beans/in/package-info.java create mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/DiscoveryService/beans/out/Message.java create mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/DiscoveryService/impl/DiscoveryServiceGetImpl.java create mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/CertificateEnrollmentService.java create mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/beans/AdditionalContext.java create mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/beans/BinarySecurityToken.java create mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/beans/ContextItem.java create mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/beans/RequestSecurityToken.java create mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/beans/RequestSecurityTokenResponse.java create mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/beans/RequestedSecurityToken.java create mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/beans/package-info.java create mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/impl/CertificateEnrollmentServiceImpl.java create mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/util/ApkGenerationException.java create mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/util/CertificateSigningService.java create mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/util/CertificateUtil.java create mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/util/Constants.java create mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/util/FileOperator.java create mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/util/KeyStoreGenerator.java create mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/util/PPSRSOApMessageHandler.java create mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/util/PasswordCallbackHandler.java create mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/IPolicy.java create mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/Attributes.java create mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/CA.java create mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/CACollection.java create mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/CAReferenceCollection.java create mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/CAURI.java create mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/CAURICollection.java create mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/CertificateEnrollmentPolicy.java create mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/CertificateValidity.java create mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/Client.java create mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/CryptoProviders.java create mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/EnrollmentPermission.java create mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/Extension.java create mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/ExtensionCollection.java create mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/FilterOIDCollection.java create mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/GetPolicies.java create mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/GetPoliciesResponse.java create mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/KeyArchivalAttributes.java create mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/OID.java create mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/OIDCollection.java create mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/OIDReferenceCollection.java create mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/ObjectFactory.java create mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/PolicyCollection.java create mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/PrivateKeyAttributes.java create mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/RARequirements.java create mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/RequestFilter.java create mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/Response.java create mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/Revision.java create mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/SupersededPolicies.java create mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/package-info.java create mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/impl/xcepimpl.java create mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/util/PPSRSOApMessageHandler.java create mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/util/ServerPasswordCallback.java 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 0000000000..5395251a1b --- /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 0000000000..825f51a379 --- /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 0000000000..7f21ab9ee1 --- /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 0000000000..8cc1d8f7a4 --- /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 0000000000..70c6e79ef0 --- /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/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 0000000000..9fb6eb629a --- /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 0000000000..8ffc134ff0 --- /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 0000000000..9f84e905ed --- /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 0000000000..84df970622 --- /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 0000000000..e964e6f573 --- /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 0000000000..48d3a95d0b --- /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 0000000000..b85ae85aac --- /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 0000000000..453eefdd21 --- /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 0000000000..32f8c35dcb --- /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 0000000000..0c7d2768fc --- /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 0000000000..75d45c5e85 --- /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 0000000000..1c3424e577 --- /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 0000000000..78ab76f4fa --- /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 0000000000..94c58163a9 --- /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 0000000000..0e88177d51 --- /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 0000000000..62897db308 --- /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 0000000000..859ac4676c --- /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 0000000000..923d156557 --- /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 0000000000..a7e141635b --- /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. + * + *

+ * <complexType name="Attributes">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element ref="{http://schemas.microsoft.com/windows/pki/2009/01/enrollmentpolicy}commonName"/>
+ *         <element name="policySchema" type="{http://www.w3.org/2001/XMLSchema}unsignedInt"/>
+ *         <element name="certificateValidity" type="{http://schemas.microsoft.com/windows/pki/2009/01/enrollmentpolicy}CertificateValidity"/>
+ *         <element name="permission" type="{http://schemas.microsoft.com/windows/pki/2009/01/enrollmentpolicy}EnrollmentPermission"/>
+ *         <element name="privateKeyAttributes" type="{http://schemas.microsoft.com/windows/pki/2009/01/enrollmentpolicy}PrivateKeyAttributes"/>
+ *         <element name="revision" type="{http://schemas.microsoft.com/windows/pki/2009/01/enrollmentpolicy}Revision"/>
+ *         <element name="supersededPolicies" type="{http://schemas.microsoft.com/windows/pki/2009/01/enrollmentpolicy}SupersededPolicies"/>
+ *         <element name="privateKeyFlags" type="{http://www.w3.org/2001/XMLSchema}unsignedInt"/>
+ *         <element name="subjectNameFlags" type="{http://www.w3.org/2001/XMLSchema}unsignedInt"/>
+ *         <element name="enrollmentFlags" type="{http://www.w3.org/2001/XMLSchema}unsignedInt"/>
+ *         <element name="generalFlags" type="{http://www.w3.org/2001/XMLSchema}unsignedInt"/>
+ *         <element name="hashAlgorithmOIDReference" type="{http://www.w3.org/2001/XMLSchema}int"/>
+ *         <element name="rARequirements" type="{http://schemas.microsoft.com/windows/pki/2009/01/enrollmentpolicy}RARequirements"/>
+ *         <element name="keyArchivalAttributes" type="{http://schemas.microsoft.com/windows/pki/2009/01/enrollmentpolicy}KeyArchivalAttributes"/>
+ *         <element name="extensions" type="{http://schemas.microsoft.com/windows/pki/2009/01/enrollmentpolicy}ExtensionCollection"/>
+ *         <any processContents='lax' maxOccurs="unbounded" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "Attributes", propOrder = { + "commonName", + "policySchema", + "certificateValidity", + "permission", + "privateKeyAttributes", + "revision", + "supersededPolicies", + "privateKeyFlags", + "subjectNameFlags", + "enrollmentFlags", + "generalFlags", + "hashAlgorithmOIDReference", + "raRequirements", + "keyArchivalAttributes", + "extensions", + "any" +}) +public class Attributes { + + @XmlElement(required = true) + protected String commonName; + @XmlSchemaType(name = "unsignedInt") + protected long policySchema; + @XmlElement(required = true) + protected CertificateValidity certificateValidity; + @XmlElement(required = true) + protected EnrollmentPermission permission; + @XmlElement(required = true) + protected PrivateKeyAttributes privateKeyAttributes; + @XmlElement(required = true) + protected Revision revision; + @XmlElement(required = true, nillable = true) + protected SupersededPolicies supersededPolicies; + @XmlElement(required = true, type = Long.class, nillable = true) + @XmlSchemaType(name = "unsignedInt") + protected Long privateKeyFlags; + @XmlElement(required = true, type = Long.class, nillable = true) + @XmlSchemaType(name = "unsignedInt") + protected Long subjectNameFlags; + @XmlElement(required = true, type = Long.class, nillable = true) + @XmlSchemaType(name = "unsignedInt") + protected Long enrollmentFlags; + @XmlElement(required = true, type = Long.class, nillable = true) + @XmlSchemaType(name = "unsignedInt") + protected Long generalFlags; + @XmlElement(required = true, type = Integer.class, nillable = true) + protected Integer hashAlgorithmOIDReference; + @XmlElement(name = "rARequirements", required = true, nillable = true) + protected RARequirements raRequirements; + @XmlElement(required = true, nillable = true) + protected KeyArchivalAttributes keyArchivalAttributes; + @XmlElement(required = true, nillable = true) + protected ExtensionCollection extensions; + @XmlAnyElement(lax = true) + protected List any; + + /** + * Gets the value of the commonName property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getCommonName() { + return commonName; + } + + /** + * Sets the value of the commonName property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setCommonName(String value) { + this.commonName = value; + } + + /** + * Gets the value of the policySchema property. + * + */ + public long getPolicySchema() { + return policySchema; + } + + /** + * Sets the value of the policySchema property. + * + */ + public void setPolicySchema(long value) { + this.policySchema = value; + } + + /** + * Gets the value of the certificateValidity property. + * + * @return + * possible object is + * {@link CertificateValidity } + * + */ + public CertificateValidity getCertificateValidity() { + return certificateValidity; + } + + /** + * Sets the value of the certificateValidity property. + * + * @param value + * allowed object is + * {@link CertificateValidity } + * + */ + public void setCertificateValidity(CertificateValidity value) { + this.certificateValidity = value; + } + + /** + * Gets the value of the permission property. + * + * @return + * possible object is + * {@link EnrollmentPermission } + * + */ + public EnrollmentPermission getPermission() { + return permission; + } + + /** + * Sets the value of the permission property. + * + * @param value + * allowed object is + * {@link EnrollmentPermission } + * + */ + public void setPermission(EnrollmentPermission value) { + this.permission = value; + } + + /** + * Gets the value of the privateKeyAttributes property. + * + * @return + * possible object is + * {@link PrivateKeyAttributes } + * + */ + public PrivateKeyAttributes getPrivateKeyAttributes() { + return privateKeyAttributes; + } + + /** + * Sets the value of the privateKeyAttributes property. + * + * @param value + * allowed object is + * {@link PrivateKeyAttributes } + * + */ + public void setPrivateKeyAttributes(PrivateKeyAttributes value) { + this.privateKeyAttributes = value; + } + + /** + * Gets the value of the revision property. + * + * @return + * possible object is + * {@link Revision } + * + */ + public Revision getRevision() { + return revision; + } + + /** + * Sets the value of the revision property. + * + * @param value + * allowed object is + * {@link Revision } + * + */ + public void setRevision(Revision value) { + this.revision = value; + } + + /** + * Gets the value of the supersededPolicies property. + * + * @return + * possible object is + * {@link SupersededPolicies } + * + */ + public SupersededPolicies getSupersededPolicies() { + return supersededPolicies; + } + + /** + * Sets the value of the supersededPolicies property. + * + * @param value + * allowed object is + * {@link SupersededPolicies } + * + */ + public void setSupersededPolicies(SupersededPolicies value) { + this.supersededPolicies = value; + } + + /** + * Gets the value of the privateKeyFlags property. + * + * @return + * possible object is + * {@link Long } + * + */ + public Long getPrivateKeyFlags() { + return privateKeyFlags; + } + + /** + * Sets the value of the privateKeyFlags property. + * + * @param value + * allowed object is + * {@link Long } + * + */ + public void setPrivateKeyFlags(Long value) { + this.privateKeyFlags = value; + } + + /** + * Gets the value of the subjectNameFlags property. + * + * @return + * possible object is + * {@link Long } + * + */ + public Long getSubjectNameFlags() { + return subjectNameFlags; + } + + /** + * Sets the value of the subjectNameFlags property. + * + * @param value + * allowed object is + * {@link Long } + * + */ + public void setSubjectNameFlags(Long value) { + this.subjectNameFlags = value; + } + + /** + * Gets the value of the enrollmentFlags property. + * + * @return + * possible object is + * {@link Long } + * + */ + public Long getEnrollmentFlags() { + return enrollmentFlags; + } + + /** + * Sets the value of the enrollmentFlags property. + * + * @param value + * allowed object is + * {@link Long } + * + */ + public void setEnrollmentFlags(Long value) { + this.enrollmentFlags = value; + } + + /** + * Gets the value of the generalFlags property. + * + * @return + * possible object is + * {@link Long } + * + */ + public Long getGeneralFlags() { + return generalFlags; + } + + /** + * Sets the value of the generalFlags property. + * + * @param value + * allowed object is + * {@link Long } + * + */ + public void setGeneralFlags(Long value) { + this.generalFlags = value; + } + + /** + * Gets the value of the hashAlgorithmOIDReference property. + * + * @return + * possible object is + * {@link Integer } + * + */ + public Integer getHashAlgorithmOIDReference() { + return hashAlgorithmOIDReference; + } + + /** + * Sets the value of the hashAlgorithmOIDReference property. + * + * @param value + * allowed object is + * {@link Integer } + * + */ + public void setHashAlgorithmOIDReference(Integer value) { + this.hashAlgorithmOIDReference = value; + } + + /** + * Gets the value of the raRequirements property. + * + * @return + * possible object is + * {@link RARequirements } + * + */ + public RARequirements getRARequirements() { + return raRequirements; + } + + /** + * Sets the value of the raRequirements property. + * + * @param value + * allowed object is + * {@link RARequirements } + * + */ + public void setRARequirements(RARequirements value) { + this.raRequirements = value; + } + + /** + * Gets the value of the keyArchivalAttributes property. + * + * @return + * possible object is + * {@link KeyArchivalAttributes } + * + */ + public KeyArchivalAttributes getKeyArchivalAttributes() { + return keyArchivalAttributes; + } + + /** + * Sets the value of the keyArchivalAttributes property. + * + * @param value + * allowed object is + * {@link KeyArchivalAttributes } + * + */ + public void setKeyArchivalAttributes(KeyArchivalAttributes value) { + this.keyArchivalAttributes = value; + } + + /** + * Gets the value of the extensions property. + * + * @return + * possible object is + * {@link ExtensionCollection } + * + */ + public ExtensionCollection getExtensions() { + return extensions; + } + + /** + * Sets the value of the extensions property. + * + * @param value + * allowed object is + * {@link ExtensionCollection } + * + */ + public void setExtensions(ExtensionCollection value) { + this.extensions = value; + } + + /** + * Gets the value of the any property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the any property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getAny().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link Object } + * {@link Element } + * + * + */ + public List getAny() { + if (any == null) { + any = new ArrayList(); + } + return this.any; + } + +} diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/CA.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/CA.java new file mode 100644 index 0000000000..283b6e4fa7 --- /dev/null +++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/CA.java @@ -0,0 +1,165 @@ + +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.XmlType; +import org.w3c.dom.Element; + + +/** + *

Java class for CA complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="CA">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="uris" type="{http://schemas.microsoft.com/windows/pki/2009/01/enrollmentpolicy}CAURICollection"/>
+ *         <element name="certificate" type="{http://www.w3.org/2001/XMLSchema}base64Binary"/>
+ *         <element name="enrollPermission" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
+ *         <element name="cAReferenceID" type="{http://www.w3.org/2001/XMLSchema}int"/>
+ *         <any processContents='lax' maxOccurs="unbounded" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "CA", propOrder = { + "uris", + "certificate", + "enrollPermission", + "caReferenceID", + "any" +}) +public class CA { + + @XmlElement(required = true) + protected CAURICollection uris; + @XmlElement(required = true) + protected byte[] certificate; + protected boolean enrollPermission; + @XmlElement(name = "cAReferenceID") + protected int caReferenceID; + @XmlAnyElement(lax = true) + protected List any; + + /** + * Gets the value of the uris property. + * + * @return + * possible object is + * {@link CAURICollection } + * + */ + public CAURICollection getUris() { + return uris; + } + + /** + * Sets the value of the uris property. + * + * @param value + * allowed object is + * {@link CAURICollection } + * + */ + public void setUris(CAURICollection value) { + this.uris = value; + } + + /** + * Gets the value of the certificate property. + * + * @return + * possible object is + * byte[] + */ + public byte[] getCertificate() { + return certificate; + } + + /** + * Sets the value of the certificate property. + * + * @param value + * allowed object is + * byte[] + */ + public void setCertificate(byte[] value) { + this.certificate = value; + } + + /** + * Gets the value of the enrollPermission property. + * + */ + public boolean isEnrollPermission() { + return enrollPermission; + } + + /** + * Sets the value of the enrollPermission property. + * + */ + public void setEnrollPermission(boolean value) { + this.enrollPermission = value; + } + + /** + * Gets the value of the caReferenceID property. + * + */ + public int getCAReferenceID() { + return caReferenceID; + } + + /** + * Sets the value of the caReferenceID property. + * + */ + public void setCAReferenceID(int value) { + this.caReferenceID = value; + } + + /** + * Gets the value of the any property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the any property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getAny().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link Object } + * {@link Element } + * + * + */ + public List getAny() { + if (any == null) { + any = new ArrayList(); + } + return this.any; + } + +} diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/CACollection.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/CACollection.java new file mode 100644 index 0000000000..d443cb53d6 --- /dev/null +++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/CACollection.java @@ -0,0 +1,69 @@ + +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.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for CACollection complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="CACollection">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="cA" type="{http://schemas.microsoft.com/windows/pki/2009/01/enrollmentpolicy}CA" maxOccurs="unbounded"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "CACollection", propOrder = { + "ca" +}) +public class CACollection { + + @XmlElement(name = "cA", required = true) + protected List ca; + + /** + * Gets the value of the ca property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the ca property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getCA().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link CA } + * + * + */ + public List getCA() { + if (ca == null) { + ca = new ArrayList(); + } + return this.ca; + } + +} diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/CAReferenceCollection.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/CAReferenceCollection.java new file mode 100644 index 0000000000..20284e2321 --- /dev/null +++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/CAReferenceCollection.java @@ -0,0 +1,69 @@ + +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.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for CAReferenceCollection complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="CAReferenceCollection">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="cAReference" type="{http://www.w3.org/2001/XMLSchema}int" maxOccurs="unbounded"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "CAReferenceCollection", propOrder = { + "caReference" +}) +public class CAReferenceCollection { + + @XmlElement(name = "cAReference", type = Integer.class) + protected List caReference; + + /** + * Gets the value of the caReference property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the caReference property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getCAReference().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link Integer } + * + * + */ + public List getCAReference() { + if (caReference == null) { + caReference = new ArrayList(); + } + return this.caReference; + } + +} diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/CAURI.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/CAURI.java new file mode 100644 index 0000000000..fc4a0fd906 --- /dev/null +++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/CAURI.java @@ -0,0 +1,170 @@ + +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 CAURI complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="CAURI">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="clientAuthentication" type="{http://www.w3.org/2001/XMLSchema}unsignedInt"/>
+ *         <element name="uri" type="{http://www.w3.org/2001/XMLSchema}anyURI"/>
+ *         <element name="priority" type="{http://www.w3.org/2001/XMLSchema}unsignedInt"/>
+ *         <element name="renewalOnly" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
+ *         <any processContents='lax' maxOccurs="unbounded" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "CAURI", propOrder = { + "clientAuthentication", + "uri", + "priority", + "renewalOnly", + "any" +}) +public class CAURI { + + @XmlSchemaType(name = "unsignedInt") + protected long clientAuthentication; + @XmlElement(required = true) + @XmlSchemaType(name = "anyURI") + protected String uri; + @XmlElement(required = true, type = Long.class, nillable = true) + @XmlSchemaType(name = "unsignedInt") + protected Long priority; + protected boolean renewalOnly; + @XmlAnyElement(lax = true) + protected List any; + + /** + * Gets the value of the clientAuthentication property. + * + */ + public long getClientAuthentication() { + return clientAuthentication; + } + + /** + * Sets the value of the clientAuthentication property. + * + */ + public void setClientAuthentication(long value) { + this.clientAuthentication = value; + } + + /** + * Gets the value of the uri property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getUri() { + return uri; + } + + /** + * Sets the value of the uri property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setUri(String value) { + this.uri = value; + } + + /** + * Gets the value of the priority property. + * + * @return + * possible object is + * {@link Long } + * + */ + public Long getPriority() { + return priority; + } + + /** + * Sets the value of the priority property. + * + * @param value + * allowed object is + * {@link Long } + * + */ + public void setPriority(Long value) { + this.priority = value; + } + + /** + * Gets the value of the renewalOnly property. + * + */ + public boolean isRenewalOnly() { + return renewalOnly; + } + + /** + * Sets the value of the renewalOnly property. + * + */ + public void setRenewalOnly(boolean value) { + this.renewalOnly = value; + } + + /** + * Gets the value of the any property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the any property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getAny().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link Object } + * {@link Element } + * + * + */ + public List getAny() { + if (any == null) { + any = new ArrayList(); + } + return this.any; + } + +} diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/CAURICollection.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/CAURICollection.java new file mode 100644 index 0000000000..5faeb2bb7e --- /dev/null +++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/CAURICollection.java @@ -0,0 +1,69 @@ + +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.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for CAURICollection complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="CAURICollection">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="cAURI" type="{http://schemas.microsoft.com/windows/pki/2009/01/enrollmentpolicy}CAURI" maxOccurs="unbounded"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "CAURICollection", propOrder = { + "cauri" +}) +public class CAURICollection { + + @XmlElement(name = "cAURI", required = true) + protected List cauri; + + /** + * Gets the value of the cauri property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the cauri property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getCAURI().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link CAURI } + * + * + */ + public List getCAURI() { + if (cauri == null) { + cauri = new ArrayList(); + } + return this.cauri; + } + +} diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/CertificateEnrollmentPolicy.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/CertificateEnrollmentPolicy.java new file mode 100644 index 0000000000..2e40d12f3c --- /dev/null +++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/CertificateEnrollmentPolicy.java @@ -0,0 +1,147 @@ + +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.XmlType; +import org.w3c.dom.Element; + + +/** + *

Java class for CertificateEnrollmentPolicy complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="CertificateEnrollmentPolicy">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="policyOIDReference" type="{http://www.w3.org/2001/XMLSchema}int"/>
+ *         <element name="cAs" type="{http://schemas.microsoft.com/windows/pki/2009/01/enrollmentpolicy}CAReferenceCollection"/>
+ *         <element name="attributes" type="{http://schemas.microsoft.com/windows/pki/2009/01/enrollmentpolicy}Attributes"/>
+ *         <any processContents='lax' maxOccurs="unbounded" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "CertificateEnrollmentPolicy", propOrder = { + "policyOIDReference", + "cAs", + "attributes", + "any" +}) +public class CertificateEnrollmentPolicy { + + protected int policyOIDReference; + @XmlElement(required = true, nillable = true) + protected CAReferenceCollection cAs; + @XmlElement(required = true) + protected Attributes attributes; + @XmlAnyElement(lax = true) + protected List any; + + /** + * Gets the value of the policyOIDReference property. + * + */ + public int getPolicyOIDReference() { + return policyOIDReference; + } + + /** + * Sets the value of the policyOIDReference property. + * + */ + public void setPolicyOIDReference(int value) { + this.policyOIDReference = value; + } + + /** + * Gets the value of the cAs property. + * + * @return + * possible object is + * {@link CAReferenceCollection } + * + */ + public CAReferenceCollection getCAs() { + return cAs; + } + + /** + * Sets the value of the cAs property. + * + * @param value + * allowed object is + * {@link CAReferenceCollection } + * + */ + public void setCAs(CAReferenceCollection value) { + this.cAs = value; + } + + /** + * Gets the value of the attributes property. + * + * @return + * possible object is + * {@link Attributes } + * + */ + public Attributes getAttributes() { + return attributes; + } + + /** + * Sets the value of the attributes property. + * + * @param value + * allowed object is + * {@link Attributes } + * + */ + public void setAttributes(Attributes value) { + this.attributes = value; + } + + /** + * Gets the value of the any property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the any property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getAny().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link Object } + * {@link Element } + * + * + */ + public List getAny() { + if (any == null) { + any = new ArrayList(); + } + return this.any; + } + +} diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/CertificateValidity.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/CertificateValidity.java new file mode 100644 index 0000000000..341ca05ff1 --- /dev/null +++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/CertificateValidity.java @@ -0,0 +1,94 @@ + +package cdm.api.windows.xcep.beans; + +import java.math.BigInteger; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlSchemaType; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for CertificateValidity complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="CertificateValidity">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="validityPeriodSeconds" type="{http://www.w3.org/2001/XMLSchema}unsignedLong"/>
+ *         <element name="renewalPeriodSeconds" type="{http://www.w3.org/2001/XMLSchema}unsignedLong"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "CertificateValidity", propOrder = { + "validityPeriodSeconds", + "renewalPeriodSeconds" +}) +public class CertificateValidity { + + @XmlElement(required = true) + @XmlSchemaType(name = "unsignedLong") + protected BigInteger validityPeriodSeconds; + @XmlElement(required = true) + @XmlSchemaType(name = "unsignedLong") + protected BigInteger renewalPeriodSeconds; + + /** + * Gets the value of the validityPeriodSeconds property. + * + * @return + * possible object is + * {@link BigInteger } + * + */ + public BigInteger getValidityPeriodSeconds() { + return validityPeriodSeconds; + } + + /** + * Sets the value of the validityPeriodSeconds property. + * + * @param value + * allowed object is + * {@link BigInteger } + * + */ + public void setValidityPeriodSeconds(BigInteger value) { + this.validityPeriodSeconds = value; + } + + /** + * Gets the value of the renewalPeriodSeconds property. + * + * @return + * possible object is + * {@link BigInteger } + * + */ + public BigInteger getRenewalPeriodSeconds() { + return renewalPeriodSeconds; + } + + /** + * Sets the value of the renewalPeriodSeconds property. + * + * @param value + * allowed object is + * {@link BigInteger } + * + */ + public void setRenewalPeriodSeconds(BigInteger value) { + this.renewalPeriodSeconds = value; + } + +} diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/Client.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/Client.java new file mode 100644 index 0000000000..a1d7fe1e4a --- /dev/null +++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/Client.java @@ -0,0 +1,135 @@ + +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 javax.xml.bind.annotation.adapters.CollapsedStringAdapter; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import javax.xml.datatype.XMLGregorianCalendar; +import org.w3c.dom.Element; + + +/** + *

Java class for Client complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="Client">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="lastUpdate" type="{http://www.w3.org/2001/XMLSchema}dateTime"/>
+ *         <element name="preferredLanguage" type="{http://www.w3.org/2001/XMLSchema}language"/>
+ *         <any processContents='lax' maxOccurs="unbounded" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "Client", propOrder = { + "lastUpdate", + "preferredLanguage", + "any" +}) +public class Client { + + @XmlElement(required = true, nillable = true) + @XmlSchemaType(name = "dateTime") + protected XMLGregorianCalendar lastUpdate; + @XmlElement(required = true, nillable = true) + @XmlJavaTypeAdapter(CollapsedStringAdapter.class) + @XmlSchemaType(name = "language") + protected String preferredLanguage; + @XmlAnyElement(lax = true) + protected List any; + + /** + * Gets the value of the lastUpdate property. + * + * @return + * possible object is + * {@link XMLGregorianCalendar } + * + */ + public XMLGregorianCalendar getLastUpdate() { + return lastUpdate; + } + + /** + * Sets the value of the lastUpdate property. + * + * @param value + * allowed object is + * {@link XMLGregorianCalendar } + * + */ + public void setLastUpdate(XMLGregorianCalendar value) { + this.lastUpdate = value; + } + + /** + * Gets the value of the preferredLanguage property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getPreferredLanguage() { + return preferredLanguage; + } + + /** + * Sets the value of the preferredLanguage property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setPreferredLanguage(String value) { + this.preferredLanguage = value; + } + + /** + * Gets the value of the any property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the any property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getAny().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link Object } + * {@link Element } + * + * + */ + public List getAny() { + if (any == null) { + any = new ArrayList(); + } + return this.any; + } + +} diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/CryptoProviders.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/CryptoProviders.java new file mode 100644 index 0000000000..3a1a935822 --- /dev/null +++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/CryptoProviders.java @@ -0,0 +1,69 @@ + +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.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for CryptoProviders complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="CryptoProviders">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="provider" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "CryptoProviders", propOrder = { + "provider" +}) +public class CryptoProviders { + + @XmlElement(required = true) + protected List provider; + + /** + * Gets the value of the provider property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the provider property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getProvider().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link String } + * + * + */ + public List getProvider() { + if (provider == null) { + provider = new ArrayList(); + } + return this.provider; + } + +} diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/EnrollmentPermission.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/EnrollmentPermission.java new file mode 100644 index 0000000000..5abcb7406c --- /dev/null +++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/EnrollmentPermission.java @@ -0,0 +1,71 @@ + +package cdm.api.windows.xcep.beans; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for EnrollmentPermission complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="EnrollmentPermission">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="enroll" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
+ *         <element name="autoEnroll" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "EnrollmentPermission", propOrder = { + "enroll", + "autoEnroll" +}) +public class EnrollmentPermission { + + protected boolean enroll; + protected boolean autoEnroll; + + /** + * Gets the value of the enroll property. + * + */ + public boolean isEnroll() { + return enroll; + } + + /** + * Sets the value of the enroll property. + * + */ + public void setEnroll(boolean value) { + this.enroll = value; + } + + /** + * Gets the value of the autoEnroll property. + * + */ + public boolean isAutoEnroll() { + return autoEnroll; + } + + /** + * Sets the value of the autoEnroll property. + * + */ + public void setAutoEnroll(boolean value) { + this.autoEnroll = value; + } + +} diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/Extension.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/Extension.java new file mode 100644 index 0000000000..811b30786d --- /dev/null +++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/Extension.java @@ -0,0 +1,99 @@ + +package cdm.api.windows.xcep.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; + + +/** + *

Java class for Extension complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="Extension">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="oIDReference" type="{http://www.w3.org/2001/XMLSchema}int"/>
+ *         <element name="critical" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
+ *         <element name="value" type="{http://www.w3.org/2001/XMLSchema}base64Binary"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "Extension", propOrder = { + "oidReference", + "critical", + "value" +}) +public class Extension { + + @XmlElement(name = "oIDReference") + protected int oidReference; + protected boolean critical; + @XmlElement(required = true, nillable = true) + protected byte[] value; + + /** + * Gets the value of the oidReference property. + * + */ + public int getOIDReference() { + return oidReference; + } + + /** + * Sets the value of the oidReference property. + * + */ + public void setOIDReference(int value) { + this.oidReference = value; + } + + /** + * Gets the value of the critical property. + * + */ + public boolean isCritical() { + return critical; + } + + /** + * Sets the value of the critical property. + * + */ + public void setCritical(boolean value) { + this.critical = value; + } + + /** + * Gets the value of the value property. + * + * @return + * possible object is + * byte[] + */ + public byte[] getValue() { + return value; + } + + /** + * Sets the value of the value property. + * + * @param value + * allowed object is + * byte[] + */ + public void setValue(byte[] value) { + this.value = value; + } + +} diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/ExtensionCollection.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/ExtensionCollection.java new file mode 100644 index 0000000000..6bd2e9d1be --- /dev/null +++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/ExtensionCollection.java @@ -0,0 +1,69 @@ + +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.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for ExtensionCollection complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="ExtensionCollection">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="extension" type="{http://schemas.microsoft.com/windows/pki/2009/01/enrollmentpolicy}Extension" maxOccurs="unbounded"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "ExtensionCollection", propOrder = { + "extension" +}) +public class ExtensionCollection { + + @XmlElement(required = true) + protected List extension; + + /** + * Gets the value of the extension property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the extension property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getExtension().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link Extension } + * + * + */ + public List getExtension() { + if (extension == null) { + extension = new ArrayList(); + } + return this.extension; + } + +} diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/FilterOIDCollection.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/FilterOIDCollection.java new file mode 100644 index 0000000000..c470f1bf9a --- /dev/null +++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/FilterOIDCollection.java @@ -0,0 +1,69 @@ + +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.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for FilterOIDCollection complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="FilterOIDCollection">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="oid" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "FilterOIDCollection", propOrder = { + "oid" +}) +public class FilterOIDCollection { + + @XmlElement(required = true) + protected List oid; + + /** + * Gets the value of the oid property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the oid property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getOid().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link String } + * + * + */ + public List getOid() { + if (oid == null) { + oid = new ArrayList(); + } + return this.oid; + } + +} diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/GetPolicies.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/GetPolicies.java new file mode 100644 index 0000000000..5051985129 --- /dev/null +++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/GetPolicies.java @@ -0,0 +1,92 @@ + +package cdm.api.windows.xcep.beans; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="client" type="{http://schemas.microsoft.com/windows/pki/2009/01/enrollmentpolicy}Client"/>
+ *         <element name="requestFilter" type="{http://schemas.microsoft.com/windows/pki/2009/01/enrollmentpolicy}RequestFilter"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "client", + "requestFilter" +}) +@XmlRootElement(name = "GetPolicies") +public class GetPolicies { + + @XmlElement(required = true) + protected Client client; + @XmlElement(required = true, nillable = true) + protected RequestFilter requestFilter; + + /** + * Gets the value of the client property. + * + * @return + * possible object is + * {@link Client } + * + */ + public Client getClient() { + return client; + } + + /** + * Sets the value of the client property. + * + * @param value + * allowed object is + * {@link Client } + * + */ + public void setClient(Client value) { + this.client = value; + } + + /** + * Gets the value of the requestFilter property. + * + * @return + * possible object is + * {@link RequestFilter } + * + */ + public RequestFilter getRequestFilter() { + return requestFilter; + } + + /** + * Sets the value of the requestFilter property. + * + * @param value + * allowed object is + * {@link RequestFilter } + * + */ + public void setRequestFilter(RequestFilter value) { + this.requestFilter = value; + } + +} diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/GetPoliciesResponse.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/GetPoliciesResponse.java new file mode 100644 index 0000000000..e2ccacc093 --- /dev/null +++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/GetPoliciesResponse.java @@ -0,0 +1,120 @@ + +package cdm.api.windows.xcep.beans; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="response" type="{http://schemas.microsoft.com/windows/pki/2009/01/enrollmentpolicy}Response"/>
+ *         <element name="cAs" type="{http://schemas.microsoft.com/windows/pki/2009/01/enrollmentpolicy}CACollection"/>
+ *         <element name="oIDs" type="{http://schemas.microsoft.com/windows/pki/2009/01/enrollmentpolicy}OIDCollection"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "response", + "cAs", + "oiDs" +}) +@XmlRootElement(name = "GetPoliciesResponse") +public class GetPoliciesResponse { + + @XmlElement(required = true, nillable = true) + protected Response response; + @XmlElement(required = true, nillable = true) + protected CACollection cAs; + @XmlElement(name = "oIDs", required = true, nillable = true) + protected OIDCollection oiDs; + + /** + * Gets the value of the response property. + * + * @return + * possible object is + * {@link Response } + * + */ + public Response getResponse() { + return response; + } + + /** + * Sets the value of the response property. + * + * @param value + * allowed object is + * {@link Response } + * + */ + public void setResponse(Response value) { + this.response = value; + } + + /** + * Gets the value of the cAs property. + * + * @return + * possible object is + * {@link CACollection } + * + */ + public CACollection getCAs() { + return cAs; + } + + /** + * Sets the value of the cAs property. + * + * @param value + * allowed object is + * {@link CACollection } + * + */ + public void setCAs(CACollection value) { + this.cAs = value; + } + + /** + * Gets the value of the oiDs property. + * + * @return + * possible object is + * {@link OIDCollection } + * + */ + public OIDCollection getOIDs() { + return oiDs; + } + + /** + * Sets the value of the oiDs property. + * + * @param value + * allowed object is + * {@link OIDCollection } + * + */ + public void setOIDs(OIDCollection value) { + this.oiDs = value; + } + +} diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/KeyArchivalAttributes.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/KeyArchivalAttributes.java new file mode 100644 index 0000000000..817d02373d --- /dev/null +++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/KeyArchivalAttributes.java @@ -0,0 +1,73 @@ + +package cdm.api.windows.xcep.beans; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlSchemaType; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for KeyArchivalAttributes complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="KeyArchivalAttributes">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="symmetricAlgorithmOIDReference" type="{http://www.w3.org/2001/XMLSchema}int"/>
+ *         <element name="symmetricAlgorithmKeyLength" type="{http://www.w3.org/2001/XMLSchema}unsignedInt"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "KeyArchivalAttributes", propOrder = { + "symmetricAlgorithmOIDReference", + "symmetricAlgorithmKeyLength" +}) +public class KeyArchivalAttributes { + + protected int symmetricAlgorithmOIDReference; + @XmlSchemaType(name = "unsignedInt") + protected long symmetricAlgorithmKeyLength; + + /** + * Gets the value of the symmetricAlgorithmOIDReference property. + * + */ + public int getSymmetricAlgorithmOIDReference() { + return symmetricAlgorithmOIDReference; + } + + /** + * Sets the value of the symmetricAlgorithmOIDReference property. + * + */ + public void setSymmetricAlgorithmOIDReference(int value) { + this.symmetricAlgorithmOIDReference = value; + } + + /** + * Gets the value of the symmetricAlgorithmKeyLength property. + * + */ + public long getSymmetricAlgorithmKeyLength() { + return symmetricAlgorithmKeyLength; + } + + /** + * Sets the value of the symmetricAlgorithmKeyLength property. + * + */ + public void setSymmetricAlgorithmKeyLength(long value) { + this.symmetricAlgorithmKeyLength = value; + } + +} diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/OID.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/OID.java new file mode 100644 index 0000000000..420d2dc173 --- /dev/null +++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/OID.java @@ -0,0 +1,169 @@ + +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 OID complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="OID">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="value" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *         <element name="group" type="{http://www.w3.org/2001/XMLSchema}unsignedInt"/>
+ *         <element name="oIDReferenceID" type="{http://www.w3.org/2001/XMLSchema}int"/>
+ *         <element name="defaultName" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *         <any processContents='lax' maxOccurs="unbounded" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "OID", propOrder = { + "value", + "group", + "oidReferenceID", + "defaultName", + "any" +}) +public class OID { + + @XmlElement(required = true) + protected String value; + @XmlSchemaType(name = "unsignedInt") + protected long group; + @XmlElement(name = "oIDReferenceID") + protected int oidReferenceID; + @XmlElement(required = true, nillable = true) + protected String defaultName; + @XmlAnyElement(lax = true) + protected List any; + + /** + * Gets the value of the value property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getValue() { + return value; + } + + /** + * Sets the value of the value property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setValue(String value) { + this.value = value; + } + + /** + * Gets the value of the group property. + * + */ + public long getGroup() { + return group; + } + + /** + * Sets the value of the group property. + * + */ + public void setGroup(long value) { + this.group = value; + } + + /** + * Gets the value of the oidReferenceID property. + * + */ + public int getOIDReferenceID() { + return oidReferenceID; + } + + /** + * Sets the value of the oidReferenceID property. + * + */ + public void setOIDReferenceID(int value) { + this.oidReferenceID = value; + } + + /** + * Gets the value of the defaultName property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getDefaultName() { + return defaultName; + } + + /** + * Sets the value of the defaultName property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setDefaultName(String value) { + this.defaultName = value; + } + + /** + * Gets the value of the any property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the any property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getAny().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link Object } + * {@link Element } + * + * + */ + public List getAny() { + if (any == null) { + any = new ArrayList(); + } + return this.any; + } + +} diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/OIDCollection.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/OIDCollection.java new file mode 100644 index 0000000000..d78178f2e4 --- /dev/null +++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/OIDCollection.java @@ -0,0 +1,69 @@ + +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.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for OIDCollection complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="OIDCollection">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="oID" type="{http://schemas.microsoft.com/windows/pki/2009/01/enrollmentpolicy}OID" maxOccurs="unbounded"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "OIDCollection", propOrder = { + "oid" +}) +public class OIDCollection { + + @XmlElement(name = "oID", required = true) + protected List oid; + + /** + * Gets the value of the oid property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the oid property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getOID().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link OID } + * + * + */ + public List getOID() { + if (oid == null) { + oid = new ArrayList(); + } + return this.oid; + } + +} diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/OIDReferenceCollection.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/OIDReferenceCollection.java new file mode 100644 index 0000000000..bcb94967ba --- /dev/null +++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/OIDReferenceCollection.java @@ -0,0 +1,69 @@ + +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.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for OIDReferenceCollection complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="OIDReferenceCollection">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="oIDReference" type="{http://www.w3.org/2001/XMLSchema}int" maxOccurs="unbounded"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "OIDReferenceCollection", propOrder = { + "oidReference" +}) +public class OIDReferenceCollection { + + @XmlElement(name = "oIDReference", type = Integer.class) + protected List oidReference; + + /** + * Gets the value of the oidReference property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the oidReference property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getOIDReference().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link Integer } + * + * + */ + public List getOIDReference() { + if (oidReference == null) { + oidReference = new ArrayList(); + } + return this.oidReference; + } + +} diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/ObjectFactory.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/ObjectFactory.java new file mode 100644 index 0000000000..b411bedd57 --- /dev/null +++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/ObjectFactory.java @@ -0,0 +1,261 @@ + +package cdm.api.windows.xcep.beans; + +import javax.xml.bind.JAXBElement; +import javax.xml.bind.annotation.XmlElementDecl; +import javax.xml.bind.annotation.XmlRegistry; +import javax.xml.namespace.QName; + + +/** + * This object contains factory methods for each + * Java content interface and Java element interface + * generated in the com.microsoft.schemas.windows.pki._2009._01.enrollmentpolicy package. + *

An ObjectFactory allows you to programatically + * construct new instances of the Java representation + * for XML content. The Java representation of XML + * content can consist of schema derived interfaces + * and classes representing the binding of schema + * type definitions, element declarations and model + * groups. Factory methods for each of these are + * provided in this class. + * + */ +@XmlRegistry +public class ObjectFactory { + + private final static QName _CommonName_QNAME = new QName("http://schemas.microsoft.com/windows/pki/2009/01/enrollmentpolicy", "commonName"); + + /** + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.microsoft.schemas.windows.pki._2009._01.enrollmentpolicy + * + */ + public ObjectFactory() { + } + + /** + * Create an instance of {@link GetPolicies } + * + */ + public GetPolicies createGetPolicies() { + return new GetPolicies(); + } + + /** + * Create an instance of {@link Client } + * + */ + public Client createClient() { + return new Client(); + } + + /** + * Create an instance of {@link RequestFilter } + * + */ + public RequestFilter createRequestFilter() { + return new RequestFilter(); + } + + /** + * Create an instance of {@link GetPoliciesResponse } + * + */ + public GetPoliciesResponse createGetPoliciesResponse() { + return new GetPoliciesResponse(); + } + + /** + * Create an instance of {@link Response } + * + */ + public Response createResponse() { + return new Response(); + } + + /** + * Create an instance of {@link CACollection } + * + */ + public CACollection createCACollection() { + return new CACollection(); + } + + /** + * Create an instance of {@link OIDCollection } + * + */ + public OIDCollection createOIDCollection() { + return new OIDCollection(); + } + + /** + * Create an instance of {@link SupersededPolicies } + * + */ + public SupersededPolicies createSupersededPolicies() { + return new SupersededPolicies(); + } + + /** + * Create an instance of {@link OID } + * + */ + public OID createOID() { + return new OID(); + } + + /** + * Create an instance of {@link ExtensionCollection } + * + */ + public ExtensionCollection createExtensionCollection() { + return new ExtensionCollection(); + } + + /** + * Create an instance of {@link Attributes } + * + */ + public Attributes createAttributes() { + return new Attributes(); + } + + /** + * Create an instance of {@link EnrollmentPermission } + * + */ + public EnrollmentPermission createEnrollmentPermission() { + return new EnrollmentPermission(); + } + + /** + * Create an instance of {@link CAReferenceCollection } + * + */ + public CAReferenceCollection createCAReferenceCollection() { + return new CAReferenceCollection(); + } + + /** + * Create an instance of {@link CertificateValidity } + * + */ + public CertificateValidity createCertificateValidity() { + return new CertificateValidity(); + } + + /** + * Create an instance of {@link CAURICollection } + * + */ + public CAURICollection createCAURICollection() { + return new CAURICollection(); + } + + /** + * Create an instance of {@link PolicyCollection } + * + */ + public PolicyCollection createPolicyCollection() { + return new PolicyCollection(); + } + + /** + * Create an instance of {@link Revision } + * + */ + public Revision createRevision() { + return new Revision(); + } + + /** + * Create an instance of {@link OIDReferenceCollection } + * + */ + public OIDReferenceCollection createOIDReferenceCollection() { + return new OIDReferenceCollection(); + } + + /** + * Create an instance of {@link CA } + * + */ + public CA createCA() { + return new CA(); + } + + /** + * Create an instance of {@link CertificateEnrollmentPolicy } + * + */ + public CertificateEnrollmentPolicy createCertificateEnrollmentPolicy() { + return new CertificateEnrollmentPolicy(); + } + + /** + * Create an instance of {@link CryptoProviders } + * + */ + public CryptoProviders createCryptoProviders() { + return new CryptoProviders(); + } + + /** + * Create an instance of {@link Extension } + * + */ + public Extension createExtension() { + return new Extension(); + } + + /** + * Create an instance of {@link FilterOIDCollection } + * + */ + public FilterOIDCollection createFilterOIDCollection() { + return new FilterOIDCollection(); + } + + /** + * Create an instance of {@link CAURI } + * + */ + public CAURI createCAURI() { + return new CAURI(); + } + + /** + * Create an instance of {@link RARequirements } + * + */ + public RARequirements createRARequirements() { + return new RARequirements(); + } + + /** + * Create an instance of {@link PrivateKeyAttributes } + * + */ + public PrivateKeyAttributes createPrivateKeyAttributes() { + return new PrivateKeyAttributes(); + } + + /** + * Create an instance of {@link KeyArchivalAttributes } + * + */ + public KeyArchivalAttributes createKeyArchivalAttributes() { + return new KeyArchivalAttributes(); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://schemas.microsoft.com/windows/pki/2009/01/enrollmentpolicy", name = "commonName") + public JAXBElement createCommonName(String value) { + return new JAXBElement(_CommonName_QNAME, String.class, null, value); + } + +} diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/PolicyCollection.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/PolicyCollection.java new file mode 100644 index 0000000000..5ec59f1880 --- /dev/null +++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/PolicyCollection.java @@ -0,0 +1,69 @@ + +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.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for PolicyCollection complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="PolicyCollection">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="policy" type="{http://schemas.microsoft.com/windows/pki/2009/01/enrollmentpolicy}CertificateEnrollmentPolicy" maxOccurs="unbounded"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "PolicyCollection", propOrder = { + "policy" +}) +public class PolicyCollection { + + @XmlElement(required = true) + protected List policy; + + /** + * Gets the value of the policy property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the policy property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getPolicy().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link CertificateEnrollmentPolicy } + * + * + */ + public List getPolicy() { + if (policy == null) { + policy = new ArrayList(); + } + return this.policy; + } + +} diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/PrivateKeyAttributes.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/PrivateKeyAttributes.java new file mode 100644 index 0000000000..f0892bc4b7 --- /dev/null +++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/PrivateKeyAttributes.java @@ -0,0 +1,197 @@ + +package cdm.api.windows.xcep.beans; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlSchemaType; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for PrivateKeyAttributes complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="PrivateKeyAttributes">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="minimalKeyLength" type="{http://www.w3.org/2001/XMLSchema}unsignedInt"/>
+ *         <element name="keySpec" type="{http://www.w3.org/2001/XMLSchema}unsignedInt"/>
+ *         <element name="keyUsageProperty" type="{http://www.w3.org/2001/XMLSchema}unsignedInt"/>
+ *         <element name="permissions" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *         <element name="algorithmOIDReference" type="{http://www.w3.org/2001/XMLSchema}int"/>
+ *         <element name="cryptoProviders" type="{http://schemas.microsoft.com/windows/pki/2009/01/enrollmentpolicy}CryptoProviders"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "PrivateKeyAttributes", propOrder = { + "minimalKeyLength", + "keySpec", + "keyUsageProperty", + "permissions", + "algorithmOIDReference", + "cryptoProviders" +}) +public class PrivateKeyAttributes { + + @XmlSchemaType(name = "unsignedInt") + protected long minimalKeyLength; + @XmlElement(required = true, type = Long.class, nillable = true) + @XmlSchemaType(name = "unsignedInt") + protected Long keySpec; + @XmlElement(required = true, type = Long.class, nillable = true) + @XmlSchemaType(name = "unsignedInt") + protected Long keyUsageProperty; + @XmlElement(required = true, nillable = true) + protected String permissions; + @XmlElement(required = true, type = Integer.class, nillable = true) + protected Integer algorithmOIDReference; + @XmlElement(required = true, nillable = true) + protected CryptoProviders cryptoProviders; + + /** + * Gets the value of the minimalKeyLength property. + * + */ + public long getMinimalKeyLength() { + return minimalKeyLength; + } + + /** + * Sets the value of the minimalKeyLength property. + * + */ + public void setMinimalKeyLength(long value) { + this.minimalKeyLength = value; + } + + /** + * Gets the value of the keySpec property. + * + * @return + * possible object is + * {@link Long } + * + */ + public Long getKeySpec() { + return keySpec; + } + + /** + * Sets the value of the keySpec property. + * + * @param value + * allowed object is + * {@link Long } + * + */ + public void setKeySpec(Long value) { + this.keySpec = value; + } + + /** + * Gets the value of the keyUsageProperty property. + * + * @return + * possible object is + * {@link Long } + * + */ + public Long getKeyUsageProperty() { + return keyUsageProperty; + } + + /** + * Sets the value of the keyUsageProperty property. + * + * @param value + * allowed object is + * {@link Long } + * + */ + public void setKeyUsageProperty(Long value) { + this.keyUsageProperty = value; + } + + /** + * Gets the value of the permissions property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getPermissions() { + return permissions; + } + + /** + * Sets the value of the permissions property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setPermissions(String value) { + this.permissions = value; + } + + /** + * Gets the value of the algorithmOIDReference property. + * + * @return + * possible object is + * {@link Integer } + * + */ + public Integer getAlgorithmOIDReference() { + return algorithmOIDReference; + } + + /** + * Sets the value of the algorithmOIDReference property. + * + * @param value + * allowed object is + * {@link Integer } + * + */ + public void setAlgorithmOIDReference(Integer value) { + this.algorithmOIDReference = value; + } + + /** + * Gets the value of the cryptoProviders property. + * + * @return + * possible object is + * {@link CryptoProviders } + * + */ + public CryptoProviders getCryptoProviders() { + return cryptoProviders; + } + + /** + * Sets the value of the cryptoProviders property. + * + * @param value + * allowed object is + * {@link CryptoProviders } + * + */ + public void setCryptoProviders(CryptoProviders value) { + this.cryptoProviders = value; + } + +} diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/RARequirements.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/RARequirements.java new file mode 100644 index 0000000000..0f31a63a32 --- /dev/null +++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/RARequirements.java @@ -0,0 +1,112 @@ + +package cdm.api.windows.xcep.beans; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlSchemaType; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for RARequirements complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="RARequirements">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="rASignatures" type="{http://www.w3.org/2001/XMLSchema}unsignedInt"/>
+ *         <element name="rAEKUs" type="{http://schemas.microsoft.com/windows/pki/2009/01/enrollmentpolicy}OIDReferenceCollection"/>
+ *         <element name="rAPolicies" type="{http://schemas.microsoft.com/windows/pki/2009/01/enrollmentpolicy}OIDReferenceCollection"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "RARequirements", propOrder = { + "raSignatures", + "raekUs", + "raPolicies" +}) +public class RARequirements { + + @XmlElement(name = "rASignatures") + @XmlSchemaType(name = "unsignedInt") + protected long raSignatures; + @XmlElement(name = "rAEKUs", required = true, nillable = true) + protected OIDReferenceCollection raekUs; + @XmlElement(name = "rAPolicies", required = true, nillable = true) + protected OIDReferenceCollection raPolicies; + + /** + * Gets the value of the raSignatures property. + * + */ + public long getRASignatures() { + return raSignatures; + } + + /** + * Sets the value of the raSignatures property. + * + */ + public void setRASignatures(long value) { + this.raSignatures = value; + } + + /** + * Gets the value of the raekUs property. + * + * @return + * possible object is + * {@link OIDReferenceCollection } + * + */ + public OIDReferenceCollection getRAEKUs() { + return raekUs; + } + + /** + * Sets the value of the raekUs property. + * + * @param value + * allowed object is + * {@link OIDReferenceCollection } + * + */ + public void setRAEKUs(OIDReferenceCollection value) { + this.raekUs = value; + } + + /** + * Gets the value of the raPolicies property. + * + * @return + * possible object is + * {@link OIDReferenceCollection } + * + */ + public OIDReferenceCollection getRAPolicies() { + return raPolicies; + } + + /** + * Sets the value of the raPolicies property. + * + * @param value + * allowed object is + * {@link OIDReferenceCollection } + * + */ + public void setRAPolicies(OIDReferenceCollection value) { + this.raPolicies = value; + } + +} diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/RequestFilter.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/RequestFilter.java new file mode 100644 index 0000000000..4037b95b65 --- /dev/null +++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/RequestFilter.java @@ -0,0 +1,100 @@ + +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.XmlType; +import org.w3c.dom.Element; + + +/** + *

Java class for RequestFilter complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="RequestFilter">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="policyOIDs" type="{http://schemas.microsoft.com/windows/pki/2009/01/enrollmentpolicy}FilterOIDCollection"/>
+ *         <any processContents='lax' maxOccurs="unbounded" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "RequestFilter", propOrder = { + "policyOIDs", + "any" +}) +public class RequestFilter { + + @XmlElement(required = true, nillable = true) + protected FilterOIDCollection policyOIDs; + @XmlAnyElement(lax = true) + protected List any; + + /** + * Gets the value of the policyOIDs property. + * + * @return + * possible object is + * {@link FilterOIDCollection } + * + */ + public FilterOIDCollection getPolicyOIDs() { + return policyOIDs; + } + + /** + * Sets the value of the policyOIDs property. + * + * @param value + * allowed object is + * {@link FilterOIDCollection } + * + */ + public void setPolicyOIDs(FilterOIDCollection value) { + this.policyOIDs = value; + } + + /** + * Gets the value of the any property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the any property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getAny().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link Object } + * {@link Element } + * + * + */ + public List getAny() { + if (any == null) { + any = new ArrayList(); + } + return this.any; + } + +} diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/Response.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/Response.java new file mode 100644 index 0000000000..0fadb8dc83 --- /dev/null +++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/Response.java @@ -0,0 +1,214 @@ + +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 Response complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="Response">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="policyID" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *         <element name="policyFriendlyName" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *         <element name="nextUpdateHours" type="{http://www.w3.org/2001/XMLSchema}unsignedInt"/>
+ *         <element name="policiesNotChanged" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
+ *         <element name="policies" type="{http://schemas.microsoft.com/windows/pki/2009/01/enrollmentpolicy}PolicyCollection"/>
+ *         <any processContents='lax' maxOccurs="unbounded" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "Response", propOrder = { + "policyID", + "policyFriendlyName", + "nextUpdateHours", + "policiesNotChanged", + "policies", + "any" +}) +public class Response { + + @XmlElement(required = true) + protected String policyID; + @XmlElement(required = true, nillable = true) + protected String policyFriendlyName; + @XmlElement(required = true, type = Long.class, nillable = true) + @XmlSchemaType(name = "unsignedInt") + protected Long nextUpdateHours; + @XmlElement(required = true, type = Boolean.class, nillable = true) + protected Boolean policiesNotChanged; + @XmlElement(required = true, nillable = true) + protected PolicyCollection policies; + @XmlAnyElement(lax = true) + protected List any; + + /** + * Gets the value of the policyID property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getPolicyID() { + return policyID; + } + + /** + * Sets the value of the policyID property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setPolicyID(String value) { + this.policyID = value; + } + + /** + * Gets the value of the policyFriendlyName property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getPolicyFriendlyName() { + return policyFriendlyName; + } + + /** + * Sets the value of the policyFriendlyName property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setPolicyFriendlyName(String value) { + this.policyFriendlyName = value; + } + + /** + * Gets the value of the nextUpdateHours property. + * + * @return + * possible object is + * {@link Long } + * + */ + public Long getNextUpdateHours() { + return nextUpdateHours; + } + + /** + * Sets the value of the nextUpdateHours property. + * + * @param value + * allowed object is + * {@link Long } + * + */ + public void setNextUpdateHours(Long value) { + this.nextUpdateHours = value; + } + + /** + * Gets the value of the policiesNotChanged property. + * + * @return + * possible object is + * {@link Boolean } + * + */ + public Boolean isPoliciesNotChanged() { + return policiesNotChanged; + } + + /** + * Sets the value of the policiesNotChanged property. + * + * @param value + * allowed object is + * {@link Boolean } + * + */ + public void setPoliciesNotChanged(Boolean value) { + this.policiesNotChanged = value; + } + + /** + * Gets the value of the policies property. + * + * @return + * possible object is + * {@link PolicyCollection } + * + */ + public PolicyCollection getPolicies() { + return policies; + } + + /** + * Sets the value of the policies property. + * + * @param value + * allowed object is + * {@link PolicyCollection } + * + */ + public void setPolicies(PolicyCollection value) { + this.policies = value; + } + + /** + * Gets the value of the any property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the any property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getAny().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link Object } + * {@link Element } + * + * + */ + public List getAny() { + if (any == null) { + any = new ArrayList(); + } + return this.any; + } + +} diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/Revision.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/Revision.java new file mode 100644 index 0000000000..decbceff53 --- /dev/null +++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/Revision.java @@ -0,0 +1,74 @@ + +package cdm.api.windows.xcep.beans; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlSchemaType; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for Revision complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="Revision">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="majorRevision" type="{http://www.w3.org/2001/XMLSchema}unsignedInt"/>
+ *         <element name="minorRevision" type="{http://www.w3.org/2001/XMLSchema}unsignedInt"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "Revision", propOrder = { + "majorRevision", + "minorRevision" +}) +public class Revision { + + @XmlSchemaType(name = "unsignedInt") + protected long majorRevision; + @XmlSchemaType(name = "unsignedInt") + protected long minorRevision; + + /** + * Gets the value of the majorRevision property. + * + */ + public long getMajorRevision() { + return majorRevision; + } + + /** + * Sets the value of the majorRevision property. + * + */ + public void setMajorRevision(long value) { + this.majorRevision = value; + } + + /** + * Gets the value of the minorRevision property. + * + */ + public long getMinorRevision() { + return minorRevision; + } + + /** + * Sets the value of the minorRevision property. + * + */ + public void setMinorRevision(long value) { + this.minorRevision = value; + } + +} diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/SupersededPolicies.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/SupersededPolicies.java new file mode 100644 index 0000000000..cc031cc4dc --- /dev/null +++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/SupersededPolicies.java @@ -0,0 +1,69 @@ + +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.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for SupersededPolicies complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="SupersededPolicies">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element ref="{http://schemas.microsoft.com/windows/pki/2009/01/enrollmentpolicy}commonName" maxOccurs="unbounded"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "SupersededPolicies", propOrder = { + "commonName" +}) +public class SupersededPolicies { + + @XmlElement(required = true) + protected List commonName; + + /** + * Gets the value of the commonName property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the commonName property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getCommonName().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link String } + * + * + */ + public List getCommonName() { + if (commonName == null) { + commonName = new ArrayList(); + } + return this.commonName; + } + +} diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/package-info.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/package-info.java new file mode 100644 index 0000000000..d43da1ec66 --- /dev/null +++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/beans/package-info.java @@ -0,0 +1,2 @@ +@javax.xml.bind.annotation.XmlSchema(namespace = "http://schemas.microsoft.com/windows/pki/2009/01/enrollmentpolicy", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) +package cdm.api.windows.xcep.beans; diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/impl/xcepimpl.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/impl/xcepimpl.java new file mode 100644 index 0000000000..03caea7ea6 --- /dev/null +++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/impl/xcepimpl.java @@ -0,0 +1,79 @@ +/* + * 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.xcep.impl; + +import cdm.api.windows.xcep.IPolicy; +import cdm.api.windows.xcep.beans.*; +import javax.jws.WebService; +import javax.xml.ws.BindingType; +import javax.xml.ws.Holder; +import javax.xml.ws.soap.Addressing; +import javax.xml.ws.soap.SOAPBinding; + +@WebService(endpointInterface = "cdm.api.windows.xcep.IPolicy", targetNamespace = "http://schemas.microsoft.com/windows/pki/2009/01/enrollmentpolicy") +@Addressing(enabled = true, required = true) +@BindingType(value = SOAPBinding.SOAP12HTTP_BINDING) +public class xcepimpl implements IPolicy { + + @Override + public void getPolicies(Client client, RequestFilter requestFilter, + Holder response, Holder cAs, + Holder oIDs) { + + System.out.println("CHECKED_SERVICE"); + + + Response rs = new Response(); + OIDCollection oidc = new OIDCollection(); + CACollection cac = new CACollection(); + + PolicyCollection pc = new PolicyCollection(); + + CertificateEnrollmentPolicy cnp = new CertificateEnrollmentPolicy(); + Attributes at = new Attributes(); + PrivateKeyAttributes pkat = new PrivateKeyAttributes(); + + pkat.setMinimalKeyLength(2048); + + at.setPolicySchema(3); + at.setPrivateKeyAttributes(pkat); + at.setHashAlgorithmOIDReference(0); + + cnp.setPolicyOIDReference(0); + cnp.setAttributes(at); + + pc.getPolicy().add(cnp); + + rs.setPolicies(pc); + + response.value = rs; + + OID oid = new OID(); + oid.setValue("1.3.14.3.2.29"); + oid.setGroup(1); + oid.setOIDReferenceID(0); + oid.setDefaultName("szOID_OIWSEC_sha1RSASign"); + + oidc.getOID().add(oid); + cAs.value = cac; + oIDs.value = oidc; + + } + +} diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/util/PPSRSOApMessageHandler.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/util/PPSRSOApMessageHandler.java new file mode 100644 index 0000000000..4c0f8adef4 --- /dev/null +++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/util/PPSRSOApMessageHandler.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.xcep.util; + + +import java.util.HashSet; +import java.util.Set; +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; + +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) { + + } + +} \ No newline at end of file diff --git a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/util/ServerPasswordCallback.java b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/util/ServerPasswordCallback.java new file mode 100644 index 0000000000..0fd039a07c --- /dev/null +++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/xcep/util/ServerPasswordCallback.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.xcep.util; + +import javax.security.auth.callback.Callback; +import javax.security.auth.callback.CallbackHandler; +import javax.security.auth.callback.UnsupportedCallbackException; +import java.io.IOException; +import org.apache.wss4j.common.ext.WSPasswordCallback; + +public class ServerPasswordCallback 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.setPassword("admin"); + } + } +} From bc93ff08a43bfac037c57e2f47bd97da1a8f7485 Mon Sep 17 00:00:00 2001 From: Geeth Munasinghe Date: Wed, 21 Jan 2015 20:14:55 +0530 Subject: [PATCH 03/12] Changing cdm to mdm --- components/device-mgt/pom.xml | 2 +- components/key-mgt/pom.xml | 59 +------------------ .../pom.xml | 4 +- pom.xml | 24 ++++++-- product/modules/distribution/pom.xml | 4 +- product/modules/integration/pom.xml | 4 +- .../tests-common/admin-clients/pom.xml | 2 +- .../integration-test-utils/pom.xml | 2 +- .../modules/integration/tests-common/pom.xml | 4 +- .../integration/tests-common/ui-pages/pom.xml | 2 +- .../agents/android/jax-rs/pom.xml | 4 +- .../agents/windows/jax-rs/pom.xml | 6 +- product/modules/mobileservices/pom.xml | 8 +-- product/modules/p2-profile-gen/pom.xml | 16 ++--- product/modules/rest-api/pom.xml | 4 +- product/pom.xml | 4 +- 16 files changed, 53 insertions(+), 96 deletions(-) diff --git a/components/device-mgt/pom.xml b/components/device-mgt/pom.xml index ea411b77f3..f17b54bf47 100644 --- a/components/device-mgt/pom.xml +++ b/components/device-mgt/pom.xml @@ -33,7 +33,7 @@ device-mgt 2.0.0-SNAPSHOT pom - WSO2 Carbon - Device Management Component + WSO2 Carbon - Mobile Device Management Component http://wso2.org diff --git a/components/key-mgt/pom.xml b/components/key-mgt/pom.xml index f00b618ce4..2ffc219ae5 100644 --- a/components/key-mgt/pom.xml +++ b/components/key-mgt/pom.xml @@ -33,64 +33,13 @@ key-mgt 2.0.0-SNAPSHOT pom - WSO2 Carbon - Device Management Component + WSO2 Carbon - Oauth Key Management Component http://wso2.org org.wso2.carbon.key.mgt.handler.valve - @@ -111,9 +60,5 @@ - + diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/pom.xml index 5dd10889c7..0ef1dd711e 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/pom.xml @@ -39,12 +39,10 @@ org.wso2.carbon org.wso2.carbon.device.mgt.mobile.impl - ${project.version} org.wso2.carbon org.wso2.carbon.device.mgt.common - ${project.version} @@ -102,7 +100,7 @@ org.wso2.carbon.core.server:${carbon.kernel.version} - org.wso2.carbon.device.mgt.server:${project.version} + org.wso2.carbon.device.mgt.server:${cdm.core.version} diff --git a/pom.xml b/pom.xml index a583f57d6b..322c9df85a 100644 --- a/pom.xml +++ b/pom.xml @@ -100,23 +100,29 @@ org.wso2.carbon org.wso2.carbon.device.mgt.core - ${project.version} + ${cdm.core.version} org.wso2.carbon org.wso2.carbon.device.mgt.common + ${cdm.core.version} + + + + org.wso2.carbon + org.wso2.carbon.device.mgt.mobile.impl ${project.version} org.wso2.carbon org.wso2.carbon.policy.mgt.common - ${project.version} + ${cdm.core.version} org.wso2.carbon org.wso2.carbon.policy.mgt.core - ${project.version} + ${cdm.core.version} @@ -197,8 +203,18 @@ - 6.1.1 + + 4.3.0 + [4.3.0, 4.4.0) + + + 1.0.0-SNAPSHOT + [1.0.0, 2.0.0) + + + 6.1.1 + 4.3.0-SNAPSHOT 1.5.4 1.3 diff --git a/product/modules/distribution/pom.xml b/product/modules/distribution/pom.xml index c7ac210bf7..45758abc60 100644 --- a/product/modules/distribution/pom.xml +++ b/product/modules/distribution/pom.xml @@ -22,8 +22,8 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - org.wso2.cdmserver - wso2cdmserver-product + org.wso2.mdmserver + wso2mdmserver-product 2.0.0-SNAPSHOT ../../pom.xml diff --git a/product/modules/integration/pom.xml b/product/modules/integration/pom.xml index fb2ef0f59e..12a6cc9551 100644 --- a/product/modules/integration/pom.xml +++ b/product/modules/integration/pom.xml @@ -21,8 +21,8 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - org.wso2.cdmserver - wso2cdmserver-product + org.wso2.mdmserver + wso2mdmserver-product 2.0.0-SNAPSHOT ../../pom.xml diff --git a/product/modules/integration/tests-common/admin-clients/pom.xml b/product/modules/integration/tests-common/admin-clients/pom.xml index 10da72790e..9cca8ec0b0 100644 --- a/product/modules/integration/tests-common/admin-clients/pom.xml +++ b/product/modules/integration/tests-common/admin-clients/pom.xml @@ -22,7 +22,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - org.wso2.cdmserver + org.wso2.mdmserver cdm-integration-tests-common 2.0.0-SNAPSHOT ../pom.xml diff --git a/product/modules/integration/tests-common/integration-test-utils/pom.xml b/product/modules/integration/tests-common/integration-test-utils/pom.xml index 28aee1ab94..38504e3a2b 100644 --- a/product/modules/integration/tests-common/integration-test-utils/pom.xml +++ b/product/modules/integration/tests-common/integration-test-utils/pom.xml @@ -22,7 +22,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - org.wso2.cdmserver + org.wso2.mdmserver cdm-integration-tests-common 2.0.0-SNAPSHOT ../pom.xml diff --git a/product/modules/integration/tests-common/pom.xml b/product/modules/integration/tests-common/pom.xml index e79e88cbf6..c491a9e58e 100644 --- a/product/modules/integration/tests-common/pom.xml +++ b/product/modules/integration/tests-common/pom.xml @@ -22,7 +22,7 @@ - org.wso2.cdmserver + org.wso2.mdmserver wso2cdm-integration 2.0.0-SNAPSHOT ../pom.xml @@ -30,7 +30,7 @@ 4.0.0 - org.wso2.cdmserver + org.wso2.mdmserver cdm-integration-tests-common pom WSO2 CDM Integration Test Common diff --git a/product/modules/integration/tests-common/ui-pages/pom.xml b/product/modules/integration/tests-common/ui-pages/pom.xml index 2906ce7f40..1efdae6d72 100644 --- a/product/modules/integration/tests-common/ui-pages/pom.xml +++ b/product/modules/integration/tests-common/ui-pages/pom.xml @@ -22,7 +22,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - org.wso2.cdmserver + org.wso2.mdmserver cdm-integration-tests-common 2.0.0-SNAPSHOT ../pom.xml diff --git a/product/modules/mobileservices/agents/android/jax-rs/pom.xml b/product/modules/mobileservices/agents/android/jax-rs/pom.xml index 54dfb6b313..808416943a 100644 --- a/product/modules/mobileservices/agents/android/jax-rs/pom.xml +++ b/product/modules/mobileservices/agents/android/jax-rs/pom.xml @@ -21,8 +21,8 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - org.wso2.cdmserver - wso2cdmserver-product-mobileservices + org.wso2.mdmserver + wso2mdmserver-product-mobileservices 2.0.0-SNAPSHOT ../../../pom.xml diff --git a/product/modules/mobileservices/agents/windows/jax-rs/pom.xml b/product/modules/mobileservices/agents/windows/jax-rs/pom.xml index e0c51bde96..a713de08a0 100644 --- a/product/modules/mobileservices/agents/windows/jax-rs/pom.xml +++ b/product/modules/mobileservices/agents/windows/jax-rs/pom.xml @@ -19,8 +19,8 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - org.wso2.cdmserver - wso2cdmserver-product-mobileservices + org.wso2.mdmserver + wso2mdmserver-product-mobileservices 2.0.0-SNAPSHOT ../../../pom.xml @@ -152,13 +152,11 @@ org.wso2.carbon org.wso2.carbon.device.mgt.common - 2.0.0-SNAPSHOT provided org.wso2.carbon org.wso2.carbon.device.mgt.core - 2.0.0-SNAPSHOT provided diff --git a/product/modules/mobileservices/pom.xml b/product/modules/mobileservices/pom.xml index 8f10c55625..5d7b134e41 100644 --- a/product/modules/mobileservices/pom.xml +++ b/product/modules/mobileservices/pom.xml @@ -3,15 +3,15 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - wso2cdmserver-product - org.wso2.cdmserver + wso2mdmserver-product + org.wso2.mdmserver 2.0.0-SNAPSHOT ../../pom.xml 4.0.0 - org.wso2.cdmserver - wso2cdmserver-product-mobileservices + org.wso2.mdmserver + wso2mdmserver-product-mobileservices pom agents/windows/jax-rs diff --git a/product/modules/p2-profile-gen/pom.xml b/product/modules/p2-profile-gen/pom.xml index ce4f57f58c..d221a04027 100644 --- a/product/modules/p2-profile-gen/pom.xml +++ b/product/modules/p2-profile-gen/pom.xml @@ -20,15 +20,15 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - org.wso2.cdmserver - wso2cdmserver-product + org.wso2.mdmserver + wso2mdmserver-product 2.0.0-SNAPSHOT ../../pom.xml 4.0.0 - wso2cdm-profile-gen - WSO2 Connected Device Manager (CDM) - P2 Profile Gen + wso2mdm-profile-gen + WSO2 Mobile Device Manager (MDM) - P2 Profile Gen pom @@ -104,13 +104,13 @@ org.wso2.carbon:org.wso2.carbon.ndatasource.feature:${carbon.platform.version} --> - org.wso2.carbon:org.wso2.carbon.device.mgt.server.feature:${project.version} + org.wso2.carbon:org.wso2.carbon.device.mgt.server.feature:${cdm.core.version} org.wso2.carbon:org.wso2.carbon.device.mgt.mobile.feature:${project.version} - org.wso2.carbon:org.wso2.carbon.policy.mgt.server.feature:${project.version} + org.wso2.carbon:org.wso2.carbon.policy.mgt.server.feature:${cdm.core.version} org.wso2.carbon:org.wso2.carbon.webapp.mgt.feature:${carbon.platform.version} @@ -251,7 +251,7 @@ org.wso2.carbon.device.mgt.server.feature.group - ${project.version} + ${cdm.core.version} org.wso2.carbon.device.mgt.mobile.feature.group @@ -259,7 +259,7 @@ org.wso2.carbon.policy.mgt.server.feature.group - ${project.version} + ${cdm.core.version} org.wso2.carbon.webapp.mgt.feature.group diff --git a/product/modules/rest-api/pom.xml b/product/modules/rest-api/pom.xml index a6d7552c04..e8671c5a0c 100644 --- a/product/modules/rest-api/pom.xml +++ b/product/modules/rest-api/pom.xml @@ -1,8 +1,8 @@ - org.wso2.cdmserver - wso2cdmserver-product + org.wso2.mdmserver + wso2mdmserver-product 2.0.0-SNAPSHOT ../../pom.xml diff --git a/product/pom.xml b/product/pom.xml index 479f83daeb..7c80f315b9 100644 --- a/product/pom.xml +++ b/product/pom.xml @@ -28,8 +28,8 @@ 4.0.0 - org.wso2.cdmserver - wso2cdmserver-product + org.wso2.mdmserver + wso2mdmserver-product pom WSO2 Connected Device Manager (CDM) - Parent From 99f7cd25e88e57292f25e3240b41051b48099aa9 Mon Sep 17 00:00:00 2001 From: Dulitha Wijewantha Date: Thu, 22 Jan 2015 10:43:36 +0530 Subject: [PATCH 04/12] Merging left over changes from MDM. Most of the changes are from @harshahL. --- .../pom1.xml~ | 0 .../dao/MobileDeviceManagementDAOFactory.java | 165 +++++++------ .../impl/MobileDeviceOperationDAOImpl.java | 10 +- .../dao/impl/MobileOperationDAOImpl.java | 4 +- .../AndroidMobileOperationManager.java | 8 +- ...obileDeviceManagementServiceComponent.java | 219 ++++++++++-------- .../util/MobileDeviceManagementUtil.java | 56 ++--- .../src/main/webapp/WEB-INF/cxf-servlet.xml | 5 +- 8 files changed, 253 insertions(+), 214 deletions(-) delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/pom1.xml~ diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/pom1.xml~ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/pom1.xml~ deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceManagementDAOFactory.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceManagementDAOFactory.java index ddaf0adf82..8415271d2f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceManagementDAOFactory.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceManagementDAOFactory.java @@ -19,81 +19,108 @@ package org.wso2.carbon.device.mgt.mobile.dao; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.mgt.common.DeviceManagementException; -import org.wso2.carbon.device.mgt.mobile.DataSourceListener; +import org.wso2.carbon.device.mgt.mobile.config.datasource.JNDILookupDefinition; import org.wso2.carbon.device.mgt.mobile.config.datasource.MobileDataSourceConfig; import org.wso2.carbon.device.mgt.mobile.dao.impl.*; import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil; -import org.wso2.carbon.device.mgt.mobile.internal.MobileDeviceManagementBundleActivator; import javax.sql.DataSource; +import java.util.Hashtable; +import java.util.List; /** * Factory class used to create MobileDeviceManagement related DAO objects. */ -public class MobileDeviceManagementDAOFactory implements DataSourceListener { - - private static DataSource dataSource; - private static MobileDataSourceConfig mobileDataSourceConfig; - private static final Log log = LogFactory.getLog(MobileDeviceManagementDAOFactory.class); - - public MobileDeviceManagementDAOFactory() { - - } - - public void init() throws DeviceManagementException { - dataSource = MobileDeviceManagementDAOUtil.resolveDataSource(mobileDataSourceConfig); - if (dataSource != null) { - MobileDeviceManagementDAOUtil.createDataSource(dataSource); - } else { - MobileDeviceManagementBundleActivator.registerDataSourceListener(this); - } - } - - public static MobileDeviceDAO getMobileDeviceDAO() { - return new MobileDeviceDAOImpl(dataSource); - } - - public static MobileOperationDAO getMobileOperationDAO() { - return new MobileOperationDAOImpl(dataSource); - } - - public static MobileOperationPropertyDAO getMobileOperationPropertyDAO() { - return new MobileOperationPropertyDAOImpl(dataSource); - } - - public static MobileDeviceOperationDAO getMobileDeviceOperationDAO() { - return new MobileDeviceOperationDAOImpl(dataSource); - } - - public static FeatureDAO getFeatureDAO() { - return new FeatureDAOImpl(dataSource); - } - - public static FeaturePropertyDAO getFeaturePropertyDAO() { - return new FeaturePropertyDAOImpl(dataSource); - } - - public static MobileDataSourceConfig getMobileDeviceManagementConfig() { - return mobileDataSourceConfig; - } - - public static void setMobileDataSourceConfig( - MobileDataSourceConfig mobileDataSourceConfig) { - MobileDeviceManagementDAOFactory.mobileDataSourceConfig = - mobileDataSourceConfig; - } - - public static DataSource getDataSource() { - return dataSource; - } - - @Override - public void notifyObserver() { - try { - dataSource = MobileDeviceManagementDAOUtil.resolveDataSource(mobileDataSourceConfig); - MobileDeviceManagementDAOUtil.createDataSource(dataSource); - } catch (DeviceManagementException e) { - log.error("Error occurred while resolving mobile device management metadata repository data source", e); - } - } -} +public class MobileDeviceManagementDAOFactory { + + private static DataSource dataSource; + private static MobileDataSourceConfig mobileDataSourceConfig; + private static final Log log = LogFactory.getLog(MobileDeviceManagementDAOFactory.class); + + public MobileDeviceManagementDAOFactory() { + + } + + public static void init() { + try { + dataSource = MobileDeviceManagementDAOFactory.resolveDataSource(mobileDataSourceConfig); + } catch (DeviceManagementException e) { + log.error("Exception occurred while initializing the mobile datasource.",e); + } + } + + /** + * Resolve data source from the data source definition. + * + * @param config Mobile data source configuration + * @return data source resolved from the data source definition + */ + private static DataSource resolveDataSource(MobileDataSourceConfig config) + throws DeviceManagementException { + DataSource dataSource = null; + if (config == null) { + throw new RuntimeException("Device Management Repository data source configuration " + + "is null and thus, is not initialized"); + } + JNDILookupDefinition jndiConfig = config.getJndiLookupDefintion(); + if (jndiConfig != null) { + if (log.isDebugEnabled()) { + log.debug("Initializing Device Management Repository data source using the JNDI " + + "Lookup Definition"); + } + List jndiPropertyList = + jndiConfig.getJndiProperties(); + if (jndiPropertyList != null) { + Hashtable jndiProperties = new Hashtable(); + for (JNDILookupDefinition.JNDIProperty prop : jndiPropertyList) { + jndiProperties.put(prop.getName(), prop.getValue()); + } + dataSource = + MobileDeviceManagementDAOUtil + .lookupDataSource(jndiConfig.getJndiName(), jndiProperties); + } else { + dataSource = MobileDeviceManagementDAOUtil + .lookupDataSource(jndiConfig.getJndiName(), null); + } + } + return dataSource; + } + + public static MobileDeviceDAO getMobileDeviceDAO() { + return new MobileDeviceDAOImpl(dataSource); + } + + public static MobileOperationDAO getMobileOperationDAO() { + return new MobileOperationDAOImpl(dataSource); + } + + public static MobileOperationPropertyDAO getMobileOperationPropertyDAO() { + return new MobileOperationPropertyDAOImpl(dataSource); + } + + public static MobileDeviceOperationDAO getMobileDeviceOperationDAO() { + return new MobileDeviceOperationDAOImpl(dataSource); + } + + public static FeatureDAO getFeatureDAO() { + return new FeatureDAOImpl(dataSource); + } + + public static FeaturePropertyDAO getFeaturePropertyDAO() { + return new FeaturePropertyDAOImpl(dataSource); + } + + public static MobileDataSourceConfig getMobileDeviceManagementConfig() { + return mobileDataSourceConfig; + } + + public static void setMobileDataSourceConfig( + MobileDataSourceConfig mobileDataSourceConfig) { + MobileDeviceManagementDAOFactory.mobileDataSourceConfig = + mobileDataSourceConfig; + } + + public static DataSource getDataSource() { + return dataSource; + } +} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileDeviceOperationDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileDeviceOperationDAOImpl.java index e2d24e5e9b..f15af1ac53 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileDeviceOperationDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileDeviceOperationDAOImpl.java @@ -52,7 +52,7 @@ public class MobileDeviceOperationDAOImpl implements MobileDeviceOperationDAO { try { conn = this.getConnection(); String createDBQuery = - "INSERT INTO MBL_DEVICE_OPERATION(DEVICE_ID, OPERATION_ID, SENT_DATE, RECEIVED_DATE) VALUES (?, ?, ?, ?)"; + "INSERT INTO MBL_DEVICE_OPERATION_MAPPING (DEVICE_ID, OPERATION_ID, SENT_DATE, RECEIVED_DATE) VALUES (?, ?, ?, ?)"; stmt = conn.prepareStatement(createDBQuery); stmt.setString(1, deviceOperation.getDeviceId()); @@ -86,7 +86,7 @@ public class MobileDeviceOperationDAOImpl implements MobileDeviceOperationDAO { try { conn = this.getConnection(); String updateDBQuery = - "UPDATE MBL_DEVICE_OPERATION SET SENT_DATE = ?, RECEIVED_DATE = ? WHERE DEVICE_ID = ? AND OPERATION_ID=?"; + "UPDATE MBL_DEVICE_OPERATION_MAPPING SET SENT_DATE = ?, RECEIVED_DATE = ? WHERE DEVICE_ID = ? AND OPERATION_ID=?"; stmt = conn.prepareStatement(updateDBQuery); stmt.setLong(1, deviceOperation.getSentDate()); stmt.setLong(2, deviceOperation.getReceivedDate()); @@ -117,7 +117,7 @@ public class MobileDeviceOperationDAOImpl implements MobileDeviceOperationDAO { try { conn = this.getConnection(); String deleteDBQuery = - "DELETE FROM MBL_DEVICE_OPERATION WHERE DEVICE_ID = ? AND OPERATION_ID=?"; + "DELETE FROM MBL_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ? AND OPERATION_ID=?"; stmt = conn.prepareStatement(deleteDBQuery); stmt.setString(1, deviceId); stmt.setInt(2, operationId); @@ -146,7 +146,7 @@ public class MobileDeviceOperationDAOImpl implements MobileDeviceOperationDAO { try { conn = this.getConnection(); String selectDBQuery = - "SELECT DEVICE_ID, OPERATION_ID, SENT_DATE, RECEIVED_DATE FROM MBL_DEVICE_OPERATION WHERE DEVICE_ID = ? AND OPERATION_ID=?"; + "SELECT DEVICE_ID, OPERATION_ID, SENT_DATE, RECEIVED_DATE FROM MBL_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ? AND OPERATION_ID=?"; stmt = conn.prepareStatement(selectDBQuery); stmt.setString(1, deviceId); stmt.setInt(2, operationId); @@ -181,7 +181,7 @@ public class MobileDeviceOperationDAOImpl implements MobileDeviceOperationDAO { try { conn = this.getConnection(); String selectDBQuery = - "SELECT DEVICE_ID, OPERATION_ID, SENT_DATE, RECEIVED_DATE FROM MBL_DEVICE_OPERATION WHERE DEVICE_ID = ?"; + "SELECT DEVICE_ID, OPERATION_ID, SENT_DATE, RECEIVED_DATE FROM MBL_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ?"; stmt = conn.prepareStatement(selectDBQuery); stmt.setString(1, deviceId); ResultSet resultSet = stmt.executeQuery(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileOperationDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileOperationDAOImpl.java index 01612098a1..e2fb47b732 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileOperationDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileOperationDAOImpl.java @@ -138,11 +138,13 @@ public class MobileOperationDAOImpl implements MobileOperationDAO { String selectDBQuery = "SELECT OPERATION_ID, FEATURE_CODE, CREATED_DATE FROM MBL_OPERATION WHERE OPERATION_ID = ?"; stmt = conn.prepareStatement(selectDBQuery); - stmt.setInt(1, operation.getOperationId()); + stmt.setInt(1, operationId); ResultSet resultSet = stmt.executeQuery(); while (resultSet.next()) { operation = new MobileOperation(); operation.setOperationId(resultSet.getInt(1)); + operation.setFeatureCode(resultSet.getString(2)); + operation.setCreatedDate(resultSet.getLong(3)); break; } } catch (SQLException e) { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidMobileOperationManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidMobileOperationManager.java index f04bba9a94..76c6332434 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidMobileOperationManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidMobileOperationManager.java @@ -58,7 +58,7 @@ public class AndroidMobileOperationManager extends AbstractMobileOperationManage mobileDeviceOperation.setDeviceId(deviceIdentifier.getId()); status = MobileDeviceManagementDAOFactory.getMobileDeviceOperationDAO() .addMobileDeviceOperation( - new MobileDeviceOperation()); + mobileDeviceOperation); } } } catch (MobileDeviceManagementDAOException e) { @@ -75,6 +75,7 @@ public class AndroidMobileOperationManager extends AbstractMobileOperationManage throws OperationManagementException { List operations = new ArrayList(); List mobileDeviceOperations = null; + List operationProperties = null; MobileOperation mobileOperation = null; try { mobileDeviceOperations = MobileDeviceManagementDAOFactory.getMobileDeviceOperationDAO() @@ -88,6 +89,11 @@ public class AndroidMobileOperationManager extends AbstractMobileOperationManage mobileOperation = MobileDeviceManagementDAOFactory.getMobileOperationDAO() .getMobileOperation( operationId); + operationProperties = + MobileDeviceManagementDAOFactory.getMobileOperationPropertyDAO() + .getAllMobileOperationPropertiesOfOperation( + operationId); + mobileOperation.setProperties(operationProperties); operations.add(MobileDeviceManagementUtil .convertMobileOperationToOperation(mobileOperation)); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementServiceComponent.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementServiceComponent.java index 195929bb2f..28606783db 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementServiceComponent.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementServiceComponent.java @@ -31,6 +31,7 @@ import org.wso2.carbon.device.mgt.mobile.config.MobileDeviceConfigurationManager import org.wso2.carbon.device.mgt.mobile.config.MobileDeviceManagementConfig; import org.wso2.carbon.device.mgt.mobile.config.datasource.MobileDataSourceConfig; import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOFactory; +import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil; import org.wso2.carbon.device.mgt.mobile.impl.android.AndroidDeviceManagerService; import org.wso2.carbon.device.mgt.mobile.impl.ios.IOSDeviceManagerService; import org.wso2.carbon.device.mgt.mobile.impl.windows.WindowsDeviceManagerService; @@ -54,112 +55,134 @@ import java.util.List; */ public class MobileDeviceManagementServiceComponent { - private ServiceRegistration androidServiceRegRef; - private ServiceRegistration iOSServiceRegRef; - private ServiceRegistration windowsServiceRegRef; + private ServiceRegistration androidServiceRegRef; + private ServiceRegistration iOSServiceRegRef; + private ServiceRegistration windowsServiceRegRef; - private static final Log log = LogFactory.getLog(MobileDeviceManagementServiceComponent.class); + private static final Log log = LogFactory.getLog(MobileDeviceManagementServiceComponent.class); - protected void activate(ComponentContext ctx) { - if (log.isDebugEnabled()) { - log.debug("Activating Mobile Device Management Service Component"); - } - try { - BundleContext bundleContext = ctx.getBundleContext(); + protected void activate(ComponentContext ctx) { + if (log.isDebugEnabled()) { + log.debug("Activating Mobile Device Management Service Component"); + } + try { + BundleContext bundleContext = ctx.getBundleContext(); /* Initialize the datasource configuration */ - MobileDeviceConfigurationManager.getInstance().initConfig(); - MobileDeviceManagementConfig config = MobileDeviceConfigurationManager.getInstance() - .getMobileDeviceManagementConfig(); - MobileDataSourceConfig dsConfig = - config.getMobileDeviceMgtRepository().getMobileDataSourceConfig(); - - MobileDeviceManagementDAOFactory.setMobileDataSourceConfig(dsConfig); - - androidServiceRegRef = - bundleContext.registerService(DeviceManagerService.class.getName(), - new AndroidDeviceManagerService(), null); - iOSServiceRegRef = - bundleContext.registerService(DeviceManagerService.class.getName(), - new IOSDeviceManagerService(), null); - windowsServiceRegRef = - bundleContext.registerService(DeviceManagerService.class.getName(), - new WindowsDeviceManagerService(), null); + MobileDeviceConfigurationManager.getInstance().initConfig(); + MobileDeviceManagementConfig config = MobileDeviceConfigurationManager.getInstance() + .getMobileDeviceManagementConfig(); + MobileDataSourceConfig dsConfig = + config.getMobileDeviceMgtRepository().getMobileDataSourceConfig(); + + MobileDeviceManagementDAOFactory.setMobileDataSourceConfig(dsConfig); + MobileDeviceManagementDAOFactory.init(); + String setupOption = System.getProperty("setup"); + if (setupOption != null) { + if (log.isDebugEnabled()) { + log.debug( + "-Dsetup is enabled. Mobile Device management repository schema initialization is about " + + "to begin"); + } + try { + MobileDeviceManagementDAOUtil.setupMobileDeviceManagementSchema( + MobileDeviceManagementDAOFactory.getDataSource()); + } catch (DeviceManagementException e) { + log.error( + "Exception occurred while initializing mobile device management database schema", + e); + } + } + + androidServiceRegRef = + bundleContext.registerService(DeviceManagerService.class.getName(), + new AndroidDeviceManagerService(), null); + iOSServiceRegRef = + bundleContext.registerService(DeviceManagerService.class.getName(), + new IOSDeviceManagerService(), null); + windowsServiceRegRef = + bundleContext.registerService(DeviceManagerService.class.getName(), + new WindowsDeviceManagerService(), null); /* Initialize all API configurations with corresponding API Providers */ - this.initAPIConfigs(); - /* Publish all mobile device management related JAX-RS services as APIs */ - this.publishAPIs(); - - if (log.isDebugEnabled()) { - log.debug("Mobile Device Management Service Component has been successfully activated"); - } - } catch (Throwable e) { - log.error("Error occurred while activating Mobile Device Management Service Component", e); - } - } - - protected void deactivate(ComponentContext ctx) { - if (log.isDebugEnabled()) { - log.debug("De-activating Mobile Device Management Service Component"); - } - try { - BundleContext bundleContext = ctx.getBundleContext(); - - androidServiceRegRef.unregister(); - iOSServiceRegRef.unregister(); - windowsServiceRegRef.unregister(); + this.initAPIConfigs(); + /* Publish all mobile device management related JAX-RS services as APIs */ + this.publishAPIs(); + + if (log.isDebugEnabled()) { + log.debug( + "Mobile Device Management Service Component has been successfully activated"); + } + } catch (Throwable e) { + log.error("Error occurred while activating Mobile Device Management Service Component", + e); + } + } + + protected void deactivate(ComponentContext ctx) { + if (log.isDebugEnabled()) { + log.debug("De-activating Mobile Device Management Service Component"); + } + try { + BundleContext bundleContext = ctx.getBundleContext(); + + androidServiceRegRef.unregister(); + iOSServiceRegRef.unregister(); + windowsServiceRegRef.unregister(); /* Removing all APIs published upon start-up for mobile device management related JAX-RS services */ - this.removeAPIs(); - if (log.isDebugEnabled()) { - log.debug("Mobile Device Management Service Component has been successfully de-activated"); - } - } catch (Throwable e) { - log.error("Error occurred while de-activating Mobile Device Management bundle", e); - } - } - - private void initAPIConfigs() throws DeviceManagementException { - List apiConfigs = - MobileDeviceConfigurationManager.getInstance().getMobileDeviceManagementConfig(). - getApiPublisherConfig().getAPIs(); - for (APIConfig apiConfig : apiConfigs) { - try { - APIProvider provider = APIManagerFactory.getInstance().getAPIProvider(apiConfig.getOwner()); - apiConfig.init(provider); - } catch (APIManagementException e) { - throw new DeviceManagementException("Error occurred while initializing API Config '" + - apiConfig.getName() + "'", e); - } - } - } - - private void publishAPIs() throws DeviceManagementException { - List apiConfigs = - MobileDeviceConfigurationManager.getInstance().getMobileDeviceManagementConfig(). - getApiPublisherConfig().getAPIs(); - for (APIConfig apiConfig : apiConfigs) { - DeviceManagementAPIPublisherUtil.publishAPI(apiConfig); - } - } - - private void removeAPIs() throws DeviceManagementException { - List apiConfigs = - MobileDeviceConfigurationManager.getInstance().getMobileDeviceManagementConfig(). - getApiPublisherConfig().getAPIs(); - for (APIConfig apiConfig : apiConfigs) { - DeviceManagementAPIPublisherUtil.removeAPI(apiConfig); - } - } - - protected void setAPIManagerConfigurationService(APIManagerConfigurationService service) { - //do nothing - } - - protected void unsetAPIManagerConfigurationService(APIManagerConfigurationService service) { - //do nothing - } + this.removeAPIs(); + if (log.isDebugEnabled()) { + log.debug( + "Mobile Device Management Service Component has been successfully de-activated"); + } + } catch (Throwable e) { + log.error("Error occurred while de-activating Mobile Device Management bundle", e); + } + } + + private void initAPIConfigs() throws DeviceManagementException { + List apiConfigs = + MobileDeviceConfigurationManager.getInstance().getMobileDeviceManagementConfig(). + getApiPublisherConfig().getAPIs(); + for (APIConfig apiConfig : apiConfigs) { + try { + APIProvider provider = + APIManagerFactory.getInstance().getAPIProvider(apiConfig.getOwner()); + apiConfig.init(provider); + } catch (APIManagementException e) { + throw new DeviceManagementException( + "Error occurred while initializing API Config '" + + apiConfig.getName() + "'", e); + } + } + } + + private void publishAPIs() throws DeviceManagementException { + List apiConfigs = + MobileDeviceConfigurationManager.getInstance().getMobileDeviceManagementConfig(). + getApiPublisherConfig().getAPIs(); + for (APIConfig apiConfig : apiConfigs) { + DeviceManagementAPIPublisherUtil.publishAPI(apiConfig); + } + } + + private void removeAPIs() throws DeviceManagementException { + List apiConfigs = + MobileDeviceConfigurationManager.getInstance().getMobileDeviceManagementConfig(). + getApiPublisherConfig().getAPIs(); + for (APIConfig apiConfig : apiConfigs) { + DeviceManagementAPIPublisherUtil.removeAPI(apiConfig); + } + } + + protected void setAPIManagerConfigurationService(APIManagerConfigurationService service) { + //do nothing + } + + protected void unsetAPIManagerConfigurationService(APIManagerConfigurationService service) { + //do nothing + } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/util/MobileDeviceManagementUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/util/MobileDeviceManagementUtil.java index d170379eea..d771cb485c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/util/MobileDeviceManagementUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/util/MobileDeviceManagementUtil.java @@ -60,39 +60,19 @@ public class MobileDeviceManagementUtil { } } - private static String getPropertyValue(Device device, String property) { - for (Device.Property prop : device.getProperties()) { - if (property.equals(prop.getName())) { - return prop.getValue(); - } - } - return null; - } - - private static Device.Property getProperty(String property, String value) { - Device.Property prop = null; - if (property != null) { - prop = new Device.Property(); - prop.setName(property); - prop.setValue(value); - return prop; - } - return prop; - } - public static MobileDevice convertToMobileDevice(Device device) { MobileDevice mobileDevice = null; if (device != null) { mobileDevice = new MobileDevice(); mobileDevice.setMobileDeviceId(device.getDeviceIdentifier()); - mobileDevice.setImei(getPropertyValue(device, MOBILE_DEVICE_IMEI)); - mobileDevice.setImsi(getPropertyValue(device, MOBILE_DEVICE_IMSI)); - mobileDevice.setRegId(getPropertyValue(device, MOBILE_DEVICE_REG_ID)); - mobileDevice.setModel(getPropertyValue(device, MOBILE_DEVICE_MODEL)); - mobileDevice.setOsVersion(getPropertyValue(device, MOBILE_DEVICE_OS_VERSION)); - mobileDevice.setVendor(getPropertyValue(device, MOBILE_DEVICE_VENDOR)); - mobileDevice.setLatitude(getPropertyValue(device, MOBILE_DEVICE_LATITUDE)); - mobileDevice.setLongitude(getPropertyValue(device, MOBILE_DEVICE_LONGITUDE)); + mobileDevice.setImei(device.getProperties().get(MOBILE_DEVICE_IMEI)); + mobileDevice.setImsi(device.getProperties().get(MOBILE_DEVICE_IMSI)); + mobileDevice.setRegId(device.getProperties().get(MOBILE_DEVICE_REG_ID)); + mobileDevice.setModel(device.getProperties().get(MOBILE_DEVICE_MODEL)); + mobileDevice.setOsVersion(device.getProperties().get(MOBILE_DEVICE_OS_VERSION)); + mobileDevice.setVendor(device.getProperties().get(MOBILE_DEVICE_VENDOR)); + mobileDevice.setLatitude(device.getProperties().get(MOBILE_DEVICE_LATITUDE)); + mobileDevice.setLongitude(device.getProperties().get(MOBILE_DEVICE_LONGITUDE)); } return mobileDevice; } @@ -101,16 +81,16 @@ public class MobileDeviceManagementUtil { Device device = null; if (mobileDevice != null) { device = new Device(); - List propertyList = new ArrayList(); - propertyList.add(getProperty(MOBILE_DEVICE_IMEI, mobileDevice.getImei())); - propertyList.add(getProperty(MOBILE_DEVICE_IMSI, mobileDevice.getImsi())); - propertyList.add(getProperty(MOBILE_DEVICE_REG_ID, mobileDevice.getRegId())); - propertyList.add(getProperty(MOBILE_DEVICE_MODEL, mobileDevice.getModel())); - propertyList.add(getProperty(MOBILE_DEVICE_OS_VERSION, mobileDevice.getOsVersion())); - propertyList.add(getProperty(MOBILE_DEVICE_VENDOR, mobileDevice.getVendor())); - propertyList.add(getProperty(MOBILE_DEVICE_LATITUDE, mobileDevice.getLatitude())); - propertyList.add(getProperty(MOBILE_DEVICE_LONGITUDE, mobileDevice.getLongitude())); - device.setProperties(propertyList); + Map propertyMap = new HashMap(); + propertyMap.put(MOBILE_DEVICE_IMEI, mobileDevice.getImei()); + propertyMap.put(MOBILE_DEVICE_IMSI, mobileDevice.getImsi()); + propertyMap.put(MOBILE_DEVICE_REG_ID, mobileDevice.getRegId()); + propertyMap.put(MOBILE_DEVICE_MODEL, mobileDevice.getModel()); + propertyMap.put(MOBILE_DEVICE_OS_VERSION, mobileDevice.getOsVersion()); + propertyMap.put(MOBILE_DEVICE_VENDOR, mobileDevice.getVendor()); + propertyMap.put(MOBILE_DEVICE_LATITUDE, mobileDevice.getLatitude()); + propertyMap.put(MOBILE_DEVICE_LONGITUDE, mobileDevice.getLongitude()); + device.setProperties(propertyMap); device.setDeviceIdentifier(mobileDevice.getMobileDeviceId()); } return device; diff --git a/product/modules/mobileservices/agents/android/jax-rs/src/main/webapp/WEB-INF/cxf-servlet.xml b/product/modules/mobileservices/agents/android/jax-rs/src/main/webapp/WEB-INF/cxf-servlet.xml index a58b5fc254..5b0c46836a 100644 --- a/product/modules/mobileservices/agents/android/jax-rs/src/main/webapp/WEB-INF/cxf-servlet.xml +++ b/product/modules/mobileservices/agents/android/jax-rs/src/main/webapp/WEB-INF/cxf-servlet.xml @@ -23,9 +23,9 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd"> - + - + @@ -53,6 +53,7 @@ + From 90402107f6e3f93f44e39566ba0b62dbbba174c5 Mon Sep 17 00:00:00 2001 From: Dulitha Wijewantha Date: Thu, 22 Jan 2015 15:51:09 +0530 Subject: [PATCH 05/12] Included the UI improvements to cdm jaggery app. Included the sso jaggery module dependency. --- pom.xml | 1 + .../jaggeryapps/cdm/api/mobile/device-api.jag | 38 ++++++++++ .../src/repository/jaggeryapps/cdm/init.js | 33 ++++++++- .../repository/jaggeryapps/cdm/jaggery.conf | 10 ++- .../jaggeryapps/cdm/modules/utility.js | 32 +++++++++ .../jaggeryapps/cdm/pages/dashboard.jag | 69 ++++++++++++++----- .../jaggeryapps/cdm/pages/device.jag | 19 ++++- product/modules/p2-profile-gen/pom.xml | 7 ++ 8 files changed, 187 insertions(+), 22 deletions(-) create mode 100644 product/modules/distribution/src/repository/jaggeryapps/cdm/api/mobile/device-api.jag create mode 100644 product/modules/distribution/src/repository/jaggeryapps/cdm/modules/utility.js diff --git a/pom.xml b/pom.xml index 322c9df85a..114eda3ab6 100644 --- a/pom.xml +++ b/pom.xml @@ -227,6 +227,7 @@ 1.1.0 1.0.0 1.0.0 + 1.1.0-SNAPSHOT 1.1.0 4.3.1 diff --git a/product/modules/distribution/src/repository/jaggeryapps/cdm/api/mobile/device-api.jag b/product/modules/distribution/src/repository/jaggeryapps/cdm/api/mobile/device-api.jag new file mode 100644 index 0000000000..10f37dc405 --- /dev/null +++ b/product/modules/distribution/src/repository/jaggeryapps/cdm/api/mobile/device-api.jag @@ -0,0 +1,38 @@ +<% +/* + * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +var utility = require("/modules/utility.js"); +var deviceManagementService = utility.getDeviceManagementService(); +var devices = deviceManagementService.getAllDevices("android"); +var logger = new Log(); +var deviceList = []; +for (i = 0; i < devices.size(); i++) { + var device = devices.get(i); + deviceList.push({ + "identifier": device.getDeviceIdentifier(), + "name": device.getName(), + "ownership": device.getOwnership(), + "owner": device.getOwner(), + "deviceType": device.getType(), + "vendor": device.getProperties().get("vendor"), + "model": device.getProperties().get("model"), + "osVersion": device.getProperties().get("osVersion") + }); +} +print(deviceList); +%> \ No newline at end of file diff --git a/product/modules/distribution/src/repository/jaggeryapps/cdm/init.js b/product/modules/distribution/src/repository/jaggeryapps/cdm/init.js index 27d9cf25ce..859dd1037f 100644 --- a/product/modules/distribution/src/repository/jaggeryapps/cdm/init.js +++ b/product/modules/distribution/src/repository/jaggeryapps/cdm/init.js @@ -1 +1,32 @@ -//Init js to execute \ No newline at end of file +/* + * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +//Init js to execute +var logger = new Log(); +logger.debug("running debug"); +var app_TENANT_CONFIGS = 'tenant.configs'; +var app_carbon = require('carbon'); +var app_configs = { + "HTTPS_URL": "https://localhost:9443" +}; + +var app_server = new app_carbon.server.Server({ + tenanted: app_configs.tenanted, + url: app_configs.HTTPS_URL + '/admin' +}); +application.put("SERVER", app_server); +application.put(app_TENANT_CONFIGS, {}); diff --git a/product/modules/distribution/src/repository/jaggeryapps/cdm/jaggery.conf b/product/modules/distribution/src/repository/jaggeryapps/cdm/jaggery.conf index 3012d60828..efc8b12576 100644 --- a/product/modules/distribution/src/repository/jaggeryapps/cdm/jaggery.conf +++ b/product/modules/distribution/src/repository/jaggeryapps/cdm/jaggery.conf @@ -1,6 +1,6 @@ { "welcomeFiles": ["pages/dashboard.jag"], - "initScripts": ["init.js"], + "initScripts": ["/init.js"], "urlMappings": [ { "url": "/devices/*", @@ -9,12 +9,16 @@ { "url": "/dashboard", "path": "/pages/dashboard.jag" + }, + { + "url": "/api/devices/mobile/*", + "path": "/api/mobile/device-api.jag" } ], "errorPages": { "500": "/error500.jag", "404": "/error404.jag", - "403": "/error403.jag" + "403": "/error403.jag " }, - "logLevel": "info" + "logLevel": "debug" } \ No newline at end of file diff --git a/product/modules/distribution/src/repository/jaggeryapps/cdm/modules/utility.js b/product/modules/distribution/src/repository/jaggeryapps/cdm/modules/utility.js new file mode 100644 index 0000000000..47b8862bfe --- /dev/null +++ b/product/modules/distribution/src/repository/jaggeryapps/cdm/modules/utility.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +//temporary + +var PrivilegedCarbonContext = Packages.org.wso2.carbon.context.PrivilegedCarbonContext, + Class = java.lang.Class; + +osgiService = function (clazz) { + return PrivilegedCarbonContext.getThreadLocalCarbonContext().getOSGiService(Class.forName(clazz)); +}; +var getDeviceManagementService= function(){ + //server.authenticate("admin", "admin"); + var realmService = osgiService('org.wso2.carbon.device.mgt.core.service.DeviceManagementService'); + //var realmService = null; + return realmService; +} diff --git a/product/modules/distribution/src/repository/jaggeryapps/cdm/pages/dashboard.jag b/product/modules/distribution/src/repository/jaggeryapps/cdm/pages/dashboard.jag index 35d2f255b5..46c5cd3dad 100644 --- a/product/modules/distribution/src/repository/jaggeryapps/cdm/pages/dashboard.jag +++ b/product/modules/distribution/src/repository/jaggeryapps/cdm/pages/dashboard.jag @@ -1,5 +1,22 @@ -<% +<% +/* + * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ var title="WSO2 CDM"; %> @@ -14,25 +31,43 @@ var title="WSO2 CDM";

Devices list

+ +
+ + + + + +
+
+
+ + + + + + + + + + + + + + +
IdentifierNameOwnerOwnershipDevice TypeVendorModelOS Version
+
+
+
sdfweroiweuroi
+
+
diff --git a/product/modules/distribution/src/repository/jaggeryapps/cdm/pages/device.jag b/product/modules/distribution/src/repository/jaggeryapps/cdm/pages/device.jag index e4930c190f..3005b915cd 100644 --- a/product/modules/distribution/src/repository/jaggeryapps/cdm/pages/device.jag +++ b/product/modules/distribution/src/repository/jaggeryapps/cdm/pages/device.jag @@ -1,5 +1,22 @@ -<% +<% +/* + * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ var title="WSO2 CDM"; %> diff --git a/product/modules/p2-profile-gen/pom.xml b/product/modules/p2-profile-gen/pom.xml index d221a04027..37962ada84 100644 --- a/product/modules/p2-profile-gen/pom.xml +++ b/product/modules/p2-profile-gen/pom.xml @@ -127,6 +127,9 @@ org.jaggeryjs.modules:uuid.feature:${uuid.feature.version} + + org.jaggeryjs.modules:sso.feature:${sso.feature.version} + org.jaggeryjs.modules:jaggery-test.feature:${jaggery-test.feature.version} @@ -281,6 +284,10 @@ org.jaggeryjs.modules.uuid.feature.group ${uuid.feature.version} + + org.jaggeryjs.modules.sso.feature.group + ${sso.feature.version} + org.jaggeryjs.modules.jaggery-test.feature.group ${jaggery-test.feature.version} From fd814c7e2455c615fd06d2b8dc38e183e9b3bd8b Mon Sep 17 00:00:00 2001 From: Geeth Munasinghe Date: Thu, 22 Jan 2015 16:41:34 +0530 Subject: [PATCH 06/12] Fixing version issues and changing cdm to mdm --- product/modules/distribution/pom.xml | 20 ++--- .../modules/distribution/src/assembly/bin.xml | 80 +++++++++---------- .../distribution/src/assembly/dist.xml | 2 +- .../src/assembly/filter.properties | 8 +- product/modules/rest-api/pom.xml | 2 - 5 files changed, 55 insertions(+), 57 deletions(-) diff --git a/product/modules/distribution/pom.xml b/product/modules/distribution/pom.xml index 45758abc60..6db365a131 100644 --- a/product/modules/distribution/pom.xml +++ b/product/modules/distribution/pom.xml @@ -29,10 +29,10 @@ 4.0.0 - wso2cdm + wso2mdm jar - 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}/docs 755 @@ -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/endorsed javax.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 @@ ../mobileservices/agents/android/jax-rs/target/cdm-android-api.war - wso2cdm-${pom.version}/repository/deployment/server/webapps + wso2mdm-${pom.version}/repository/deployment/server/webapps 755 ../rest-api/target/wso2cdm-api.war - wso2cdm-${pom.version}/repository/deployment/server/webapps + wso2mdm-${pom.version}/repository/deployment/server/webapps 755 @@ -280,7 +280,7 @@ --> src/repository/conf/tomcat/context.xml - wso2cdm-${project.version}/repository/conf/tomcat + wso2mdm-${project.version}/repository/conf/tomcat true 644 @@ -294,37 +294,37 @@ INSTALL.txt - wso2cdm-${project.version} + wso2mdm-${project.version} true 644 README.txt - wso2cdm-${project.version} + wso2mdm-${project.version} true 644 LICENSE.txt - wso2cdm-${project.version} + wso2mdm-${project.version} true 644 release-notes.html - wso2cdm-${project.version} + wso2mdm-${project.version} true 644 target/wso2carbon-core-${carbon.kernel.version}/bin/README.txt - wso2cdm-${project.version}/bin/ + wso2mdm-${project.version}/bin/ true 644 target/wso2carbon-core-${carbon.kernel.version}/bin/version.txt - wso2cdm-${project.version}/bin/ + wso2mdm-${project.version}/bin/ true 644 @@ -334,7 +334,7 @@ ../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/etc/logging-config.xml - wso2cdm-${project.version}/repository/conf/etc + wso2mdm-${project.version}/repository/conf/etc true 644 @@ -344,7 +344,7 @@ ../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/event-broker.xml - wso2cdm-${project.version}/repository/conf + wso2mdm-${project.version}/repository/conf true 644 @@ -354,7 +354,7 @@ ../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/security/application-authentication.xml - wso2cdm-${project.version}/repository/conf/security + wso2mdm-${project.version}/repository/conf/security true 644 @@ -364,14 +364,14 @@ ../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/thrift-authentication.xml - wso2cdm-${project.version}/repository/conf + wso2mdm-${project.version}/repository/conf true 644 src/repository/conf/multitenancy/cloud-services-desc.xml - wso2cdm-${project.version}/repository/conf/multitenancy/ + wso2mdm-${project.version}/repository/conf/multitenancy/ true @@ -383,19 +383,19 @@ --> src/repository/conf/application-authenticators.xml - wso2cdm-${project.version}/repository/conf/security/ + wso2mdm-${project.version}/repository/conf/security/ true 644 target/wso2carbon-core-${carbon.kernel.version}/repository/conf/README - wso2cdm-${project.version}/repository/conf/ + wso2mdm-${project.version}/repository/conf/ true 644 src/repository/conf/identity.xml - wso2cdm-${project.version}/repository/conf + wso2mdm-${project.version}/repository/conf 644 diff --git a/product/modules/distribution/src/assembly/dist.xml b/product/modules/distribution/src/assembly/dist.xml index d0a9a55a8d..beff318242 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 a0ebf6302a..19404cf6e9 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/rest-api/pom.xml b/product/modules/rest-api/pom.xml index e8671c5a0c..354dbdb2d9 100644 --- a/product/modules/rest-api/pom.xml +++ b/product/modules/rest-api/pom.xml @@ -134,13 +134,11 @@ org.wso2.carbon org.wso2.carbon.device.mgt.common - 2.0.0-SNAPSHOT provided org.wso2.carbon org.wso2.carbon.device.mgt.core - 2.0.0-SNAPSHOT provided From 2947e6fd21c4d13ba03306f349adb73c45f02021 Mon Sep 17 00:00:00 2001 From: asok Date: Thu, 22 Jan 2015 19:12:40 +0530 Subject: [PATCH 07/12] commiting windows plugin --- .../agents/windows/jax-rs/pom.xml | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/product/modules/mobileservices/agents/windows/jax-rs/pom.xml b/product/modules/mobileservices/agents/windows/jax-rs/pom.xml index 8f9ab89a7a..326e4885c1 100644 --- a/product/modules/mobileservices/agents/windows/jax-rs/pom.xml +++ b/product/modules/mobileservices/agents/windows/jax-rs/pom.xml @@ -29,9 +29,9 @@ 4.0.0 org.wso2.carbon - cdm-android-api - JAX-RS Android API - JAX-RS Android API + cdm-windows-api + JAX-RS Windows API + JAX-RS Windows API war @@ -159,6 +159,26 @@ wss4j-ws-security-common 2.0.0 + + org.bouncycastle + bcpkix-jdk15on + 1.49 + + + org.bouncycastle + bcprov-jdk15on + 1.49 + + + org.codehaus.plexus + plexus-utils + 3.0.21 + + + com.madgag.spongycastle + pkix + 1.51.0.0 + org.apache.cxf cxf-rt-ws-security From 8e3d4e11e304dcbe21068c975f350fafec08f514 Mon Sep 17 00:00:00 2001 From: prabathabey Date: Thu, 22 Jan 2015 19:20:57 +0530 Subject: [PATCH 08/12] Adding org.wso2.carbon.um.ws.service.client.feature.group feature required for API management related dependencies --- product/modules/p2-profile-gen/pom.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/product/modules/p2-profile-gen/pom.xml b/product/modules/p2-profile-gen/pom.xml index d221a04027..0ebd1840f4 100644 --- a/product/modules/p2-profile-gen/pom.xml +++ b/product/modules/p2-profile-gen/pom.xml @@ -211,6 +211,9 @@ org.wso2.carbon:org.wso2.carbon.identity.authenticator.saml2.sso.server.feature:${carbon.platform.version} + + org.wso2.carbon:org.wso2.carbon.um.ws.service.client.feature:${carbon.platform.version} + org.wso2.carbon:org.wso2.carbon.registry.core.feature:${carbon.platform.version} @@ -438,6 +441,10 @@ org.wso2.carbon.governance.lifecycle.management.feature.group ${carbon.platform.version} + + org.wso2.carbon.um.ws.service.client.feature.group + ${carbon.platform.version} + From 9f71408001b9aa99e54443ebef1360c63df3caf2 Mon Sep 17 00:00:00 2001 From: Dulitha Wijewantha Date: Thu, 22 Jan 2015 21:20:08 +0530 Subject: [PATCH 09/12] * Fixed the JNDI bug * Added a device module method and apis for a single device * UI improvement to the device page --- .../datasource/MobileDataSourceConfig.java | 6 +- .../dao/MobileDeviceManagementDAOFactory.java | 2 +- .../util/MobileDeviceManagementDAOUtil.java | 2 +- .../jaggeryapps/cdm/api/mobile/device-api.jag | 37 ++++----- .../jaggeryapps/cdm/client/javascript/main.js | 26 ++++++- .../jaggeryapps/cdm/modules/device.js | 75 +++++++++++++++++++ .../jaggeryapps/cdm/pages/device.jag | 75 ++++++++++++------- 7 files changed, 166 insertions(+), 57 deletions(-) create mode 100644 product/modules/distribution/src/repository/jaggeryapps/cdm/modules/device.js diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/datasource/MobileDataSourceConfig.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/datasource/MobileDataSourceConfig.java index 2b9c570c9f..5245b01717 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/datasource/MobileDataSourceConfig.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/datasource/MobileDataSourceConfig.java @@ -22,13 +22,11 @@ import javax.xml.bind.annotation.XmlRootElement; /** * Class for holding data source configuration in mobile-config.xml at parsing with JAXB. */ -@XmlRootElement(name = "DataSourceConfiguration") -public class MobileDataSourceConfig { +@XmlRootElement(name = "DataSourceConfiguration") public class MobileDataSourceConfig { private JNDILookupDefinition jndiLookupDefinition; - @XmlElement(name = "JndiLookupDefinition", nillable = true) - public JNDILookupDefinition getJndiLookupDefintion() { + @XmlElement(name = "JndiLookupDefinition", nillable = true) public JNDILookupDefinition getJndiLookupDefinition() { return jndiLookupDefinition; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceManagementDAOFactory.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceManagementDAOFactory.java index 8415271d2f..c014f9d6b9 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceManagementDAOFactory.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceManagementDAOFactory.java @@ -62,7 +62,7 @@ public class MobileDeviceManagementDAOFactory { throw new RuntimeException("Device Management Repository data source configuration " + "is null and thus, is not initialized"); } - JNDILookupDefinition jndiConfig = config.getJndiLookupDefintion(); + JNDILookupDefinition jndiConfig = config.getJndiLookupDefinition(); if (jndiConfig != null) { if (log.isDebugEnabled()) { log.debug("Initializing Device Management Repository data source using the JNDI " + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/util/MobileDeviceManagementDAOUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/util/MobileDeviceManagementDAOUtil.java index 146a33bcbf..1aec46825d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/util/MobileDeviceManagementDAOUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/util/MobileDeviceManagementDAOUtil.java @@ -51,7 +51,7 @@ public class MobileDeviceManagementDAOUtil { throw new RuntimeException("Device Management Repository data source configuration " + "is null and thus, is not initialized"); } - JNDILookupDefinition jndiConfig = config.getJndiLookupDefintion(); + JNDILookupDefinition jndiConfig = config.getJndiLookupDefinition(); if (jndiConfig != null) { if (log.isDebugEnabled()) { log.debug("Initializing Device Management Repository data source using the JNDI " + diff --git a/product/modules/distribution/src/repository/jaggeryapps/cdm/api/mobile/device-api.jag b/product/modules/distribution/src/repository/jaggeryapps/cdm/api/mobile/device-api.jag index 10f37dc405..783176d285 100644 --- a/product/modules/distribution/src/repository/jaggeryapps/cdm/api/mobile/device-api.jag +++ b/product/modules/distribution/src/repository/jaggeryapps/cdm/api/mobile/device-api.jag @@ -16,23 +16,24 @@ * specific language governing permissions and limitations * under the License. */ -var utility = require("/modules/utility.js"); -var deviceManagementService = utility.getDeviceManagementService(); -var devices = deviceManagementService.getAllDevices("android"); -var logger = new Log(); -var deviceList = []; -for (i = 0; i < devices.size(); i++) { - var device = devices.get(i); - deviceList.push({ - "identifier": device.getDeviceIdentifier(), - "name": device.getName(), - "ownership": device.getOwnership(), - "owner": device.getOwner(), - "deviceType": device.getType(), - "vendor": device.getProperties().get("vendor"), - "model": device.getProperties().get("model"), - "osVersion": device.getProperties().get("osVersion") - }); + +var verb = request.getMethod(); +var uri = request.getRequestURI(); +var callPath=uri.replace("/cdm/api/",""); +var log = new Log(); +var deviceModule = require("/modules/device.js"); +if (uri != null) { + var uriMatcher = new URIMatcher(callPath); + log.info(callPath); + if (uriMatcher.match("devices/mobile/{type}/{deviceid}/")) { + var deviceId = uriMatcher.elements().deviceid; + var type = uriMatcher.elements().type; + var result = deviceModule.viewDevice(type, deviceId); + print(result); + } + if (uriMatcher.match("devices/mobile/")) { + var result = deviceModule.listDevices(); + print(result); + } } -print(deviceList); %> \ No newline at end of file diff --git a/product/modules/distribution/src/repository/jaggeryapps/cdm/client/javascript/main.js b/product/modules/distribution/src/repository/jaggeryapps/cdm/client/javascript/main.js index 7c3d5d9791..0fa9dd49d8 100644 --- a/product/modules/distribution/src/repository/jaggeryapps/cdm/client/javascript/main.js +++ b/product/modules/distribution/src/repository/jaggeryapps/cdm/client/javascript/main.js @@ -1,6 +1,24 @@ +/* + * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ function identifierFormatter(value, row, index) { return [ - '' - ].join('');} \ No newline at end of file + '' + ].join(''); +} \ No newline at end of file diff --git a/product/modules/distribution/src/repository/jaggeryapps/cdm/modules/device.js b/product/modules/distribution/src/repository/jaggeryapps/cdm/modules/device.js new file mode 100644 index 0000000000..c208c91a4b --- /dev/null +++ b/product/modules/distribution/src/repository/jaggeryapps/cdm/modules/device.js @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +var utility = require("/modules/utility.js"); +var DeviceIdentifier = Packages.org.wso2.carbon.device.mgt.common.DeviceIdentifier; +var log = new Log(); + +var deviceManagementService = utility.getDeviceManagementService(); + +var listDevices = function () { + var devices = deviceManagementService.getAllDevices("android"); + var deviceList = []; + + for (i = 0; i < devices.size(); i++) { + var device = devices.get(i); + deviceList.push({ + "identifier": device.getDeviceIdentifier(), + "name": device.getName(), + "ownership": device.getOwnership(), + "owner": device.getOwner(), + "deviceType": device.getType(), + "vendor": device.getProperties().get("vendor"), + "model": device.getProperties().get("model"), + "osVersion": device.getProperties().get("osVersion") + }); + } + return deviceList; +} +var getDevice = function(type, deviceId){ + var deviceIdentifier = new DeviceIdentifier(); + deviceIdentifier.setType(type); + deviceIdentifier.setId(deviceId); + var device = deviceManagementService.getDevice(deviceIdentifier); + return device; +} + +var viewDevice = function(type, deviceId){ + var device = this.getDevice(type, deviceId); + + var entries = device.getProperties().entrySet(); + var iterator = entries.iterator(); + var properties = {}; + while(iterator.hasNext()){ + var entry = iterator.next(); + var key = entry.getKey(); + var value = entry.getValue(); + properties[key]= value; + } + return { + "identifier": device.getDeviceIdentifier(), + "name": device.getName(), + "ownership": device.getOwnership(), + "owner": device.getOwner(), + "deviceType": device.getType(), + "vendor": device.getProperties().get("vendor"), + "model": device.getProperties().get("model"), + "osVersion": device.getProperties().get("osVersion"), + "properties": properties + }; +} \ No newline at end of file diff --git a/product/modules/distribution/src/repository/jaggeryapps/cdm/pages/device.jag b/product/modules/distribution/src/repository/jaggeryapps/cdm/pages/device.jag index 3005b915cd..91977bdade 100644 --- a/product/modules/distribution/src/repository/jaggeryapps/cdm/pages/device.jag +++ b/product/modules/distribution/src/repository/jaggeryapps/cdm/pages/device.jag @@ -26,11 +26,20 @@ var title="WSO2 CDM"; <% include("/includes/header.jag"); + + var deviceModule = require("/modules/device.js"); + var uri = request.getRequestURI(); + var callPath=uri.replace("/cdm/",""); + var uriMatcher = new URIMatcher(callPath); + uriMatcher.match("devices/{type}/{deviceid}/"); + var deviceId = uriMatcher.elements().deviceid; + var type = uriMatcher.elements().type; + var device = deviceModule.viewDevice(type, deviceId); %>
-

Dulitha's iPhone

+

<%=device.name%>

@@ -50,36 +59,44 @@ var title="WSO2 CDM";
-

Model: GT-I9500

-

IMSI : GT-I9500

-

IMEI : GT-I9500

-
-
-
-
-

Model: GT-I9500

-

IMSI : GT-I9500

-

IMEI : GT-I9500

-
-
-
-
- - - - - - - -
App namePackage name
-
-
-
-
-
+ + <% + for (var property in device.properties) { + if (device.properties.hasOwnProperty(property)) { + var value = device.properties[property]; + %> +

<%=property %>: <%=value %>

+ <% + } + } + %> +
+
+
+
+

Model: GT-I9500

+

IMSI : GT-I9500

+

IMEI : GT-I9500

+
+
+
+
+ + + + + + + +
App namePackage name
+
+
+ - <% + + +<% include("/includes/layout-footer.jag"); %> From 7fc424425904384d59f96d26bc31be6d88e6a554 Mon Sep 17 00:00:00 2001 From: prabathabey Date: Thu, 22 Jan 2015 21:59:36 +0530 Subject: [PATCH 10/12] Fixing issues in package-info.java --- .../java/cdm/api/windows/wstep/beans/package-info.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 index 453eefdd21..5e744bb255 100644 --- 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 @@ -17,11 +17,11 @@ */ @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) + xmlns = { + @XmlNs(prefix = "", namespaceURI = "http://www.w3.org/2003/05/soap-envelope") + }, elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) -package com.ex.wstep; +package cdm.api.windows.wstep.beans; import javax.xml.bind.annotation.XmlNs; import javax.xml.bind.annotation.XmlSchema; \ No newline at end of file From 163fe58120b724d31f588871802ba4e29a101657 Mon Sep 17 00:00:00 2001 From: harshanL Date: Thu, 22 Jan 2015 22:04:51 +0530 Subject: [PATCH 11/12] Added new changes in operation management --- .../datasource/MobileDataSourceConfig.java | 2 +- .../dao/MobileDeviceManagementDAOFactory.java | 14 +- .../mobile/dao/MobileDeviceOperationDAO.java | 79 ----- .../dao/MobileDeviceOperationMappingDAO.java | 110 ++++++ ...{FeatureDAO.java => MobileFeatureDAO.java} | 20 +- ...DAO.java => MobileFeaturePropertyDAO.java} | 18 +- .../mgt/mobile/dao/MobileOperationDAO.java | 2 +- .../dao/MobileOperationPropertyDAO.java | 2 +- .../impl/MobileDeviceOperationDAOImpl.java | 218 ------------ .../MobileDeviceOperationMappingDAOImpl.java | 331 ++++++++++++++++++ ...DAOImpl.java => MobileFeatureDAOImpl.java} | 86 ++--- ...java => MobileFeaturePropertyDAOImpl.java} | 54 +-- .../util/MobileDeviceManagementDAOUtil.java | 55 --- ...java => MobileDeviceOperationMapping.java} | 27 +- .../dto/{Feature.java => MobileFeature.java} | 4 +- ...operty.java => MobileFeatureProperty.java} | 4 +- .../AndroidMobileOperationManager.java | 68 +++- .../util/MobileDeviceManagementUtil.java | 8 +- .../MobileDeviceManagementConfigTests.java | 119 +++++++ .../device/mgt/mobile/impl/TestUtils.java | 54 +++ .../mgt/mobile/impl/common/DBTypes.java | 0 .../impl/common/TestDBConfiguration.java | 0 .../impl/common/TestDBConfigurations.java | 0 .../mobile/impl/dao/FeatureDAOTestSuite.java | 139 ++++++++ .../impl/dao/FeaturePropertyDAOTestSuite.java | 20 ++ .../impl/dao/MobileDeviceDAOTestSuite.java | 20 ++ .../MobileDeviceOperationDAOTestSuite.java | 20 ++ .../impl/dao/MobileOperationDAOTestSuite.java | 20 ++ .../MobileOperationPropertyDAOTestSuite.java | 20 ++ .../mobile/impl/dao/FeatureDAOTestSuite.java | 141 -------- .../malformed-mobile-config-no-api-config.xml | 40 +++ ...-mobile-config-no-api-publisher-config.xml | 40 +++ ...malformed-mobile-config-no-apis-config.xml | 40 +++ .../malformed-mobile-config-no-ds-config.xml | 40 +++ ...malformed-mobile-config-no-jndi.config.xml | 40 +++ .../malformed-mobile-config-no-mgt-repo.xml | 40 +++ .../MobileDeviceManagementConfigSchema.xsd | 67 ++++ .../src/test/resources/sql/CreateH2TestDB.sql | 104 ++++-- .../src/test/resources/testdbconfig.xml | 2 +- .../src/test/resources/testng.xml | 3 +- .../modules/distribution/src/assembly/bin.xml | 10 + .../repository/database/WSO2MobileDM_DB.h2.db | Bin 0 -> 45056 bytes .../src/repository/dbscripts/cdm/h2.sql | 2 +- .../repository/dbscripts/cdm/plugins/h2.sql | 14 +- .../dbscripts/cdm/plugins/mysql.sql | 1 + .../mobileservices/android/Enrollment.java | 217 ++++++------ .../mobileservices/android/Operation.java | 4 +- .../api/windows/wstep/beans/package-info.java | 27 -- 48 files changed, 1561 insertions(+), 785 deletions(-) delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceOperationDAO.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceOperationMappingDAO.java rename components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/{FeatureDAO.java => MobileFeatureDAO.java} (77%) rename components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/{FeaturePropertyDAO.java => MobileFeaturePropertyDAO.java} (77%) delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileDeviceOperationDAOImpl.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileDeviceOperationMappingDAOImpl.java rename components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/{FeatureDAOImpl.java => MobileFeatureDAOImpl.java} (74%) rename components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/{FeaturePropertyDAOImpl.java => MobileFeaturePropertyDAOImpl.java} (75%) rename components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/{MobileDeviceOperation.java => MobileDeviceOperationMapping.java} (70%) rename components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/{Feature.java => MobileFeature.java} (94%) rename components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/{FeatureProperty.java => MobileFeatureProperty.java} (89%) create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/MobileDeviceManagementConfigTests.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/TestUtils.java rename components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/{ => java}/org/wso2/carbon/device/mgt/mobile/impl/common/DBTypes.java (100%) rename components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/{ => java}/org/wso2/carbon/device/mgt/mobile/impl/common/TestDBConfiguration.java (100%) rename components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/{ => java}/org/wso2/carbon/device/mgt/mobile/impl/common/TestDBConfigurations.java (100%) create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/FeatureDAOTestSuite.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/FeaturePropertyDAOTestSuite.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceDAOTestSuite.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceOperationDAOTestSuite.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileOperationDAOTestSuite.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileOperationPropertyDAOTestSuite.java delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/org/wso2/carbon/device/mgt/mobile/impl/dao/FeatureDAOTestSuite.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/config/malformed-mobile-config-no-api-config.xml create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/config/malformed-mobile-config-no-api-publisher-config.xml create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/config/malformed-mobile-config-no-apis-config.xml create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/config/malformed-mobile-config-no-ds-config.xml create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/config/malformed-mobile-config-no-jndi.config.xml create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/config/malformed-mobile-config-no-mgt-repo.xml create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/config/schema/MobileDeviceManagementConfigSchema.xsd create mode 100644 product/modules/distribution/src/repository/database/WSO2MobileDM_DB.h2.db delete mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/beans/package-info.java diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/datasource/MobileDataSourceConfig.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/datasource/MobileDataSourceConfig.java index 2b9c570c9f..16c9ac7030 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/datasource/MobileDataSourceConfig.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/datasource/MobileDataSourceConfig.java @@ -28,7 +28,7 @@ public class MobileDataSourceConfig { private JNDILookupDefinition jndiLookupDefinition; @XmlElement(name = "JndiLookupDefinition", nillable = true) - public JNDILookupDefinition getJndiLookupDefintion() { + public JNDILookupDefinition getJndiLookupDefinition() { return jndiLookupDefinition; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceManagementDAOFactory.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceManagementDAOFactory.java index 8415271d2f..831a14452d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceManagementDAOFactory.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceManagementDAOFactory.java @@ -62,7 +62,7 @@ public class MobileDeviceManagementDAOFactory { throw new RuntimeException("Device Management Repository data source configuration " + "is null and thus, is not initialized"); } - JNDILookupDefinition jndiConfig = config.getJndiLookupDefintion(); + JNDILookupDefinition jndiConfig = config.getJndiLookupDefinition(); if (jndiConfig != null) { if (log.isDebugEnabled()) { log.debug("Initializing Device Management Repository data source using the JNDI " + @@ -98,16 +98,16 @@ public class MobileDeviceManagementDAOFactory { return new MobileOperationPropertyDAOImpl(dataSource); } - public static MobileDeviceOperationDAO getMobileDeviceOperationDAO() { - return new MobileDeviceOperationDAOImpl(dataSource); + public static MobileDeviceOperationMappingDAO getMobileDeviceOperationDAO() { + return new MobileDeviceOperationMappingDAOImpl(dataSource); } - public static FeatureDAO getFeatureDAO() { - return new FeatureDAOImpl(dataSource); + public static MobileFeatureDAO getFeatureDAO() { + return new MobileFeatureDAOImpl(dataSource); } - public static FeaturePropertyDAO getFeaturePropertyDAO() { - return new FeaturePropertyDAOImpl(dataSource); + public static MobileFeaturePropertyDAO getFeaturePropertyDAO() { + return new MobileFeaturePropertyDAOImpl(dataSource); } public static MobileDataSourceConfig getMobileDeviceManagementConfig() { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceOperationDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceOperationDAO.java deleted file mode 100644 index ad2710e2f6..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceOperationDAO.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2015, 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 org.wso2.carbon.device.mgt.mobile.dao; - -import org.wso2.carbon.device.mgt.mobile.dto.MobileDeviceOperation; - -import java.util.List; - -/** - * This class represents the mapping between device and operations. - */ -public interface MobileDeviceOperationDAO { - /** - * Add a new mapping to plugin device_operation table. - * - * @param deviceOperation DeviceOperation object that holds data related to the DeviceOperation - * to be inserted. - * @return The status of the operation. If the insert was successful or not. - * @throws MobileDeviceManagementDAOException - */ - boolean addMobileDeviceOperation(MobileDeviceOperation deviceOperation) - throws MobileDeviceManagementDAOException; - - /** - * Update a feature in the feature table. - * - * @param deviceOperation DeviceOperation object that holds data has to be updated. - * @return The status of the operation. If the update was successful or not. - * @throws MobileDeviceManagementDAOException - */ - boolean updateMobileDeviceOperation(MobileDeviceOperation deviceOperation) - throws MobileDeviceManagementDAOException; - - /** - * Delete a given device operation from device operation table. - * - * @param deviceId Device id of the mapping to be deleted. - * @param operationId Operation id of the mapping to be deleted. - * @return The status of the operation. If the deletion was successful or not. - * @throws MobileDeviceManagementDAOException - */ - boolean deleteMobileDeviceOperation(String deviceId, int operationId) - throws MobileDeviceManagementDAOException; - - /** - * Retrieve a given device operation from plugin database. - * - * @param deviceId Device id of the mapping to be retrieved. - * @param operationId Operation id of the mapping to be retrieved. - * @return DeviceOperation object that holds data of the device operation mapping represented by - * deviceId and operationId. - * @throws MobileDeviceManagementDAOException - */ - MobileDeviceOperation getMobileDeviceOperation(String deviceId, int operationId) - throws MobileDeviceManagementDAOException; - - /** - * Retrieve all the device operation mapping from plugin database. - * - * @return Device operation mapping object list. - * @throws MobileDeviceManagementDAOException - */ - List getAllMobileDeviceOperationsOfDevice(String deviceId) - throws MobileDeviceManagementDAOException; -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceOperationMappingDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceOperationMappingDAO.java new file mode 100644 index 0000000000..4f8c798026 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceOperationMappingDAO.java @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2015, 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 org.wso2.carbon.device.mgt.mobile.dao; + +import org.wso2.carbon.device.mgt.mobile.dto.MobileDeviceOperationMapping; + +import java.util.List; + +/** + * This class represents the mapping between mobile device and operations. + */ +public interface MobileDeviceOperationMappingDAO { + /** + * Add a new mobile device operation mapping to the table. + * + * @param deviceOperation MobileDeviceOperation object that holds data related to the MobileDeviceOperation + * to be inserted. + * @return The status of the operation. If the insert was successful or not. + * @throws MobileDeviceManagementDAOException + */ + boolean addMobileDeviceOperation(MobileDeviceOperationMapping deviceOperation) + throws MobileDeviceManagementDAOException; + + /** + * Updates a mobile device operation mapping. + * + * @param deviceOperation MobileDeviceOperation object that holds data has to be updated. + * @return The status of the operation. If the update was successful or not. + * @throws MobileDeviceManagementDAOException + */ + boolean updateMobileDeviceOperation(MobileDeviceOperationMapping deviceOperation) + throws MobileDeviceManagementDAOException; + + /** + * Updates a mobile device operation mapping to In-Progress state. + * + * @param deviceId Device id of the mapping to be deleted. + * @param operationId Operation id of the mapping to be deleted. + * @return The status of the operation. If the update was successful or not. + * @throws MobileDeviceManagementDAOException + */ + boolean updateMobileDeviceOperationToInProgress(String deviceId, int operationId) + throws MobileDeviceManagementDAOException; + + /** + * Updates a mobile device operation mapping to completed state. + * + * @param deviceId Device id of the mapping to be deleted. + * @param operationId Operation id of the mapping to be deleted. + * @return The status of the operation. If the update was successful or not. + * @throws MobileDeviceManagementDAOException + */ + boolean updateMobileDeviceOperationToCompleted(String deviceId, int operationId) + throws MobileDeviceManagementDAOException; + + /** + * Delete a given mobile device operation mapping from table. + * + * @param deviceId Device id of the mapping to be deleted. + * @param operationId Operation id of the mapping to be deleted. + * @return The status of the operation. If the deletion was successful or not. + * @throws MobileDeviceManagementDAOException + */ + boolean deleteMobileDeviceOperation(String deviceId, int operationId) + throws MobileDeviceManagementDAOException; + + /** + * Retrieves a given mobile device operation from the plugin database. + * + * @param deviceId Device id of the mapping to be retrieved. + * @param operationId Operation id of the mapping to be retrieved. + * @return MobileDeviceOperation object that holds data of the device operation mapping represented by + * deviceId and operationId. + * @throws MobileDeviceManagementDAOException + */ + MobileDeviceOperationMapping getMobileDeviceOperation(String deviceId, int operationId) + throws MobileDeviceManagementDAOException; + + /** + * Retrieves all the of mobile device operation mappings relavent to the given mobile device. + * + * @return Device operation mapping object list. + * @throws MobileDeviceManagementDAOException + */ + List getAllMobileDeviceOperationsOfDevice(String deviceId) + throws MobileDeviceManagementDAOException; + + /** + * Retrieves all the pending device operation mappings of a mobiel device. + * + * @return Device operation mapping object list. + * @throws MobileDeviceManagementDAOException + */ + List getAllPendingOperationsOfMobileDevice(String deviceId) + throws MobileDeviceManagementDAOException; +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/FeatureDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileFeatureDAO.java similarity index 77% rename from components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/FeatureDAO.java rename to components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileFeatureDAO.java index 0997dd0321..8b516443ac 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/FeatureDAO.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileFeatureDAO.java @@ -16,33 +16,33 @@ package org.wso2.carbon.device.mgt.mobile.dao; -import org.wso2.carbon.device.mgt.mobile.dto.Feature; +import org.wso2.carbon.device.mgt.mobile.dto.MobileFeature; import java.util.List; /** - * This class represents the key operations associated with persisting feature related + * This class represents the key operations associated with persisting mobile feature related * information. */ -public interface FeatureDAO { +public interface MobileFeatureDAO { /** * Add a new feature to feature table. * - * @param feature Feature object that holds data related to the feature to be inserted. + * @param mobileFeature Feature object that holds data related to the feature to be inserted. * @return The status of the operation. If the insert was successful or not. * @throws MobileDeviceManagementDAOException */ - boolean addFeature(Feature feature) throws MobileDeviceManagementDAOException; + boolean addFeature(MobileFeature mobileFeature) throws MobileDeviceManagementDAOException; /** * Update a feature in the feature table. * - * @param feature Feature object that holds data has to be updated. + * @param mobileFeature Feature object that holds data has to be updated. * @return The status of the operation. If the update was successful or not. * @throws MobileDeviceManagementDAOException */ - boolean updateFeature(Feature feature) throws MobileDeviceManagementDAOException; + boolean updateFeature(MobileFeature mobileFeature) throws MobileDeviceManagementDAOException; /** * Delete a feature from feature table when the feature id is given. @@ -69,7 +69,7 @@ public interface FeatureDAO { * @return Feature object that holds data of the feature represented by featureId. * @throws MobileDeviceManagementDAOException */ - Feature getFeatureById(String featureId) throws MobileDeviceManagementDAOException; + MobileFeature getFeatureById(String featureId) throws MobileDeviceManagementDAOException; /** * Retrieve a given feature from feature table when the feature code is given. @@ -78,7 +78,7 @@ public interface FeatureDAO { * @return Feature object that holds data of the feature represented by featureCode. * @throws MobileDeviceManagementDAOException */ - Feature getFeatureByCode(String featureCode) throws MobileDeviceManagementDAOException; + MobileFeature getFeatureByCode(String featureCode) throws MobileDeviceManagementDAOException; /** * Retrieve all the features from plugin specific database. @@ -86,5 +86,5 @@ public interface FeatureDAO { * @return Feature object list. * @throws MobileDeviceManagementDAOException */ - List getAllFeatures() throws MobileDeviceManagementDAOException; + List getAllFeatures() throws MobileDeviceManagementDAOException; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/FeaturePropertyDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileFeaturePropertyDAO.java similarity index 77% rename from components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/FeaturePropertyDAO.java rename to components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileFeaturePropertyDAO.java index adf014dc7d..a61a598a97 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/FeaturePropertyDAO.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileFeaturePropertyDAO.java @@ -16,33 +16,33 @@ package org.wso2.carbon.device.mgt.mobile.dao; -import org.wso2.carbon.device.mgt.mobile.dto.FeatureProperty; +import org.wso2.carbon.device.mgt.mobile.dto.MobileFeatureProperty; import java.util.List; /** - * This class represents the key operations associated with persisting feature property related + * This class represents the key operations associated with persisting mobile feature property related * information. */ -public interface FeaturePropertyDAO { +public interface MobileFeaturePropertyDAO { /** * Add a new feature property to feature property table. * - * @param featureProperty Feature property object that holds data related to the feature property to be inserted. + * @param mobileFeatureProperty Feature property object that holds data related to the feature property to be inserted. * @return The status of the operation. If the insert was successful or not. * @throws MobileDeviceManagementDAOException */ - boolean addFeatureProperty(FeatureProperty featureProperty) + boolean addFeatureProperty(MobileFeatureProperty mobileFeatureProperty) throws MobileDeviceManagementDAOException; /** * Update a feature property in the feature property table. * - * @param featureProperty Feature property object that holds data has to be updated. + * @param mobileFeatureProperty Feature property object that holds data has to be updated. * @return The status of the operation. If the update was successful or not. * @throws MobileDeviceManagementDAOException */ - boolean updateFeatureProperty(FeatureProperty featureProperty) + boolean updateFeatureProperty(MobileFeatureProperty mobileFeatureProperty) throws MobileDeviceManagementDAOException; /** @@ -61,7 +61,7 @@ public interface FeaturePropertyDAO { * @return Feature property object that holds data of the feature property represented by propertyId. * @throws MobileDeviceManagementDAOException */ - FeatureProperty getFeatureProperty(String property) throws MobileDeviceManagementDAOException; + MobileFeatureProperty getFeatureProperty(String property) throws MobileDeviceManagementDAOException; /** * Retrieve a list of feature property corresponds to a feature id . @@ -70,7 +70,7 @@ public interface FeaturePropertyDAO { * @return Feature property object that holds data of the feature property represented by propertyId. * @throws MobileDeviceManagementDAOException */ - List getFeaturePropertyOfFeature(String featureId) + List getFeaturePropertyOfFeature(String featureId) throws MobileDeviceManagementDAOException; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileOperationDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileOperationDAO.java index bdd69c7edf..d43ec82fea 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileOperationDAO.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileOperationDAO.java @@ -19,7 +19,7 @@ package org.wso2.carbon.device.mgt.mobile.dao; import org.wso2.carbon.device.mgt.mobile.dto.MobileOperation; /** - * This class represents the key operations associated with persisting operation related + * This class represents the key operations associated with persisting mobile operation related * information. */ public interface MobileOperationDAO { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileOperationPropertyDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileOperationPropertyDAO.java index 4d8ef7eebb..3bb7c64611 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileOperationPropertyDAO.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileOperationPropertyDAO.java @@ -21,7 +21,7 @@ import org.wso2.carbon.device.mgt.mobile.dto.MobileOperationProperty; import java.util.List; /** - * This class represents the key operations associated with persisting operation property related + * This class represents the key operations associated with persisting mobile operation property related * information. */ public interface MobileOperationPropertyDAO { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileDeviceOperationDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileDeviceOperationDAOImpl.java deleted file mode 100644 index f15af1ac53..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileDeviceOperationDAOImpl.java +++ /dev/null @@ -1,218 +0,0 @@ -/* - * Copyright (c) 2015, 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 org.wso2.carbon.device.mgt.mobile.dao.impl; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceOperationDAO; -import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException; -import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil; -import org.wso2.carbon.device.mgt.mobile.dto.MobileDeviceOperation; - -import javax.sql.DataSource; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; - -/** - * Implementation of MobileDeviceOperationDAO. - */ -public class MobileDeviceOperationDAOImpl implements MobileDeviceOperationDAO { - - private DataSource dataSource; - private static final Log log = LogFactory.getLog(MobileDeviceOperationDAOImpl.class); - - public MobileDeviceOperationDAOImpl(DataSource dataSource) { - this.dataSource = dataSource; - } - - @Override - public boolean addMobileDeviceOperation(MobileDeviceOperation deviceOperation) - throws MobileDeviceManagementDAOException { - boolean status = false; - Connection conn = null; - PreparedStatement stmt = null; - try { - conn = this.getConnection(); - String createDBQuery = - "INSERT INTO MBL_DEVICE_OPERATION_MAPPING (DEVICE_ID, OPERATION_ID, SENT_DATE, RECEIVED_DATE) VALUES (?, ?, ?, ?)"; - - stmt = conn.prepareStatement(createDBQuery); - stmt.setString(1, deviceOperation.getDeviceId()); - stmt.setLong(2, deviceOperation.getOperationId()); - stmt.setLong(3, deviceOperation.getSentDate()); - stmt.setLong(4, deviceOperation.getReceivedDate()); - int rows = stmt.executeUpdate(); - if (rows > 0) { - status = true; - } - } catch (SQLException e) { - String msg = "Error occurred while adding device id - '" + - deviceOperation.getDeviceId() + " and operation id - " + - deviceOperation.getOperationId() + - " to mapping table MBL_DEVICE_OPERATION"; - ; - log.error(msg, e); - throw new MobileDeviceManagementDAOException(msg, e); - } finally { - MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null); - } - return status; - } - - @Override - public boolean updateMobileDeviceOperation(MobileDeviceOperation deviceOperation) - throws MobileDeviceManagementDAOException { - boolean status = false; - Connection conn = null; - PreparedStatement stmt = null; - try { - conn = this.getConnection(); - String updateDBQuery = - "UPDATE MBL_DEVICE_OPERATION_MAPPING SET SENT_DATE = ?, RECEIVED_DATE = ? WHERE DEVICE_ID = ? AND OPERATION_ID=?"; - stmt = conn.prepareStatement(updateDBQuery); - stmt.setLong(1, deviceOperation.getSentDate()); - stmt.setLong(2, deviceOperation.getReceivedDate()); - stmt.setString(3, deviceOperation.getDeviceId()); - stmt.setInt(4, deviceOperation.getOperationId()); - int rows = stmt.executeUpdate(); - if (rows > 0) { - status = true; - } - } catch (SQLException e) { - String msg = "Error occurred while updating device id - '" + - deviceOperation.getDeviceId() + " and operation id - " + - deviceOperation.getOperationId() + " in table MBL_DEVICE_OPERATION"; - log.error(msg, e); - throw new MobileDeviceManagementDAOException(msg, e); - } finally { - MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null); - } - return status; - } - - @Override - public boolean deleteMobileDeviceOperation(String deviceId, int operationId) - throws MobileDeviceManagementDAOException { - boolean status = false; - Connection conn = null; - PreparedStatement stmt = null; - try { - conn = this.getConnection(); - String deleteDBQuery = - "DELETE FROM MBL_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ? AND OPERATION_ID=?"; - stmt = conn.prepareStatement(deleteDBQuery); - stmt.setString(1, deviceId); - stmt.setInt(2, operationId); - int rows = stmt.executeUpdate(); - if (rows > 0) { - status = true; - } - } catch (SQLException e) { - String msg = - "Error occurred while deleting the table entry MBL_DEVICE_OPERATION with device id - '" + - deviceId + " and operation id - " + operationId; - log.error(msg, e); - throw new MobileDeviceManagementDAOException(msg, e); - } finally { - MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null); - } - return status; - } - - @Override - public MobileDeviceOperation getMobileDeviceOperation(String deviceId, int operationId) - throws MobileDeviceManagementDAOException { - Connection conn = null; - PreparedStatement stmt = null; - MobileDeviceOperation deviceOperation = null; - try { - conn = this.getConnection(); - String selectDBQuery = - "SELECT DEVICE_ID, OPERATION_ID, SENT_DATE, RECEIVED_DATE FROM MBL_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ? AND OPERATION_ID=?"; - stmt = conn.prepareStatement(selectDBQuery); - stmt.setString(1, deviceId); - stmt.setInt(2, operationId); - ResultSet resultSet = stmt.executeQuery(); - while (resultSet.next()) { - deviceOperation = new MobileDeviceOperation(); - deviceOperation.setDeviceId(resultSet.getString(1)); - deviceOperation.setOperationId(resultSet.getInt(2)); - deviceOperation.setSentDate(resultSet.getInt(3)); - deviceOperation.setReceivedDate(resultSet.getInt(4)); - break; - } - } catch (SQLException e) { - String msg = - "Error occurred while fetching table MBL_DEVICE_OPERATION entry with device id - '" + - deviceId + " and operation id - " + operationId; - log.error(msg, e); - throw new MobileDeviceManagementDAOException(msg, e); - } finally { - MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null); - } - return deviceOperation; - } - - @Override - public List getAllMobileDeviceOperationsOfDevice(String deviceId) - throws MobileDeviceManagementDAOException { - Connection conn = null; - PreparedStatement stmt = null; - MobileDeviceOperation deviceOperation = null; - List deviceOperations = new ArrayList(); - try { - conn = this.getConnection(); - String selectDBQuery = - "SELECT DEVICE_ID, OPERATION_ID, SENT_DATE, RECEIVED_DATE FROM MBL_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ?"; - stmt = conn.prepareStatement(selectDBQuery); - stmt.setString(1, deviceId); - ResultSet resultSet = stmt.executeQuery(); - while (resultSet.next()) { - deviceOperation = new MobileDeviceOperation(); - deviceOperation.setDeviceId(resultSet.getString(1)); - deviceOperation.setOperationId(resultSet.getInt(2)); - deviceOperation.setSentDate(resultSet.getInt(3)); - deviceOperation.setReceivedDate(resultSet.getInt(4)); - deviceOperations.add(deviceOperation); - } - } catch (SQLException e) { - String msg = - "Error occurred while fetching mapping table MBL_DEVICE_OPERATION entries of device id - '" + - deviceId; - log.error(msg, e); - throw new MobileDeviceManagementDAOException(msg, e); - } finally { - MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null); - } - return deviceOperations; - } - - private Connection getConnection() throws MobileDeviceManagementDAOException { - try { - return dataSource.getConnection(); - } catch (SQLException e) { - String msg = "Error occurred while obtaining a connection from the mobile device " + - "management metadata repository datasource."; - log.error(msg, e); - throw new MobileDeviceManagementDAOException(msg, e); - } - } -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileDeviceOperationMappingDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileDeviceOperationMappingDAOImpl.java new file mode 100644 index 0000000000..387b09d17a --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileDeviceOperationMappingDAOImpl.java @@ -0,0 +1,331 @@ +/* + * Copyright (c) 2015, 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 org.wso2.carbon.device.mgt.mobile.dao.impl; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceOperationMappingDAO; +import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException; +import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil; +import org.wso2.carbon.device.mgt.mobile.dto.MobileDeviceOperationMapping; + +import javax.sql.DataSource; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +/** + * Implementation of MobileDeviceOperationMappingDAO. + */ +public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperationMappingDAO { + + private DataSource dataSource; + private static final Log log = LogFactory.getLog(MobileDeviceOperationMappingDAOImpl.class); + + public MobileDeviceOperationMappingDAOImpl(DataSource dataSource) { + this.dataSource = dataSource; + } + + @Override + public boolean addMobileDeviceOperation(MobileDeviceOperationMapping deviceOperation) + throws MobileDeviceManagementDAOException { + boolean status = false; + Connection conn = null; + PreparedStatement stmt = null; + try { + conn = this.getConnection(); + String createDBQuery = + "INSERT INTO MBL_DEVICE_OPERATION_MAPPING (DEVICE_ID, OPERATION_ID, SENT_DATE, " + + "RECEIVED_DATE, STATUS) VALUES (?, ?, ?, ?, ?)"; + + stmt = conn.prepareStatement(createDBQuery); + stmt.setString(1, deviceOperation.getDeviceId()); + stmt.setLong(2, deviceOperation.getOperationId()); + stmt.setLong(3, deviceOperation.getSentDate()); + stmt.setLong(4, deviceOperation.getReceivedDate()); + stmt.setString(5, deviceOperation.getStatus().name()); + int rows = stmt.executeUpdate(); + if (rows > 0) { + status = true; + } + } catch (SQLException e) { + String msg = "Error occurred while adding device id - '" + + deviceOperation.getDeviceId() + " and operation id - " + + deviceOperation.getOperationId() + + " to mapping table MBL_DEVICE_OPERATION"; + ; + log.error(msg, e); + throw new MobileDeviceManagementDAOException(msg, e); + } finally { + MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null); + } + return status; + } + + @Override + public boolean updateMobileDeviceOperation(MobileDeviceOperationMapping deviceOperation) + throws MobileDeviceManagementDAOException { + boolean status = false; + Connection conn = null; + PreparedStatement stmt = null; + try { + conn = this.getConnection(); + String updateDBQuery = + "UPDATE MBL_DEVICE_OPERATION_MAPPING SET SENT_DATE = ?, RECEIVED_DATE = ?, STATUS = ? " + + "WHERE DEVICE_ID = ? AND OPERATION_ID=?"; + stmt = conn.prepareStatement(updateDBQuery); + stmt.setLong(1, deviceOperation.getSentDate()); + stmt.setLong(2, deviceOperation.getReceivedDate()); + stmt.setString(3, deviceOperation.getStatus().name()); + stmt.setString(4, deviceOperation.getDeviceId()); + stmt.setInt(5, deviceOperation.getOperationId()); + int rows = stmt.executeUpdate(); + if (rows > 0) { + status = true; + } + } catch (SQLException e) { + String msg = "Error occurred while updating device id - '" + + deviceOperation.getDeviceId() + " and operation id - " + + deviceOperation.getOperationId() + " in table MBL_DEVICE_OPERATION"; + log.error(msg, e); + throw new MobileDeviceManagementDAOException(msg, e); + } finally { + MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null); + } + return status; + } + + @Override + public boolean updateMobileDeviceOperationToInProgress(String deviceId, int operationId) + throws MobileDeviceManagementDAOException { + boolean status = false; + Connection conn = null; + PreparedStatement stmt = null; + try { + conn = this.getConnection(); + String updateDBQuery = + "UPDATE MBL_DEVICE_OPERATION_MAPPING SET SENT_DATE = ?, STATUS = ? " + + "WHERE DEVICE_ID = ? AND OPERATION_ID=?"; + stmt = conn.prepareStatement(updateDBQuery); + stmt.setLong(1, new Date().getTime()); + stmt.setString(2, MobileDeviceOperationMapping.Status.INPROGRESS.name()); + stmt.setString(3, deviceId); + stmt.setInt(4, operationId); + int rows = stmt.executeUpdate(); + if (rows > 0) { + status = true; + } + } catch (SQLException e) { + String msg = + "Error occurred while updating the Status of operation to in-progress of device id - '" + + deviceId + " and operation id - " + + operationId + " in table MBL_DEVICE_OPERATION"; + log.error(msg, e); + throw new MobileDeviceManagementDAOException(msg, e); + } finally { + MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null); + } + return status; + } + + @Override + public boolean updateMobileDeviceOperationToCompleted(String deviceId, + int operationId) + throws MobileDeviceManagementDAOException { + boolean status = false; + Connection conn = null; + PreparedStatement stmt = null; + try { + conn = this.getConnection(); + String updateDBQuery = + "UPDATE MBL_DEVICE_OPERATION_MAPPING SET RECEIVED_DATE = ?, STATUS = ? " + + "WHERE DEVICE_ID = ? AND OPERATION_ID=?"; + stmt = conn.prepareStatement(updateDBQuery); + stmt.setLong(1, new Date().getTime()); + stmt.setString(2, MobileDeviceOperationMapping.Status.COMPLETED.name()); + stmt.setString(3, deviceId); + stmt.setInt(4, operationId); + int rows = stmt.executeUpdate(); + if (rows > 0) { + status = true; + } + } catch (SQLException e) { + String msg = + "Error occurred while updating the Status of operation to completed of device id - '" + + deviceId + " and operation id - " + + operationId + " in table MBL_DEVICE_OPERATION"; + log.error(msg, e); + throw new MobileDeviceManagementDAOException(msg, e); + } finally { + MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null); + } + return status; + } + + @Override + public boolean deleteMobileDeviceOperation(String deviceId, int operationId) + throws MobileDeviceManagementDAOException { + boolean status = false; + Connection conn = null; + PreparedStatement stmt = null; + try { + conn = this.getConnection(); + String deleteDBQuery = + "DELETE FROM MBL_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ? AND OPERATION_ID=?"; + stmt = conn.prepareStatement(deleteDBQuery); + stmt.setString(1, deviceId); + stmt.setInt(2, operationId); + int rows = stmt.executeUpdate(); + if (rows > 0) { + status = true; + } + } catch (SQLException e) { + String msg = + "Error occurred while deleting the table entry MBL_DEVICE_OPERATION with " + + " device id - '" + deviceId + " and operation id - " + operationId; + log.error(msg, e); + throw new MobileDeviceManagementDAOException(msg, e); + } finally { + MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null); + } + return status; + } + + @Override + public MobileDeviceOperationMapping getMobileDeviceOperation(String deviceId, int operationId) + throws MobileDeviceManagementDAOException { + Connection conn = null; + PreparedStatement stmt = null; + MobileDeviceOperationMapping mblDeviceOperation = null; + try { + conn = this.getConnection(); + String selectDBQuery = + "SELECT DEVICE_ID, OPERATION_ID, SENT_DATE, RECEIVED_DATE, STATUS FROM " + + "MBL_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ? AND OPERATION_ID=?"; + stmt = conn.prepareStatement(selectDBQuery); + stmt.setString(1, deviceId); + stmt.setInt(2, operationId); + ResultSet resultSet = stmt.executeQuery(); + while (resultSet.next()) { + mblDeviceOperation = new MobileDeviceOperationMapping(); + mblDeviceOperation.setDeviceId(resultSet.getString(1)); + mblDeviceOperation.setOperationId(resultSet.getInt(2)); + mblDeviceOperation.setSentDate(resultSet.getInt(3)); + mblDeviceOperation.setReceivedDate(resultSet.getInt(4)); + mblDeviceOperation.setStatus(resultSet.getString(5)); + break; + } + } catch (SQLException e) { + String msg = + "Error occurred while fetching table MBL_DEVICE_OPERATION entry with device id - '" + + deviceId + " and operation id - " + operationId; + log.error(msg, e); + throw new MobileDeviceManagementDAOException(msg, e); + } finally { + MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null); + } + return mblDeviceOperation; + } + + @Override + public List getAllMobileDeviceOperationsOfDevice(String deviceId) + throws MobileDeviceManagementDAOException { + Connection conn = null; + PreparedStatement stmt = null; + MobileDeviceOperationMapping mblDeviceOperation = null; + List mblDeviceOperations = new ArrayList(); + try { + conn = this.getConnection(); + String selectDBQuery = + "SELECT DEVICE_ID, OPERATION_ID, SENT_DATE, RECEIVED_DATE, STATUS FROM " + + "MBL_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ?"; + stmt = conn.prepareStatement(selectDBQuery); + stmt.setString(1, deviceId); + ResultSet resultSet = stmt.executeQuery(); + while (resultSet.next()) { + mblDeviceOperation = new MobileDeviceOperationMapping(); + mblDeviceOperation.setDeviceId(resultSet.getString(1)); + mblDeviceOperation.setOperationId(resultSet.getInt(2)); + mblDeviceOperation.setSentDate(resultSet.getInt(3)); + mblDeviceOperation.setReceivedDate(resultSet.getInt(4)); + mblDeviceOperation.setStatus(resultSet.getString(5)); + mblDeviceOperations.add(mblDeviceOperation); + } + } catch (SQLException e) { + String msg = + "Error occurred while fetching mapping table MBL_DEVICE_OPERATION entries of " + + "device id - '" + deviceId; + log.error(msg, e); + throw new MobileDeviceManagementDAOException(msg, e); + } finally { + MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null); + } + return mblDeviceOperations; + } + + @Override + public List getAllPendingOperationsOfMobileDevice(String deviceId) + throws MobileDeviceManagementDAOException { + Connection conn = null; + PreparedStatement stmt = null; + MobileDeviceOperationMapping mblDeviceOperation = null; + List mblDeviceOperations = new ArrayList(); + try { + + conn = this.getConnection(); + String selectDBQuery = + "SELECT DEVICE_ID, OPERATION_ID, SENT_DATE, RECEIVED_DATE, STATUS FROM" + + " MBL_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ? AND STATUS = 'NEW'"; + stmt = conn.prepareStatement(selectDBQuery); + stmt.setString(1, deviceId); + ResultSet resultSet = stmt.executeQuery(); + while (resultSet.next()) { + mblDeviceOperation = new MobileDeviceOperationMapping(); + mblDeviceOperation.setDeviceId(resultSet.getString(1)); + mblDeviceOperation.setOperationId(resultSet.getInt(2)); + mblDeviceOperation.setSentDate(resultSet.getInt(3)); + mblDeviceOperation.setReceivedDate(resultSet.getInt(4)); + mblDeviceOperation.setStatus(resultSet.getString(5)); + mblDeviceOperations.add(mblDeviceOperation); + } + } catch (SQLException e) { + String msg = + "Error occurred while fetching mapping table MBL_DEVICE_OPERATION entries of" + + " device id - '" + deviceId; + log.error(msg, e); + throw new MobileDeviceManagementDAOException(msg, e); + } finally { + MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null); + } + return mblDeviceOperations; + } + + private Connection getConnection() throws MobileDeviceManagementDAOException { + try { + return dataSource.getConnection(); + } catch (SQLException e) { + String msg = "Error occurred while obtaining a connection from the mobile device " + + "management metadata repository datasource."; + log.error(msg, e); + throw new MobileDeviceManagementDAOException(msg, e); + } + } +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/FeatureDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileFeatureDAOImpl.java similarity index 74% rename from components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/FeatureDAOImpl.java rename to components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileFeatureDAOImpl.java index 429349e186..6f983089d8 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/FeatureDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileFeatureDAOImpl.java @@ -18,10 +18,10 @@ package org.wso2.carbon.device.mgt.mobile.dao.impl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.mobile.dao.FeatureDAO; +import org.wso2.carbon.device.mgt.mobile.dao.MobileFeatureDAO; import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException; import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil; -import org.wso2.carbon.device.mgt.mobile.dto.Feature; +import org.wso2.carbon.device.mgt.mobile.dto.MobileFeature; import javax.sql.DataSource; import java.sql.Connection; @@ -32,19 +32,19 @@ import java.util.ArrayList; import java.util.List; /** - * Implementation of FeatureDAO. + * Implementation of MobileFeatureDAO. */ -public class FeatureDAOImpl implements FeatureDAO { +public class MobileFeatureDAOImpl implements MobileFeatureDAO { private DataSource dataSource; - private static final Log log = LogFactory.getLog(FeatureDAOImpl.class); + private static final Log log = LogFactory.getLog(MobileFeatureDAOImpl.class); - public FeatureDAOImpl(DataSource dataSource) { + public MobileFeatureDAOImpl(DataSource dataSource) { this.dataSource = dataSource; } @Override - public boolean addFeature(Feature feature) throws MobileDeviceManagementDAOException { + public boolean addFeature(MobileFeature mobileFeature) throws MobileDeviceManagementDAOException { boolean status = false; Connection conn = null; PreparedStatement stmt = null; @@ -54,16 +54,16 @@ public class FeatureDAOImpl implements FeatureDAO { "INSERT INTO MBL_FEATURE(CODE, NAME, DESCRIPTION) VALUES (?, ?, ?)"; stmt = conn.prepareStatement(createDBQuery); - stmt.setString(1, feature.getCode()); - stmt.setString(2, feature.getName()); - stmt.setString(3, feature.getDescription()); + stmt.setString(1, mobileFeature.getCode()); + stmt.setString(2, mobileFeature.getName()); + stmt.setString(3, mobileFeature.getDescription()); int rows = stmt.executeUpdate(); if (rows > 0) { status = true; } } catch (SQLException e) { String msg = "Error occurred while adding feature code - '" + - feature.getCode() + "' to feature table"; + mobileFeature.getCode() + "' to feature table"; log.error(msg, e); throw new MobileDeviceManagementDAOException(msg, e); } finally { @@ -73,7 +73,7 @@ public class FeatureDAOImpl implements FeatureDAO { } @Override - public boolean updateFeature(Feature feature) + public boolean updateFeature(MobileFeature mobileFeature) throws MobileDeviceManagementDAOException { boolean status = false; Connection conn = null; @@ -83,17 +83,17 @@ public class FeatureDAOImpl implements FeatureDAO { String updateDBQuery = "UPDATE MBL_FEATURE SET CODE = ?, NAME = ?, DESCRIPTION = ? WHERE FEATURE_ID = ?"; stmt = conn.prepareStatement(updateDBQuery); - stmt.setString(1, feature.getCode()); - stmt.setString(2, feature.getName()); - stmt.setString(3, feature.getDescription()); - stmt.setInt(4, feature.getId()); + stmt.setString(1, mobileFeature.getCode()); + stmt.setString(2, mobileFeature.getName()); + stmt.setString(3, mobileFeature.getDescription()); + stmt.setInt(4, mobileFeature.getId()); int rows = stmt.executeUpdate(); if (rows > 0) { status = true; } } catch (SQLException e) { String msg = "Error occurred while updating the feature with feature code - '" + - feature.getId() + "'"; + mobileFeature.getId() + "'"; log.error(msg, e); throw new MobileDeviceManagementDAOException(msg, e); } finally { @@ -155,11 +155,11 @@ public class FeatureDAOImpl implements FeatureDAO { } @Override - public Feature getFeatureByCode(String featureCode) + public MobileFeature getFeatureByCode(String featureCode) throws MobileDeviceManagementDAOException { Connection conn = null; PreparedStatement stmt = null; - Feature feature = null; + MobileFeature mobileFeature = null; try { conn = this.getConnection(); String selectDBQuery = @@ -168,11 +168,11 @@ public class FeatureDAOImpl implements FeatureDAO { stmt.setString(1, featureCode); ResultSet resultSet = stmt.executeQuery(); while (resultSet.next()) { - feature = new Feature(); - feature.setId(resultSet.getInt(1)); - feature.setCode(resultSet.getString(2)); - feature.setName(resultSet.getString(3)); - feature.setDescription(resultSet.getString(4)); + mobileFeature = new MobileFeature(); + mobileFeature.setId(resultSet.getInt(1)); + mobileFeature.setCode(resultSet.getString(2)); + mobileFeature.setName(resultSet.getString(3)); + mobileFeature.setDescription(resultSet.getString(4)); break; } } catch (SQLException e) { @@ -183,15 +183,15 @@ public class FeatureDAOImpl implements FeatureDAO { } finally { MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null); } - return feature; + return mobileFeature; } @Override - public Feature getFeatureById(String featureID) + public MobileFeature getFeatureById(String featureID) throws MobileDeviceManagementDAOException { Connection conn = null; PreparedStatement stmt = null; - Feature feature = null; + MobileFeature mobileFeature = null; try { conn = this.getConnection(); String selectDBQuery = @@ -200,11 +200,11 @@ public class FeatureDAOImpl implements FeatureDAO { stmt.setString(1, featureID); ResultSet resultSet = stmt.executeQuery(); while (resultSet.next()) { - feature = new Feature(); - feature.setId(resultSet.getInt(1)); - feature.setCode(resultSet.getString(2)); - feature.setName(resultSet.getString(3)); - feature.setDescription(resultSet.getString(4)); + mobileFeature = new MobileFeature(); + mobileFeature.setId(resultSet.getInt(1)); + mobileFeature.setCode(resultSet.getString(2)); + mobileFeature.setName(resultSet.getString(3)); + mobileFeature.setDescription(resultSet.getString(4)); break; } } catch (SQLException e) { @@ -215,15 +215,15 @@ public class FeatureDAOImpl implements FeatureDAO { } finally { MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null); } - return feature; + return mobileFeature; } @Override - public List getAllFeatures() throws MobileDeviceManagementDAOException { + public List getAllFeatures() throws MobileDeviceManagementDAOException { Connection conn = null; PreparedStatement stmt = null; - Feature feature; - List features = new ArrayList(); + MobileFeature mobileFeature; + List mobileFeatures = new ArrayList(); try { conn = this.getConnection(); String selectDBQuery = @@ -231,14 +231,14 @@ public class FeatureDAOImpl implements FeatureDAO { stmt = conn.prepareStatement(selectDBQuery); ResultSet resultSet = stmt.executeQuery(); while (resultSet.next()) { - feature = new Feature(); - feature.setId(resultSet.getInt(1)); - feature.setCode(resultSet.getString(2)); - feature.setName(resultSet.getString(3)); - feature.setDescription(resultSet.getString(4)); - features.add(feature); + mobileFeature = new MobileFeature(); + mobileFeature.setId(resultSet.getInt(1)); + mobileFeature.setCode(resultSet.getString(2)); + mobileFeature.setName(resultSet.getString(3)); + mobileFeature.setDescription(resultSet.getString(4)); + mobileFeatures.add(mobileFeature); } - return features; + return mobileFeatures; } catch (SQLException e) { String msg = "Error occurred while fetching all features.'"; log.error(msg, e); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/FeaturePropertyDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileFeaturePropertyDAOImpl.java similarity index 75% rename from components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/FeaturePropertyDAOImpl.java rename to components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileFeaturePropertyDAOImpl.java index 4c623fad3e..f99a2c7f04 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/FeaturePropertyDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileFeaturePropertyDAOImpl.java @@ -18,10 +18,10 @@ package org.wso2.carbon.device.mgt.mobile.dao.impl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.mobile.dao.FeaturePropertyDAO; +import org.wso2.carbon.device.mgt.mobile.dao.MobileFeaturePropertyDAO; import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException; import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil; -import org.wso2.carbon.device.mgt.mobile.dto.FeatureProperty; +import org.wso2.carbon.device.mgt.mobile.dto.MobileFeatureProperty; import javax.sql.DataSource; import java.sql.Connection; @@ -32,19 +32,19 @@ import java.util.ArrayList; import java.util.List; /** - * Implementation of FeaturePropertyDAO. + * Implementation of MobileFeaturePropertyDAO. */ -public class FeaturePropertyDAOImpl implements FeaturePropertyDAO { +public class MobileFeaturePropertyDAOImpl implements MobileFeaturePropertyDAO { private DataSource dataSource; - private static final Log log = LogFactory.getLog(FeaturePropertyDAOImpl.class); + private static final Log log = LogFactory.getLog(MobileFeaturePropertyDAOImpl.class); - public FeaturePropertyDAOImpl(DataSource dataSource) { + public MobileFeaturePropertyDAOImpl(DataSource dataSource) { this.dataSource = dataSource; } @Override - public boolean addFeatureProperty(FeatureProperty featureProperty) + public boolean addFeatureProperty(MobileFeatureProperty mobileFeatureProperty) throws MobileDeviceManagementDAOException { boolean status = false; Connection conn = null; @@ -55,15 +55,15 @@ public class FeaturePropertyDAOImpl implements FeaturePropertyDAO { "INSERT INTO MBL_FEATURE_PROPERTY(PROPERTY, FEATURE_ID) VALUES (?, ?)"; stmt = conn.prepareStatement(createDBQuery); - stmt.setString(1, featureProperty.getProperty()); - stmt.setString(2, featureProperty.getFeatureID()); + stmt.setString(1, mobileFeatureProperty.getProperty()); + stmt.setString(2, mobileFeatureProperty.getFeatureID()); int rows = stmt.executeUpdate(); if (rows > 0) { status = true; } } catch (SQLException e) { String msg = "Error occurred while adding property id - '" + - featureProperty.getFeatureID() + "'"; + mobileFeatureProperty.getFeatureID() + "'"; log.error(msg, e); throw new MobileDeviceManagementDAOException(msg, e); } finally { @@ -73,7 +73,7 @@ public class FeaturePropertyDAOImpl implements FeaturePropertyDAO { } @Override - public boolean updateFeatureProperty(FeatureProperty featureProperty) + public boolean updateFeatureProperty(MobileFeatureProperty mobileFeatureProperty) throws MobileDeviceManagementDAOException { boolean status = false; Connection conn = null; @@ -83,15 +83,15 @@ public class FeaturePropertyDAOImpl implements FeaturePropertyDAO { String updateDBQuery = "UPDATE MBL_FEATURE_PROPERTY SET FEATURE_ID = ? WHERE PROPERTY = ?"; stmt = conn.prepareStatement(updateDBQuery); - stmt.setString(1, featureProperty.getFeatureID()); - stmt.setString(2, featureProperty.getProperty()); + stmt.setString(1, mobileFeatureProperty.getFeatureID()); + stmt.setString(2, mobileFeatureProperty.getProperty()); int rows = stmt.executeUpdate(); if (rows > 0) { status = true; } } catch (SQLException e) { String msg = "Error occurred while updating the feature property with property - '" + - featureProperty.getProperty() + "'"; + mobileFeatureProperty.getProperty() + "'"; log.error(msg, e); throw new MobileDeviceManagementDAOException(msg, e); } finally { @@ -128,11 +128,11 @@ public class FeaturePropertyDAOImpl implements FeaturePropertyDAO { } @Override - public FeatureProperty getFeatureProperty(String property) + public MobileFeatureProperty getFeatureProperty(String property) throws MobileDeviceManagementDAOException { Connection conn = null; PreparedStatement stmt = null; - FeatureProperty featureProperty = null; + MobileFeatureProperty mobileFeatureProperty = null; try { conn = this.getConnection(); String selectDBQuery = @@ -141,9 +141,9 @@ public class FeaturePropertyDAOImpl implements FeaturePropertyDAO { stmt.setString(1, property); ResultSet resultSet = stmt.executeQuery(); while (resultSet.next()) { - featureProperty = new FeatureProperty(); - featureProperty.setProperty(resultSet.getString(1)); - featureProperty.setFeatureID(resultSet.getString(2)); + mobileFeatureProperty = new MobileFeatureProperty(); + mobileFeatureProperty.setProperty(resultSet.getString(1)); + mobileFeatureProperty.setFeatureID(resultSet.getString(2)); break; } } catch (SQLException e) { @@ -154,16 +154,16 @@ public class FeaturePropertyDAOImpl implements FeaturePropertyDAO { } finally { MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null); } - return featureProperty; + return mobileFeatureProperty; } @Override - public List getFeaturePropertyOfFeature(String featureId) + public List getFeaturePropertyOfFeature(String featureId) throws MobileDeviceManagementDAOException { Connection conn = null; PreparedStatement stmt = null; - FeatureProperty featureProperty = null; - List FeatureProperties = new ArrayList(); + MobileFeatureProperty mobileFeatureProperty = null; + List FeatureProperties = new ArrayList(); try { conn = this.getConnection(); String selectDBQuery = @@ -172,10 +172,10 @@ public class FeaturePropertyDAOImpl implements FeaturePropertyDAO { stmt.setString(1, featureId); ResultSet resultSet = stmt.executeQuery(); while (resultSet.next()) { - featureProperty = new FeatureProperty(); - featureProperty.setProperty(resultSet.getString(1)); - featureProperty.setFeatureID(resultSet.getString(2)); - FeatureProperties.add(featureProperty); + mobileFeatureProperty = new MobileFeatureProperty(); + mobileFeatureProperty.setProperty(resultSet.getString(1)); + mobileFeatureProperty.setFeatureID(resultSet.getString(2)); + FeatureProperties.add(mobileFeatureProperty); } return FeatureProperties; } catch (SQLException e) { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/util/MobileDeviceManagementDAOUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/util/MobileDeviceManagementDAOUtil.java index 146a33bcbf..af181b321b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/util/MobileDeviceManagementDAOUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/util/MobileDeviceManagementDAOUtil.java @@ -39,40 +39,6 @@ public class MobileDeviceManagementDAOUtil { private static final Log log = LogFactory.getLog(MobileDeviceManagementDAOUtil.class); - /** - * Resolve data source from the data source definition. - * - * @param config Mobile data source configuration - * @return data source resolved from the data source definition - */ - public static DataSource resolveDataSource(MobileDataSourceConfig config) throws DeviceManagementException { - DataSource dataSource = null; - if (config == null) { - throw new RuntimeException("Device Management Repository data source configuration " + - "is null and thus, is not initialized"); - } - JNDILookupDefinition jndiConfig = config.getJndiLookupDefintion(); - if (jndiConfig != null) { - if (log.isDebugEnabled()) { - log.debug("Initializing Device Management Repository data source using the JNDI " + - "Lookup Definition"); - } - List jndiPropertyList = - jndiConfig.getJndiProperties(); - if (jndiPropertyList != null) { - Hashtable jndiProperties = new Hashtable(); - for (JNDILookupDefinition.JNDIProperty prop : jndiPropertyList) { - jndiProperties.put(prop.getName(), prop.getValue()); - } - dataSource = - MobileDeviceManagementDAOUtil.lookupDataSource(jndiConfig.getJndiName(), jndiProperties); - } else { - dataSource = MobileDeviceManagementDAOUtil.lookupDataSource(jndiConfig.getJndiName(), null); - } - } - return dataSource; - } - public static DataSource lookupDataSource(String dataSourceName, final Hashtable jndiProperties) throws DeviceManagementException { @@ -113,27 +79,6 @@ public class MobileDeviceManagementDAOUtil { } } - /** - * Initializes the creation of mobile device management schema if -Dsetup has provided. - * - * @param dataSource Mobile data source - */ - public static void createDataSource(DataSource dataSource) { - String setupOption = System.getProperty("setup"); - if (setupOption != null) { - if (log.isDebugEnabled()) { - log.debug( - "-Dsetup is enabled. Mobile Device management repository schema initialization is about " + - "to begin"); - } - try { - MobileDeviceManagementDAOUtil.setupMobileDeviceManagementSchema(dataSource); - } catch (DeviceManagementException e) { - log.error("Exception occurred while initializing mobile device management database schema", e); - } - } - } - /** * Creates the mobile device management schema. * diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/MobileDeviceOperation.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/MobileDeviceOperationMapping.java similarity index 70% rename from components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/MobileDeviceOperation.java rename to components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/MobileDeviceOperationMapping.java index c565accdb4..f21ee7d4f6 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/MobileDeviceOperation.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/MobileDeviceOperationMapping.java @@ -17,14 +17,37 @@ package org.wso2.carbon.device.mgt.mobile.dto; /** - * DTO of Mobile Device Operations. + * DTO of Mobile Device Operation Mappings. */ -public class MobileDeviceOperation { +public class MobileDeviceOperationMapping { private String deviceId; private int operationId; private long sentDate; private long receivedDate; + private Status status; + + public enum Status { + NEW, INPROGRESS, COMPLETED + } + + public Status getStatus() { + return status; + } + + public void setStatus(Status status) { + this.status = status; + } + + public void setStatus(String status) { + if(Status.NEW.name().equals(status)){ + this.status = Status.NEW; + }else if(Status.INPROGRESS.name().equals(status)){ + this.status = Status.INPROGRESS; + }else if(Status.COMPLETED.name().equals(status)){ + this.status = Status.COMPLETED; + } + } public String getDeviceId() { return deviceId; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/Feature.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/MobileFeature.java similarity index 94% rename from components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/Feature.java rename to components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/MobileFeature.java index 2fb173b568..38b6944d61 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/Feature.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/MobileFeature.java @@ -19,9 +19,9 @@ package org.wso2.carbon.device.mgt.mobile.dto; import java.io.Serializable; /** - * DTO of features. + * DTO of Mobile features. */ -public class Feature implements Serializable { +public class MobileFeature implements Serializable { private int id; private String code; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/FeatureProperty.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/MobileFeatureProperty.java similarity index 89% rename from components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/FeatureProperty.java rename to components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/MobileFeatureProperty.java index a29cebaff6..5068006cad 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/FeatureProperty.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/MobileFeatureProperty.java @@ -17,9 +17,9 @@ package org.wso2.carbon.device.mgt.mobile.dto; /** - * DTO of feature property. Represents a property of a feature. + * DTO of Mobile feature property. Represents a property of a mobile feature. */ -public class FeatureProperty { +public class MobileFeatureProperty { private String property; private String featureID; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidMobileOperationManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidMobileOperationManager.java index 76c6332434..aeb22ba7bc 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidMobileOperationManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidMobileOperationManager.java @@ -23,12 +23,13 @@ import org.wso2.carbon.device.mgt.common.OperationManagementException; import org.wso2.carbon.device.mgt.mobile.AbstractMobileOperationManager; import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException; import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOFactory; -import org.wso2.carbon.device.mgt.mobile.dto.MobileDeviceOperation; +import org.wso2.carbon.device.mgt.mobile.dto.MobileDeviceOperationMapping; import org.wso2.carbon.device.mgt.mobile.dto.MobileOperation; import org.wso2.carbon.device.mgt.mobile.dto.MobileOperationProperty; import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementUtil; import java.util.ArrayList; +import java.util.Date; import java.util.List; public class AndroidMobileOperationManager extends AbstractMobileOperationManager { @@ -40,7 +41,7 @@ public class AndroidMobileOperationManager extends AbstractMobileOperationManage OperationManagementException { boolean status = false; try { - MobileDeviceOperation mobileDeviceOperation = null; + MobileDeviceOperationMapping mobileDeviceOperationMapping = null; MobileOperation mobileOperation = MobileDeviceManagementUtil.convertToMobileOperation(operation); int operationId = MobileDeviceManagementDAOFactory.getMobileOperationDAO() @@ -53,12 +54,13 @@ public class AndroidMobileOperationManager extends AbstractMobileOperationManage operationProperty); } for (DeviceIdentifier deviceIdentifier : devices) { - mobileDeviceOperation = new MobileDeviceOperation(); - mobileDeviceOperation.setOperationId(operationId); - mobileDeviceOperation.setDeviceId(deviceIdentifier.getId()); + mobileDeviceOperationMapping = new MobileDeviceOperationMapping(); + mobileDeviceOperationMapping.setOperationId(operationId); + mobileDeviceOperationMapping.setDeviceId(deviceIdentifier.getId()); + mobileDeviceOperationMapping.setStatus(MobileDeviceOperationMapping.Status.NEW); status = MobileDeviceManagementDAOFactory.getMobileDeviceOperationDAO() .addMobileDeviceOperation( - mobileDeviceOperation); + mobileDeviceOperationMapping); } } } catch (MobileDeviceManagementDAOException e) { @@ -74,17 +76,18 @@ public class AndroidMobileOperationManager extends AbstractMobileOperationManage public List getOperations(DeviceIdentifier deviceIdentifier) throws OperationManagementException { List operations = new ArrayList(); - List mobileDeviceOperations = null; + List mobileDeviceOperationMappings = null; List operationProperties = null; MobileOperation mobileOperation = null; try { - mobileDeviceOperations = MobileDeviceManagementDAOFactory.getMobileDeviceOperationDAO() + mobileDeviceOperationMappings = MobileDeviceManagementDAOFactory.getMobileDeviceOperationDAO() .getAllMobileDeviceOperationsOfDevice( deviceIdentifier .getId()); - if (mobileDeviceOperations.size() > 0) { + if (mobileDeviceOperationMappings.size() > 0) { List operationIds = MobileDeviceManagementUtil - .getMobileOperationIdsFromMobileDeviceOperations(mobileDeviceOperations); + .getMobileOperationIdsFromMobileDeviceOperations( + mobileDeviceOperationMappings); for (Integer operationId : operationIds) { mobileOperation = MobileDeviceManagementDAOFactory.getMobileOperationDAO() .getMobileOperation( @@ -107,4 +110,49 @@ public class AndroidMobileOperationManager extends AbstractMobileOperationManage } return operations; } + + @Override + public List getPendingOperations(DeviceIdentifier deviceIdentifier) + throws OperationManagementException { + List operations = new ArrayList(); + List mobileDeviceOperationMappings = null; + List operationProperties = null; + MobileOperation mobileOperation = null; + try { + //Get the list of pending operations for the given device + mobileDeviceOperationMappings = MobileDeviceManagementDAOFactory.getMobileDeviceOperationDAO() + .getAllPendingOperationsOfMobileDevice( + deviceIdentifier + .getId()); + //Go through each operation mapping for retrieving the data corresponding to each operation + for (MobileDeviceOperationMapping operation : mobileDeviceOperationMappings) { + //Get the MobileOperation data + mobileOperation = MobileDeviceManagementDAOFactory.getMobileOperationDAO() + .getMobileOperation(operation + .getOperationId()); + //Get properties of the operation + operationProperties = + MobileDeviceManagementDAOFactory.getMobileOperationPropertyDAO() + .getAllMobileOperationPropertiesOfOperation( + operation.getOperationId()); + mobileOperation.setProperties(operationProperties); + operations.add(MobileDeviceManagementUtil + .convertMobileOperationToOperation(mobileOperation)); + //Update the MobileDeviceOperationMapping data to the In-Progress state + operation.setStatus(MobileDeviceOperationMapping.Status.INPROGRESS); + operation.setSentDate(new Date().getTime()); + MobileDeviceManagementDAOFactory.getMobileDeviceOperationDAO() + .updateMobileDeviceOperationToInProgress( + operation.getDeviceId(), + operation.getOperationId()); + } + } catch (MobileDeviceManagementDAOException e) { + String msg = + "Error while fetching the operations for the android device " + + deviceIdentifier.getId(); + log.error(msg, e); + throw new OperationManagementException(msg, e); + } + return operations; + } } \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/util/MobileDeviceManagementUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/util/MobileDeviceManagementUtil.java index d771cb485c..78b120e480 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/util/MobileDeviceManagementUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/util/MobileDeviceManagementUtil.java @@ -23,7 +23,7 @@ import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.Operation; import org.wso2.carbon.device.mgt.mobile.dto.MobileDevice; -import org.wso2.carbon.device.mgt.mobile.dto.MobileDeviceOperation; +import org.wso2.carbon.device.mgt.mobile.dto.MobileDeviceOperationMapping; import org.wso2.carbon.device.mgt.mobile.dto.MobileOperation; import org.wso2.carbon.device.mgt.mobile.dto.MobileOperationProperty; @@ -115,10 +115,10 @@ public class MobileDeviceManagementUtil { } public static List getMobileOperationIdsFromMobileDeviceOperations( - List mobileDeviceOperations) { + List mobileDeviceOperationMappings) { List mobileOperationIds = new ArrayList(); - for(MobileDeviceOperation mobileDeviceOperation:mobileDeviceOperations){ - mobileOperationIds.add(mobileDeviceOperation.getOperationId()); + for(MobileDeviceOperationMapping mobileDeviceOperationMapping : mobileDeviceOperationMappings){ + mobileOperationIds.add(mobileDeviceOperationMapping.getOperationId()); } return mobileOperationIds; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/MobileDeviceManagementConfigTests.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/MobileDeviceManagementConfigTests.java new file mode 100644 index 0000000000..db177105fc --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/MobileDeviceManagementConfigTests.java @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2014 - 2015, 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 org.wso2.carbon.device.mgt.mobile.impl; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; +import org.wso2.carbon.device.mgt.mobile.config.MobileDeviceManagementConfig; +import org.xml.sax.SAXException; + +import javax.xml.XMLConstants; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Unmarshaller; +import javax.xml.validation.Schema; +import javax.xml.validation.SchemaFactory; +import java.io.File; + +public class MobileDeviceManagementConfigTests { + + private static final Log log = LogFactory.getLog(MobileDeviceManagementConfigTests.class); + private static final String MALFORMED_TEST_CONFIG_LOCATION_NO_MGT_REPOSITORY = + "./src/test/resources/config/malformed-mobile-config-no-mgt-repo.xml"; + private static final String MALFORMED_TEST_CONFIG_LOCATION_NO_DS_CONFIG = + "./src/test/resources/config/malformed-mobile-config-no-ds-config.xml"; + private static final String MALFORMED_TEST_CONFIG_LOCATION_NO_JNDI_CONFIG = + "./src/test/resources/config/malformed-mobile-config-no-jndi-config.xml"; + private static final String MALFORMED_TEST_CONFIG_LOCATION_NO_APIS_CONFIG = + "./src/test/resources/config/malformed-mobile-config-no-apis-config.xml"; + private static final String MALFORMED_TEST_CONFIG_LOCATION_NO_API_CONFIG = + "./src/test/resources/config/malformed-mobile-config-no-api-config.xml"; + private static final String MALFORMED_TEST_CONFIG_LOCATION_NO_API_PUBLISHER_CONFIG = + "./src/test/resources/config/malformed-mobile-config-no-api-publisher-config.xml"; + private static final String TEST_CONFIG_SCHEMA_LOCATION = + "./src/test/resources/config/schema/MobileDeviceManagementConfigSchema.xsd"; + + private Schema schema; + + @BeforeClass + private void initSchema() { + File deviceManagementSchemaConfig = new File(MobileDeviceManagementConfigTests.TEST_CONFIG_SCHEMA_LOCATION); + SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); + try { + schema = factory.newSchema(deviceManagementSchemaConfig); + } catch (SAXException e) { + Assert.fail("Invalid schema found", e); + } + } + + @Test() + public void testMandateManagementRepositoryElement() { + File malformedConfig = + new File(MobileDeviceManagementConfigTests.MALFORMED_TEST_CONFIG_LOCATION_NO_MGT_REPOSITORY); + this.validateMalformedConfig(malformedConfig); + } + + @Test + public void testMandateDataSourceConfigurationElement() { + File malformedConfig = new File(MobileDeviceManagementConfigTests.MALFORMED_TEST_CONFIG_LOCATION_NO_DS_CONFIG); + this.validateMalformedConfig(malformedConfig); + } + + @Test + public void testMandateJndiLookupDefinitionElement() { + File malformedConfig = new File(MobileDeviceManagementConfigTests.MALFORMED_TEST_CONFIG_LOCATION_NO_JNDI_CONFIG); + this.validateMalformedConfig(malformedConfig); + } + + @Test + public void testMandateAPIPublisherElement() { + File malformedConfig = new File(MobileDeviceManagementConfigTests.MALFORMED_TEST_CONFIG_LOCATION_NO_API_PUBLISHER_CONFIG); + this.validateMalformedConfig(malformedConfig); + } + + @Test + public void testMandateAPIsElement() { + File malformedConfig = new File(MobileDeviceManagementConfigTests.MALFORMED_TEST_CONFIG_LOCATION_NO_APIS_CONFIG); + this.validateMalformedConfig(malformedConfig); + } + + @Test + public void testMandateAPIElement() { + File malformedConfig = new File(MobileDeviceManagementConfigTests.MALFORMED_TEST_CONFIG_LOCATION_NO_API_CONFIG); + this.validateMalformedConfig(malformedConfig); + } + + private void validateMalformedConfig(File malformedConfig) { + try { + JAXBContext ctx = JAXBContext.newInstance(MobileDeviceManagementConfig.class); + Unmarshaller um = ctx.createUnmarshaller(); + um.setSchema(this.getSchema()); + um.unmarshal(malformedConfig); + Assert.assertTrue(false); + } catch (JAXBException e) { + log.error("Error occurred while unmarsharlling mobile device management config", e); + Assert.assertTrue(true); + } + } + + private Schema getSchema() { + return schema; + } + +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/TestUtils.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/TestUtils.java new file mode 100644 index 0000000000..12a3b6ca42 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/TestUtils.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2014 - 2015, 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 org.wso2.carbon.device.mgt.mobile.impl; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; + +public class TestUtils { + + private static final Log log = LogFactory.getLog(TestUtils.class); + + public static void cleanupResources(Connection conn, Statement stmt, ResultSet rs) { + if (rs != null) { + try { + rs.close(); + } catch (SQLException e) { + log.warn("Error occurred while closing result set", e); + } + } + if (stmt != null) { + try { + stmt.close(); + } catch (SQLException e) { + log.warn("Error occurred while closing prepared statement", e); + } + } + if (conn != null) { + try { + conn.close(); + } catch (SQLException e) { + log.warn("Error occurred while closing database connection", e); + } + } + } + +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/org/wso2/carbon/device/mgt/mobile/impl/common/DBTypes.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/common/DBTypes.java similarity index 100% rename from components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/org/wso2/carbon/device/mgt/mobile/impl/common/DBTypes.java rename to components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/common/DBTypes.java diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/org/wso2/carbon/device/mgt/mobile/impl/common/TestDBConfiguration.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/common/TestDBConfiguration.java similarity index 100% rename from components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/org/wso2/carbon/device/mgt/mobile/impl/common/TestDBConfiguration.java rename to components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/common/TestDBConfiguration.java diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/org/wso2/carbon/device/mgt/mobile/impl/common/TestDBConfigurations.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/common/TestDBConfigurations.java similarity index 100% rename from components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/org/wso2/carbon/device/mgt/mobile/impl/common/TestDBConfigurations.java rename to components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/common/TestDBConfigurations.java diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/FeatureDAOTestSuite.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/FeatureDAOTestSuite.java new file mode 100644 index 0000000000..620127c5ac --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/FeatureDAOTestSuite.java @@ -0,0 +1,139 @@ +/* + * 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 org.wso2.carbon.device.mgt.mobile.impl.dao; + +import org.apache.commons.dbcp.BasicDataSource; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Parameters; +import org.testng.annotations.Test; +import org.w3c.dom.Document; +import org.wso2.carbon.device.mgt.common.DeviceManagementException; +import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException; +import org.wso2.carbon.device.mgt.mobile.dao.impl.MobileFeatureDAOImpl; +import org.wso2.carbon.device.mgt.mobile.dto.MobileFeature; +import org.wso2.carbon.device.mgt.mobile.impl.common.DBTypes; +import org.wso2.carbon.device.mgt.mobile.impl.common.TestDBConfiguration; +import org.wso2.carbon.device.mgt.mobile.impl.common.TestDBConfigurations; +import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementUtil; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Unmarshaller; +import java.io.File; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.Statement; +import java.util.Iterator; + +public class FeatureDAOTestSuite { + + private TestDBConfiguration testDBConfiguration; + private Connection conn = null; + private Statement stmt = null; + private MobileFeatureDAOImpl featureDAO; + + @BeforeClass + @Parameters("dbType") + public void setUpDB(String dbTypeStr) throws Exception { + + DBTypes dbType = DBTypes.valueOf(dbTypeStr); + testDBConfiguration = getTestDBConfiguration(dbType); + + switch (dbType) { + case H2: + createH2DB(testDBConfiguration); + BasicDataSource testDataSource = new BasicDataSource(); + testDataSource.setDriverClassName(testDBConfiguration.getDriverClass()); + testDataSource.setUrl(testDBConfiguration.getConnectionUrl()); + testDataSource.setUsername(testDBConfiguration.getUserName()); + testDataSource.setPassword(testDBConfiguration.getPwd()); + featureDAO = new MobileFeatureDAOImpl(testDataSource); + default: + } + } + + private TestDBConfiguration getTestDBConfiguration(DBTypes dbType) throws + MobileDeviceManagementDAOException, + DeviceManagementException { + + File deviceMgtConfig = new File("src/test/resources/testdbconfig.xml"); + Document doc = null; + testDBConfiguration = null; + TestDBConfigurations testDBConfigurations = null; + + doc = MobileDeviceManagementUtil.convertToDocument(deviceMgtConfig); + JAXBContext testDBContext = null; + + try { + testDBContext = JAXBContext.newInstance(TestDBConfigurations.class); + Unmarshaller unmarshaller = testDBContext.createUnmarshaller(); + testDBConfigurations = (TestDBConfigurations) unmarshaller.unmarshal(doc); + } catch (JAXBException e) { + throw new MobileDeviceManagementDAOException("Error parsing test db configurations", e); + } + + Iterator itrDBConfigs = + testDBConfigurations.getDbTypesList().iterator(); + while (itrDBConfigs.hasNext()) { + testDBConfiguration = itrDBConfigs.next(); + if (testDBConfiguration.getDbType().equals(dbType.toString())) { + break; + } + } + + return testDBConfiguration; + } + + private void createH2DB(TestDBConfiguration testDBConf) throws Exception { + Class.forName(testDBConf.getDriverClass()); + conn = DriverManager.getConnection(testDBConf.getConnectionUrl()); + stmt = conn.createStatement(); + stmt.executeUpdate("RUNSCRIPT FROM './src/test/resources/sql/CreateH2TestDB.sql'"); + stmt.close(); + conn.close(); + } + + @Test + public void addFeature() throws MobileDeviceManagementDAOException, DeviceManagementException { + + MobileFeature mobileFeature = new MobileFeature(); + mobileFeature.setCode("Camera"); + mobileFeature.setDescription("Camera enable or disable"); + mobileFeature.setName("Camera"); + boolean added = featureDAO.addFeature(mobileFeature); + // Long deviceId = null; + // try { + // conn = DeviceManagementDAOFactory.getDataSource().getConnection(); + // stmt = conn.createStatement(); + // ResultSet resultSet = stmt + // .executeQuery("SELECT ID from DM_DEVICE DEVICE where DEVICE.DEVICE_IDENTIFICATION='111'"); + // + // while (resultSet.next()) { + // deviceId = resultSet.getLong(1); + // } + // conn.close(); + // } catch (SQLException sqlEx) { + // throw new DeviceManagementDAOException("error in fetch device by device identification id", sqlEx); + // } + + Assert.assertTrue(added, "Device Id is null"); + } + +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/FeaturePropertyDAOTestSuite.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/FeaturePropertyDAOTestSuite.java new file mode 100644 index 0000000000..1937493681 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/FeaturePropertyDAOTestSuite.java @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2014 - 2015, 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 org.wso2.carbon.device.mgt.mobile.impl.dao; + +public class FeaturePropertyDAOTestSuite { +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceDAOTestSuite.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceDAOTestSuite.java new file mode 100644 index 0000000000..0c390a104e --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceDAOTestSuite.java @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2014 - 2015, 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 org.wso2.carbon.device.mgt.mobile.impl.dao; + +public class MobileDeviceDAOTestSuite { +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceOperationDAOTestSuite.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceOperationDAOTestSuite.java new file mode 100644 index 0000000000..2ae371e76a --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceOperationDAOTestSuite.java @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2014 - 2015, 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 org.wso2.carbon.device.mgt.mobile.impl.dao; + +public class MobileDeviceOperationDAOTestSuite { +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileOperationDAOTestSuite.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileOperationDAOTestSuite.java new file mode 100644 index 0000000000..ebc277e31c --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileOperationDAOTestSuite.java @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2014 - 2015, 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 org.wso2.carbon.device.mgt.mobile.impl.dao; + +public class MobileOperationDAOTestSuite { +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileOperationPropertyDAOTestSuite.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileOperationPropertyDAOTestSuite.java new file mode 100644 index 0000000000..4c43ed27bf --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileOperationPropertyDAOTestSuite.java @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2014 - 2015, 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 org.wso2.carbon.device.mgt.mobile.impl.dao; + +public class MobileOperationPropertyDAOTestSuite { +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/org/wso2/carbon/device/mgt/mobile/impl/dao/FeatureDAOTestSuite.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/org/wso2/carbon/device/mgt/mobile/impl/dao/FeatureDAOTestSuite.java deleted file mode 100644 index e90733b30c..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/org/wso2/carbon/device/mgt/mobile/impl/dao/FeatureDAOTestSuite.java +++ /dev/null @@ -1,141 +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 org.wso2.carbon.device.mgt.mobile.impl.dao; - -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Parameters; -import org.testng.annotations.Test; -import org.w3c.dom.Document; -import org.wso2.carbon.device.mgt.common.DeviceManagementException; -import org.wso2.carbon.device.mgt.mobile.impl.common.DBTypes; -import org.wso2.carbon.device.mgt.mobile.impl.common.TestDBConfiguration; -import org.wso2.carbon.device.mgt.mobile.impl.common.TestDBConfigurations; -import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil; -import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException; -import org.wso2.carbon.device.mgt.mobile.dao.impl.FeatureDAOImpl; -import org.wso2.carbon.device.mgt.mobile.dto.*; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Unmarshaller; -import java.io.File; -import java.sql.*; -import java.util.Date; -import java.util.Iterator; - -public class FeatureDAOTestSuite { - - private TestDBConfiguration testDBConfiguration; - private Connection conn = null; - private Statement stmt = null; - private FeatureDAOImpl featureDAO; - - @BeforeClass - @Parameters("dbType") - public void setUpDB(String dbTypeStr) throws Exception { - - DBTypes dbType = DBTypes.valueOf(dbTypeStr); - testDBConfiguration = getTestDBConfiguration(dbType); - - switch (dbType) { - case H2: - createH2DB(testDBConfiguration); - BasicDataSource testDataSource = new BasicDataSource(); - testDataSource.setDriverClassName(testDBConfiguration.getDriverClass()); - testDataSource.setUrl(testDBConfiguration.getConnectionUrl()); - testDataSource.setUsername(testDBConfiguration.getUserName()); - testDataSource.setPassword(testDBConfiguration.getPwd()); - featureDAO = new FeatureDAOImpl(testDataSource); - default: - } - } - - private TestDBConfiguration getTestDBConfiguration(DBTypes dbType) throws - MobileDeviceManagementDAOException, - DeviceManagementException { - - File deviceMgtConfig = new File("src/test/resources/testdbconfig.xml"); - Document doc = null; - testDBConfiguration = null; - TestDBConfigurations testDBConfigurations = null; - - doc = DeviceManagerUtil.convertToDocument(deviceMgtConfig); - JAXBContext testDBContext = null; - - try { - testDBContext = JAXBContext.newInstance(TestDBConfigurations.class); - Unmarshaller unmarshaller = testDBContext.createUnmarshaller(); - testDBConfigurations = (TestDBConfigurations) unmarshaller.unmarshal(doc); - } catch (JAXBException e) { - throw new MobileDeviceManagementDAOException("Error parsing test db configurations", e); - } - - Iterator itrDBConfigs = testDBConfigurations.getDbTypesList().iterator(); - while (itrDBConfigs.hasNext()) { - testDBConfiguration = itrDBConfigs.next(); - if (testDBConfiguration.getDbType().equals(dbType.toString())) { - break; - } - } - - return testDBConfiguration; - } - - private void createH2DB(TestDBConfiguration testDBConf) throws Exception { - - Class.forName(testDBConf.getDriverClass()); - conn = DriverManager.getConnection(testDBConf.getConnectionUrl()); - stmt = conn.createStatement(); - stmt.executeUpdate("RUNSCRIPT FROM './src/test/resources/sql/CreateH2TestDB.sql'"); - stmt.close(); - conn.close(); - - } - - - @Test - public void addFeature() throws MobileDeviceManagementDAOException, DeviceManagementException { - - - - Feature feature = new Feature(); - feature.setCode("Camera"); - feature.setDescription("Camera enable or disable"); - feature.setName("Camera"); - boolean added = featureDAO.addFeature(feature); -// Long deviceId = null; -// try { -// conn = DeviceManagementDAOFactory.getDataSource().getConnection(); -// stmt = conn.createStatement(); -// ResultSet resultSet = stmt -// .executeQuery("SELECT ID from DM_DEVICE DEVICE where DEVICE.DEVICE_IDENTIFICATION='111'"); -// -// while (resultSet.next()) { -// deviceId = resultSet.getLong(1); -// } -// conn.close(); -// } catch (SQLException sqlEx) { -// throw new DeviceManagementDAOException("error in fetch device by device identification id", sqlEx); -// } - - Assert.assertTrue(added, "Device Id is null"); - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/config/malformed-mobile-config-no-api-config.xml b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/config/malformed-mobile-config-no-api-config.xml new file mode 100644 index 0000000000..bb498e902f --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/config/malformed-mobile-config-no-api-config.xml @@ -0,0 +1,40 @@ + + + + + + + + jdbc/MobileDM_DS + + + + + + + + enrollment + admin + enrollment + 1.0.0 + http://localhost:9763/ + http,https + + + + + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/config/malformed-mobile-config-no-api-publisher-config.xml b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/config/malformed-mobile-config-no-api-publisher-config.xml new file mode 100644 index 0000000000..8b2fc6209e --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/config/malformed-mobile-config-no-api-publisher-config.xml @@ -0,0 +1,40 @@ + + + + + + + + jdbc/MobileDM_DS + + + + + + + + enrollment + admin + enrollment + 1.0.0 + http://localhost:9763/ + http,https + + + + + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/config/malformed-mobile-config-no-apis-config.xml b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/config/malformed-mobile-config-no-apis-config.xml new file mode 100644 index 0000000000..081b0dc074 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/config/malformed-mobile-config-no-apis-config.xml @@ -0,0 +1,40 @@ + + + + + + + + jdbc/MobileDM_DS + + + + + + + + enrollment + admin + enrollment + 1.0.0 + http://localhost:9763/ + http,https + + + + + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/config/malformed-mobile-config-no-ds-config.xml b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/config/malformed-mobile-config-no-ds-config.xml new file mode 100644 index 0000000000..d4080aa442 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/config/malformed-mobile-config-no-ds-config.xml @@ -0,0 +1,40 @@ + + + + + + + + jdbc/MobileDM_DS + + + + + + + + enrollment + admin + enrollment + 1.0.0 + http://localhost:9763/ + http,https + + + + + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/config/malformed-mobile-config-no-jndi.config.xml b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/config/malformed-mobile-config-no-jndi.config.xml new file mode 100644 index 0000000000..67e41f5a0f --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/config/malformed-mobile-config-no-jndi.config.xml @@ -0,0 +1,40 @@ + + + + + + + + jdbc/MobileDM_DS + + + + + + + + enrollment + admin + enrollment + 1.0.0 + http://localhost:9763/ + http,https + + + + + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/config/malformed-mobile-config-no-mgt-repo.xml b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/config/malformed-mobile-config-no-mgt-repo.xml new file mode 100644 index 0000000000..ce26db6fd1 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/config/malformed-mobile-config-no-mgt-repo.xml @@ -0,0 +1,40 @@ + + + + + + + + jdbc/MobileDM_DS + + + + + + + + enrollment + admin + enrollment + 1.0.0 + http://localhost:9763/ + http,https + + + + + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/config/schema/MobileDeviceManagementConfigSchema.xsd b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/config/schema/MobileDeviceManagementConfigSchema.xsd new file mode 100644 index 0000000000..65204b6ba8 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/config/schema/MobileDeviceManagementConfigSchema.xsd @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/sql/CreateH2TestDB.sql b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/sql/CreateH2TestDB.sql index afcd19ca06..39610edd9a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/sql/CreateH2TestDB.sql +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/sql/CreateH2TestDB.sql @@ -1,24 +1,82 @@ -CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE -( - ID INT auto_increment NOT NULL, - NAME VARCHAR(300) NULL DEFAULT NULL, - PRIMARY KEY (ID) -); -CREATE TABLE IF NOT EXISTS DM_DEVICE -( - ID INT auto_increment NOT NULL, - DESCRIPTION TEXT NULL DEFAULT NULL, - NAME VARCHAR(100) NULL DEFAULT NULL, - DATE_OF_ENROLLMENT BIGINT NULL DEFAULT NULL, - DATE_OF_LAST_UPDATE BIGINT NULL DEFAULT NULL, - OWNERSHIP VARCHAR(45) NULL DEFAULT NULL, - STATUS VARCHAR(15) NULL DEFAULT NULL, - DEVICE_TYPE_ID INT(11) NULL DEFAULT NULL, - DEVICE_IDENTIFICATION VARCHAR(300) NULL DEFAULT NULL, - OWNER VARCHAR(45) NULL DEFAULT NULL, - TENANT_ID INTEGER DEFAULT 0, - PRIMARY KEY (ID), - CONSTRAINT fk_DM_DEVICE_DM_DEVICE_TYPE2 FOREIGN KEY (DEVICE_TYPE_ID ) - REFERENCES DM_DEVICE_TYPE (ID ) ON DELETE NO ACTION ON UPDATE NO ACTION -); \ No newline at end of file +-- ----------------------------------------------------- +-- Table `MBL_DEVICE` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `MBL_DEVICE` ( + `MOBILE_DEVICE_ID` VARCHAR(45) NOT NULL , + `REG_ID` VARCHAR(45) NULL DEFAULT NULL , + `IMEI` VARCHAR(45) NULL DEFAULT NULL , + `IMSI` VARCHAR(45) NULL DEFAULT NULL , + `OS_VERSION` VARCHAR(45) NULL DEFAULT NULL , + `DEVICE_MODEL` VARCHAR(45) NULL DEFAULT NULL , + `VENDOR` VARCHAR(45) NULL DEFAULT NULL , + `LATITUDE` VARCHAR(45) NULL DEFAULT NULL, + `LONGITUDE` VARCHAR(45) NULL DEFAULT NULL, + PRIMARY KEY (`MOBILE_DEVICE_ID`) ); + + +-- ----------------------------------------------------- +-- Table `MBL_FEATURE` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `MBL_FEATURE` ( + `FEATURE_ID` INT NOT NULL AUTO_INCREMENT , + `CODE` VARCHAR(45) NOT NULL , + `NAME` VARCHAR(100) NULL , + `DESCRIPTION` VARCHAR(200) NULL , + PRIMARY KEY (`FEATURE_ID`) ); + +-- ----------------------------------------------------- +-- Table `MBL_OPERATION` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `MBL_OPERATION` ( + `OPERATION_ID` INT NOT NULL AUTO_INCREMENT , + `FEATURE_CODE` VARCHAR(45) NOT NULL , + `CREATED_DATE` BIGINT NULL , + PRIMARY KEY (`OPERATION_ID`)); + +-- ----------------------------------------------------- +-- Table `MBL_DEVICE_OPERATION_MAPPING` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `MBL_DEVICE_OPERATION_MAPPING` ( + `DEVICE_ID` VARCHAR(45) NOT NULL , + `OPERATION_ID` INT NOT NULL , + `SENT_DATE` BIGINT NULL , + `RECEIVED_DATE` BIGINT NULL , + PRIMARY KEY (`DEVICE_ID`, `OPERATION_ID`) , + CONSTRAINT `fk_MBL_DEVICE_OPERATION_MBL_DEVICE` + FOREIGN KEY (`DEVICE_ID` ) + REFERENCES `MBL_DEVICE` (`MOBILE_DEVICE_ID` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT `fk_MBL_DEVICE_OPERATION_MBL_OPERATION1` + FOREIGN KEY (`OPERATION_ID` ) + REFERENCES `MBL_OPERATION` (`OPERATION_ID` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION); + +-- ----------------------------------------------------- +-- Table `MBL_OPERATION_PROPERTY` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `MBL_OPERATION_PROPERTY` ( + `OPERATION_ID` INT NOT NULL , + `PROPERTY` VARCHAR(45) NOT NULL , + `VALUE` TEXT NULL , + PRIMARY KEY (`OPERATION_ID`, `PROPERTY`) , + CONSTRAINT `fk_MBL_OPERATION_PROPERTY_MBL_OPERATION1` + FOREIGN KEY (`OPERATION_ID` ) + REFERENCES `MBL_OPERATION` (`OPERATION_ID` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION); + +-- ----------------------------------------------------- +-- Table `MBL_FEATURE_PROPERTY` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `MBL_FEATURE_PROPERTY` ( + `PROPERTY` VARCHAR(45) NOT NULL , + `FEATURE_ID` VARCHAR(45) NOT NULL , + PRIMARY KEY (`PROPERTY`) , + CONSTRAINT `fk_MBL_FEATURE_PROPERTY_MBL_FEATURE1` + FOREIGN KEY (`FEATURE_ID` ) + REFERENCES `MBL_FEATURE` (`FEATURE_ID` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/testdbconfig.xml b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/testdbconfig.xml index 34e89a1392..d28ebbf8c5 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/testdbconfig.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/testdbconfig.xml @@ -16,7 +16,7 @@ - jdbc:h2:mem:cdm-test-db;DB_CLOSE_DELAY=-1 + jdbc:h2:mem:cdm-mobile-test-db;DB_CLOSE_DELAY=-1 org.h2.Driver diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/testng.xml b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/testng.xml index 8bdba93ad7..2048666886 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/testng.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/testng.xml @@ -15,13 +15,12 @@ - + - diff --git a/product/modules/distribution/src/assembly/bin.xml b/product/modules/distribution/src/assembly/bin.xml index d9f01fee5b..7420ae1f65 100644 --- a/product/modules/distribution/src/assembly/bin.xml +++ b/product/modules/distribution/src/assembly/bin.xml @@ -460,5 +460,15 @@ 644 + + + + ../distribution/src/repository/database/WSO2MobileDM_DB.h2.db + + ${pom.artifactId}-${pom.version}/repository/database + WSO2MobileDM_DB.h2.db + 644 + + diff --git a/product/modules/distribution/src/repository/database/WSO2MobileDM_DB.h2.db b/product/modules/distribution/src/repository/database/WSO2MobileDM_DB.h2.db new file mode 100644 index 0000000000000000000000000000000000000000..78086440fdc9634924760809b633ef648247456a GIT binary patch literal 45056 zcmeI4-*4ks701)bO+1s?GR-8VlNma5v$NAAyUvW0IKPAta_rmIYGMc5=}ZCP?X*+0 zAo0Qqb_L>L1wsh%vTw^@fIx@`q!lj+iG78CU|#?sArSDeZ%F$v96PoXw@IARmd#Wr z(nPg$e9yU`dwlOC_v=$G)9or19@ZaqXt_*N@NedEEOs>(kH_$Z1dsp{Kmter3B14r zep>$XUx(q7-V59f3>^s|0VIF~kN^@m1p!?DPXP-}kpL1v0!RP}ToMAw#4FFAbC;wu z*bO9r1dsp{Kmtf$E&}N{KXUAz!|O&ec4LYA=QZvRDekw++|NG6y_e>`f0O%Wmiy8w zr{3b)x48#*xXfK{>0a`qeDW`IIY1*MfCP{L5TLNDpxAP=d3Z2POl6%!Zqk;`zC2M(-;r(;aZWfNq{;}ImhLX%f|4h%l zim&k^N$1H5?RpU%G69ar3Q7Bx!}iO0e%ywqJh|yx?09XJ@zC|e|tNzD+6X~D-5=Lb;Mq*r@`$jYQt9DZOY~sVuCH6i~{w~Eo{v?JBeIfxQ zaNz_*3 zxeGn+dp#bz*zZ8dm_~Fga0tsKU4GkZRhEFQ5}iB66s$ea0WXtwB}3kpjG|aCQBAj~ zHt2SF*JP9&bdpi3L_Pyle={v-o%SV5)wN(mW@qh5dpB=`)8WhwPTNlIPR_u-usz6J8*|4fq~D{NPl znLTpZllpyC+nTMRK6w>9JP@=oOF=zJ{U6bqr~hyMkLv3+81QdPXp$@p=~w5whnvUlVb9&jm6z|uX>pJY+{%B9x|OFk>)y~o+cR$2QA87O zdXs6EtvJuIbkr@F6NdM>!DOcHGUenarUg&(n1R2FFna1DRm$FSfB#=Q*O?U?Ljp(u z2_OL^fCLtrKsM*D|Jj8O5`#kmNB{{S0VIF~&Xqv=p1c2_Nt|n|*ccK(0!RP}AOR$> z$OO_qdL6=Z_Wx5$+@Ipy2MO*M9QWQe?w#x0*Ort2xRLluI&nQiezM4&z}S!g5_s_m zyb8O_Z%-+iH{3X#qD2_nQkFtn$|rZUr|u<7CD=;V=G#h^CT=C4+&?cm+K+gI_G8$y zVU4`w@dmrLCu`*yYzsEWLk0@llm^}Lf_iF?sgWjTl!OO*=r<>l{sBQY?c;^kvguga3qflir_bF?7tA2fy5 z{?UHBQ9U@U9~S7gWNyJ1JfzcSt#818*r*F+NSzNMk|e4OMIDbeA%(|M&EWzdD_-q zpHU%CH}=Or>+153Z9!J(1B+G#K}dfq2lIxj|6AqWT}!ID#K(6M@2n@X_u?Ps<3GF~ zzxLwKE7$`h5JiC8gvIBrDT_~_$cbKm+M)F)xNx?PsZG+b`1IymeA>qrpTNg4!PyEd zKEJ*avG|NGo~$?Ymz1Ig3PPBM9Wf!4^Yx3!ntL!g^=y-UVc=BbwPnVtb-7xxg-)$u zi%Pw1OKq`cSH+s3NNrZD2xCQG-O8`FrNgW@T)6yp&eD9ilB^6%QE2rD3n+(lLZYcu z=@GrZ{D#NvJR+i?z%pQhSFLSYp&izR<;rxr?atH>A@AOtl6PJ`+~}+mLs>T}qdTMY zt5}AVQ|C)L@mR`v4#w*p^N?*HL}i6rWb{|Y|;7qvj(=STnvAOR$R1TGJOblhG4Um};MOV|@6fCP{L5 getAllOperations( + public List getPendingOperations( @PathParam("id") String id) throws AndroidAgentException { @@ -52,7 +52,7 @@ public class Operation { DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id); operations = dmService.getOperationManager( DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID) - .getOperations(deviceIdentifier); + .getPendingOperations(deviceIdentifier); Response.status(HttpStatus.SC_OK); return operations; } catch (DeviceManagementServiceException deviceMgtServiceEx) { 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 deleted file mode 100644 index 453eefdd21..0000000000 --- a/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/beans/package-info.java +++ /dev/null @@ -1,27 +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. - */ - -@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 From 2b3ee5e4f2409e5f00935698142825a72529ebe2 Mon Sep 17 00:00:00 2001 From: harshanL Date: Thu, 22 Jan 2015 22:33:26 +0530 Subject: [PATCH 12/12] Added package-info.java --- .../api/windows/wstep/beans/package-info.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/beans/package-info.java 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 0000000000..11f6f3452d --- /dev/null +++ b/product/modules/mobileservices/agents/windows/jax-rs/src/main/java/cdm/api/windows/wstep/beans/package-info.java @@ -0,0 +1,28 @@ + +/* + * 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 cdm.api.windows.wstep.beans; + +import javax.xml.bind.annotation.XmlNs; +import javax.xml.bind.annotation.XmlSchema;