/** * Build a new <code>AclProperty</code> object from the request body of the * ACL method call. * * @param aclElement * @return new <code>AclProperty</code> * @throws DavException */ public static AclProperty createFromXml(Element aclElement) throws DavException { if (!DomUtil.matches(aclElement, SecurityConstants.ACL.getName(), SecurityConstants.ACL.getNamespace())) { throw new DavException(DavServletResponse.SC_BAD_REQUEST, "ACL request requires a DAV:acl body."); } List<Ace> aces = new ArrayList<Ace>(); ElementIterator it = DomUtil.getChildren(aclElement, Ace.XML_ACE, SecurityConstants.NAMESPACE); while (it.hasNext()) { Element aceElem = it.nextElement(); aces.add(Ace.createFromXml(aceElem)); } return new AclProperty(aces); }
/** * Build a new <code>AclProperty</code> object from the request body of the * ACL method call. * * @param aclElement * @return new <code>AclProperty</code> * @throws DavException */ public static AclProperty createFromXml(Element aclElement) throws DavException { if (!DomUtil.matches(aclElement, SecurityConstants.ACL.getName(), SecurityConstants.ACL.getNamespace())) { throw new DavException(DavServletResponse.SC_BAD_REQUEST, "ACL request requires a DAV:acl body."); } List<Ace> aces = new ArrayList<Ace>(); ElementIterator it = DomUtil.getChildren(aclElement, Ace.XML_ACE, SecurityConstants.NAMESPACE); while (it.hasNext()) { Element aceElem = it.nextElement(); aces.add(Ace.createFromXml(aceElem)); } return new AclProperty(aces); }
/** * Build a new <code>AclProperty</code> object from the request body of the * ACL method call. * * @param aclElement * @return new <code>AclProperty</code> * @throws DavException */ public static AclProperty createFromXml(Element aclElement) throws DavException { if (!DomUtil.matches(aclElement, SecurityConstants.ACL.getName(), SecurityConstants.ACL.getNamespace())) { throw new DavException(DavServletResponse.SC_BAD_REQUEST, "ACL request requires a DAV:acl body."); } List aces = new ArrayList(); ElementIterator it = DomUtil.getChildren(aclElement, Ace.XML_ACE, SecurityConstants.NAMESPACE); while (it.hasNext()) { Element aceElem = it.nextElement(); aces.add(Ace.createFromXml(aceElem)); } return new AclProperty(aces); }
/** * Used to Set the Aces at the given path. * @param client Client making the request. * @param aces Aces to set. * @param path Path to Resource * @throws CalDAV4JException on error. */ public void setAces(HttpClient client, AclProperty.Ace[] aces, String path) throws CalDAV4JException { HttpAclMethod method = null; try { method = methodFactory.createAclMethod(getCalendarCollectionRoot() + UrlUtils.defaultString(path, "") , new AclProperty(aces)); HttpResponse response = client.execute(getDefaultHttpHost(method.getURI()), method); int status = response.getStatusLine().getStatusCode(); switch (status) { case CalDAVStatus.SC_OK: break; case CalDAVStatus.SC_NOT_FOUND: throw new ResourceNotFoundException(ResourceNotFoundException.IdentifierType.PATH, method.getURI().toString()); case CalDAVStatus.SC_UNAUTHORIZED: default: throw new BadStatusException(status, method.getMethod(), getCalendarCollectionRoot()); } } catch (IOException e) { throw new CalDAV4JException("Error in ACL " + getCalendarCollectionRoot(), e); } finally { if(method != null) method.reset(); } }