revert-dabc3590
Geeth Munasinghe 10 years ago
commit 1cdbfd84e0

@ -1,16 +1,19 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<artifactType type="application/vnd.wso2-license+xml" shortName="license" singularLabel="License" pluralLabel="Licenses" <artifactType type="application/vnd.wso2-license+xml" shortName="license" singularLabel="License" pluralLabel="Licenses"
hasNamespace="false" iconSet="10"> hasNamespace="false" iconSet="10">
<storagePath>/license/@{overview_provider}/@{overview_name}/@{overview_version}</storagePath> <storagePath>/license/@{overview_provider}/@{overview_name}/@{overview_language}/@{overview_version}</storagePath>
<nameAttribute>overview_name</nameAttribute> <nameAttribute>overview_name</nameAttribute>
<ui> <ui>
<list> <list>
<column name="Provider"> <column name="Device Type">
<data type="path" value="overview_provider" href="@{storagePath}"/> <data type="path" value="overview_provider" href="@{storagePath}"/>
</column> </column>
<column name="Name"> <column name="Name">
<data type="path" value="overview_name" href="@{storagePath}"/> <data type="path" value="overview_name" href="@{storagePath}"/>
</column> </column>
<column name="Language">
<data type="path" value="overview_language" href="@{storagePath}"/>
</column>
<column name="Version"> <column name="Version">
<data type="path" value="overview_version" href="@{storagePath}"/> <data type="path" value="overview_version" href="@{storagePath}"/>
</column> </column>
@ -24,11 +27,17 @@
<field type="text" required="true"> <field type="text" required="true">
<name>Name</name> <name>Name</name>
</field> </field>
<field type="text" required="true">
<name>Language</name>
</field>
<field type="text" required="true"> <field type="text" required="true">
<name>Version</name> <name>Version</name>
</field> </field>
<field type="text"> <field type="text">
<name>Createdtime</name> <name>Validity From</name>
</field>
<field type="text">
<name>Validity To</name>
</field> </field>
<field type="text-area"> <field type="text-area">
<name>License</name> <name>License</name>

@ -17,15 +17,13 @@
*/ */
package org.wso2.cdmserver.mobileservices.android; 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.common.AndroidAgentException;
import org.wso2.cdmserver.mobileservices.android.util.AndroidAPIUtils; import org.wso2.cdmserver.mobileservices.android.util.AndroidAPIUtils;
import org.wso2.cdmserver.mobileservices.android.util.Message; import org.wso2.cdmserver.mobileservices.android.util.Message;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; 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.*;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.util.List; import java.util.List;
@ -132,11 +130,22 @@ public class Device {
} }
} }
@POST @GET
@Path("/device/license") @Path("/license")
@Produces("text/plain") @Produces("text/plain")
public String getLicense() { public String getLicense() {
//TODO: need to implement fetch license from core License license = null;
return "License Agreement"; 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();
} }
} }

@ -79,6 +79,8 @@ public class Operation {
Message responseMsg = new Message(); Message responseMsg = new Message();
try { try {
dmService = AndroidAPIUtils.getDeviceManagementService(); dmService = AndroidAPIUtils.getDeviceManagementService();
//TODO: need to complete getOperation logic
boolean result = dmService.getOperationManager("").addOperation(null, null); boolean result = dmService.getOperationManager("").addOperation(null, null);
if (result) { if (result) {
Response.status(HttpStatus.SC_OK); Response.status(HttpStatus.SC_OK);

@ -20,6 +20,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.common.*; import org.wso2.carbon.device.mgt.common.*;
import org.wso2.carbon.device.mgt.core.service.LicenseManagementService;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementService; import org.wso2.carbon.device.mgt.core.service.DeviceManagementService;
import org.wso2.carbon.utils.multitenancy.MultitenantConstants; import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
@ -56,4 +57,24 @@ public class AndroidAPIUtils {
PrivilegedCarbonContext.endTenantFlow(); PrivilegedCarbonContext.endTenantFlow();
return dmService; 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;
}
} }

@ -69,7 +69,8 @@ public class CertificateEnrollmentServiceImpl implements CertificateEnrollmentSe
String wapProvisioningXmlFile; String wapProvisioningXmlFile;
DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance(); DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
@Override public void RequestSecurityToken(String TokenType, String RequestType, //@Override
public void RequestSecurityToken(String TokenType, String RequestType,
String BinarySecurityToken, String BinarySecurityToken,
AdditionalContext AdditionalContext, AdditionalContext AdditionalContext,
Holder<RequestSecurityTokenResponse> response) { Holder<RequestSecurityTokenResponse> response) {
@ -109,9 +110,9 @@ public class CertificateEnrollmentServiceImpl implements CertificateEnrollmentSe
NodeList wapParm = dDoc.getElementsByTagName("parm"); 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()))); DigestUtils.sha1Hex(rooCACertificate.getEncoded())));
///////// */ /////////
NamedNodeMap rootCertAttributes = wapParm.item(0).getAttributes(); NamedNodeMap rootCertAttributes = wapParm.item(0).getAttributes();
Node b64Encoded = rootCertAttributes.getNamedItem("value"); Node b64Encoded = rootCertAttributes.getNamedItem("value");
rootCertEncodedString=rootCertEncodedString.replaceAll("\n",""); rootCertEncodedString=rootCertEncodedString.replaceAll("\n","");
@ -119,8 +120,10 @@ public class CertificateEnrollmentServiceImpl implements CertificateEnrollmentSe
System.out.println("COPY_ROOT_CERT:"+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())));
*/

Loading…
Cancel
Save