revert-70aa11f8
charitha 9 years ago
parent 3d870786ae
commit aadf87e5d9

@ -118,7 +118,7 @@ public class GroupImpl implements Group {
@Override @Override
@GET @GET
@Produces("application/json") @Produces("application/json")
public Response getGroups(@QueryParam("start") int startIndex, @PathParam("length") int length) { public Response getGroups(@QueryParam("start") int startIndex, @QueryParam("length") int length) {
try { try {
PaginationResult paginationResult = DeviceMgtAPIUtils.getGroupManagementProviderService() PaginationResult paginationResult = DeviceMgtAPIUtils.getGroupManagementProviderService()
.getGroups(startIndex, length); .getGroups(startIndex, length);
@ -331,8 +331,7 @@ public class GroupImpl implements Group {
@Produces("application/json") @Produces("application/json")
public Response addSharing(@QueryParam("shareUser") String shareUser, public Response addSharing(@QueryParam("shareUser") String shareUser,
@PathParam("groupName") String groupName, @PathParam("owner") String owner, @PathParam("groupName") String groupName, @PathParam("owner") String owner,
@PathParam("roleName") String roleName, @PathParam("roleName") String roleName, String[] permissions) {
@FormParam("permissions") String[] permissions) {
try { try {
boolean isAdded = DeviceMgtAPIUtils.getGroupManagementProviderService().addGroupSharingRole( boolean isAdded = DeviceMgtAPIUtils.getGroupManagementProviderService().addGroupSharingRole(

@ -21,6 +21,11 @@ package org.wso2.carbon.device.mgt.jaxrs.api.impl;
import org.apache.commons.httpclient.HttpStatus; import org.apache.commons.httpclient.HttpStatus;
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.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationException;
import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationService;
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
import org.wso2.carbon.device.mgt.jaxrs.api.common.MDMAPIException; import org.wso2.carbon.device.mgt.jaxrs.api.common.MDMAPIException;
import org.wso2.carbon.device.mgt.jaxrs.api.util.DeviceMgtAPIUtils; import org.wso2.carbon.device.mgt.jaxrs.api.util.DeviceMgtAPIUtils;
import org.wso2.carbon.device.mgt.jaxrs.beans.PriorityUpdatedPolicyWrapper; import org.wso2.carbon.device.mgt.jaxrs.beans.PriorityUpdatedPolicyWrapper;
@ -97,6 +102,22 @@ public class PolicyImpl implements org.wso2.carbon.device.mgt.jaxrs.api.Policy {
private Response addPolicy(PolicyManagerService policyManagementService, ResponsePayload responseMsg, private Response addPolicy(PolicyManagerService policyManagementService, ResponsePayload responseMsg,
org.wso2.carbon.policy.mgt.common.Policy policy) { org.wso2.carbon.policy.mgt.common.Policy policy) {
List<Device> devices = policy.getDevices();
if (devices != null && devices.size() == 1) {
DeviceAccessAuthorizationService deviceAccessAuthorizationService = DeviceManagementDataHolder.getInstance().getDeviceAccessAuthorizationService();
DeviceIdentifier deviceIdentifier = new DeviceIdentifier(devices.get(0).getDeviceIdentifier(), devices.get(0).getType());
PrivilegedCarbonContext threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
String username = threadLocalCarbonContext.getUsername();
try {
if (!deviceAccessAuthorizationService.isUserAuthorized(deviceIdentifier, username)) {
return Response.status(Response.Status.UNAUTHORIZED).build();
}
} catch (DeviceAccessAuthorizationException e) {
String msg = "Device access authorization exception";
log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
}
}
try { try {
PolicyAdministratorPoint pap = policyManagementService.getPAP(); PolicyAdministratorPoint pap = policyManagementService.getPAP();
pap.addPolicy(policy); pap.addPolicy(policy);

@ -669,6 +669,12 @@
<url>/policies/inactive-policy</url> <url>/policies/inactive-policy</url>
<method>POST</method> <method>POST</method>
</Permission> </Permission>
<Permission>
<name>Add Policy</name>
<path>/device-mgt/user/policies/add</path>
<url>/policies/inactive-policy</url>
<method>POST</method>
</Permission>
<Permission> <Permission>
<name>List policies</name> <name>List policies</name>
@ -704,6 +710,12 @@
<url>/policies/active-policy</url> <url>/policies/active-policy</url>
<method>POST</method> <method>POST</method>
</Permission> </Permission>
<Permission>
<name>Add Policy</name>
<path>/device-mgt/user/policies/add</path>
<url>/policies/inactive-policy</url>
<method>POST</method>
</Permission>
<Permission> <Permission>
<name>Remove policy</name> <name>Remove policy</name>
@ -726,6 +738,20 @@
<method>GET</method> <method>GET</method>
</Permission> </Permission>
<Permission>
<name>List user policies</name>
<path>/device-mgt/user/policies/list</path>
<url>/policies</url>
<method>GET</method>
</Permission>
<Permission>
<name>List user policies</name>
<path>/device-mgt/user/policies/list</path>
<url>/policies/*</url>
<method>GET</method>
</Permission>
<Permission> <Permission>
<name>Update policy</name> <name>Update policy</name>
<path>/device-mgt/admin/policies/update</path> <path>/device-mgt/admin/policies/update</path>

@ -668,6 +668,9 @@ var userModule = function () {
if (publicMethods.isAuthorized("/permission/admin/device-mgt/admin/roles/add")) { if (publicMethods.isAuthorized("/permission/admin/device-mgt/admin/roles/add")) {
permissions["ADD_ROLE"] = true; permissions["ADD_ROLE"] = true;
} }
if (publicMethods.isAuthorized("/permission/admin/device-mgt/admin/policies/add")) {
permissions["ADD_ADMIN_POLICY"] = true;
}
if (publicMethods.isAuthorized("/permission/admin/device-mgt/user/policies/add")) { if (publicMethods.isAuthorized("/permission/admin/device-mgt/user/policies/add")) {
permissions["ADD_POLICY"] = true; permissions["ADD_POLICY"] = true;
} }

@ -16,6 +16,7 @@
{{/zone}} {{/zone}}
{{#zone "navbarActions"}} {{#zone "navbarActions"}}
{{#if permissions.ADD_ADMIN_POLICY}}
<li> <li>
<a href="{{@app.context}}/policy/add" class="cu-btn"> <a href="{{@app.context}}/policy/add" class="cu-btn">
<span class="icon fw-stack"> <span class="icon fw-stack">
@ -25,7 +26,9 @@
Add Policy Add Policy
</a> </a>
</li> </li>
<li> {{/if}}
{{#if permissions.CHANGE_POLICY_PRIORITY}}
<li>
<a href="{{@app.context}}/policy/priority" class="cu-btn"> <a href="{{@app.context}}/policy/priority" class="cu-btn">
<span class="icon fw-stack"> <span class="icon fw-stack">
<i class="fw fw-throttling-policy fw-stack-1x"></i> <i class="fw fw-throttling-policy fw-stack-1x"></i>
@ -34,6 +37,7 @@
Policy Priority Policy Priority
</a> </a>
</li> </li>
{{/if}}
<li> <li>
<a href="#" class="cu-btn" id="appbar-btn-apply-changes"> <a href="#" class="cu-btn" id="appbar-btn-apply-changes">
<span class="icon fw-stack"> <span class="icon fw-stack">

@ -16,14 +16,17 @@
* under the License. * under the License.
*/ */
function onRequest(context){ function onRequest(context) {
context.handlebars.registerHelper('equal', function (lvalue, rvalue, options) { context.handlebars.registerHelper('equal', function (lvalue, rvalue, options) {
if (arguments.length < 3) if (arguments.length < 3) {
throw new Error("Handlebars Helper equal needs 2 parameters"); throw new Error("Handlebars Helper equal needs 2 parameters");
if( lvalue!=rvalue ) { }
if (lvalue != rvalue) {
return options.inverse(this); return options.inverse(this);
} else { } else {
return options.fn(this); return options.fn(this);
} }
}); });
var userModule = require("/app/modules/user.js").userModule;
return {permissions: userModule.getUIPermissions()};
} }

@ -22,7 +22,7 @@
<div class="col-md-3 col-xs-3"> <div class="col-md-3 col-xs-3">
<div class="itm-wiz" data-step="policy-criteria"> <div class="itm-wiz" data-step="policy-criteria">
<div class="wiz-no">3</div> <div class="wiz-no">3</div>
<div class="wiz-lbl hidden-xs"><span>Assign to groups</span></div> <div class="wiz-lbl hidden-xs"><span>Assign</span></div>
</div> </div>
<br class="c-both"/> <br class="c-both"/>
</div> </div>

Loading…
Cancel
Save