Search in sources :

Example 1 with PermissionImpl

use of org.apereo.portal.security.provider.PermissionImpl in project uPortal by Jasig.

the class PermissionAssignmentMapController method updatePermission.

@RequestMapping(value = "/updatePermission", method = RequestMethod.GET)
public ModelAndView updatePermission(@RequestParam("principal") String principal, @RequestParam("assignment") String assignment, @RequestParam("principals[]") String[] principals, @RequestParam("owner") String owner, @RequestParam("activity") String activity, @RequestParam("target") String target, HttpServletRequest request, HttpServletResponse response) throws Exception {
    // ensure the current user is authorized to update and view permissions
    final IPerson currentUser = personManager.getPerson((HttpServletRequest) request);
    if (!permissionAdministrationHelper.canEditPermission(currentUser, target) || !permissionAdministrationHelper.canViewPermission(currentUser, target)) {
        response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
        return null;
    }
    JsonEntityBean bean = groupListHelper.getEntityForPrincipal(principal);
    if (bean != null) {
        IAuthorizationPrincipal p = groupListHelper.getPrincipalForEntity(bean);
        IPermission[] directPermissions = permissionStore.select(owner, p.getPrincipalString(), activity, target, null);
        this.authorizationService.removePermissions(directPermissions);
        assignment = assignment.toUpperCase();
        if (assignment.equals(Assignment.Type.GRANT.toString()) || assignment.equals(Assignment.Type.DENY.toString())) {
            IPermission permission = new PermissionImpl(owner);
            permission.setActivity(activity);
            permission.setPrincipal(bean.getPrincipalString());
            permission.setTarget(target);
            permission.setType(assignment);
            this.authorizationService.addPermissions(new IPermission[] { permission });
        }
    } else {
        log.warn("Unable to resolve the following principal (will " + "be omitted from the list of assignments):  " + principal);
    }
    return getOwners(principals, owner, activity, target, request, response);
}
Also used : IPerson(org.apereo.portal.security.IPerson) JsonEntityBean(org.apereo.portal.layout.dlm.remoting.JsonEntityBean) IPermission(org.apereo.portal.security.IPermission) PermissionImpl(org.apereo.portal.security.provider.PermissionImpl) IAuthorizationPrincipal(org.apereo.portal.security.IAuthorizationPrincipal) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

JsonEntityBean (org.apereo.portal.layout.dlm.remoting.JsonEntityBean)1 IAuthorizationPrincipal (org.apereo.portal.security.IAuthorizationPrincipal)1 IPermission (org.apereo.portal.security.IPermission)1 IPerson (org.apereo.portal.security.IPerson)1 PermissionImpl (org.apereo.portal.security.provider.PermissionImpl)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1