@Override
  public String render(RenderContext rc) {
    log.debug("render");
    Resource resource = rc.getTargetPage();
    Request request = (Request) rc.getAttribute("request");
    if (request == null)
      throw new RuntimeException("expected to find request in RenderContext attribute");

    PermissionsAuthoriser permissionsAuthoriser =
        RequestContext.getCurrent().get(PermissionsAuthoriser.class);
    if (permissionsAuthoriser == null)
      throw new IllegalStateException("Not found in configuration: " + PermissionsAuthoriser.class);

    Boolean b =
        permissionsAuthoriser.authorise(
            resource, request, request.getMethod(), request.getAuthorization());
    log.debug("result: " + b);
    if (b == null) return null;
    else return b.toString();
  }
Esempio n. 2
0
 @Override
 public boolean authorise( Request request, Method method, Auth auth ) {
     PermissionChecker permissionChecker = RequestContext.getCurrent().get( PermissionChecker.class );
     Role editingRole = _(AuthoringPermissionService.class).getEditRole( editee );
     return permissionChecker.hasRole( editingRole, this.editee, auth );
 }