Merge branch 'master' into 'master'

Enrollment application install feature for policy

See merge request entgra/carbon-device-mgt!37
revert-70aa11f8
Dharmakeerthi Lasantha 6 years ago
commit b90f188e9b

@ -156,10 +156,12 @@
"perm:admin:device-type", "perm:admin:device-type",
"perm:device:enroll", "perm:device:enroll",
"perm:geo-service:analytics-view", "perm:geo-service:analytics-view",
"perm:geo-service:alerts-manage" "perm:geo-service:alerts-manage",
"appm:read"
], ],
"isOAuthEnabled": true, "isOAuthEnabled": true,
"backendRestEndpoints": { "backendRestEndpoints": {
"deviceMgt": "/api/device-mgt/v1.0" "deviceMgt": "/api/device-mgt/v1.0",
"appMgt": "/api/appm/store/v1.1"
} }
} }

@ -14,6 +14,23 @@
* either express or implied. See the License for the * either express or implied. See the License for the
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*
*
* Copyright (c) 2018, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
*
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/ */
var policyModule; var policyModule;
@ -180,6 +197,55 @@ policyModule = function () {
} }
}; };
/*
Get apps available in the store from backend service.
*/
publicMethods.getStoreAppsForPolicy = function () {
var carbonUser = session.get(constants["USER_SESSION_KEY"]);
if (!carbonUser) {
log.error("User object was not found in the session");
userModule.logout(function () {
response.sendRedirect(devicemgtProps["appContext"] + "login");
});
}
try {
var url = devicemgtProps["managerHTTPSURL"] + devicemgtProps["backendRestEndpoints"]["appMgt"] +
"/apps/mobileapp?field-filter=all";
return serviceInvokers.XMLHttp.get(url,
function (backendResponse) {
var response = {};
if (backendResponse.status === 200 && backendResponse.responseText) {
var appListFromRestEndpoint = parse(backendResponse.responseText)["appList"];
var storeApps = [];
var i, appObjectFromRestEndpoint, appObjectToView;
for (i=0; i<appListFromRestEndpoint.length; i++) {
appObjectFromRestEndpoint = appListFromRestEndpoint[i];
appObjectToView = {};
appObjectToView["appName"] = appObjectFromRestEndpoint["name"];
appObjectToView["appId"] = appObjectFromRestEndpoint["id"];
appObjectToView["packageName"] = appObjectFromRestEndpoint["appmeta"]["package"];
appObjectToView["version"] = appObjectFromRestEndpoint["version"];
appObjectToView["platform"] = appObjectFromRestEndpoint["platform"];
storeApps.push(appObjectToView);
}
response.status = "success";
response.content = storeApps;
return response;
} else {
response.status = "error";
if (backendResponse.responseText === "Scope validation failed") {
response.content = "Permission Denied";
} else {
response.content = backendResponse.responseText;
}
return response;
}
});
} catch (e) {
throw e;
}
};
/* /*
@Updated - used by getAllPolicies @Updated - used by getAllPolicies
*/ */

@ -14,6 +14,23 @@
either express or implied. See the License for the either express or implied. See the License for the
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
Copyright (c) 2018, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
Version 2.0 (the "License"); you may not use this file except
in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
}} }}
{{unit "cdmf.unit.ui.title" pageTitle="Policy Management | Add Policy"}} {{unit "cdmf.unit.ui.title" pageTitle="Policy Management | Add Policy"}}
@ -40,4 +57,5 @@
{{#zone "content"}} {{#zone "content"}}
{{unit "cdmf.unit.device.operation-mod"}} {{unit "cdmf.unit.device.operation-mod"}}
{{unit "cdmf.unit.policy.create"}} {{unit "cdmf.unit.policy.create"}}
{{unit "cdmf.unit.lib.data-table"}}
{{/zone}} {{/zone}}

@ -14,6 +14,23 @@
either express or implied. See the License for the either express or implied. See the License for the
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
Copyright (c) 2018, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
Version 2.0 (the "License"); you may not use this file except
in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
}} }}
{{unit "cdmf.unit.ui.title" pageTitle="Policy Management | Edit Policy"}} {{unit "cdmf.unit.ui.title" pageTitle="Policy Management | Edit Policy"}}
@ -40,4 +57,5 @@
{{#zone "content"}} {{#zone "content"}}
{{unit "cdmf.unit.device.operation-mod"}} {{unit "cdmf.unit.device.operation-mod"}}
{{unit "cdmf.unit.policy.edit"}} {{unit "cdmf.unit.policy.edit"}}
{{unit "cdmf.unit.lib.data-table"}}
{{/zone}} {{/zone}}

@ -14,6 +14,23 @@
either express or implied. See the License for the either express or implied. See the License for the
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
Copyright (c) 2018, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
Version 2.0 (the "License"); you may not use this file except
in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
}} }}
{{unit "cdmf.unit.ui.title" pageTitle="Policy Management | View Policy"}} {{unit "cdmf.unit.ui.title" pageTitle="Policy Management | View Policy"}}
@ -48,4 +65,5 @@
{{#zone "content"}} {{#zone "content"}}
{{unit "cdmf.unit.device.operation-mod"}} {{unit "cdmf.unit.device.operation-mod"}}
{{unit "cdmf.unit.policy.view"}} {{unit "cdmf.unit.policy.view"}}
{{unit "cdmf.unit.lib.data-table"}}
{{/zone}} {{/zone}}

@ -1,7 +1,9 @@
{{#zone "content"}} {{#zone "content"}}
{{#if isAuthorized}} {{#if isAuthorized}}
<span id="logged-in-user" class="hidden" data-username="{{@user.username}}" data-domain="{{@user.domain}}" <span id="logged-in-user" class="hidden" data-username="{{@user.username}}" data-domain="{{@user.domain}}"
data-tenant-id="{{@user.tenantId}}" data-iscloud="{{isCloud}}" data-isDeviceOwnerEnabled="{{isDeviceOwnerEnabled}}"></span> data-tenant-id="{{@user.tenantId}}" data-iscloud="{{isCloud}}"
data-isDeviceOwnerEnabled="{{isDeviceOwnerEnabled}}" data-storeapps="{{storeApps}}">
</span>
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">

@ -14,6 +14,23 @@
* KIND, either express or implied. See the License for the * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*
*
* Copyright (c) 2018, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
*
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/ */
function onRequest(context) { function onRequest(context) {
@ -24,6 +41,7 @@ function onRequest(context) {
var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"];
var groupModule = require("/app/modules/business-controllers/group.js")["groupModule"]; var groupModule = require("/app/modules/business-controllers/group.js")["groupModule"];
var policyModule = require("/app/modules/business-controllers/policy.js")["policyModule"];
var types = {}; var types = {};
types.isAuthorized = userModule.isAuthorized("/permission/admin/device-mgt/policies/manage"); types.isAuthorized = userModule.isAuthorized("/permission/admin/device-mgt/policies/manage");
@ -97,6 +115,8 @@ function onRequest(context) {
types["isCloud"] = devicemgtProps.isCloud; types["isCloud"] = devicemgtProps.isCloud;
types["isDeviceOwnerEnabled"] = devicemgtProps.isDeviceOwnerEnabled; types["isDeviceOwnerEnabled"] = devicemgtProps.isDeviceOwnerEnabled;
var enrollmentApps = policyModule.getStoreAppsForPolicy();
types["storeApps"] = JSON.stringify(enrollmentApps["content"]);
return types; return types;
} }

@ -13,6 +13,23 @@
* either express or implied. See the License for the * either express or implied. See the License for the
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*
*
* Copyright (c) 2018, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
*
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/ */
var stepForwardFrom = {}; var stepForwardFrom = {};
@ -145,8 +162,10 @@ stepForwardFrom["policy-platform"] = function (actionButton) {
var policyOperationsTemplateCacheKey = deviceType + '-policy-operations'; var policyOperationsTemplateCacheKey = deviceType + '-policy-operations';
if (policyOperationsTemplateSrc) { if (policyOperationsTemplateSrc) {
var storeApps = getStoreApps($("#logged-in-user").data("storeapps"), deviceType);
$.template(policyOperationsTemplateCacheKey, context + policyOperationsTemplateSrc, function (template) { $.template(policyOperationsTemplateCacheKey, context + policyOperationsTemplateSrc, function (template) {
var content = template({"iscloud" : $("#logged-in-user").data("iscloud"), "isDeviceOwnerEnabled" : $("#logged-in-user").data("isdeviceownerenabled")}); var content = template({"iscloud" : $("#logged-in-user").data("iscloud"),
"isDeviceOwnerEnabled" : $("#logged-in-user").data("isdeviceownerenabled"), "storeapps" : storeApps});
$("#device-type-policy-operations").html(content).removeClass("hidden"); $("#device-type-policy-operations").html(content).removeClass("hidden");
$(".policy-platform").addClass("hidden"); $(".policy-platform").addClass("hidden");
}); });
@ -172,6 +191,24 @@ stepForwardFrom["policy-platform"] = function (actionButton) {
$(".wr-advance-operations-init").addClass("hidden"); $(".wr-advance-operations-init").addClass("hidden");
}; };
/**
* Retrieve store apps of the given device type
*
* @param storeApps
* @param deviceType
* @returns {Array}
*/
function getStoreApps(storeApps, deviceType) {
var selectedApps = [];
var i;
for (i=0; i<storeApps.length; i++) {
if (deviceType === storeApps[i].platform) {
selectedApps.push(storeApps[i]);
}
}
return selectedApps;
}
/** /**
* Forward action of policy profile page. Generates policy profile payload. * Forward action of policy profile page. Generates policy profile payload.
*/ */

@ -1,7 +1,7 @@
{{#zone "content"}} {{#zone "content"}}
{{#if isAuthorized }} {{#if isAuthorized }}
<span id="logged-in-user" class="hidden" data-username="{{@user.username}}" data-domain="{{@user.domain}}" <span id="logged-in-user" class="hidden" data-username="{{@user.username}}" data-domain="{{@user.domain}}"
data-tenant-id="{{@user.tenantId}}" data-iscloud="{{isCloud}}"></span> data-tenant-id="{{@user.tenantId}}" data-iscloud="{{isCloud}}" data-storeapps="{{storeApps}}"></span>
<span id="policy-operations" class="hidden" data-template="{{policyOperations.template}}" <span id="policy-operations" class="hidden" data-template="{{policyOperations.template}}"
data-script="{{policyOperations.script}}" data-style="{{policyOperations.style}}"></span> data-script="{{policyOperations.script}}" data-style="{{policyOperations.style}}"></span>
<div class="row"> <div class="row">

@ -14,6 +14,23 @@
* either express or implied. See the License for the * either express or implied. See the License for the
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*
*
* Copyright (c) 2018, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
*
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/ */
function onRequest(context) { function onRequest(context) {
@ -21,6 +38,7 @@ function onRequest(context) {
var utility = require("/app/modules/utility.js").utility; var utility = require("/app/modules/utility.js").utility;
var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
var groupModule = require("/app/modules/business-controllers/group.js")["groupModule"]; var groupModule = require("/app/modules/business-controllers/group.js")["groupModule"];
var policyModule = require("/app/modules/business-controllers/policy.js")["policyModule"];
var rolesResult = userModule.getRoles(); var rolesResult = userModule.getRoles();
if (rolesResult.status == "success") { if (rolesResult.status == "success") {
@ -63,5 +81,8 @@ function onRequest(context) {
var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"];
context["isCloud"] = devicemgtProps.isCloud; context["isCloud"] = devicemgtProps.isCloud;
var enrollmentApps = policyModule.getStoreAppsForPolicy();
context["storeApps"] = JSON.stringify(enrollmentApps["content"]);
return context; return context;
} }

@ -14,6 +14,23 @@
* either express or implied. See the License for the * either express or implied. See the License for the
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*
*
* Copyright (c) 2018, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
*
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/ */
var validateStep = {}; var validateStep = {};
@ -202,7 +219,8 @@ skipStep["policy-platform"] = function (policyPayloadObj) {
hasPolicyProfileScript = false; hasPolicyProfileScript = false;
} }
$.template(policyEditTemplateCacheKey, context + policyEditTemplateSrc, function (template) { $.template(policyEditTemplateCacheKey, context + policyEditTemplateSrc, function (template) {
var content = template({"iscloud" : $("#logged-in-user").data("iscloud")}); var storeApps = getStoreApps($("#logged-in-user").data("storeapps"), deviceType);
var content = template({"iscloud" : $("#logged-in-user").data("iscloud"), "storeapps" : storeApps});
$("#device-type-policy-operations").html(content).removeClass("hidden"); $("#device-type-policy-operations").html(content).removeClass("hidden");
$(".policy-platform").addClass("hidden"); $(".policy-platform").addClass("hidden");
if (hasPolicyProfileScript) { if (hasPolicyProfileScript) {
@ -230,6 +248,24 @@ skipStep["policy-platform"] = function (policyPayloadObj) {
} }
}; };
/**
* Retrieve store apps of the given device type
*
* @param storeApps
* @param deviceType
* @returns {Array}
*/
function getStoreApps(storeApps, deviceType) {
var selectedApps = [];
var i;
for (i=0; i<storeApps.length; i++) {
if (storeApps[i].platform === deviceType) {
selectedApps.push(storeApps[i]);
}
}
return selectedApps;
}
/** /**
* Forward action of policy profile page. Generates policy profile payload. * Forward action of policy profile page. Generates policy profile payload.
*/ */

@ -14,6 +14,23 @@
* KIND, either express or implied. See the License for the * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*
*
* Copyright (c) 2018, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
*
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/ */
@ -123,71 +140,69 @@ public class ComplianceDecisionPointImpl implements ComplianceDecisionPoint {
public void reEnforcePolicy(DeviceIdentifier deviceIdentifier, NonComplianceData complianceData) throws public void reEnforcePolicy(DeviceIdentifier deviceIdentifier, NonComplianceData complianceData) throws
PolicyComplianceException { PolicyComplianceException {
try { // do not re-enforce policy if the only feature to be applied is enrollment app install
Policy policy = complianceData.getPolicy(); if (complianceData.getComplianceFeatures().size() != 1 || !PolicyManagementConstants
if (policy != null) { .ENROLLMENT_APP_INSTALL_FEATURE_CODE.equals(complianceData.getComplianceFeatures().get(0)
List<DeviceIdentifier> deviceIdentifiers = new ArrayList<DeviceIdentifier>(); .getFeatureCode())) {
deviceIdentifiers.add(deviceIdentifier); try {
Policy policy = complianceData.getPolicy();
if (policy != null) {
List<ProfileOperation> profileOperationList = new ArrayList<ProfileOperation>(); List<DeviceIdentifier> deviceIdentifiers = new ArrayList<>();
deviceIdentifiers.add(deviceIdentifier);
PolicyOperation policyOperation = new PolicyOperation();
policyOperation.setEnabled(true); List<ProfileOperation> profileOperationList = new ArrayList<>();
policyOperation.setType(Operation.Type.POLICY);
policyOperation.setCode(PolicyOperation.POLICY_OPERATION_CODE); PolicyOperation policyOperation = new PolicyOperation();
policyOperation.setEnabled(true);
policyOperation.setType(Operation.Type.POLICY);
if (complianceData.isCompletePolicy()) { policyOperation.setCode(PolicyOperation.POLICY_OPERATION_CODE);
List<ProfileFeature> effectiveFeatures = policy.getProfile().getProfileFeaturesList();
if (complianceData.isCompletePolicy()) {
for (ProfileFeature feature : effectiveFeatures) { List<ProfileFeature> effectiveFeatures = policy.getProfile().getProfileFeaturesList();
ProfileOperation profileOperation = new ProfileOperation(); for (ProfileFeature feature : effectiveFeatures) {
ProfileOperation profileOperation = new ProfileOperation();
profileOperation.setCode(feature.getFeatureCode()); profileOperation.setCode(feature.getFeatureCode());
profileOperation.setEnabled(true); profileOperation.setEnabled(true);
profileOperation.setStatus(Operation.Status.PENDING); profileOperation.setStatus(Operation.Status.PENDING);
profileOperation.setType(Operation.Type.PROFILE); profileOperation.setType(Operation.Type.PROFILE);
profileOperation.setPayLoad(feature.getContent()); profileOperation.setPayLoad(feature.getContent());
profileOperationList.add(profileOperation); profileOperationList.add(profileOperation);
} }
} else { } else {
List<ComplianceFeature> noneComplianceFeatures = complianceData.getComplianceFeatures(); List<ComplianceFeature> noneComplianceFeatures = complianceData.getComplianceFeatures();
List<ProfileFeature> effectiveFeatures = policy.getProfile().getProfileFeaturesList(); List<ProfileFeature> effectiveFeatures = policy.getProfile().getProfileFeaturesList();
for (ComplianceFeature feature : noneComplianceFeatures) { for (ComplianceFeature feature : noneComplianceFeatures) {
for (ProfileFeature pf : effectiveFeatures) {
for (ProfileFeature pf : effectiveFeatures) { if (pf.getFeatureCode().equalsIgnoreCase(feature.getFeatureCode())) {
if (pf.getFeatureCode().equalsIgnoreCase(feature.getFeatureCode())) { ProfileOperation profileOperation = new ProfileOperation();
profileOperation.setCode(feature.getFeatureCode());
ProfileOperation profileOperation = new ProfileOperation(); profileOperation.setEnabled(true);
profileOperation.setStatus(Operation.Status.PENDING);
profileOperation.setCode(feature.getFeatureCode()); profileOperation.setType(Operation.Type.PROFILE);
profileOperation.setEnabled(true); profileOperation.setPayLoad(pf.getContent());
profileOperation.setStatus(Operation.Status.PENDING); profileOperationList.add(profileOperation);
profileOperation.setType(Operation.Type.PROFILE); }
profileOperation.setPayLoad(pf.getContent());
profileOperationList.add(profileOperation);
} }
} }
} }
} policyOperation.setProfileOperations(profileOperationList);
policyOperation.setProfileOperations(profileOperationList); policyOperation.setPayLoad(policyOperation.getProfileOperations());
policyOperation.setPayLoad(policyOperation.getProfileOperations());
//TODO: Fix this properly later adding device type to be passed in when the task manage executes "addOperations()" //TODO: Fix this properly later adding device type to be passed in when the task manage executes "addOperations()"
String type = null; String type = null;
if (deviceIdentifiers.size() > 0) { if (deviceIdentifiers.size() > 0) {
type = deviceIdentifiers.get(0).getType(); type = deviceIdentifiers.get(0).getType();
} }
PolicyManagementDataHolder.getInstance().getDeviceManagementService(). PolicyManagementDataHolder.getInstance().getDeviceManagementService().
addOperation(type, policyOperation, deviceIdentifiers); addOperation(type, policyOperation, deviceIdentifiers);
}
} catch (InvalidDeviceException e) {
throw new PolicyComplianceException("Invalid Device identifiers found.", e);
} catch (OperationManagementException e) {
throw new PolicyComplianceException("Error occurred while re-enforcing the policy to device " + deviceIdentifier.getId() + " - " +
deviceIdentifier.getType(), e);
} }
} catch (InvalidDeviceException e) {
throw new PolicyComplianceException("Invalid Device identifiers found.", e);
} catch (OperationManagementException e) {
throw new PolicyComplianceException("Error occurred while re-enforcing the policy to device " + deviceIdentifier.getId() + " - " +
deviceIdentifier.getType(), e);
} }
} }

@ -31,6 +31,8 @@ public final class PolicyManagementConstants {
public static final String WARN = "WARN"; public static final String WARN = "WARN";
public static final String BLOCK = "BLOCK"; public static final String BLOCK = "BLOCK";
public static final String ENROLLMENT_APP_INSTALL_FEATURE_CODE = "ENROLLMENT_APP_INSTALL";
public static final String MONITORING_TASK_TYPE = "MONITORING_TASK"; public static final String MONITORING_TASK_TYPE = "MONITORING_TASK";
public static final String MONITORING_TASK_NAME = "MONITORING"; public static final String MONITORING_TASK_NAME = "MONITORING";
public static final String MONITORING_TASK_CLAZZ = "org.wso2.carbon.policy.mgt.core.task.MonitoringTask"; public static final String MONITORING_TASK_CLAZZ = "org.wso2.carbon.policy.mgt.core.task.MonitoringTask";

Loading…
Cancel
Save