Creating runtime permission policy for android devices

revert-dabc3590
Pasindu 8 years ago
parent 2806a7a31c
commit 60470d039a

@ -1646,7 +1646,67 @@ public interface DeviceManagementAdminService {
"If a passcode policy has been set in EMM, the lock code should comply to the passcode policy.\t",
required = true)
LockCodeBeanWrapper lockCodeBeanWrapper);
/*
@POST
@Path("/set-runtime-permission-policy")
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
httpMethod = "POST",
value = "Setting a Runtime Permission Policy on Android Devices",
notes = "Set a runtime permission policy on Android devices.",
response = Activity.class,
tags = "Android Device Management Administrative Service",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:set-runtime-permission-policy")
})
}
)
@ApiResponses(value = {
@ApiResponse(
code = 201,
message = "Created. \n Successfully scheduled the set runtime permission policy operation.",
response = Activity.class,
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
description = "URL of the activity instance that refers to the scheduled operation."),
@ResponseHeader(
name = "Content-Type",
description = "Content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource was last modified.\n" +
"Used by caches, or in conditional requests.")}),
@ApiResponse(
code = 303,
message = "See Other. \n The source can be retrieved from the URL specified in the location header.",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
description = "The Source URL of the document.")}),
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(
code = 415,
message = "Unsupported media type. \n The entity of the request was in a not supported format."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
"Server error occurred while adding a new set runtime permission policy operation.")
})
Response setRuntimePermissionPolicy(
@ApiParam(
name = "runtimePermissionPolicy",
value = "The properties required to set a runtime permission policy.",
required = true)
RuntimePermissionPolicyBeanWrapper runtimePermissionPolicyBeanWrapper);
*/
@POST
@Path("/set-password-policy")
@ApiOperation(

@ -27,37 +27,8 @@ 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.core.operation.mgt.CommandOperation;
import org.wso2.carbon.device.mgt.core.operation.mgt.ProfileOperation;
import org.wso2.carbon.mdm.services.android.bean.ApplicationInstallation;
import org.wso2.carbon.mdm.services.android.bean.ApplicationUninstallation;
import org.wso2.carbon.mdm.services.android.bean.ApplicationUpdate;
import org.wso2.carbon.mdm.services.android.bean.BlacklistApplications;
import org.wso2.carbon.mdm.services.android.bean.Camera;
import org.wso2.carbon.mdm.services.android.bean.DeviceEncryption;
import org.wso2.carbon.mdm.services.android.bean.DeviceLock;
import org.wso2.carbon.mdm.services.android.bean.ErrorResponse;
import org.wso2.carbon.mdm.services.android.bean.LockCode;
import org.wso2.carbon.mdm.services.android.bean.Notification;
import org.wso2.carbon.mdm.services.android.bean.PasscodePolicy;
import org.wso2.carbon.mdm.services.android.bean.UpgradeFirmware;
import org.wso2.carbon.mdm.services.android.bean.Vpn;
import org.wso2.carbon.mdm.services.android.bean.WebClip;
import org.wso2.carbon.mdm.services.android.bean.Wifi;
import org.wso2.carbon.mdm.services.android.bean.WipeData;
import org.wso2.carbon.mdm.services.android.bean.wrapper.ApplicationInstallationBeanWrapper;
import org.wso2.carbon.mdm.services.android.bean.wrapper.ApplicationUninstallationBeanWrapper;
import org.wso2.carbon.mdm.services.android.bean.wrapper.ApplicationUpdateBeanWrapper;
import org.wso2.carbon.mdm.services.android.bean.wrapper.BlacklistApplicationsBeanWrapper;
import org.wso2.carbon.mdm.services.android.bean.wrapper.CameraBeanWrapper;
import org.wso2.carbon.mdm.services.android.bean.wrapper.DeviceLockBeanWrapper;
import org.wso2.carbon.mdm.services.android.bean.wrapper.EncryptionBeanWrapper;
import org.wso2.carbon.mdm.services.android.bean.wrapper.LockCodeBeanWrapper;
import org.wso2.carbon.mdm.services.android.bean.wrapper.NotificationBeanWrapper;
import org.wso2.carbon.mdm.services.android.bean.wrapper.PasswordPolicyBeanWrapper;
import org.wso2.carbon.mdm.services.android.bean.wrapper.UpgradeFirmwareBeanWrapper;
import org.wso2.carbon.mdm.services.android.bean.wrapper.VpnBeanWrapper;
import org.wso2.carbon.mdm.services.android.bean.wrapper.WebClipBeanWrapper;
import org.wso2.carbon.mdm.services.android.bean.wrapper.WifiBeanWrapper;
import org.wso2.carbon.mdm.services.android.bean.wrapper.WipeDataBeanWrapper;
import org.wso2.carbon.mdm.services.android.bean.*;
import org.wso2.carbon.mdm.services.android.bean.wrapper.*;
import org.wso2.carbon.mdm.services.android.exception.BadRequestException;
import org.wso2.carbon.mdm.services.android.exception.UnexpectedServerErrorException;
import org.wso2.carbon.mdm.services.android.services.DeviceManagementAdminService;
@ -937,7 +908,48 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build());
}
}
/*
@POST
@Path("/set-runtime-permission-policy")
@Override
public Response setRuntimePermissionPolicy(RuntimePermissionPolicyBeanWrapper runtimePermissionPolicyBeanWrapper){
if (log.isDebugEnabled()) {
log.debug("Invoking 'runtime permission policy' operation");
}
try {
if (runtimePermissionPolicyBeanWrapper == null || runtimePermissionPolicyBeanWrapper.getOperation() == null) {
String errorMessage = "The payload of the change runtime permission policy operation is incorrect";
log.error(errorMessage);
throw new BadRequestException(
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
}
RuntimePermissionPolicy runtimePermissionPolicy = runtimePermissionPolicyBeanWrapper.getOperation();
ProfileOperation operation = new ProfileOperation();
operation.setCode(AndroidConstants.OperationCodes.RUNTIME_PERMISSION_POLICY);
operation.setType(Operation.Type.PROFILE);
operation.setPayLoad(runtimePermissionPolicy.toJSON());
return AndroidAPIUtils.getOperationResponse(runtimePermissionPolicyBeanWrapper.getDeviceIDs(),
operation);
} catch (InvalidDeviceException e) {
String errorMessage = "Invalid Device Identifiers found.";
log.error(errorMessage, e);
throw new BadRequestException(
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
} catch (OperationManagementException e) {
String errorMessage = "Issue in retrieving operation management service instance";
log.error(errorMessage, e);
throw new UnexpectedServerErrorException(
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build());
} catch (DeviceManagementException e) {
String errorMessage = "Issue in retrieving device management service instance";
log.error(errorMessage, e);
throw new UnexpectedServerErrorException(
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build());
}
}
*/
@POST
@Path("/set-password-policy")
@Override

@ -79,6 +79,7 @@ public final class AndroidConstants {
public static final String WIFI = "WIFI";
public static final String CAMERA = "CAMERA";
public static final String DEVICE_MUTE = "DEVICE_MUTE";
public static final String RUNTIME_PERMISSION_POLICY = "RUNTIME_PERMISSION_POLICY";
public static final String PASSCODE_POLICY = "PASSCODE_POLICY";
public static final String DEVICE_INFO = "DEVICE_INFO";
public static final String ENTERPRISE_WIPE = "ENTERPRISE_WIPE";
@ -104,6 +105,11 @@ public final class AndroidConstants {
public static final String WORK_PROFILE = "WORK_PROFILE";
}
public final class RuntimePermissionType {
public static final String PERMISSION_POLICY_PROMPT = "PERMISSION_POLICY_PROMPT";
public static final String PERMISSION_POLICY_AUTO_GRANT = "PERMISSION_POLICY_AUTO_GRANT";
public static final String PERMISSION_POLICY_AUTO_DENY = "PERMISSION_POLICY_AUTO_DENY";
}
public final class StatusCodes {
private StatusCodes() {
throw new AssertionError();

@ -1,4 +1,3 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,

@ -88,6 +88,18 @@
class="fw fw-success"></i></span>
<span id="app-restriction-error" class="has-error status-icon hidden"><i class="fw fw-error"></i></span>
</a>
<a href="javascript:void(0)" onclick="showAdvanceOperation('runtime-permission-policy', this)">
<span class="fw-stack fw-lg">
<i class="fw fw-application fw-stack-1x"></i>
<i class="fw fw-block fw-stack-2x"></i>
</span>
Runtime Permission Policy (COSU)
<span id="runtime-permission-policy-configured" class="has-configured status-icon hidden"><i
class="fw fw-success"></i></span>
<span id="runtime-permission-policy-ok" class="has-success status-icon hidden"><i
class="fw fw-success"></i></span>
<span id="runtime-permission-policy-error" class="has-error status-icon hidden"><i class="fw fw-error"></i></span>
</a>
<a href="javascript:void(0)" class="worker-profile"
onclick="showAdvanceOperation('cosu-system-update-policy', this)">
<span class="wr-hidden-operation-icon fw-stack">
@ -271,8 +283,6 @@
</div>
</div>
</div>
<!-- /passcode-policy -->
<!-- camera -->
<div class="wr-hidden-operation" data-operation="camera">
<div class="panel panel-default operation-data" data-operation="camera" data-operation-code="CAMERA">
@ -1221,6 +1231,56 @@
</div>
</div>
</div>
<!-- runtime permission policy -->
<div class="wr-hidden-operation" data-operation="runtime-permission-policy">
<div class="panel panel-default operation-data" data-operation="runtime-permission-policy-body"
data-operation-code="RUNTIME_PERMISSION_POLICY">
<div id="runtime-permission-policy-heading" class="panel-heading" role="tab">
<h2 class="sub-title panel-title">
Runtime Permission Policy (COSU)
<label id="runtime-permission-policy-lbl" class="wr-input-control switch" data-toggle="collapse"
data-target="#runtime-permission-policy-body">
<input type="checkbox"/>
<span class="helper"></span>
<span class="text"></span>
</label>
</h2>
<div class="panel-title-description">
This configuration can be used to set a runtime permission policy to an Android Device.
</div>
</div>
<div id="runtime-permission-policy-body" class="panel-collapse panel-body collapse"
role="tabpanel"
aria-labelledby="runtime-permission-policy-body">
<hr/>
<div class="wr-input-control">
<label class="wr-input-label" for="runtime-permission-policy-window-start-time">
Set runtime permission
<span class="helper" title="When an app requests a runtime permission, this enforces whether the user needs to prompted or the permission either automatically granted or denied.">
<span class="wr-help-tip glyphicon glyphicon-question-sign"></span>
</span>
</label>
<select id="runtime-permission-policy-permission-type"
class="form-control operationDataKeys"
data-key="runtimePermissionPolicyPermissionType" data-default="0">
<option value="1" selected="selected">PROMPT USER</option>
<option value="2">AUTO GRANT</option>
<option value="3">AUTO DENY</option>
</select>
<div>
<ul class="message message-info">
<i class="icon fw fw-info"></i>
<a>
Already granted or denied permissions are not affected by this.
</a>
</ul>
</div>
</div>
</div>
</div>
</div>
<!-- cosu-system-update-policy -->
<div class="wr-hidden-operation" data-operation="cosu-system-update-policy">
<div class="panel panel-default operation-data" data-operation="cosu-system-update-policy-body"

@ -1,31 +1,29 @@
instructions.configure = \
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/);\
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/devicetypes/);\
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/devicetypes/android_sense/);\
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/webapps/);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.androidsense_${feature.version}/webapps/,target:${installFolder}/../../deployment/server/webapps/,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/carbonapps/);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.androidsense_${feature.version}/carbonapps/,target:${installFolder}/../../resources/devicetypes/android_sense/,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../../resources/);\
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../../resources/devicetypes/);\
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../../resources/devicetypes/android_sense/);\
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../../repository/deployment/server/webapps/);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.androidsense_${feature.version}/webapps/,target:${installFolder}/../../../repository/deployment/server/webapps/,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../../repository/deployment/server/carbonapps/);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.androidsense_${feature.version}/carbonapps/,target:${installFolder}/../../../resources/devicetypes/android_sense/,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.androidsense_${feature.version}/dbscripts/,target:${installFolder}/../../../dbscripts/cdm/plugins/android_sense,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.androidsense_${feature.version}/datasources/,target:${installFolder}/../../conf/datasources/,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/jaggeryapps/);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.androidsense_${feature.version}/jaggeryapps/,target:${installFolder}/../../deployment/server/jaggeryapps/,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../database/);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.androidsense_${feature.version}/database/,target:${installFolder}/../../database/,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/devicetypes/);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.androidsense_${feature.version}/devicetypes/,target:${installFolder}/../../deployment/server/devicetypes/,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.androidsense_${feature.version}/datasources/,target:${installFolder}/../../../repository/conf/datasources/,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../../repository/deployment/server/jaggeryapps/);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.androidsense_${feature.version}/jaggeryapps/,target:${installFolder}/../../../repository/deployment/server/jaggeryapps/,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../../repository/deployment/server/devicetypes/);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.androidsense_${feature.version}/devicetypes/,target:${installFolder}/../../../repository/deployment/server/devicetypes/,overwrite:true);\
instructions.unconfigure = \
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/webapps/android_sense.war);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/webapps/android_sense);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../../repository/deployment/server/webapps/android_sense.war);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../../repository/deployment/server/webapps/android_sense);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../../dbscripts/cdm/plugins/android_sense);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../resources/sketches/android_sense);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../conf/datasources/androidsense-datasources.xml);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../database/AndroidSenseDM_DB.h2.db);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.device-view);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.analytics-view);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.platform.configuration);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.realtime.analytics-view);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/carbonapps/android_sense.car);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/devicetypes/android_sense.xml);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../../repository/resources/sketches/android_sense);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../../repository/conf/datasources/androidsense-datasources.xml);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../../repository/database/AndroidSenseDM_DB.h2.db);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../../repository/deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.device-view);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../../repository/deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../../repository/deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.analytics-view);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../../repository/deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.platform.configuration);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../../repository/deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.realtime.analytics-view);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../../repository/deployment/server/carbonapps/android_sense.car);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../../repository/deployment/server/devicetypes/android_sense.xml);\

@ -193,6 +193,10 @@
<Name>Password Policy</Name>
<Description>Set passcode policy</Description>
</Feature>
<Feature code="RUNTIME_PERMISSION_POLICY">
<Name>Runtime Permission Policy</Name>
<Description>Set runtime permission</Description>
</Feature>
<Feature code="VPN">
<Name>Configure VPN</Name>
<Description>Configure VPN settings</Description>

@ -1128,7 +1128,7 @@
<javax.ws.rs.version>1.1.1</javax.ws.rs.version>
<!-- Carbon Device Management -->
<carbon.devicemgt.version>2.0.58</carbon.devicemgt.version>
<carbon.devicemgt.version>2.0.62-SNAPSHOT</carbon.devicemgt.version>
<carbon.devicemgt.version.range>[2.0.0, 3.0.0)</carbon.devicemgt.version.range>
<!-- Carbon App Management -->

Loading…
Cancel
Save