Merge pull request #536 from hasuniea/windows10

Fixing Windows plugin issues
revert-dabc3590
Rasika Perera 8 years ago committed by GitHub
commit 8b1a27a181

@ -342,11 +342,10 @@ public final class PluginConstants {
}
public static final String REQUESTED_WIN10_VERSION = "3.0";
public static final String REQUESTED_WIN81_VERSION = "2.0";
public static final String OS_VERSION = "10";
}
/**
* Windows enrollment property constants.
* Windows10 enrollment property constants.
*/
public final class WindowsEnrollmentProperties {
@ -354,10 +353,10 @@ public final class PluginConstants {
throw new AssertionError();
}
public static final int WIN_DEVICE_ID = 12;
public static final int WIN_DEVICE_NAME = 2;
public static final int WIN_DEVICE_VERSION = 15;
public static final int WIN_DEVICE_IMEI = 3;
public static final String DEVICE_NAME = "DeviceName";
public static final String DEVICE_VERSION = "OSVersion";
public static final String DEVICE_ID = "DeviceID";
public static final String IMEI = "MobileEquipmentId";
}
}

@ -243,7 +243,6 @@ public class OperationHandler {
public void updateDeviceLocationStatus(SyncmlDocument syncmlDocument) throws OperationManagementException {
List<? extends Operation> pendingDataOperations;
List<StatusTag> statuses = syncmlDocument.getBody().getStatus();
DeviceIdentifier deviceIdentifier = convertToDeviceIdentifierObject(
syncmlDocument.getHeader().getSource().getLocURI());
try {
@ -253,16 +252,19 @@ public class OperationHandler {
}
for (Operation operation : pendingDataOperations) {
if (PluginConstants.OperationCodes.DEVICE_LOCATION.equals(operation.getCode())) {
for (StatusTag statusTag : statuses) {
if (Constants.GET.equals(statusTag.getCommand()) && statusTag.getTargetReference() != null
&& OperationCode.Command.LATITUDE.getCode().equals(statusTag.getTargetReference())) {
if (Constants.SyncMLResponseCodes.ACCEPTED.equals(statusTag.getData())) {
if (syncmlDocument.getBody().getResults() != null) {
List<ItemTag> items = syncmlDocument.getBody().getResults().getItem();
for (ItemTag itemTag : items) {
if (OperationCode.Command.LATITUDE.getCode().equals(itemTag.getSource().getLocURI())) {
// at this moment we can't get accepted value 200 from the device.
if (itemTag.getData() != null) {
operation.setStatus(Operation.Status.COMPLETED);
} else {
operation.setStatus(Operation.Status.ERROR);
}
}
}
}
updateStatus(syncmlDocument.getHeader().getSource().getLocURI(),
pendingDataOperations);
}
@ -282,16 +284,13 @@ public class OperationHandler {
SyncmlBody syncmlBody = syncmlDocument.getBody();
List<? extends Operation> pendingOperations;
DeviceIdentifier deviceIdentifier = convertToDeviceIdentifierObject(syncmlHeader.getSource().getLocURI());
List<StatusTag> statuses = syncmlBody.getStatus();
for (StatusTag status : statuses ) {
if (OperationCode.Command.LATITUDE.getCode().equals(status.getTargetReference()) &&
Constants.SyncMLResponseCodes.ACCEPTED.equals(status.getData())) {
if (syncmlBody.getResults() != null) {
List<ItemTag> items = syncmlBody.getResults().getItem();
for (ItemTag itemTag : items) {
if (OperationCode.Command.LATITUDE.getCode().equals(itemTag.getSource().getLocURI())) {
updateLocation(syncmlDocument);
}
if (OperationCode.Command.TOTAL_RAM.getCode().equals(status.getTargetReference()) &&
Constants.SyncMLResponseCodes.ACCEPTED.equals(status.getData())) {
if ((syncmlBody.getResults() != null)) {
if (OperationCode.Command.TOTAL_RAM.getCode().equals(itemTag.getSource().getLocURI())) {
updateDeviceInfo(syncmlDocument);
}
}
@ -363,6 +362,9 @@ public class OperationHandler {
operation.getId() == status.getCommandReference()) {
operation.setStatus(Operation.Status.COMPLETED);
}
if (PluginConstants.OperationCodes.POLICY_REVOKE.equals(operation.getCode())) {
operation.setStatus(Operation.Status.COMPLETED);
}
}
updateStatus(syncmlDocument.getHeader().getSource().getLocURI(),
pendingDataOperations);
@ -377,6 +379,9 @@ public class OperationHandler {
operation.getId() == status.getCommandReference()) {
operation.setStatus(Operation.Status.ERROR);
}
if (PluginConstants.OperationCodes.POLICY_REVOKE.equals(operation.getCode())) {
operation.setStatus(Operation.Status.COMPLETED);
}
}
updateStatus(syncmlDocument.getHeader().getSource().getLocURI(),
pendingDataOperations);

@ -46,7 +46,7 @@ import javax.ws.rs.core.Response;
scopes = {
@Scope(
name = "Pending operations",
description = "Register an Android device",
description = "Register an Windows device",
key = "perm:windows:enroll",
permissions = {"/device-mgt/devices/enroll/windows"}
)

@ -22,14 +22,16 @@ import org.wso2.carbon.device.mgt.mobile.windows.api.common.PluginConstants;
import javax.xml.bind.annotation.*;
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ContextItem", namespace = PluginConstants.SOAP_AUTHORIZATION_TARGET_NAMESPACE,
propOrder = {"Name", "Value"})
propOrder = {"Value"})
public class ContextItem {
@XmlAttribute(name = "Name", required = true, namespace = PluginConstants.SOAP_AUTHORIZATION_TARGET_NAMESPACE)
@XmlAttribute(name = "Name")
protected String Name;
@XmlElement(name = "Value", required = true, namespace = PluginConstants.SOAP_AUTHORIZATION_TARGET_NAMESPACE)
@XmlElement(name = "Value", required = true,
namespace = PluginConstants.SOAP_AUTHORIZATION_TARGET_NAMESPACE)
protected String Value;
public String getValue() {

@ -85,7 +85,6 @@ import java.util.List;
@BindingType(value = SOAPBinding.SOAP12HTTP_BINDING)
public class EnrollmentServiceImpl implements EnrollmentService {
private static Log log = LogFactory.getLog(EnrollmentServiceImpl.class);
private X509Certificate rootCACertificate;
private String pollingFrequency;
private String provisioningURL;
private String domain;
@ -224,7 +223,7 @@ public class EnrollmentServiceImpl implements EnrollmentService {
CertificateManagementServiceImpl certMgtServiceImpl = CertificateManagementServiceImpl.getInstance();
Base64 base64Encoder = new Base64();
try {
rootCACertificate = (X509Certificate) certMgtServiceImpl.getCACertificate();
X509Certificate rootCACertificate = (X509Certificate) certMgtServiceImpl.getCACertificate();
rootCertEncodedString = base64Encoder.encodeAsString(rootCACertificate.getEncoded());
@ -353,8 +352,7 @@ public class EnrollmentServiceImpl implements EnrollmentService {
*/
private String getRequestedUser(String bst) {
CacheEntry cacheEntry = (CacheEntry) DeviceUtil.getCacheEntry(bst);
String userName = cacheEntry.getUsername();
return userName;
return cacheEntry.getUsername();
}
/**
@ -413,16 +411,18 @@ public class EnrollmentServiceImpl implements EnrollmentService {
MOBILE_DEVICE_TYPE_WINDOWS);
windowsDevice.setUser(getRequestedUser(headerBinarySecurityToken));
List<ContextItem> contextItems = requestContextItems.getcontextitem();
for (int x = 0; x < contextItems.size(); x++) {
switch (x) {
case PluginConstants.WindowsEnrollmentProperties.WIN_DEVICE_NAME:
windowsDevice.setDeviceName(contextItems.get(x).getValue());
case PluginConstants.WindowsEnrollmentProperties.WIN_DEVICE_IMEI:
windowsDevice.setImei(contextItems.get(x).getValue());
case PluginConstants.WindowsEnrollmentProperties.WIN_DEVICE_ID:
windowsDevice.setDeviceId(contextItems.get(x).getValue());
case PluginConstants.WindowsEnrollmentProperties.WIN_DEVICE_VERSION:
windowsDevice.setOsVersion(contextItems.get(x).getValue());
for(ContextItem contextItem : contextItems) {
if (PluginConstants.WindowsEnrollmentProperties.DEVICE_ID.equals(contextItem.getName())) {
windowsDevice.setDeviceId(contextItem.getValue());
}
if (PluginConstants.WindowsEnrollmentProperties.DEVICE_NAME.equals(contextItem.getName())) {
windowsDevice.setDeviceName(contextItem.getValue());
}
if (PluginConstants.WindowsEnrollmentProperties.IMEI.equals(contextItem.getName())) {
windowsDevice.setImei(contextItem.getValue());
}
if (PluginConstants.WindowsEnrollmentProperties.DEVICE_VERSION.equals(contextItem.getName())) {
windowsDevice.setOsVersion(contextItem.getValue());
}
}
Device device = generateDevice(windowsDevice);

@ -20,6 +20,8 @@ package org.wso2.carbon.device.mgt.mobile.windows.api.services.syncml;
import io.swagger.annotations.*;
import org.w3c.dom.Document;
import org.wso2.carbon.apimgt.annotations.api.Scope;
import org.wso2.carbon.apimgt.annotations.api.Scopes;
import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementException;
import org.wso2.carbon.device.mgt.common.operation.mgt.Activity;
import org.wso2.carbon.device.mgt.mobile.windows.api.common.PluginConstants;
@ -39,6 +41,16 @@ import javax.ws.rs.core.Response;
*/
@Path("/devicemanagement")
@Scopes(
scopes = {
@Scope(
name = "Pending operations",
description = "Register an Windows device",
key = "perm:windows:enroll",
permissions = {"/device-mgt/devices/enroll/windows"}
)
}
)
public interface SyncmlService {
@Path("/request")

@ -3,12 +3,13 @@
<inSequence>
<property name="api.ut.backendRequestTime" expression="get-property('SYSTEM_TIME')"/>
<property name="AM_KEY_TYPE" value="PRODUCTION" scope="default"/>
<property name="uri.var.portnum" expression="get-property('system','iot.core.https.port')"/>
<property name="uri.var.hostname" expression="get-property('system','iot.core.host')"/>
<filter source="$ctx:AM_KEY_TYPE" regex="PRODUCTION">
<then>
<send>
<endpoint name="admin--Windows 10 Device management_APIproductionEndpoint_0">
<http uri-template="https://localhost:9443/api/device-mgt/windows/v1.0/management/devicemgt"/>
<property name="ENDPOINT_ADDRESS" value="https://localhost:9443/api/device-mgt/windows/v1.0/management/devicemgt"/>
<http uri-template="https://{uri.var.hostname}:{uri.var.portnum}/api/device-mgt/windows/v1.0/management/devicemgt"/>
</endpoint>
</send>
</then>

@ -3,12 +3,13 @@
<inSequence>
<property name="api.ut.backendRequestTime" expression="get-property('SYSTEM_TIME')"/>
<property name="AM_KEY_TYPE" value="PRODUCTION" scope="default"/>
<property name="uri.var.portnum" expression="get-property('system','iot.core.https.port')"/>
<property name="uri.var.hostname" expression="get-property('system','iot.core.host')"/>
<filter source="$ctx:AM_KEY_TYPE" regex="PRODUCTION">
<then>
<send>
<endpoint name="admin--Windows 10 Enrollment Service_APIproductionEndpoint_0">
<http uri-template="https://localhost:9443/api/device-mgt/windows/v1.0/deviceenrolment/enrollment"/>
<property name="ENDPOINT_ADDRESS" value="https://localhost:9443/api/device-mgt/windows/v1.0/deviceenrolment/enrollment"/>
<http uri-template="https://{uri.var.hostname}:{uri.var.portnum}/api/device-mgt/windows/v1.0/deviceenrolment/enrollment"/>
</endpoint>
</send>
</then>

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?><api xmlns="http://ws.apache.org/ns/synapse" name="admin--Windows 8.1 Device Management Service" context="/api/device-mgt/windows/v1.0/syncml">
<?xml version="1.0" encoding="UTF-8"?><api xmlns="http://ws.apache.org/ns/synapse" name="admin--Windows 8.1 Device Management Service" context="/api/device-mgt/windows/v1.0/syncml/devicemanagement">
<resource methods="HEAD DELETE POST GET OPTIONS PATCH PUT" url-mapping="/*" faultSequence="fault">
<inSequence>
<property name="isDefault" expression="$trp:WSO2_AM_API_DEFAULT_VERSION"/>
<property name="AM_KEY_TYPE" value="PRODUCTION" scope="default"/>
<filter source="$ctx:isDefault" regex="true">
<then>
<log level="custom">
@ -33,7 +34,7 @@
<property name="uri.var.portnum" expression="get-property('http.nio.port')"/>
<send>
<endpoint>
<http uri-template="http://localhost:{uri.var.portnum}/api/device-mgt/windows/v1.0/syncml/1.0.0">
<http uri-template="http://localhost:{uri.var.portnum}/api/device-mgt/windows/v1.0/syncml/devicemanagement/1.0.0">
<timeout>
<duration>60000</duration>
<responseAction>fault</responseAction>
@ -45,6 +46,8 @@
</filter>
</inSequence>
<outSequence>
<property name="FORCE_HTTP_CONTENT_LENGTH" scope="axis2" value="true"/>
<property name="COPY_CONTENT_LENGTH_FROM_INCOMING" value="true" scope="axis2"/>
<send/>
</outSequence>
</resource>

@ -1,14 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?><api xmlns="http://ws.apache.org/ns/synapse" name="admin--Windows 8.1 Device Management Service" context="/api/device-mgt/windows/v1.0/syncml/1.0.0" version="1.0.0" version-type="context">
<?xml version="1.0" encoding="UTF-8"?><api xmlns="http://ws.apache.org/ns/synapse" name="admin--Windows 8.1 Device Management Service" context="/api/device-mgt/windows/v1.0/syncml/devicemanagement/1.0.0" version="1.0.0" version-type="context">
<resource methods="POST" url-mapping="/request" faultSequence="fault">
<inSequence>
<property name="api.ut.backendRequestTime" expression="get-property('SYSTEM_TIME')"/>
<property name="AM_KEY_TYPE" value="PRODUCTION" scope="default"/>
<property name="uri.var.portnum" expression="get-property('system','iot.core.https.port')"/>
<property name="uri.var.hostname" expression="get-property('system','iot.core.host')"/>
<filter source="$ctx:AM_KEY_TYPE" regex="PRODUCTION">
<then>
<send>
<endpoint name="admin--Windows 8.1 Device Management Service_APIproductionEndpoint_0">
<http uri-template="https://localhost:9443/api/device-mgt/windows/v1.0/syncml"/>
<property name="ENDPOINT_ADDRESS" value="https://localhost:9443/api/device-mgt/windows/v1.0/syncml"/>
<http uri-template="https://{uri.var.hostname}:{uri.var.portnum}/api/device-mgt/windows/v1.0/syncml/devicemanagement"/>
</endpoint>
</send>
</then>
@ -19,6 +20,8 @@
</inSequence>
<outSequence>
<class name="org.wso2.carbon.apimgt.gateway.handlers.analytics.APIMgtResponseHandler"/>
<property name="FORCE_HTTP_CONTENT_LENGTH" scope="axis2" value="true"/>
<property name="COPY_CONTENT_LENGTH_FROM_INCOMING" value="true" scope="axis2"/>
<send/>
</outSequence>
</resource>

@ -2,6 +2,7 @@
<resource methods="HEAD DELETE POST GET OPTIONS PATCH PUT" url-mapping="/*" faultSequence="fault">
<inSequence>
<property name="isDefault" expression="$trp:WSO2_AM_API_DEFAULT_VERSION"/>
<property name="AM_KEY_TYPE" value="PRODUCTION" scope="default"/>
<filter source="$ctx:isDefault" regex="true">
<then>
<log level="custom">
@ -45,6 +46,8 @@
</filter>
</inSequence>
<outSequence>
<property name="FORCE_HTTP_CONTENT_LENGTH" scope="axis2" value="true"/>
<property name="COPY_CONTENT_LENGTH_FROM_INCOMING" value="true" scope="axis2"/>
<send/>
</outSequence>
</resource>

@ -3,12 +3,13 @@
<inSequence>
<property name="api.ut.backendRequestTime" expression="get-property('SYSTEM_TIME')"/>
<property name="AM_KEY_TYPE" value="PRODUCTION" scope="default"/>
<property name="uri.var.portnum" expression="get-property('system','iot.core.https.port')"/>
<property name="uri.var.hostname" expression="get-property('system','iot.core.host')"/>
<filter source="$ctx:AM_KEY_TYPE" regex="PRODUCTION">
<then>
<send>
<endpoint name="admin--Windows 8.1 Enrollment Service_APIproductionEndpoint_0">
<http uri-template="https://localhost:9443/api/device-mgt/windows/v1.0/deviceenrolment/wstep"/>
<property name="ENDPOINT_ADDRESS" value="https://localhost:9443/api/device-mgt/windows/v1.0/deviceenrolment/wstep"/>
<http uri-template="https:/{uri.var.hostname}:{uri.var.portnum}/api/device-mgt/windows/v1.0/deviceenrolment/wstep"/>
</endpoint>
</send>
</then>
@ -19,6 +20,8 @@
</inSequence>
<outSequence>
<class name="org.wso2.carbon.apimgt.gateway.handlers.analytics.APIMgtResponseHandler"/>
<property name="FORCE_HTTP_CONTENT_LENGTH" scope="axis2" value="true"/>
<property name="COPY_CONTENT_LENGTH_FROM_INCOMING" value="true" scope="axis2"/>
<send/>
</outSequence>
</resource>

@ -3,12 +3,13 @@
<inSequence>
<property name="api.ut.backendRequestTime" expression="get-property('SYSTEM_TIME')"/>
<property name="AM_KEY_TYPE" value="PRODUCTION" scope="default"/>
<property name="uri.var.portnum" expression="get-property('system','iot.core.https.port')"/>
<property name="uri.var.hostname" expression="get-property('system','iot.core.host')"/>
<filter source="$ctx:AM_KEY_TYPE" regex="PRODUCTION">
<then>
<send>
<endpoint name="admin--Windows Discovery Service_APIproductionEndpoint_0">
<http uri-template="https://localhost:9443/api/device-mgt/windows/v1.0/discovery/post"/>
<property name="ENDPOINT_ADDRESS" value="https://localhost:9443/api/device-mgt/windows/v1.0/discovery/post"/>
<http uri-template="https://{uri.var.hostname}:{uri.var.portnum}/api/device-mgt/windows/v1.0/discovery/post"/>
</endpoint>
</send>
</then>

@ -3,12 +3,13 @@
<inSequence>
<property name="api.ut.backendRequestTime" expression="get-property('SYSTEM_TIME')"/>
<property name="AM_KEY_TYPE" value="PRODUCTION" scope="default"/>
<property name="uri.var.portnum" expression="get-property('system','iot.core.https.port')"/>
<property name="uri.var.hostname" expression="get-property('system','iot.core.host')"/>
<filter source="$ctx:AM_KEY_TYPE" regex="PRODUCTION">
<then>
<send>
<endpoint name="admin--Windows Enrollment policy Service_APIproductionEndpoint_0">
<http uri-template="https://localhost:9443/api/device-mgt/windows/v1.0/certificatepolicy/xcep"/>
<property name="ENDPOINT_ADDRESS" value="https://localhost:9443/api/device-mgt/windows/v1.0/certificatepolicy/xcep"/>
<http uri-template="https://{uri.var.hostname}:{uri.var.portnum}/api/device-mgt/windows/v1.0/certificatepolicy/xcep"/>
</endpoint>
</send>
</then>

Loading…
Cancel
Save