## Apache Zeta Components Manual :: Docs For Class ezcWebdavServer

### Webdav::ezcWebdavServer

### Class ezcWebdavServer

Base class for creating a webdav server, capable of serving webdav requests.

1. $server=ezcWebdavServer :: getInstance ();
3. // Optionally register aditional transport handlers
5. // This step is only required, if you want to add custom or third party extensions
6. // implementations for special clients.
7. // Create a new configuration set for the client
8. $newClientConf=new ezcWebdavServerConfiguration (
9. // Regular expression to match client name
10. '(My.*Webdav\s+Cliengt)i',
11. // Class name of transport handler, extending <a href="../Webdav/ezcWebdavTransport.html">ezcWebdavTransport</a>
12. 'myCustomTransportTransport'
13. // There are more settings you can provide, see //.
14. );
15. // Append the configuration at front, because the last configuration is a
16. // catch all for misc clients.
17. $server->configurations->insertBefore($newClientConf,0);
19. // If you want to use a different path factory globally, you need to replace
20. // it in every configuration.
21. $myPathFactory=new ezcWebdavBasicPathFactory ('http://webdav.server/base/path');
22. foreach($server->configurationas$config)
23. {
24. $config->pathFactory=$myPathFactory;
25. }
27. // Serve data using file backend with data in the local directory "/path"
28. // Make sure this directory is read and writable for your server and that
29. // the umask is set accordingly in the server settings, if you want to
30. // access the files as a different user, too.
31. $backend=newezcWebdavBackendFile('/path');
33. // Make the server serve WebDAV requests
34. $server-> handle ($backend);

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

static ezcWebdavServer 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

void __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

ezcWebdavErrorResponse createUnauthenticatedResponse( string $uri , string $desc )

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

ezcWebdavErrorResponse createUnauthorizedResponse( string $uri , string $desc )

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

void handle( ezcWebdavBackend $backend , [string $uri = null] )

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

void init( ezcWebdavPathFactory $pathFactory , ezcWebdavXmlTool $xmlTool , ezcWebdavPropertyHandler $propertyHandler , ezcWebdavHeaderHandler $headerHandler , ezcWebdavTransport $transport )

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

bool isAuthorized( string $path , ezcWebdavAuth $credentials , [int $access = ezcWebdavAuthorizer::ACCESS_READ] )

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

It returns true, if authorization is not enabled or succeeded. False is returned otherwise.

##### Parameters:

Name | Type | Description
--- | --- | ---
`$path` | string |
`$credentials` | ezcWebdavAuth |
`$access` | int |

#### reset

void reset( )

Reset the server to its initial state.

Resets the internal server state as if a new instance has just been constructed.

Documentation generated by phpDocumentor 1.4.3