예제 #1
0
 /**
  * Creates an ezcWebdavErrorResponse to indicate the need for authentication.
  *
  * Creates a {@link ezcWebdavErrorResponse} object with status code {@link
  * ezcWebdavResponse::STATUS_401} and a corresponding WWW-Authenticate
  * header using the $realm define in {@link ezcWebdavServerOptions}. The
  * $uri and $desc parameters are used to create the error response.
  *
  * @param string $uri
  * @param string $desc 
  * 
  * @return ezcWebdavErrorResponse
  *
  * @access private
  */
 public function createUnauthenticatedResponse($uri, $desc)
 {
     $res = new ezcWebdavErrorResponse(ezcWebdavResponse::STATUS_401, $uri, $desc);
     $wwwAuthHeader = array('basic' => 'Basic realm="' . $this->options->realm . '"');
     if ($this->properties['auth'] instanceof ezcWebdavDigestAuthenticator) {
         $wwwAuthHeader['digest'] = 'Digest realm="' . $this->options->realm . '"' . ', nonce="' . $this->getNonce() . '"' . ', algorithm="MD5"';
         // @todo Do we want an opaque value here, too?
     }
     $res->setHeader('WWW-Authenticate', $wwwAuthHeader);
     return $res;
 }
예제 #2
0
 /**
  * Attaches the given data to the $error.
  *
  * @param ezcWebdavErrorResponse $error
  * @param ezcWebdavResource|ezcWebdavCollection $node
  * @param ezcWebdavLockDiscoveryProperty $lockDiscovery
  * @return ezcWebdavErrorResponse
  */
 protected function createLockViolation(ezcWebdavErrorResponse $error, $node, ezcWebdavLockDiscoveryProperty $lockDiscovery = null)
 {
     $error->setPluginData(ezcWebdavLockPlugin::PLUGIN_NAMESPACE, 'node', $node);
     $error->setPluginData(ezcWebdavLockPlugin::PLUGIN_NAMESPACE, 'lockdiscovery', $lockDiscovery);
     return $error;
 }
예제 #3
0
 /**
  * Returns display information for a error response object.
  *
  * This method returns the display information generated for a $response
  * object of type {@link ezcWebdavErrorResponse}. It returns an
  * instance of {@link ezcWebdavDisplayInformation} containing the
  * post-processed response object and the appropriate body.
  *
  * The $xml parameter defines, if an XML representation should be
  * generated, too (for use in {@link $this->processMultiStatusResponse()}),
  * or if only the headers should be manipulated and an empty response body
  * should be used.
  *
  * The display information generated by this response contains the post
  * processed $response and a {@link DOMDocument} representing the XML
  * response body. If the $xml parameter is set to false, an empty display
  * information is generated, to indicate that only headers should be send. 
  *
  * This method utilizes {@link ezcWebdavServer->xmlTool} to
  * perform basic XML operations, so this is the place to perform such
  * changeds. You should overwrite this method, if your client has problems
  * specifically with the {@link ezcWebdavErrorResponse} response.
  *
  * @param ezcWebdavErrorResponse $response 
  * @param bool $xml DOMDocument in result only generated of true.
  * @return ezcWebdavXmlDisplayInformation|ezcWebdavEmptyDisplayInformation
  */
 protected function processErrorResponse(ezcWebdavErrorResponse $response, $xml = false)
 {
     $res = new ezcWebdavEmptyDisplayInformation($response);
     if ($xml === true) {
         $dom = ezcWebdavServer::getInstance()->xmlTool->createDom();
         $responseElement = $dom->appendChild(ezcWebdavServer::getInstance()->xmlTool->createDomElement($dom, 'response'));
         $responseElement->appendChild(ezcWebdavServer::getInstance()->xmlTool->createDomElement($dom, 'href'))->nodeValue = ezcWebdavServer::getInstance()->pathFactory->generateUriFromPath($response->requestUri);
         $responseElement->appendChild(ezcWebdavServer::getInstance()->xmlTool->createDomElement($dom, 'status'))->nodeValue = (string) $response;
         if (!empty($response->responseDescription)) {
             $responseElement->appendChild(ezcWebdavServer::getInstance()->xmlTool->createDomElement($dom, 'responsedescription'))->nodeValue = $response->responseDescription;
         }
         $res = new ezcWebdavXmlDisplayInformation($response, $dom);
     } elseif ($response->responseDescription !== null) {
         // User $responseDescription as body
         $response->setHeader('Content-Type', 'text/plain; charset="utf-8"');
         $response->setHeader('Content-Length', (string) strlen($response->responseDescription));
         $res = new ezcWebdavStringDisplayInformation($response, $response->responseDescription);
     }
     return $res;
 }