Merge branch 'release-3.0.x' of https://github.com/wso2/carbon-device-mgt-plugins into windows10

revert-dabc3590
Hasunie 8 years ago
commit 8bd06c60f2

@ -689,26 +689,29 @@ function intializeWebsocketUrls() {
wso2.gadgets.state.getGlobalState(function (state) { wso2.gadgets.state.getGlobalState(function (state) {
deviceId = state.device.id; deviceId = state.device.id;
deviceType = state.device.type; deviceType = state.device.type;
var hostname = window.parent.location.hostname;
var port = window.parent.location.port;
if (deviceId && deviceType) { if (deviceId && deviceType) {
//TODO need to get the token
wso2.gadgets.identity.getUsername(function (username) { wso2.gadgets.identity.getUsername(function (username) {
$.getJSON("/portal/store/carbon.super/fs/gadget/geo-dashboard/controllers/get_server_info.jag?username=" + username, function (data) { wso2.gadgets.identity.getAccessToken(function (accessToken) {
webSocketURL = 'wss://' + data.ip + ':' + data.httpsPort + ApplicationOptions.constance.PATH_SEPARATOR + ApplicationOptions.constance $.getJSON("/portal/store/carbon.super/fs/gadget/geo-dashboard/controllers/get_server_info.jag?username=" + username, function (data) {
.CEP_WEB_SOCKET_OUTPUT_ADAPTOR_WEBAPP_NAME + ApplicationOptions.constance.PATH_SEPARATOR + ApplicationOptions webSocketURL = 'wss://' + hostname + ':' + port + ApplicationOptions.constance.PATH_SEPARATOR + ApplicationOptions.constance
.constance.TENANT_INDEX + ApplicationOptions.constance.PATH_SEPARATOR + data.user.domain + .CEP_WEB_SOCKET_OUTPUT_ADAPTOR_WEBAPP_NAME + ApplicationOptions.constance.PATH_SEPARATOR + ApplicationOptions
ApplicationOptions.constance.PATH_SEPARATOR + ApplicationOptions.constance .constance.TENANT_INDEX + ApplicationOptions.constance.PATH_SEPARATOR + data.user.domain +
.CEP_WEB_SOCKET_OUTPUT_ADAPTOR_NAME + ApplicationOptions.constance.PATH_SEPARATOR + ApplicationOptions.constance.VERSION ApplicationOptions.constance.PATH_SEPARATOR + ApplicationOptions.constance
+ "?deviceId=" + deviceId + "&deviceType=" + deviceType; .CEP_WEB_SOCKET_OUTPUT_ADAPTOR_NAME + ApplicationOptions.constance.PATH_SEPARATOR + ApplicationOptions.constance.VERSION
alertWebSocketURL = 'wss://' + data.ip + ':' + data.httpsPort + ApplicationOptions.constance.PATH_SEPARATOR + ApplicationOptions.constance + "?deviceId=" + deviceId + "&deviceType=" + deviceType;
.CEP_WEB_SOCKET_OUTPUT_ADAPTOR_WEBAPP_NAME + ApplicationOptions.constance.PATH_SEPARATOR + ApplicationOptions alertWebSocketURL = 'wss://' + hostname + ':' + port + ApplicationOptions.constance.PATH_SEPARATOR + ApplicationOptions.constance
.constance.TENANT_INDEX + ApplicationOptions.constance.PATH_SEPARATOR + data.user.domain + .CEP_WEB_SOCKET_OUTPUT_ADAPTOR_WEBAPP_NAME + ApplicationOptions.constance.PATH_SEPARATOR + ApplicationOptions
ApplicationOptions.constance.PATH_SEPARATOR + ApplicationOptions.constance .constance.TENANT_INDEX + ApplicationOptions.constance.PATH_SEPARATOR + data.user.domain +
.CEP_ON_ALERT_WEB_SOCKET_OUTPUT_ADAPTOR_NAME + ApplicationOptions.constance.PATH_SEPARATOR + ApplicationOptions.constance.VERSION ApplicationOptions.constance.PATH_SEPARATOR + ApplicationOptions.constance
+ "?deviceId=" + deviceId + "&deviceType=" + deviceType; .CEP_ON_ALERT_WEB_SOCKET_OUTPUT_ADAPTOR_NAME + ApplicationOptions.constance.PATH_SEPARATOR + ApplicationOptions.constance.VERSION
document.cookie = "websocket-token=619e6170-10e8-31f0-904b-b7770d53e545; path=/"; + "?deviceId=" + deviceId + "&deviceType=" + deviceType;
$("#proximity_alert").hide(); document.cookie = "websocket-token=" + accessToken + "; path=/";
initializeWebSocket(); $("#proximity_alert").hide();
initializeOnAlertWebSocket(); initializeWebSocket();
initializeOnAlertWebSocket();
});
}); });
}); });
} else { } else {

@ -116,7 +116,7 @@ public class SenseClientAsyncExecutor extends AsyncTask<String, Void, Map<String
TokenIssuerService tokenIssuerService = Feign.builder().client(disableHostnameVerification).requestInterceptor( TokenIssuerService tokenIssuerService = Feign.builder().client(disableHostnameVerification).requestInterceptor(
new BasicAuthRequestInterceptor(apiApplicationKey.getConsumerKey(), apiApplicationKey.getConsumerSecret())) new BasicAuthRequestInterceptor(apiApplicationKey.getConsumerKey(), apiApplicationKey.getConsumerSecret()))
.contract(new JAXRSContract()).encoder(new JacksonEncoder()).decoder(new JacksonDecoder()) .contract(new JAXRSContract()).encoder(new JacksonEncoder()).decoder(new JacksonDecoder())
.target(TokenIssuerService.class, endpoint + SenseConstants.TOKEN_ISSUER_CONTEXT); .target(TokenIssuerService.class, endpoint);
accessTokenInfo = tokenIssuerService.getToken(PASSWORD_GRANT_TYPE, username, password, "device_" + deviceId); accessTokenInfo = tokenIssuerService.getToken(PASSWORD_GRANT_TYPE, username, password, "device_" + deviceId);
//DeviceRegister //DeviceRegister

@ -39,7 +39,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:hint="@string/hostname" android:layout_height="wrap_content" android:hint="@string/hostname"
android:id="@+id/hostname" android:id="@+id/hostname"
android:text="https://localhost:9443" android:text="https://localhost:8243"
android:inputType="text" android:inputType="text"
android:maxLines="1" android:singleLine="true"/> android:maxLines="1" android:singleLine="true"/>

@ -1,7 +1,7 @@
<resources> <resources>
<string name="app_name">WSO2-SenseAgent</string> <string name="app_name">WSO2-SenseAgent</string>
<string name="title_activity_sense_settings">Sense Settings</string> <string name="title_activity_sense_settings">Sense Settings</string>
<string name="hostname">Server URL https://host:9443</string> <string name="hostname">Server URL https://host:8243</string>
<string name="speakup">Speakup to capture the words</string> <string name="speakup">Speakup to capture the words</string>
<string name="action_settings">DeEnroll</string> <string name="action_settings">DeEnroll</string>
<string name="title_activity_activity_select_sensor">ActivitySelectSensor</string> <string name="title_activity_activity_select_sensor">ActivitySelectSensor</string>

@ -28,18 +28,10 @@
<param-name>isSharedWithAllTenants</param-name> <param-name>isSharedWithAllTenants</param-name>
<param-value>true</param-value> <param-value>true</param-value>
</context-param> </context-param>
<context-param>
<param-name>providerTenantDomain</param-name>
<param-value>carbon.super</param-value>
</context-param>
<!--publish to apim--> <!--publish to apim-->
<context-param> <context-param>
<param-name>managed-api-enabled</param-name> <param-name>managed-api-enabled</param-name>
<param-value>true</param-value> <param-value>true</param-value>
</context-param> </context-param>
<context-param>
<param-name>managed-api-owner</param-name>
<param-value>admin</param-value>
</context-param>
</web-app> </web-app>

@ -73,4 +73,20 @@
</div> </div>
</div> </div>
</div> </div>
<div class="panel panel-default tab-pane"
id="geo_dashboard" role="tabpanel" aria-labelledby="geo_dashboard">
<div class="panel-heading">Map</div>
<div id="chartWrapper">
</div>
<a class="padding-left"
href="{{portalUrl}}/portal/dashboards/geo-dashboard/?GLOBAL-STATE={{anchor}}">
<span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-statistics fw-stack-1x"></i>
</span> View Device Location
</a>
</div>
{{/zone}} {{/zone}}

@ -28,10 +28,13 @@ function onRequest(context) {
var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"];
var device = deviceModule.viewDevice(deviceType, deviceId); var device = deviceModule.viewDevice(deviceType, deviceId);
if (device && device.status != "error") { if (device && device.status != "error") {
var anchor = { "device" : { "id" : device.content.deviceIdentifier, "type" : device.content.type}};
return { return {
"device": device.content, "device": device.content,
"autoCompleteParams": autoCompleteParams, "autoCompleteParams": autoCompleteParams,
"encodedFeaturePayloads": "" "encodedFeaturePayloads": "",
"portalUrl" : devicemgtProps['portalURL'],
"anchor" : JSON.stringify(anchor)
}; };
} else { } else {
response.sendError(404, "Device Id " + deviceId + " of type " + deviceType + " cannot be found!"); response.sendError(404, "Device Id " + deviceId + " of type " + deviceType + " cannot be found!");

@ -28,19 +28,11 @@
<param-name>isSharedWithAllTenants</param-name> <param-name>isSharedWithAllTenants</param-name>
<param-value>true</param-value> <param-value>true</param-value>
</context-param> </context-param>
<context-param>
<param-name>providerTenantDomain</param-name>
<param-value>carbon.super</param-value>
</context-param>
<!--publish to apim--> <!--publish to apim-->
<context-param> <context-param>
<param-name>managed-api-enabled</param-name> <param-name>managed-api-enabled</param-name>
<param-value>true</param-value> <param-value>true</param-value>
</context-param> </context-param>
<context-param>
<param-name>managed-api-owner</param-name>
<param-value>admin</param-value>
</context-param>
</web-app> </web-app>

@ -75,4 +75,20 @@
</div> </div>
</div> </div>
</div> </div>
<div class="panel panel-default tab-pane"
id="geo_dashboard" role="tabpanel" aria-labelledby="geo_dashboard">
<div class="panel-heading">Map</div>
<div id="chartWrapper">
</div>
<a class="padding-left"
href="{{portalUrl}}/portal/dashboards/geo-dashboard/?GLOBAL-STATE={{anchor}}">
<span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-statistics fw-stack-1x"></i>
</span> View Device Location
</a>
</div>
{{/zone}} {{/zone}}

@ -28,7 +28,14 @@ function onRequest(context) {
var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"];
var device = deviceModule.viewDevice(deviceType, deviceId); var device = deviceModule.viewDevice(deviceType, deviceId);
if (device && device.status != "error") { if (device && device.status != "error") {
return {"device": device.content, "autoCompleteParams" : autoCompleteParams, "encodedFeaturePayloads": ""}; var anchor = { "device" : { "id" : device.content.deviceIdentifier, "type" : device.content.type}};
return {
"device": device.content,
"autoCompleteParams" : autoCompleteParams,
"encodedFeaturePayloads": "",
"portalUrl" : devicemgtProps['portalURL'],
"anchor" : JSON.stringify(anchor)
};
} else { } else {
response.sendError(404, "Device Id " + deviceId + " of type " + deviceType + " cannot be found!"); response.sendError(404, "Device Id " + deviceId + " of type " + deviceType + " cannot be found!");
exit(); exit();

@ -28,19 +28,11 @@
<param-name>isSharedWithAllTenants</param-name> <param-name>isSharedWithAllTenants</param-name>
<param-value>true</param-value> <param-value>true</param-value>
</context-param> </context-param>
<context-param>
<param-name>providerTenantDomain</param-name>
<param-value>carbon.super</param-value>
</context-param>
<!--publish to apim--> <!--publish to apim-->
<context-param> <context-param>
<param-name>managed-api-enabled</param-name> <param-name>managed-api-enabled</param-name>
<param-value>true</param-value> <param-value>true</param-value>
</context-param> </context-param>
<context-param>
<param-name>managed-api-owner</param-name>
<param-value>admin</param-value>
</context-param>
</web-app> </web-app>

@ -75,4 +75,20 @@
</div> </div>
</div> </div>
</div> </div>
<div class="panel panel-default tab-pane"
id="geo_dashboard" role="tabpanel" aria-labelledby="geo_dashboard">
<div class="panel-heading">Map</div>
<div id="chartWrapper">
</div>
<a class="padding-left"
href="{{portalUrl}}/portal/dashboards/geo-dashboard/?GLOBAL-STATE={{anchor}}">
<span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-statistics fw-stack-1x"></i>
</span> View Device Location
</a>
</div>
{{/zone}} {{/zone}}

@ -28,7 +28,14 @@ function onRequest(context) {
var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"];
var device = deviceModule.viewDevice(deviceType, deviceId); var device = deviceModule.viewDevice(deviceType, deviceId);
if (device && device.status != "error") { if (device && device.status != "error") {
return {"device": device.content, "autoCompleteParams" : autoCompleteParams, "encodedFeaturePayloads": ""}; var anchor = { "device" : { "id" : device.content.deviceIdentifier, "type" : device.content.type}};
return {
"device": device.content,
"autoCompleteParams" : autoCompleteParams,
"encodedFeaturePayloads": "",
"portalUrl" : devicemgtProps['portalURL'],
"anchor" : JSON.stringify(anchor)
};
} else { } else {
response.sendError(404, "Device Id " + deviceId + " of type " + deviceType + " cannot be found!"); response.sendError(404, "Device Id " + deviceId + " of type " + deviceType + " cannot be found!");
exit(); exit();

@ -111,7 +111,7 @@ public class FireAlarmHTTPCommunicator extends HTTPTransportHandler {
AgentManager agentManager = AgentManager.getInstance(); AgentManager agentManager = AgentManager.getInstance();
String pathContext = request.getPathInfo(); String pathContext = request.getPathInfo();
String separator = File.separator; String separator = File.separatorChar=='\\' ? "\\\\" : File.separator ;
if (pathContext.toUpperCase().contains( if (pathContext.toUpperCase().contains(
separator + AgentConstants.TEMPERATURE_CONTROL)) { separator + AgentConstants.TEMPERATURE_CONTROL)) {

@ -34,9 +34,5 @@
<param-name>managed-api-enabled</param-name> <param-name>managed-api-enabled</param-name>
<param-value>true</param-value> <param-value>true</param-value>
</context-param> </context-param>
<context-param>
<param-name>managed-api-owner</param-name>
<param-value>admin</param-value>
</context-param>
</web-app> </web-app>

@ -83,6 +83,7 @@
org.wso2.carbon.event.input.adapter.core, org.wso2.carbon.event.input.adapter.core,
org.wso2.carbon.event.input.adapter.core.exception, org.wso2.carbon.event.input.adapter.core.exception,
org.jivesoftware.smack.*, org.jivesoftware.smack.*,
javax.xml,
javax.xml.bind, javax.xml.bind,
javax.xml.bind.annotation, javax.xml.bind.annotation,
javax.xml.parsers; version="${javax.xml.parsers.import.pkg.version}", javax.xml.parsers; version="${javax.xml.parsers.import.pkg.version}",

@ -6,6 +6,7 @@ import org.w3c.dom.Document;
import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.config.exception.VirtualFirealarmConfigurationException; import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.config.exception.VirtualFirealarmConfigurationException;
import org.wso2.carbon.utils.CarbonUtils; import org.wso2.carbon.utils.CarbonUtils;
import javax.xml.XMLConstants;
import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException; import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller; import javax.xml.bind.Unmarshaller;
@ -50,6 +51,7 @@ public class VirtualFirealarmConfig {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true); factory.setNamespaceAware(true);
try { try {
factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
DocumentBuilder docBuilder = factory.newDocumentBuilder(); DocumentBuilder docBuilder = factory.newDocumentBuilder();
return docBuilder.parse(file); return docBuilder.parse(file);
} catch (Exception e) { } catch (Exception e) {

@ -28,19 +28,11 @@
<param-name>isSharedWithAllTenants</param-name> <param-name>isSharedWithAllTenants</param-name>
<param-value>true</param-value> <param-value>true</param-value>
</context-param> </context-param>
<context-param>
<param-name>providerTenantDomain</param-name>
<param-value>carbon.super</param-value>
</context-param>
<!--publish to apim--> <!--publish to apim-->
<context-param> <context-param>
<param-name>managed-api-enabled</param-name> <param-name>managed-api-enabled</param-name>
<param-value>false</param-value> <param-value>false</param-value>
</context-param> </context-param>
<context-param>
<param-name>managed-api-owner</param-name>
<param-value>admin</param-value>
</context-param>
</web-app> </web-app>

@ -134,6 +134,7 @@
</Export-Package> </Export-Package>
<Import-Package> <Import-Package>
org.wso2.carbon.event.output.adapter.core.*, org.wso2.carbon.event.output.adapter.core.*,
javax.xml,
javax.xml.namespace; version=0.0.0, javax.xml.namespace; version=0.0.0,
org.apache.axis2, org.apache.axis2,
org.apache.axis2.client, org.apache.axis2.client,

@ -75,7 +75,8 @@ public class WebsocketConfig {
return websocketValidationConfigs; return websocketValidationConfigs;
} }
public void setWebsocketValidationConfigs(WebsocketValidationConfigs websocketValidationConfigs) { public void setWebsocketValidationConfigs(WebsocketValidationConfigs websocketValidationConfigsTemp) {
websocketValidationConfigs = websocketValidationConfigs; websocketValidationConfigs = websocketValidationConfigsTemp;
} }
} }

@ -21,6 +21,7 @@ package org.wso2.carbon.device.mgt.output.adapter.websocket.util;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.wso2.carbon.device.mgt.output.adapter.websocket.config.WebsocketValidationConfigurationFailedException; import org.wso2.carbon.device.mgt.output.adapter.websocket.config.WebsocketValidationConfigurationFailedException;
import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import java.io.File; import java.io.File;
@ -34,6 +35,7 @@ public class WebsocketUtils {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true); factory.setNamespaceAware(true);
try { try {
factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
DocumentBuilder docBuilder = factory.newDocumentBuilder(); DocumentBuilder docBuilder = factory.newDocumentBuilder();
return docBuilder.parse(file); return docBuilder.parse(file);
} catch (Exception e) { } catch (Exception e) {

@ -300,7 +300,7 @@ public class AndroidDeviceInfo extends DeviceInfo implements Serializable {
} }
public Date getUpdatedTime() { public Date getUpdatedTime() {
if(this.updatedTime.equals((Object)null)) { if(this.updatedTime == null) {
this.updatedTime = new Date(); this.updatedTime = new Date();
} }

@ -83,13 +83,7 @@ public class GsonMessageBodyHandler implements MessageBodyWriter<Object>, Messag
OutputStreamWriter writer = new OutputStreamWriter(entityStream, UTF_8); OutputStreamWriter writer = new OutputStreamWriter(entityStream, UTF_8);
try { try {
Type jsonType; getGson().toJson(object, type, writer);
if (type.equals(type)) {
jsonType = type;
} else {
jsonType = type;
}
getGson().toJson(object, jsonType, writer);
} finally { } finally {
writer.close(); writer.close();
} }

@ -57,7 +57,7 @@ import java.util.List;
} }
), ),
tags = { tags = {
@Tag(name = "devicemgt_android", description = "") @Tag(name = "android", description = "")
} }
) )
@Path("/admin/devices") @Path("/admin/devices")

@ -64,7 +64,7 @@ import java.util.List;
} }
), ),
tags = { tags = {
@Tag(name = "devicemgt_android", description = "") @Tag(name = "android", description = "")
} }
) )
@Api(value = "Android Device Management", @Api(value = "Android Device Management",

@ -54,7 +54,7 @@ import javax.ws.rs.core.Response;
} }
), ),
tags = { tags = {
@Tag(name = "devicemgt_android", description = "") @Tag(name = "android", description = "")
} }
) )
@Api(value = "Android Configuration Management", description = "This API carries all the resource used to mange the Android platform configurations.") @Api(value = "Android Configuration Management", description = "This API carries all the resource used to mange the Android platform configurations.")

@ -52,7 +52,7 @@ import javax.ws.rs.core.Response;
} }
), ),
tags = { tags = {
@Tag(name = "devicemgt_android", description = "") @Tag(name = "android", description = "")
} }
) )
@Api(value = "Event Receiver", description = "Event publishing/retrieving related APIs. To enable event publishing/retrieving you need to" + @Api(value = "Event Receiver", description = "Event publishing/retrieving related APIs. To enable event publishing/retrieving you need to" +

@ -39,7 +39,7 @@ import org.wso2.carbon.mdm.services.android.util.AndroidConstants;
import org.wso2.carbon.mdm.services.android.util.AndroidDeviceUtils; import org.wso2.carbon.mdm.services.android.util.AndroidDeviceUtils;
import org.wso2.carbon.mdm.services.android.util.Message; import org.wso2.carbon.mdm.services.android.util.Message;
import org.wso2.carbon.policy.mgt.common.PolicyManagementException; import org.wso2.carbon.policy.mgt.common.PolicyManagementException;
import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException; import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.PolicyComplianceException;
import org.wso2.carbon.policy.mgt.core.PolicyManagerService; import org.wso2.carbon.policy.mgt.core.PolicyManagerService;
import javax.validation.Valid; import javax.validation.Valid;

@ -47,6 +47,7 @@ import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagement
import org.wso2.carbon.device.mgt.common.operation.mgt.Activity; import org.wso2.carbon.device.mgt.common.operation.mgt.Activity;
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.ComplianceFeature;
import org.wso2.carbon.device.mgt.core.app.mgt.ApplicationManagementProviderService; import org.wso2.carbon.device.mgt.core.app.mgt.ApplicationManagementProviderService;
import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceDetailsMgtException; import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceDetailsMgtException;
import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceInformationManager; import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceInformationManager;
@ -55,7 +56,7 @@ import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
import org.wso2.carbon.mdm.services.android.bean.DeviceState; import org.wso2.carbon.mdm.services.android.bean.DeviceState;
import org.wso2.carbon.mdm.services.android.bean.ErrorResponse; import org.wso2.carbon.mdm.services.android.bean.ErrorResponse;
import org.wso2.carbon.mdm.services.android.exception.BadRequestException; import org.wso2.carbon.mdm.services.android.exception.BadRequestException;
import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException; import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.PolicyComplianceException;
import org.wso2.carbon.policy.mgt.core.PolicyManagerService; import org.wso2.carbon.policy.mgt.core.PolicyManagerService;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
@ -275,7 +276,8 @@ public class AndroidAPIUtils {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.info("Received compliance status from MONITOR operation ID: " + operation.getId()); log.info("Received compliance status from MONITOR operation ID: " + operation.getId());
} }
getPolicyManagerService().checkPolicyCompliance(deviceIdentifier, operation.getPayLoad()); getPolicyManagerService().checkPolicyCompliance(deviceIdentifier,
getComplianceFeatures(operation.getPayLoad()));
} else if (!Operation.Status.ERROR.equals(operation.getStatus()) && AndroidConstants. } else if (!Operation.Status.ERROR.equals(operation.getStatus()) && AndroidConstants.
OperationCodes.APPLICATION_LIST.equals(operation.getCode())) { OperationCodes.APPLICATION_LIST.equals(operation.getCode())) {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
@ -493,4 +495,29 @@ public class AndroidAPIUtils {
} }
return ""; return "";
} }
private static List<ComplianceFeature> getComplianceFeatures(Object compliancePayload) throws PolicyComplianceException {
String compliancePayloadString = new Gson().toJson(compliancePayload);
if (compliancePayload == null) {
return null;
}
// Parsing json string to get compliance features.
JsonElement jsonElement;
if (compliancePayloadString instanceof String) {
jsonElement = new JsonParser().parse(compliancePayloadString);
} else {
throw new PolicyComplianceException("Invalid policy compliance payload");
}
JsonArray jsonArray = jsonElement.getAsJsonArray();
Gson gson = new Gson();
ComplianceFeature complianceFeature;
List<ComplianceFeature> complianceFeatures = new ArrayList<ComplianceFeature>(jsonArray.size());
for (JsonElement element : jsonArray) {
complianceFeature = gson.fromJson(element, ComplianceFeature.class);
complianceFeatures.add(complianceFeature);
}
return complianceFeatures;
}
} }

@ -51,10 +51,6 @@
<param-name>managed-api-enabled</param-name> <param-name>managed-api-enabled</param-name>
<param-value>true</param-value> <param-value>true</param-value>
</context-param> </context-param>
<context-param>
<param-name>managed-api-owner</param-name>
<param-value>admin</param-value>
</context-param>
<context-param> <context-param>
<param-name>doAuthentication</param-name> <param-name>doAuthentication</param-name>
<param-value>true</param-value> <param-value>true</param-value>

@ -121,9 +121,9 @@ if (uriMatcher.match("/{context}/api/user/authenticate")) {
} else { } else {
userRoles = String(addUserFormData.userRoles).split(","); userRoles = String(addUserFormData.userRoles).split(",");
} }
if (username.length < devicemgtProps.usernameLength) { if (username.length < devicemgtProps.userValidationConfig.usernameLength) {
log.error("Username Must be between 1 and " + devicemgtProps.usernameLength + " characters long"); log.error("Username Must be between 1 and " + devicemgtProps.userValidationConfig.usernameLength + " characters long");
result = "Username Must be between 1 and " + devicemgtProps.usernameLength + " characters long"; result = "Username Must be between 1 and " + devicemgtProps.userValidationConfig.usernameLength + " characters long";
} else { } else {
try { try {
result = userModule.addUser(username, firstname, lastname, emailAddress, userRoles); result = userModule.addUser(username, firstname, lastname, emailAddress, userRoles);

@ -1,6 +1,5 @@
{ {
"appContext" : "/android-web-agent/", "appContext" : "/android-web-agent/",
"apiContext" : "api",
"httpsURL" : "%https.ip%", "httpsURL" : "%https.ip%",
"httpURL" : "%http.ip%", "httpURL" : "%http.ip%",
"enrollmentDir": "/android-web-agent/enrollment", "enrollmentDir": "/android-web-agent/enrollment",
@ -24,7 +23,9 @@
"tokenServiceURL": "%https.ip%/oauth2/token" "tokenServiceURL": "%https.ip%/oauth2/token"
}, },
"adminUser":"admin", "adminUser":"admin",
"usernameLength":30, "userValidationConfig" : {
"usernameLength":30
},
"device" : { "device" : {
"ios" : { "ios" : {
"location" : "%http.ip%/android-web-agent/public/mdm.page.enrollments.ios.download-agent/asset/ios-agent.ipa", "location" : "%http.ip%/android-web-agent/public/mdm.page.enrollments.ios.download-agent/asset/ios-agent.ipa",
@ -35,16 +36,6 @@
}, },
"androidAgentApp" : "android-agent.apk", "androidAgentApp" : "android-agent.apk",
"windowsConfigRoot" : "%http.ip%/api/device-mgt/windows/v1.0/services/federated/bst/authentication", "windowsConfigRoot" : "%http.ip%/api/device-mgt/windows/v1.0/services/federated/bst/authentication",
"ssoConfiguration" : {
"enabled" : false,
"issuer" : "mdm",
"appName" : "admin_android-web-agent",
"identityProviderURL" : "%https.ip%/sso/samlsso.jag",
"responseSigningEnabled" : "true",
"keyStorePassword" : "wso2carbon",
"identityAlias" : "wso2carbon",
"keyStoreName" : "/repository/resources/security/wso2carbon.jks"
},
"generalConfig" : { "generalConfig" : {
"host" : "%http.ip%", "host" : "%http.ip%",
"companyName" : "WSO2 Enterprise Mobility Manager", "companyName" : "WSO2 Enterprise Mobility Manager",

@ -59,6 +59,7 @@
org.osgi.framework, org.osgi.framework,
org.osgi.service.component, org.osgi.service.component,
org.apache.commons.logging, org.apache.commons.logging,
javax.xml,
javax.xml.bind.*, javax.xml.bind.*,
javax.sql, javax.sql,
javax.xml.parsers; version=0.0.0, javax.xml.parsers; version=0.0.0,

@ -27,6 +27,7 @@ import org.wso2.carbon.device.mgt.common.ProvisioningConfig;
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager; import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager;
import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry; import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry;
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration; import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
import org.wso2.carbon.device.mgt.common.policy.mgt.PolicyMonitoringManager;
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig; import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig;
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
import org.wso2.carbon.device.mgt.mobile.android.impl.util.AndroidPluginConstants; import org.wso2.carbon.device.mgt.mobile.android.impl.util.AndroidPluginConstants;
@ -47,6 +48,7 @@ public class AndroidDeviceManagementService implements DeviceManagementService {
private static final String NOTIFIER_PROPERTY = "notifierType"; private static final String NOTIFIER_PROPERTY = "notifierType";
private static final String GCM_API_KEY = "gcmAPIKey"; private static final String GCM_API_KEY = "gcmAPIKey";
private static final String GCM_SENDER_ID = "gcmSenderId"; private static final String GCM_SENDER_ID = "gcmSenderId";
private PolicyMonitoringManager policyMonitoringManager;
@Override @Override
public String getType() { public String getType() {
@ -61,6 +63,7 @@ public class AndroidDeviceManagementService implements DeviceManagementService {
@Override @Override
public void init() throws DeviceManagementException { public void init() throws DeviceManagementException {
this.deviceManager = new AndroidDeviceManager(); this.deviceManager = new AndroidDeviceManager();
this.policyMonitoringManager = new AndroidPolicyMonitoringManager();
} }
@Override @Override
@ -105,6 +108,11 @@ public class AndroidDeviceManagementService implements DeviceManagementService {
return null; return null;
} }
@Override
public PolicyMonitoringManager getPolicyMonitoringManager() {
return policyMonitoringManager;
}
private String getConfigProperty(List<ConfigurationEntry> configs, String propertyName) { private String getConfigProperty(List<ConfigurationEntry> configs, String propertyName) {
for (ConfigurationEntry entry : configs) { for (ConfigurationEntry entry : configs) {
if (propertyName.equals(entry.getName())) { if (propertyName.equals(entry.getName())) {

@ -25,39 +25,27 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonParser; import com.google.gson.JsonParser;
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.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; import org.wso2.carbon.device.mgt.common.policy.mgt.PolicyMonitoringManager;
import org.wso2.carbon.device.mgt.mobile.android.impl.gcm.GCMService; import org.wso2.carbon.device.mgt.common.policy.mgt.Policy;
import org.wso2.carbon.device.mgt.mobile.android.internal.AndroidDeviceManagementDataHolder; import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.NonComplianceData;
import org.wso2.carbon.policy.mgt.common.Policy; import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.ComplianceFeature;
import org.wso2.carbon.policy.mgt.common.monitor.ComplianceData; import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.PolicyComplianceException;
import org.wso2.carbon.policy.mgt.common.monitor.ComplianceFeature;
import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException;
import org.wso2.carbon.policy.mgt.common.spi.PolicyMonitoringService;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class AndroidPolicyMonitoringService implements PolicyMonitoringService { public class AndroidPolicyMonitoringManager implements PolicyMonitoringManager {
private static Log log = LogFactory.getLog(AndroidPolicyMonitoringService.class); private static Log log = LogFactory.getLog(AndroidPolicyMonitoringManager.class);
@Override @Override
public void notifyDevices(List<Device> list) throws PolicyComplianceException { public NonComplianceData checkPolicyCompliance(DeviceIdentifier deviceIdentifier, Policy policy,
GCMService gcmService = AndroidDeviceManagementDataHolder.getInstance().getGCMService();
if (gcmService.isGCMEnabled() && !list.isEmpty()) {
gcmService.sendNotification("POLICY_BUNDLE", list);
}
}
@Override
public ComplianceData checkPolicyCompliance(DeviceIdentifier deviceIdentifier, Policy policy,
Object compliancePayload) throws PolicyComplianceException { Object compliancePayload) throws PolicyComplianceException {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Checking policy compliance status of device '" + deviceIdentifier.getId() + "'"); log.debug("Checking policy compliance status of device '" + deviceIdentifier.getId() + "'");
} }
ComplianceData complianceData = new ComplianceData(); NonComplianceData complianceData = new NonComplianceData();
if (compliancePayload == null || policy == null) { if (compliancePayload == null || policy == null) {
return complianceData; return complianceData;
} }
@ -93,8 +81,4 @@ public class AndroidPolicyMonitoringService implements PolicyMonitoringService {
return complianceData; return complianceData;
} }
@Override
public String getType() {
return DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID;
}
} }

@ -38,6 +38,7 @@ import org.wso2.carbon.registry.api.RegistryException;
import org.wso2.carbon.registry.api.Resource; import org.wso2.carbon.registry.api.Resource;
import org.wso2.carbon.registry.core.Registry; import org.wso2.carbon.registry.core.Registry;
import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import java.io.File; import java.io.File;
@ -66,6 +67,7 @@ public class MobileDeviceManagementUtil {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true); factory.setNamespaceAware(true);
try { try {
factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
DocumentBuilder docBuilder = factory.newDocumentBuilder(); DocumentBuilder docBuilder = factory.newDocumentBuilder();
return docBuilder.parse(file); return docBuilder.parse(file);
} catch (Exception e) { } catch (Exception e) {

@ -25,10 +25,8 @@ import org.osgi.framework.ServiceRegistration;
import org.osgi.service.component.ComponentContext; import org.osgi.service.component.ComponentContext;
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
import org.wso2.carbon.device.mgt.mobile.android.impl.AndroidDeviceManagementService; import org.wso2.carbon.device.mgt.mobile.android.impl.AndroidDeviceManagementService;
import org.wso2.carbon.device.mgt.mobile.android.impl.AndroidPolicyMonitoringService;
import org.wso2.carbon.device.mgt.mobile.android.impl.gcm.GCMService; import org.wso2.carbon.device.mgt.mobile.android.impl.gcm.GCMService;
import org.wso2.carbon.ndatasource.core.DataSourceService; import org.wso2.carbon.ndatasource.core.DataSourceService;
import org.wso2.carbon.policy.mgt.common.spi.PolicyMonitoringService;
import org.wso2.carbon.registry.core.service.RegistryService; import org.wso2.carbon.registry.core.service.RegistryService;
/** /**
@ -75,8 +73,8 @@ public class AndroidDeviceManagementServiceComponent {
// Policy management service // Policy management service
bundleContext.registerService(PolicyMonitoringService.class, // bundleContext.registerService(PolicyMonitoringManager.class,
new AndroidPolicyMonitoringService(), null); // new AndroidPolicyMonitoringManager(), null);
AndroidDeviceManagementDataHolder.getInstance().setAndroidDeviceManagementService( AndroidDeviceManagementDataHolder.getInstance().setAndroidDeviceManagementService(
androidDeviceManagementService); androidDeviceManagementService);

@ -82,13 +82,7 @@ public class GsonMessageBodyHandler implements MessageBodyWriter<Object>, Messag
OutputStreamWriter writer = new OutputStreamWriter(entityStream, UTF_8); OutputStreamWriter writer = new OutputStreamWriter(entityStream, UTF_8);
try { try {
Type jsonType; getGson().toJson(object, type, writer);
if (type.equals(type)) {
jsonType = type;
} else {
jsonType = type;
}
getGson().toJson(object, jsonType, writer);
} finally { } finally {
writer.close(); writer.close();
} }

@ -188,10 +188,10 @@ public class WindowsAPIUtils {
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
AuthenticatorConfigService authenticatorConfigService = AuthenticatorConfigService authenticatorConfigService =
(AuthenticatorConfigService) ctx.getOSGiService(AuthenticatorConfigService.class, null); (AuthenticatorConfigService) ctx.getOSGiService(AuthenticatorConfigService.class, null);
AuthenticatorConfig authenticatorConfig = authenticatorConfigService.getAuthenticatorConfig("BST");
if (authenticatorConfigService == null) { if (authenticatorConfigService == null) {
throw new IllegalStateException("AuthenticatorConfiguration service has not initialized."); throw new IllegalStateException("AuthenticatorConfiguration service has not initialized.");
} }
AuthenticatorConfig authenticatorConfig = authenticatorConfigService.getAuthenticatorConfig("BST");
if (authenticatorConfig == null) { if (authenticatorConfig == null) {
throw new IllegalStateException("BST authenticatorConfig has not initialized."); throw new IllegalStateException("BST authenticatorConfig has not initialized.");
} }

@ -37,9 +37,9 @@ import org.wso2.carbon.device.mgt.mobile.windows.api.common.util.WindowsAPIUtils
import org.wso2.carbon.device.mgt.mobile.windows.api.services.syncml.beans.Profile; import org.wso2.carbon.device.mgt.mobile.windows.api.services.syncml.beans.Profile;
import org.wso2.carbon.device.mgt.mobile.windows.api.operations.*; import org.wso2.carbon.device.mgt.mobile.windows.api.operations.*;
import org.wso2.carbon.policy.mgt.common.PolicyManagementException; import org.wso2.carbon.policy.mgt.common.PolicyManagementException;
import org.wso2.carbon.policy.mgt.common.ProfileFeature; import org.wso2.carbon.device.mgt.common.policy.mgt.ProfileFeature;
import org.wso2.carbon.policy.mgt.common.monitor.ComplianceFeature; import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.ComplianceFeature;
import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException; import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.PolicyComplianceException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -183,7 +183,7 @@ public class OperationHandler {
if ((Constants.SyncMLResponseCodes.ACCEPTED.equals(status.getData()))) { if ((Constants.SyncMLResponseCodes.ACCEPTED.equals(status.getData()))) {
pendingDataOperations = WindowsAPIUtils.getPendingOperations(deviceIdentifier); pendingDataOperations = WindowsAPIUtils.getPendingOperations(deviceIdentifier);
for (Operation operation : pendingDataOperations) { for (Operation operation : pendingDataOperations) {
if ((OperationCode.Command.DEVICE_RING.equals(operation.getCode())) && if ((OperationCode.Command.DEVICE_RING.getCode().equals(operation.getCode())) &&
(operation.getId() == status.getCommandReference())) { (operation.getId() == status.getCommandReference())) {
operation.setStatus(Operation.Status.COMPLETED); operation.setStatus(Operation.Status.COMPLETED);
updateStatus(syncmlDocument.getHeader().getSource().getLocURI(), updateStatus(syncmlDocument.getHeader().getSource().getLocURI(),
@ -215,7 +215,7 @@ public class OperationHandler {
} }
for (Operation operation : pendingDataOperations) { for (Operation operation : pendingDataOperations) {
if ((OperationCode.Command.WIPE_DATA.equals(operation.getCode())) && if ((OperationCode.Command.WIPE_DATA.getCode().equals(operation.getCode())) &&
(operation.getId() == status.getCommandReference())) { (operation.getId() == status.getCommandReference())) {
operation.setStatus(Operation.Status.COMPLETED); operation.setStatus(Operation.Status.COMPLETED);
updateStatus(syncmlDocument.getHeader().getSource().getLocURI(), updateStatus(syncmlDocument.getHeader().getSource().getLocURI(),
@ -341,13 +341,13 @@ public class OperationHandler {
if (status.getTargetReference() == null) { if (status.getTargetReference() == null) {
updateDeviceOperations(status, syncmlDocument, deviceIdentifier); updateDeviceOperations(status, syncmlDocument, deviceIdentifier);
} else { } else {
if ((OperationCode.Command.DEVICE_LOCK.equals(status.getTargetReference()))) { if ((OperationCode.Command.DEVICE_LOCK.getCode().equals(status.getTargetReference()))) {
updateLockOperation(status, syncmlDocument, deviceIdentifier); updateLockOperation(status, syncmlDocument, deviceIdentifier);
} }
if ((OperationCode.Command.DEVICE_RING.equals(status.getTargetReference()))) { if ((OperationCode.Command.DEVICE_RING.getCode().equals(status.getTargetReference()))) {
ring(status, syncmlDocument, deviceIdentifier); ring(status, syncmlDocument, deviceIdentifier);
} }
if (equals(OperationCode.Command.WIPE_DATA.equals(status.getTargetReference()))) { if ((OperationCode.Command.WIPE_DATA.getCode().equals(status.getTargetReference()))) {
dataWipe(status, syncmlDocument, deviceIdentifier); dataWipe(status, syncmlDocument, deviceIdentifier);
} }
} }

@ -33,7 +33,7 @@ import org.wso2.carbon.device.mgt.mobile.windows.api.services.syncml.beans.Wifi;
import org.wso2.carbon.device.mgt.mobile.windows.api.operations.*; import org.wso2.carbon.device.mgt.mobile.windows.api.operations.*;
import org.wso2.carbon.policy.mgt.common.FeatureManagementException; import org.wso2.carbon.policy.mgt.common.FeatureManagementException;
import org.wso2.carbon.policy.mgt.common.PolicyManagementException; import org.wso2.carbon.policy.mgt.common.PolicyManagementException;
import org.wso2.carbon.policy.mgt.common.ProfileFeature; import org.wso2.carbon.device.mgt.common.policy.mgt.ProfileFeature;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;

@ -51,6 +51,7 @@ import org.xml.sax.SAXException;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.jws.WebService; import javax.jws.WebService;
import javax.servlet.ServletContext; import javax.servlet.ServletContext;
import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
@ -102,7 +103,7 @@ public class EnrollmentServiceImpl implements EnrollmentService {
String headerTo = null; String headerTo = null;
String encodedWap; String encodedWap;
List<Header> headers = getHeaders(); List<Header> headers = getHeaders();
for (Header headerElement : headers != null ? headers : null) { for (Header headerElement : headers) {
String nodeName = headerElement.getName().getLocalPart(); String nodeName = headerElement.getName().getLocalPart();
if (PluginConstants.SECURITY.equals(nodeName)) { if (PluginConstants.SECURITY.equals(nodeName)) {
Element element = (Element) headerElement.getObject(); Element element = (Element) headerElement.getObject();
@ -231,6 +232,7 @@ public class EnrollmentServiceImpl implements EnrollmentService {
signedCertEncodedString = base64Encoder.encodeAsString(signedCertificate.getEncoded()); signedCertEncodedString = base64Encoder.encodeAsString(signedCertificate.getEncoded());
DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance(); DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
domFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
DocumentBuilder builder; DocumentBuilder builder;
builder = domFactory.newDocumentBuilder(); builder = domFactory.newDocumentBuilder();

@ -112,7 +112,7 @@ public class CertificateEnrollmentServiceImpl implements CertificateEnrollmentSe
String headerTo = null; String headerTo = null;
String encodedWap; String encodedWap;
List<Header> headers = getHeaders(); List<Header> headers = getHeaders();
for (Header headerElement : headers != null ? headers : null) { for (Header headerElement : headers) {
String nodeName = headerElement.getName().getLocalPart(); String nodeName = headerElement.getName().getLocalPart();
if (PluginConstants.SECURITY.equals(nodeName)) { if (PluginConstants.SECURITY.equals(nodeName)) {
Element element = (Element) headerElement.getObject(); Element element = (Element) headerElement.getObject();

@ -56,10 +56,6 @@
<param-name>managed-api-enabled</param-name> <param-name>managed-api-enabled</param-name>
<param-value>true</param-value> <param-value>true</param-value>
</context-param> </context-param>
<context-param>
<param-name>managed-api-owner</param-name>
<param-value>admin</param-value>
</context-param>
<context-param> <context-param>
<param-name>doAuthentication</param-name> <param-name>doAuthentication</param-name>
<param-value>true</param-value> <param-value>true</param-value>

@ -121,9 +121,9 @@ if (uriMatcher.match("/{context}/api/user/authenticate")) {
} else { } else {
userRoles = String(addUserFormData.userRoles).split(","); userRoles = String(addUserFormData.userRoles).split(",");
} }
if (username.length < devicemgtProps.usernameLength) { if (username.length < devicemgtProps.userValidationConfig.usernameLength) {
log.error("Username Must be between 1 and " + devicemgtProps.usernameLength + " characters long"); log.error("Username Must be between 1 and " + devicemgtProps.userValidationConfig.usernameLength + " characters long");
result = "Username Must be between 1 and " + devicemgtProps.usernameLength + " characters long"; result = "Username Must be between 1 and " + devicemgtProps.userValidationConfig.usernameLength + " characters long";
} else { } else {
try { try {
result = userModule.addUser(username, firstname, lastname, emailAddress, userRoles); result = userModule.addUser(username, firstname, lastname, emailAddress, userRoles);

@ -1,6 +1,5 @@
{ {
"appContext" : "/windows-web-agent/", "appContext" : "/windows-web-agent/",
"apiContext" : "api",
"httpsURL" : "%https.ip%", "httpsURL" : "%https.ip%",
"httpURL" : "%http.ip%", "httpURL" : "%http.ip%",
"enrollmentDir": "/windows-web-agent/enrollment", "enrollmentDir": "/windows-web-agent/enrollment",
@ -24,7 +23,9 @@
"tokenServiceURL": "%https.ip%/oauth2/token" "tokenServiceURL": "%https.ip%/oauth2/token"
}, },
"adminUser":"admin", "adminUser":"admin",
"usernameLength":30, "userValidationConfig": {
"usernameLength":30
},
"device" : { "device" : {
"ios" : { "ios" : {
"location" : "%http.ip%/windows-web-agent/public/mdm.page.enrollments.ios.download-agent/asset/ios-agent.ipa", "location" : "%http.ip%/windows-web-agent/public/mdm.page.enrollments.ios.download-agent/asset/ios-agent.ipa",
@ -35,16 +36,6 @@
}, },
"androidAgentApp" : "android-agent.apk", "androidAgentApp" : "android-agent.apk",
"windowsConfigRoot" : "%http.ip%/api/device-mgt/windows/v1.0/federated/bst/authentication", "windowsConfigRoot" : "%http.ip%/api/device-mgt/windows/v1.0/federated/bst/authentication",
"ssoConfiguration" : {
"enabled" : false,
"issuer" : "mdm",
"appName" : "admin_windows-web-agent",
"identityProviderURL" : "%https.ip%/sso/samlsso.jag",
"responseSigningEnabled" : "true",
"keyStorePassword" : "wso2carbon",
"identityAlias" : "wso2carbon",
"keyStoreName" : "/repository/resources/security/wso2carbon.jks"
},
"generalConfig" : { "generalConfig" : {
"host" : "%http.ip%", "host" : "%http.ip%",
"companyName" : "WSO2 Enterprise Mobility Manager", "companyName" : "WSO2 Enterprise Mobility Manager",

@ -142,7 +142,7 @@ var handlers = function () {
"client credentials to session context as the server is unable to obtain " + "client credentials to session context as the server is unable to obtain " +
"dynamic client credentials - setUpEncodedTenantBasedClientAppCredentials(x)"); "dynamic client credentials - setUpEncodedTenantBasedClientAppCredentials(x)");
} else { } else {
if (devicemgtProps["apimgt-gateway"]) { if (devicemgtProps["gatewayEnabled"]) {
var jwtToken = tokenUtil.getAccessTokenByJWTGrantType(dynamicClientAppCredentials); var jwtToken = tokenUtil.getAccessTokenByJWTGrantType(dynamicClientAppCredentials);
if (!jwtToken) { if (!jwtToken) {
throw new Error("{/app/modules/oauth/token-handlers.js} Could not set up encoded tenant based " + throw new Error("{/app/modules/oauth/token-handlers.js} Could not set up encoded tenant based " +

@ -32,7 +32,7 @@ under the License. --}}
{{ {{
unit "mdm.unit.wizard-stepper" unit "mdm.unit.wizard-stepper"
steps = "Start Workplace, steps = "Start Workplace,
Login to Enterprise Mobility Manager, Login to WSO2 IoT Server,
Accept End User License Agreement" Accept End User License Agreement"
currentStep = "Start Workplace" currentStep = "Start Workplace"
currentStepIndex = 0 currentStepIndex = 0
@ -40,7 +40,7 @@ under the License. --}}
Start the Workplace app to continue device enrollment. Start the Workplace app to continue device enrollment.
<br class="c-both" /> <br class="c-both" />
<br class="c-both" /> <br class="c-both" />
Setting up a Workplace account with WSO2 Enterprise Mobility Manager Setting up a Workplace account with WSO2 IoT Server
will offer you company policies, certificates and apps that help you connect will offer you company policies, certificates and apps that help you connect
to your business. to your business.
<br class="c-both" /> <br class="c-both" />

@ -32,7 +32,7 @@ under the License. --}}
{{ {{
unit "mdm.unit.wizard-stepper" unit "mdm.unit.wizard-stepper"
steps = "Start Workplace, steps = "Start Workplace,
Login to Enterprise Mobility Manager, Login to WSO2 IoT Server,
Accept End User License Agreement" Accept End User License Agreement"
currentStep = "Accept End User License Agreement" currentStep = "Accept End User License Agreement"
currentStepIndex = 2 currentStepIndex = 2

@ -25,7 +25,7 @@ under the License. --}}
}} }}
{{/zone}} {{/zone}}
{{!-- Inputting content into defined zones in enrollment layout --}} {{!-- Inputting content into defined zones in enrollment layout --}}
{{unit "mdm.unit.ui.title" pageTitle="Windows Phone Enrollment | Login to Enterprise Mobility Manager"}} {{unit "mdm.unit.ui.title" pageTitle="Windows Phone Enrollment | Login to WSO2 IoT Server"}}
{{#zone "headerTitle"}} {{#zone "headerTitle"}}
Windows Phone Enrollment Windows Phone Enrollment
{{/zone}} {{/zone}}
@ -33,9 +33,9 @@ under the License. --}}
{{ {{
unit "mdm.unit.wizard-stepper" unit "mdm.unit.wizard-stepper"
steps = "Start Workplace, steps = "Start Workplace,
Login to Enterprise Mobility Manager, Login to WSO2 IoT Server,
Accept End User License Agreement" Accept End User License Agreement"
currentStep = "Login to Enterprise Mobility Manager" currentStep = "Login to WSO2 IoT Server"
currentStepIndex = 1 currentStepIndex = 1
}} }}
{{ {{

@ -55,6 +55,7 @@
org.osgi.framework, org.osgi.framework,
org.osgi.service.component, org.osgi.service.component,
org.apache.commons.logging, org.apache.commons.logging,
javax.xml,
javax.xml.bind.*, javax.xml.bind.*,
javax.sql, javax.sql,
javax.naming, javax.naming,

@ -23,6 +23,7 @@ import org.wso2.carbon.device.mgt.common.DeviceManager;
import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig; import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig;
import org.wso2.carbon.device.mgt.common.ProvisioningConfig; import org.wso2.carbon.device.mgt.common.ProvisioningConfig;
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager; import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager;
import org.wso2.carbon.device.mgt.common.policy.mgt.PolicyMonitoringManager;
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig; import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig;
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
@ -34,6 +35,7 @@ public class WindowsDeviceManagementService implements DeviceManagementService {
private DeviceManager deviceManager; private DeviceManager deviceManager;
public static final String DEVICE_TYPE_WINDOWS = "windows"; public static final String DEVICE_TYPE_WINDOWS = "windows";
private final static String DEVICE_TYPE_PROVIDER_DOMAIN = "carbon.super"; private final static String DEVICE_TYPE_PROVIDER_DOMAIN = "carbon.super";
private PolicyMonitoringManager policyMonitoringManager;
@Override @Override
public String getType() { public String getType() {
@ -48,6 +50,7 @@ public class WindowsDeviceManagementService implements DeviceManagementService {
@Override @Override
public void init() throws DeviceManagementException { public void init() throws DeviceManagementException {
this.deviceManager = new WindowsDeviceManager(); this.deviceManager = new WindowsDeviceManager();
this.policyMonitoringManager = new WindowsPolicyMonitoringManager();
} }
@Override @Override
@ -70,4 +73,9 @@ public class WindowsDeviceManagementService implements DeviceManagementService {
return null; return null;
} }
@Override
public PolicyMonitoringManager getPolicyMonitoringManager() {
return policyMonitoringManager;
}
} }

@ -20,36 +20,29 @@ package org.wso2.carbon.device.mgt.mobile.windows.impl;
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.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; import org.wso2.carbon.device.mgt.common.policy.mgt.PolicyMonitoringManager;
import org.wso2.carbon.policy.mgt.common.Policy; import org.wso2.carbon.device.mgt.common.policy.mgt.Policy;
import org.wso2.carbon.policy.mgt.common.monitor.ComplianceData; import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.NonComplianceData;
import org.wso2.carbon.policy.mgt.common.monitor.ComplianceFeature; import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.ComplianceFeature;
import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException; import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.PolicyComplianceException;
import org.wso2.carbon.policy.mgt.common.spi.PolicyMonitoringService;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class WindowsPolicyMonitoringService implements PolicyMonitoringService { public class WindowsPolicyMonitoringManager implements PolicyMonitoringManager {
private static Log log = LogFactory.getLog(WindowsPolicyMonitoringService.class); private static Log log = LogFactory.getLog(WindowsPolicyMonitoringManager.class);
@Override @Override
public void notifyDevices(List<Device> list) throws PolicyComplianceException { public NonComplianceData checkPolicyCompliance(DeviceIdentifier deviceIdentifier, Policy policy, Object compliancePayload)
}
@Override
public ComplianceData checkPolicyCompliance(DeviceIdentifier deviceIdentifier, Policy policy, Object compliancePayload)
throws PolicyComplianceException { throws PolicyComplianceException {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("checking policy compliance status of device '" + deviceIdentifier.getId() + "'"); log.debug("checking policy compliance status of device '" + deviceIdentifier.getId() + "'");
} }
List<ComplianceFeature> complianceFeatures = (List<ComplianceFeature>) compliancePayload; List<ComplianceFeature> complianceFeatures = (List<ComplianceFeature>) compliancePayload;
List<ComplianceFeature> nonComplianceFeatures = new ArrayList<>(); List<ComplianceFeature> nonComplianceFeatures = new ArrayList<>();
ComplianceData complianceData = new ComplianceData(); NonComplianceData complianceData = new NonComplianceData();
if (policy == null || compliancePayload == null) { if (policy == null || compliancePayload == null) {
return complianceData; return complianceData;
@ -66,8 +59,4 @@ public class WindowsPolicyMonitoringService implements PolicyMonitoringService {
return complianceData; return complianceData;
} }
@Override
public String getType() {
return DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS;
}
} }

@ -38,6 +38,7 @@ import org.wso2.carbon.registry.api.RegistryException;
import org.wso2.carbon.registry.api.Resource; import org.wso2.carbon.registry.api.Resource;
import org.wso2.carbon.registry.core.Registry; import org.wso2.carbon.registry.core.Registry;
import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import java.io.File; import java.io.File;
@ -66,6 +67,7 @@ public class MobileDeviceManagementUtil {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true); factory.setNamespaceAware(true);
try { try {
factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
DocumentBuilder docBuilder = factory.newDocumentBuilder(); DocumentBuilder docBuilder = factory.newDocumentBuilder();
return docBuilder.parse(file); return docBuilder.parse(file);
} catch (Exception e) { } catch (Exception e) {

@ -23,11 +23,7 @@ import org.apache.commons.logging.LogFactory;
import org.osgi.framework.BundleContext; import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration; import org.osgi.framework.ServiceRegistration;
import org.osgi.service.component.ComponentContext; import org.osgi.service.component.ComponentContext;
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
import org.wso2.carbon.device.mgt.mobile.windows.impl.WindowsDeviceManagementService;
import org.wso2.carbon.device.mgt.mobile.windows.impl.WindowsPolicyMonitoringService;
import org.wso2.carbon.ndatasource.core.DataSourceService; import org.wso2.carbon.ndatasource.core.DataSourceService;
import org.wso2.carbon.policy.mgt.common.spi.PolicyMonitoringService;
import org.wso2.carbon.registry.core.service.RegistryService; import org.wso2.carbon.registry.core.service.RegistryService;
/** /**
@ -67,8 +63,8 @@ public class WindowsDeviceManagementServiceComponent {
// Policy management service // Policy management service
bundleContext.registerService(PolicyMonitoringService.class, // bundleContext.registerService(PolicyMonitoringManager.class,
new WindowsPolicyMonitoringService(), null); // new WindowsPolicyMonitoringManager(), null);
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Android Mobile Device Management Service Component has been successfully activated"); log.debug("Android Mobile Device Management Service Component has been successfully activated");

@ -253,11 +253,11 @@
</propertyDef> </propertyDef>
</properties> </properties>
</adviceFile> </adviceFile>
<bundles> <!--<bundles>-->
<bundleDef> <!--<bundleDef>-->
org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.mobile.android:${carbon.devicemgt.plugins.version} <!--org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.mobile.android:${carbon.devicemgt.plugins.version}-->
</bundleDef> <!--</bundleDef>-->
</bundles> <!--</bundles>-->
<importFeatures> <importFeatures>
<importFeatureDef> <importFeatureDef>
org.wso2.carbon.core.server:${carbon.kernel.version} org.wso2.carbon.core.server:${carbon.kernel.version}

@ -348,4 +348,5 @@
</Operation> </Operation>
</Operations> </Operations>
</TaskConfiguration> </TaskConfiguration>
<PolicyMonitoring enabled="true"/>
</DeviceTypeConfiguration> </DeviceTypeConfiguration>

@ -202,11 +202,11 @@
</propertyDef> </propertyDef>
</properties> </properties>
</adviceFile> </adviceFile>
<bundles> <!--<bundles>-->
<bundleDef> <!--<bundleDef>-->
org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.mobile.windows:${carbon.devicemgt.plugins.version} <!--org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.mobile.windows:${carbon.devicemgt.plugins.version}-->
</bundleDef> <!--</bundleDef>-->
</bundles> <!--</bundles>-->
<importFeatures> <importFeatures>
<importFeatureDef> <importFeatureDef>
org.wso2.carbon.core.server:${carbon.kernel.version} org.wso2.carbon.core.server:${carbon.kernel.version}

@ -152,4 +152,6 @@
<authorizationRequired>false</authorizationRequired> <authorizationRequired>false</authorizationRequired>
</DeviceAuthorizationConfig> </DeviceAuthorizationConfig>
<PolicyMonitoring enabled="true"/>
</DeviceTypeConfiguration> </DeviceTypeConfiguration>

Loading…
Cancel
Save