Search in sources :

Example 1 with AclProperty

use of org.apache.jackrabbit.webdav.security.AclProperty in project jackrabbit by apache.

the class AbstractWebdavServlet method doAcl.

/**
 * The ACL method
 *
 * @param request
 * @param response
 * @param resource
 * @throws DavException
 * @throws IOException
 */
protected void doAcl(WebdavRequest request, WebdavResponse response, DavResource resource) throws DavException, IOException {
    if (!(resource instanceof AclResource)) {
        response.sendError(DavServletResponse.SC_METHOD_NOT_ALLOWED);
        return;
    }
    Document doc = request.getRequestDocument();
    if (doc == null) {
        throw new DavException(DavServletResponse.SC_BAD_REQUEST, "ACL request requires a DAV:acl body.");
    }
    AclProperty acl = AclProperty.createFromXml(doc.getDocumentElement());
    ((AclResource) resource).alterAcl(acl);
}
Also used : AclProperty(org.apache.jackrabbit.webdav.security.AclProperty) AclResource(org.apache.jackrabbit.webdav.security.AclResource) DavException(org.apache.jackrabbit.webdav.DavException) Document(org.w3c.dom.Document)

Example 2 with AclProperty

use of org.apache.jackrabbit.webdav.security.AclProperty in project jackrabbit by apache.

the class AclPrincipalReport method init.

/**
 * @see Report#init(DavResource, ReportInfo)
 */
@Override
public void init(DavResource resource, ReportInfo info) throws DavException {
    super.init(resource, info);
    // build the DAV:responses objects.
    DavProperty<?> acl = resource.getProperty(SecurityConstants.ACL);
    if (!(acl instanceof AclProperty)) {
        throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR, "DAV:acl property expected.");
    }
    DavResourceLocator loc = resource.getLocator();
    Map<String, MultiStatusResponse> respMap = new HashMap<String, MultiStatusResponse>();
    List<AclProperty.Ace> list = (List<AclProperty.Ace>) ((AclProperty) acl).getValue();
    for (AclProperty.Ace ace : list) {
        String href = normalizeResourceHref(ace.getPrincipal().getHref());
        if (href == null || respMap.containsKey(href)) {
            // ignore non-href principals and principals that have been listed before
            continue;
        }
        // href-principal that has not been found before
        DavResourceLocator princLocator = loc.getFactory().createResourceLocator(loc.getPrefix(), href);
        DavResource principalResource = resource.getFactory().createResource(princLocator, resource.getSession());
        respMap.put(href, new MultiStatusResponse(principalResource, info.getPropertyNameSet()));
    }
    this.responses = respMap.values().toArray(new MultiStatusResponse[respMap.size()]);
}
Also used : AclProperty(org.apache.jackrabbit.webdav.security.AclProperty) DavResource(org.apache.jackrabbit.webdav.DavResource) DavException(org.apache.jackrabbit.webdav.DavException) HashMap(java.util.HashMap) MultiStatusResponse(org.apache.jackrabbit.webdav.MultiStatusResponse) List(java.util.List) DavResourceLocator(org.apache.jackrabbit.webdav.DavResourceLocator)

Aggregations

DavException (org.apache.jackrabbit.webdav.DavException)2 AclProperty (org.apache.jackrabbit.webdav.security.AclProperty)2 HashMap (java.util.HashMap)1 List (java.util.List)1 DavResource (org.apache.jackrabbit.webdav.DavResource)1 DavResourceLocator (org.apache.jackrabbit.webdav.DavResourceLocator)1 MultiStatusResponse (org.apache.jackrabbit.webdav.MultiStatusResponse)1 AclResource (org.apache.jackrabbit.webdav.security.AclResource)1 Document (org.w3c.dom.Document)1