Example #1
0
 /**
  * Handles DELETE requests.
  *
  * Performs all lock related checks necessary for the DELETE request. In case
  * a violation with locks is detected or any other pre-condition check
  * fails, this method returns an instance of {@link ezcWebdavResponse}. If
  * everything is correct, null is returned, so that the $request is handled
  * by the backend.
  *
  * @param ezcWebdavRequest $request ezcWebdavDeleteRequest
  * @return ezcWebdavResponse|null
  */
 public function receivedRequest(ezcWebdavRequest $request)
 {
     $ifHeader = $request->getHeader('If');
     $targetLockRefresher = null;
     if ($ifHeader !== null) {
         $targetLockRefresher = new ezcWebdavLockRefreshRequestGenerator($request);
     }
     $violation = $this->tools->checkViolations(new ezcWebdavLockCheckInfo($request->requestUri, ezcWebdavRequest::DEPTH_INFINITY, $request->getHeader('If'), $request->getHeader('Authorization'), ezcWebdavAuthorizer::ACCESS_WRITE, $targetLockRefresher), true);
     // Lock refresh must occur no matter if the request succeeds
     if ($targetLockRefresher !== null) {
         $targetLockRefresher->sendRequests();
     }
     if ($violation !== null) {
         // ezcWebdavErrorResponse
         return $violation;
     }
 }
Example #2
0
 /**
  * Handles MKCOL requests.
  *
  * Performs all lock related checks necessary for the MKCOL request. In
  * case a violation with locks is detected or any other pre-condition check
  * fails, this method returns an instance of {@link ezcWebdavResponse}. If
  * everything is correct, null is returned, so that the $request is handled
  * by the backend.
  *
  * @param ezcWebdavRequest $request ezcWebdavMakeCollectionRequest
  * @return ezcWebdavResponse|null
  */
 public function receivedRequest(ezcWebdavRequest $request)
 {
     $this->request = $request;
     $target = $request->requestUri;
     $parent = dirname($target);
     $ifHeader = $request->getHeader('If');
     $authHeader = $request->getHeader('Authorization');
     $targetLockRefresher = null;
     if ($ifHeader !== null) {
         $targetLockRefresher = new ezcWebdavLockRefreshRequestGenerator($request);
     }
     $violation = $this->tools->checkViolations(new ezcWebdavLockCheckInfo($target, ezcWebdavRequest::DEPTH_ZERO, $ifHeader, $authHeader, ezcWebdavAuthorizer::ACCESS_WRITE, $targetLockRefresher), true);
     if ($violation !== null && $violation->status !== ezcWebdavResponse::STATUS_404) {
         // Desired collection exists and conditions are violated
         return $violation;
     }
     if ($violation !== null && $violation->status === ezcWebdavResponse::STATUS_404) {
         // Desired collection does not exist, check parent
         $violation = $this->tools->checkViolations(new ezcWebdavLockCheckInfo($parent, ezcWebdavRequest::DEPTH_ZERO, $ifHeader, $authHeader, ezcWebdavAuthorizer::ACCESS_WRITE, $targetLockRefresher), true);
         if ($violation !== null) {
             if ($violation->status === ezcWebdavResponse::STATUS_404) {
                 // The parent does not exist, not the target.
                 $violation->status = ezcWebdavResponse::STATUS_409;
             }
             return $violation;
         }
     }
     // Lock refresh must occur no matter if the request succeeds
     if ($targetLockRefresher !== null) {
         $targetLockRefresher->sendRequests();
         // Store property for later patching
         $this->lockDiscoveryProp = $targetLockRefresher->getLockDiscoveryProperty($target);
         if ($this->lockDiscoveryProp === null) {
             $this->lockDiscoveryProp = $targetLockRefresher->getLockDiscoveryProperty($parent);
             $this->isParentProp = true;
         }
     }
     return null;
 }
Example #3
0
 /**
  * Handles PROPPATCH requests.
  *
  * Performs all lock related checks necessary for the PROPPATCH request. In
  * case a violation with locks is detected or any other pre-condition check
  * fails, this method returns an instance of {@link ezcWebdavResponse}. If
  * everything is correct, null is returned, so that the $request is handled
  * by the backend.
  *
  * @param ezcWebdavPropPatchRequest $request 
  * @return ezcWebdavResponse
  */
 public function receivedRequest(ezcWebdavRequest $request)
 {
     $ifHeader = $request->getHeader('If');
     $targetLockRefresher = null;
     if ($ifHeader !== null) {
         $targetLockRefresher = new ezcWebdavLockRefreshRequestGenerator($request);
     }
     $violation = $this->tools->checkViolations(new ezcWebdavLockCheckInfo($request->requestUri, ezcWebdavRequest::DEPTH_ZERO, $request->getHeader('If'), $request->getHeader('Authorization'), ezcWebdavAuthorizer::ACCESS_WRITE, $targetLockRefresher, false), true);
     if ($violation !== null) {
         // ezcWebdavErrorResponse
         return $violation;
     }
     // Lock refresh must occur no matter if the request succeeds
     if ($targetLockRefresher !== null) {
         $targetLockRefresher->sendRequests();
     }
     if ($request->updates->contains('lockdiscovery')) {
         return new ezcWebdavMultistatusResponse(new ezcWebdavErrorResponse(ezcWebdavResponse::STATUS_409, $request->requestUri, "Property 'lockdiscovery' is readonly."));
     }
     if ($request->updates->contains('lockinfo')) {
         return new ezcWebdavMultistatusResponse(new ezcWebdavErrorResponse(ezcWebdavResponse::STATUS_409, $request->requestUri, "Property 'lockinfo' is readonly."));
     }
 }
Example #4
0
 /**
  * Handles COPY requests.
  *
  * Performs all lock related checks necessary for the COPY request. In case
  * a violation with locks is detected or any other pre-condition check
  * fails, this method returns an instance of {@link ezcWebdavResponse}. If
  * everything is correct, null is returned, so that the $request is handled
  * by the backend.
  *
  * @param ezcWebdavRequest $request ezcWebdavCopyRequest
  * @return ezcWebdavResponse|null
  */
 public function receivedRequest(ezcWebdavRequest $request)
 {
     $backend = ezcWebdavServer::getInstance()->backend;
     $this->request = $request;
     $destination = $request->getHeader('Destination');
     $destParent = dirname($destination);
     $ifHeader = $request->getHeader('If');
     $authHeader = $request->getHeader('Authorization');
     // Check destination parent and collect the lock properties to
     // set after successfully moving
     $destinationLockRefresher = new ezcWebdavLockRefreshRequestGenerator($request);
     $violation = $this->tools->checkViolations(new ezcWebdavLockCheckInfo($destParent, ezcWebdavRequest::DEPTH_ZERO, $ifHeader, $authHeader, ezcWebdavAuthorizer::ACCESS_WRITE, $destinationLockRefresher), true);
     if ($violation !== null) {
         if ($violation->status === ezcWebdavResponse::STATUS_404) {
             // Destination parent not found
             return new ezcWebdavErrorResponse(ezcWebdavResponse::STATUS_409, $violation->requestUri);
         }
         return $violation;
     }
     // Check destination itself, if it exsists
     $violation = $this->tools->checkViolations(new ezcWebdavLockCheckInfo($destination, ezcWebdavRequest::DEPTH_INFINITY, $ifHeader, $authHeader, ezcWebdavAuthorizer::ACCESS_WRITE, $destinationLockRefresher), true);
     // Destination might be there but not violated, or might not be there
     if ($violation !== null && $violation->status !== ezcWebdavResponse::STATUS_404) {
         // ezcWebdavErrorResponse
         return $violation;
     }
     // Perform lock refresh (must occur no matter if request succeeds)
     $destinationLockRefresher->sendRequests();
     // Store infos for use on correct moving
     // @TODO: Do we always get the correct property here?
     $this->lockDiscoveryProp = $destinationLockRefresher->getLockDiscoveryProperty($destParent);
     $sourcePaths = $this->getSourcePaths();
     if (is_object($sourcePaths)) {
         // ezcWebdavErrorResponse
         return $sourcePaths;
     }
     $this->sourcePaths = $sourcePaths;
     // Backend now handles the request
     return null;
 }
Example #5
0
 /**
  * Performs a manual request for a lock.
  *
  * Clients may send a lock request without a body and with an If header, to
  * indicate they want to reset the timeout for a lock. This method handles
  * such requests.
  * 
  * @param ezcWebdavLockRequest $request 
  * @return ezcWebdavResponse
  */
 protected function refreshLock(ezcWebdavLockRequest $request)
 {
     if (($ifHeader = $request->getHeader('If')) === null) {
         return new ezcWebdavErrorResponse(ezcWebdavResponse::STATUS_412, 'If header needs to be provided to refresh a lock.');
     }
     $reqGen = new ezcWebdavLockRefreshRequestGenerator($request);
     $violation = $this->tools->checkViolations(new ezcWebdavLockCheckInfo($request->requestUri, $request->getHeader('Depth'), $request->getHeader('If'), $request->getHeader('Authorization'), ezcWebdavAuthorizer::ACCESS_WRITE, $reqGen));
     if ($violation !== null) {
         return $this->createLockError($violation);
     }
     $reqGen->sendRequests();
     return new ezcWebdavLockResponse($reqGen->getLockDiscoveryProperty($request->requestUri));
 }