Zeta Components Manual :: Docs For Class ezcWebdavServer
Webdav::ezcWebdavServer
Class ezcWebdavServer
Base class for creating a webdav server, capable of serving webdav requests.
- // Optionally register aditional transport handlers
- // This step is only required, if you want to add custom or third party extensions
- // implementations for special clients.
- // Create a new configuration set for the client
- // Regular expression to match client name
- '(My.*Webdav\s+Cliengt)i',
- // Class name of transport handler, extending <a href="ezcWebdavTransport.html">ezcWebdavTransport</a>
- 'myCustomTransportTransport'
- // There are more settings you can provide, see //.
- );
- // Append the configuration at front, because the last configuration is a
- // catch all for misc clients.
- $server->configurations->insertBefore( $newClientConf, 0 );
- // If you want to use a different path factory globally, you need to replace
- // it in every configuration.
- foreach ( $server->configuration as $config )
- {
- $config->pathFactory = $myPathFactory;
- }
- // Serve data using file backend with data in the local directory "/path"
- // Make sure this directory is read and writable for your server and that
- // the umask is set accordingly in the server settings, if you want to
- // access the files as a different user, too.
- $backend = new ezcWebdavBackendFile( '/path' );
- // Make the server serve WebDAV requests
Source for this file: /Webdav/src/server.php
Version: | //autogentag// |
Properties
ezcWebdavAuth | read/write |
$auth
The central authentication mechanism for the WebDAV server. This instance will be used to perform authentication and authorization on every incoming request. A valid property value is an object that at least implements ezcWebdavBasicAuthenticator or ezcWebdavDigestAuthenticator or both. In addition ezcWebdavAuthorizer may be implemented. The default is null, indicating that no authentication/authorization is provided. |
ezcWebdavBackend | read |
$backend
The backend given to ezcWebdavServer->handle(). Null before handle() was called. |
ezcWebdavServerConfigurationManager | read/write |
$configurations
Configuration manager, handling different client configurations for this server. |
ezcWebdavPathFactory | read |
$pathFactory
The path factory object used to translate between URIs and local paths. Configured by the ezcWebdavServerConfigurationManager when the ezcWebdavServer::handle() method is run}. |
ezcWebdavPluginRegistry | read |
$pluginRegistry
The internal plugin registry. Can be accessed to register and remove plugins. |
ezcWebdavPropertyHandler | read |
$propertyHandler
The property handler object used to parse and serialize WebDAV properties on the transport level. Configured by the ezcWebdavServerConfigurationManager when the ezcWebdavServer::handle() method is run}. |
ezcWebdavTransport | read |
$transport
The transport layer object used to parse and serialize WebDAV requests and responses. Configured by the ezcWebdavServerConfigurationManager when the ezcWebdavServer::handle() method is run}. |
ezcWebdavXmlTool | read |
$xmlTool
The XML tool object used for XML related operations in the server and transport level. Configured by the ezcWebdavServerConfigurationManager when the ezcWebdavServer::handle() method is run}. |
Member Variables
protected static ezcWebdavServer |
$instance
Singleton instance. |
protected array(string=>mixed) |
$properties
= array()
Properties. |
Method Summary
public static ezcWebdavServer |
getInstance(
)
Returns singleton instance. |
protected void |
__construct(
)
Creates a new instance. |
public ezcWebdavErrorResponse |
createUnauthenticatedResponse(
$uri
, $desc
)
Creates an ezcWebdavErrorResponse to indicate the need for authentication. |
public ezcWebdavErrorResponse |
createUnauthorizedResponse(
$uri
, $desc
)
Creates an ezcWebdavErrorResponse to indicate unauthorized access. |
public void |
handle(
$backend
, [ $uri
= null] )
Handles the current request. |
public void |
init(
$pathFactory
, $xmlTool
, $propertyHandler
, $headerHandler
, $transport
)
Initializes the server with the given objects. |
public bool |
isAuthorized(
$path
, $credentials
, [ $access
= ezcWebdavAuthorizer::ACCESS_READ] )
Performs authorization. |
public void |
reset(
)
Reset the server to its initial state. |
Methods
getInstance
Returns singleton instance.
The instantiation of 2 WebDAV servers at the same time does not make sense and could possibly cause strange effects, like double sending of a response. Therefore the server implements a singleton and its only instance must be retrieved using this method. Configuration changes can then be performed through the properties of this instance.
__construct
Creates a new instance.
The constructor is protected due to singleton reasons. Use getInstance() and then use the properties of the server to adjust its configuration.
createUnauthenticatedResponse
Creates an ezcWebdavErrorResponse to indicate the need for authentication.
Creates a ezcWebdavErrorResponse object with status code ezcWebdavResponse::STATUS_401 and a corresponding WWW-Authenticate header using the $realm define in ezcWebdavServerOptions. The $uri and $desc parameters are used to create the error response.
Parameters:
Name | Type | Description |
---|---|---|
$uri |
string | |
$desc |
string |
createUnauthorizedResponse
Creates an ezcWebdavErrorResponse to indicate unauthorized access.
Creates a ezcWebdavErrorResponse object with status code ezcWebdavResponse::STATUS_403. The $uri and $desc parameters are used to create the error response.
Parameters:
Name | Type | Description |
---|---|---|
$uri |
string | |
$desc |
string |
handle
Handles the current request.
This method is the absolute heart of the Webdav component. It is called to make the server instance handle the current request. This means, a ezcWebdavTransport is selected and instantiated through the ezcWebdavServerConfigurationManager in $configurations. This transport (and all other objects, created from the configuration) is used to parse the incoming request into an instance of ezcWebdavRequest, which is then handed to the submitted $backend for handling. The resulting ezcWebdavResponse is serialized by the ezcWebdavTransport and send back to the client.
The method receives at least an instance of ezcWebdavBackend, which is used to server the request. Optionally, the request URI can be submitted in $uri. If this is not the case, the request URI is determined by the server variables
- $_SERVER['SERVER_NAME']
- $_SERVER['REQUEST_URI']
Parameters:
Name | Type | Description |
---|---|---|
$backend |
ezcWebdavBackend | |
$uri |
string |
init
Initializes the server with the given objects.
This method is marked proteced, because it is intended to be used by by ezcWebdavServerConfiguration instances and instances of derived classes, but not directly.
Parameters:
Name | Type | Description |
---|---|---|
$pathFactory |
ezcWebdavPathFactory | |
$xmlTool |
ezcWebdavXmlTool | |
$propertyHandler |
ezcWebdavPropertyHandler | |
$headerHandler |
ezcWebdavHeaderHandler | |
$transport |
ezcWebdavTransport |
isAuthorized
Performs authorization.
This method does several things:
- Check if authorization is enabled by ezcWebdavServer->$auth
- If it is, extract username from Authenticate header or choose ''
- Check authorization
Parameters:
Name | Type | Description |
---|---|---|
$path |
string | |
$credentials |
ezcWebdavAuth | |
$access |
int |
reset
Reset the server to its initial state.
Resets the internal server state as if a new instance has just been constructed.