From b96d561ef0c138980219532207c68b1e796ea0e9 Mon Sep 17 00:00:00 2001 From: manoj Date: Fri, 23 Jan 2015 11:02:25 +0530 Subject: [PATCH 1/3] License Manaproduct/modules/mobileservices/agents/android/jax-rs/src/main/java/org/wso2/cdmserver/mobileservices/android/util/AndroidAPIUtils.javagement --- .../java/org/wso2/cdmserver/mobileservices/android/Device.java | 1 + .../org/wso2/cdmserver/mobileservices/android/Operation.java | 2 ++ .../cdmserver/mobileservices/android/util/AndroidAPIUtils.java | 2 ++ 3 files changed, 5 insertions(+) diff --git a/product/modules/mobileservices/agents/android/jax-rs/src/main/java/org/wso2/cdmserver/mobileservices/android/Device.java b/product/modules/mobileservices/agents/android/jax-rs/src/main/java/org/wso2/cdmserver/mobileservices/android/Device.java index 037d5cf305..84a514f2aa 100644 --- a/product/modules/mobileservices/agents/android/jax-rs/src/main/java/org/wso2/cdmserver/mobileservices/android/Device.java +++ b/product/modules/mobileservices/agents/android/jax-rs/src/main/java/org/wso2/cdmserver/mobileservices/android/Device.java @@ -137,6 +137,7 @@ public class Device { @Produces("text/plain") public String getLicense() { //TODO: need to implement fetch license from core + // AndroidAPIUtils.getDeviceManagementService().updateDeviceInfo(device); return "License Agreement"; } } diff --git a/product/modules/mobileservices/agents/android/jax-rs/src/main/java/org/wso2/cdmserver/mobileservices/android/Operation.java b/product/modules/mobileservices/agents/android/jax-rs/src/main/java/org/wso2/cdmserver/mobileservices/android/Operation.java index 4255364977..9136e9f47c 100644 --- a/product/modules/mobileservices/agents/android/jax-rs/src/main/java/org/wso2/cdmserver/mobileservices/android/Operation.java +++ b/product/modules/mobileservices/agents/android/jax-rs/src/main/java/org/wso2/cdmserver/mobileservices/android/Operation.java @@ -79,6 +79,8 @@ public class Operation { Message responseMsg = new Message(); try { dmService = AndroidAPIUtils.getDeviceManagementService(); + + //TODO: need to complete getOperation logic boolean result = dmService.getOperationManager("").addOperation(null, null); if (result) { Response.status(HttpStatus.SC_OK); diff --git a/product/modules/mobileservices/agents/android/jax-rs/src/main/java/org/wso2/cdmserver/mobileservices/android/util/AndroidAPIUtils.java b/product/modules/mobileservices/agents/android/jax-rs/src/main/java/org/wso2/cdmserver/mobileservices/android/util/AndroidAPIUtils.java index 9ac3ec0573..9696a14700 100644 --- a/product/modules/mobileservices/agents/android/jax-rs/src/main/java/org/wso2/cdmserver/mobileservices/android/util/AndroidAPIUtils.java +++ b/product/modules/mobileservices/agents/android/jax-rs/src/main/java/org/wso2/cdmserver/mobileservices/android/util/AndroidAPIUtils.java @@ -20,6 +20,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.device.mgt.common.*; +import org.wso2.carbon.device.mgt.core.LicenseManager; import org.wso2.carbon.device.mgt.core.service.DeviceManagementService; import org.wso2.carbon.utils.multitenancy.MultitenantConstants; @@ -56,4 +57,5 @@ public class AndroidAPIUtils { PrivilegedCarbonContext.endTenantFlow(); return dmService; } + } From 4974d49320232d391b45ac8cb7ec4ded16d46856 Mon Sep 17 00:00:00 2001 From: manoj Date: Fri, 23 Jan 2015 13:49:27 +0530 Subject: [PATCH 2/3] License Management --- .../mobileservices/android/Device.java | 24 +++++++++++++------ .../android/util/AndroidAPIUtils.java | 21 +++++++++++++++- 2 files changed, 37 insertions(+), 8 deletions(-) diff --git a/product/modules/mobileservices/agents/android/jax-rs/src/main/java/org/wso2/cdmserver/mobileservices/android/Device.java b/product/modules/mobileservices/agents/android/jax-rs/src/main/java/org/wso2/cdmserver/mobileservices/android/Device.java index 84a514f2aa..0a9e01ffce 100644 --- a/product/modules/mobileservices/agents/android/jax-rs/src/main/java/org/wso2/cdmserver/mobileservices/android/Device.java +++ b/product/modules/mobileservices/agents/android/jax-rs/src/main/java/org/wso2/cdmserver/mobileservices/android/Device.java @@ -17,15 +17,13 @@ */ package org.wso2.cdmserver.mobileservices.android; +import org.wso2.carbon.device.mgt.common.*; import org.wso2.cdmserver.mobileservices.android.common.AndroidAgentException; import org.wso2.cdmserver.mobileservices.android.util.AndroidAPIUtils; import org.wso2.cdmserver.mobileservices.android.util.Message; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.common.DeviceIdentifier; -import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; -import org.wso2.carbon.device.mgt.common.DeviceManagementException; -import org.wso2.carbon.device.mgt.common.DeviceManagementServiceException; + import javax.ws.rs.*; import javax.ws.rs.core.Response; import java.util.List; @@ -132,12 +130,24 @@ public class Device { } } - @POST + @GET @Path("/device/license") @Produces("text/plain") public String getLicense() { //TODO: need to implement fetch license from core - // AndroidAPIUtils.getDeviceManagementService().updateDeviceInfo(device); - return "License Agreement"; + License license = null; + try { + try { + license = AndroidAPIUtils.getLicenseManagerService().getLicense(DeviceManagementConstants + .MobileDeviceTypes + .MOBILE_DEVICE_TYPE_ANDROID, DeviceManagementConstants.LanguageCodes.LANGUAGE_CODE_ENGLISH_US); + } catch (LicenseManagementException e) { + e.printStackTrace(); + } + }catch(DeviceManagementServiceException deviceMgtEx){ + deviceMgtEx.printStackTrace(); + } + + return license.getLicenseText(); } } diff --git a/product/modules/mobileservices/agents/android/jax-rs/src/main/java/org/wso2/cdmserver/mobileservices/android/util/AndroidAPIUtils.java b/product/modules/mobileservices/agents/android/jax-rs/src/main/java/org/wso2/cdmserver/mobileservices/android/util/AndroidAPIUtils.java index 9696a14700..39ee771de3 100644 --- a/product/modules/mobileservices/agents/android/jax-rs/src/main/java/org/wso2/cdmserver/mobileservices/android/util/AndroidAPIUtils.java +++ b/product/modules/mobileservices/agents/android/jax-rs/src/main/java/org/wso2/cdmserver/mobileservices/android/util/AndroidAPIUtils.java @@ -20,7 +20,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.device.mgt.common.*; -import org.wso2.carbon.device.mgt.core.LicenseManager; +import org.wso2.carbon.device.mgt.core.service.LicenseManagementService; import org.wso2.carbon.device.mgt.core.service.DeviceManagementService; import org.wso2.carbon.utils.multitenancy.MultitenantConstants; @@ -58,4 +58,23 @@ public class AndroidAPIUtils { return dmService; } + public static LicenseManagementService getLicenseManagerService() throws DeviceManagementServiceException{ + + //TODO: complete login change super tenent context + LicenseManagementService licenseManagementService; + PrivilegedCarbonContext.startTenantFlow(); + PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + ctx.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME); + ctx.setTenantId(MultitenantConstants.SUPER_TENANT_ID); + licenseManagementService = (LicenseManagementService) ctx.getOSGiService(LicenseManagementService.class, null); + + if (licenseManagementService == null){ + String msg = "License management service not initialized"; + log.error(msg); + throw new DeviceManagementServiceException(msg); + } + PrivilegedCarbonContext.endTenantFlow(); + return licenseManagementService; + } + } From 329f956f3d612d07feb8429de91bdfbc3704fb02 Mon Sep 17 00:00:00 2001 From: manoj Date: Fri, 23 Jan 2015 18:19:21 +0530 Subject: [PATCH 3/3] License Management --- .../src/repository/resources/rxts/license.rxt | 15 ++++++++++++--- .../cdmserver/mobileservices/android/Device.java | 4 +--- .../impl/CertificateEnrollmentServiceImpl.java | 15 +++++++++------ 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/product/modules/distribution/src/repository/resources/rxts/license.rxt b/product/modules/distribution/src/repository/resources/rxts/license.rxt index 72f5c2618a..2fc84c6db9 100644 --- a/product/modules/distribution/src/repository/resources/rxts/license.rxt +++ b/product/modules/distribution/src/repository/resources/rxts/license.rxt @@ -1,16 +1,19 @@ - /license/@{overview_provider}/@{overview_name}/@{overview_version} + /license/@{overview_provider}/@{overview_name}/@{overview_language}/@{overview_version} overview_name - + + + + @@ -24,11 +27,17 @@ Name + + Language + Version - Createdtime + Validity From + + + Validity To License diff --git a/product/modules/mobileservices/agents/android/jax-rs/src/main/java/org/wso2/cdmserver/mobileservices/android/Device.java b/product/modules/mobileservices/agents/android/jax-rs/src/main/java/org/wso2/cdmserver/mobileservices/android/Device.java index 0a9e01ffce..20af913fff 100644 --- a/product/modules/mobileservices/agents/android/jax-rs/src/main/java/org/wso2/cdmserver/mobileservices/android/Device.java +++ b/product/modules/mobileservices/agents/android/jax-rs/src/main/java/org/wso2/cdmserver/mobileservices/android/Device.java @@ -131,10 +131,9 @@ public class Device { } @GET - @Path("/device/license") + @Path("/license") @Produces("text/plain") public String getLicense() { - //TODO: need to implement fetch license from core License license = null; try { try { @@ -147,7 +146,6 @@ public class Device { }catch(DeviceManagementServiceException deviceMgtEx){ deviceMgtEx.printStackTrace(); } - return license.getLicenseText(); } } 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 index 32f8c35dcb..ca41e7394d 100644 --- 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 @@ -69,7 +69,8 @@ public class CertificateEnrollmentServiceImpl implements CertificateEnrollmentSe String wapProvisioningXmlFile; DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance(); - @Override public void RequestSecurityToken(String TokenType, String RequestType, + //@Override + public void RequestSecurityToken(String TokenType, String RequestType, String BinarySecurityToken, AdditionalContext AdditionalContext, Holder response) { @@ -109,18 +110,20 @@ public class CertificateEnrollmentServiceImpl implements CertificateEnrollmentSe NodeList wapParm = dDoc.getElementsByTagName("parm"); ///////// - wapParm.item(0).getParentNode().getAttributes().getNamedItem("type").setTextContent(String.valueOf( + /* 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()))); - ///////// + ///////// + ///////// +/* + wapParm.item(1).getParentNode().getAttributes().getNamedItem("type").setTextContent(String.valueOf(DigestUtils.sha1Hex(signedCert.getEncoded()))); +*/