DAVServer Class
Properties Methods Events Config Settings Errors
A class used for implementing DAV servers, granting full control over data storage, access and permissions, and server behavior.
Syntax
davsdk.DAVServer
Remarks
The DAVServer class provides a streamlined way to extend WebDAV server support to data stored in different locations, including the local filesystem, remote storage, or in custom storage like a database. DAVServer is easy to use with minimal setup while also being flexible and highly configurable.
Getting Started
The DAVServer component provides an event-driven API for implementing WebDAV servers that can serve data from any data source, enforce granular access control rules, and implement custom logic according to your specific file access needs.
The Getting Started page provides a comprehensive introduction to the component, including hosting options and handling of events. The class may be hosted using an embedded server, within an existing server framework like ASP.NET Core, or in offline mode. A brief overview of hosting options is included below. Please refer to the Hosting Options page for additional details.
Hosting the Server
The class can be hosted one of three ways:
- Via the embedded HTTP server
- Integrated with an external server framework
- In a fully-offline mode
Comprehensive information on hosting options and configuration can be found in the Hosting Options page.
Property List
The following is the full list of the properties of the class with short descriptions. Click on the links for further details.
ProcessingMode | The mode in which the class will be hosted. |
Request | The body of the HTTP request to be processed by the class. |
RequestHeaders | The full set of headers of the HTTP request to be processed by the class. |
Response | The body of the HTTP response generated after processing a request with the class. |
ResponseHeaders | The full set of headers of the HTTP response generated after processing a request with the class. |
ServerCert | The certificate used during SSL negotiation. |
ServerSettings | The embedded HTTP server settings used by the class. |
Method List
The following is the full list of the methods of the class with short descriptions. Click on the links for further details.
Config | Sets or retrieves a configuration setting. |
GetSessionParam | Provides the value of the specified session parameter. |
ListFile | Passes information about a specific file to the class. |
ListFolder | Passes information about a specific directory to the class. |
ProcessRequest | Processes the request and sends the result. |
SetSessionParam | Sets a user-defined value as a session parameter. |
StartListening | Instructs the class to start listening for incoming connections. |
StopListening | Instructs the class to stop listening for new connections. |
Event List
The following is the full list of the events fired by the class with short descriptions. Click on the links for further details.
CheckAccess | Fires when the class needs to create or open a file or directory. |
CopyFile | Fires when the class needs to copy a file or directory. |
CreateDirectory | Fires when the class needs to create a new directory. |
CreateFile | Fires when the class needs to create an empty file. |
DeleteFile | Fires when the class needs to delete a file or directory. |
DeleteProperty | Fires when the class needs to delete specific custom metadata of a file or directory. |
Error | Fires information about unhandled exceptions caught by the class. |
GetFile | Fires when the class needs to serve file data. |
GetFileInfo | Fires when the class needs to obtain information about a specific file or directory. |
GetFileLocks | Fires when the class needs to obtain information about the existing locks of a file or directory. |
GetProperty | Fires when the class needs to retrieve specific custom metadata about a file or directory. |
GetQuotaInfo | Fires when the class needs to obtain information about the storage. |
ListDirectory | Fires when the class needs to enumerate the contents of a directory. |
ListProperties | Fires when the class needs to enumerate the custom metadata of a file or directory. |
LockFile | Fires when the class needs to lock a file or directory. |
Log | Fires once for each log message. |
PutFile | Fires when the class needs to store file data. |
ReadFile | Fires when the class needs to serve file data. |
RenameFile | Fires when the class needs to rename or move a file or directory. |
SessionEnd | Fires when the class ends a session. |
SessionStart | Fires when the class starts a session. |
SetFileInfo | Fires when the class needs to update times and attributes of a specific file or directory. |
SetFileSize | Fires when the class needs to adjust the size of an open file. |
SetProperty | Fires when the class needs to add or update custom metadata to a file or directory. |
UnknownRequest | Fires when the class does not recognize the request. |
UnlockFile | Fires when the class needs to unlock a file or directory. |
UserAuthRequest | Fires when the class attempts to authenticate a client. |
WriteFile | Fires when the class needs to store file data. |
Config Settings
The following is a list of config settings for the class with short descriptions. Click on the links for further details.
EnableRecursiveDirectoryListings | Whether directories may be enumerated recursively. |
FireCheckAccessEvent | Whether the CheckAccess event is fired. |
LogLevel | The level of detail that is logged. |
LogRequestBody | Whether bodies of requests are logged on Debug log level. |
LogResponseBody | Whether bodies of responses are logged on Debug log level. |
ReadOnly | Whether the server works in read-only mode. |
ServerDAVURIPrefix | The endpoint prefix used by the server to serve requests. |
UseSimpleFileEnumeration | Whether an enumeration is performed with additional parameters. |
ProcessingMode Property (DAVServer Class)
The mode in which the class will be hosted.
Syntax
public int getProcessingMode(); public void setProcessingMode(int processingMode); Enumerated values: public final static int modeEmbeddedServer = 0; public final static int modeExternalServer = 1; public final static int modeOffline = 2;
Default Value
0
Remarks
This property governs whether the class operates via the embedded HTTP server, an external server, or in a fully-offline mode. Possible values are as follows:
- modeEmbeddedServer (0, default): Use embedded server.
- modeExternalServer (1): Use external server.
- modeOffline (2): Use offline processing.
Please refer to the Hosting Options pages to the learn more about the different processing modes and how they relate to configuring a host server.
Request Property (DAVServer Class)
The body of the HTTP request to be processed by the class.
Syntax
public byte[] getRequest(); public void setRequest(byte[] request);
Default Value
""
Remarks
When the ProcessingMode property is set to modeOffline, the class processes inbound HTTP requests via this property and the RequestHeaders property.
After setting this property to the full body content of the HTTP request, as well as setting any headers in the RequestHeaders property, the class will begin processing the request when the ProcessRequest method is called.
RequestHeaders Property (DAVServer Class)
The full set of headers of the HTTP request to be processed by the class.
Syntax
public String getRequestHeaders(); public void setRequestHeaders(String requestHeaders);
Default Value
""
Remarks
When the ProcessingMode property is set to modeOffline, the class processes inbound HTTP requests via this property and the Request property.
After setting this property to the header content of the HTTP request, as well as setting the body content in the Request property, the class will begin processing the request when the ProcessRequest method is called.
Response Property (DAVServer Class)
The body of the HTTP response generated after processing a request with the class.
Syntax
public byte[] getResponse(); public void setResponse(byte[] response);
Default Value
""
Remarks
When the ProcessingMode property is set to modeOffline, this property holds the body of the HTTP response that was generated as a result of calling the ProcessRequest method.
Note that this response is not sent to a client, and instead the class simply populates this property along with the ResponseHeaders property.
ResponseHeaders Property (DAVServer Class)
The full set of headers of the HTTP response generated after processing a request with the class.
Syntax
public String getResponseHeaders(); public void setResponseHeaders(String responseHeaders);
Default Value
""
Remarks
When the ProcessingMode property is set to modeOffline, this property holds the headers of the HTTP response that was generated as a result of calling the ProcessRequest method.
Note that this response is not sent to a client, and instead the class simply populates this property along with the Response property.
ServerCert Property (DAVServer Class)
The certificate used during SSL negotiation.
Syntax
public Certificate getServerCert(); public void setServerCert(Certificate serverCert);
Remarks
When the ProcessingMode property is set to modeEmbeddedServer, this property holds the digital certificate that the class will use during SSL negotiation.
This is the server's certificate, and it must be set before the StartListening method is called.
Please refer to the Certificate type for a complete list of fields.ServerSettings Property (DAVServer Class)
The embedded HTTP server settings used by the class.
Syntax
public ServerSettings getServerSettings(); public void setServerSettings(ServerSettings serverSettings);
Remarks
When the ProcessingMode property is set to modeEmbeddedServer, this property is used to define the necessary fields to configure the embedded HTTP server.
Please refer to the ServerSettings type for a complete list of fields.Config Method (DAVServer Class)
Sets or retrieves a configuration setting.
Syntax
public String config(String configurationString);
Remarks
Config is a generic method available in every class. It is used to set and retrieve configuration settings for the class.
These settings are similar in functionality to properties, but they are rarely used. In order to avoid "polluting" the property namespace of the class, access to these internal properties is provided through the Config method.
To set a configuration setting named PROPERTY, you must call Config("PROPERTY=VALUE"), where VALUE is the value of the setting expressed as a string. For boolean values, use the strings "True", "False", "0", "1", "Yes", or "No" (case does not matter).
To read (query) the value of a configuration setting, you must call Config("PROPERTY"). The value will be returned as a string.
GetSessionParam Method (DAVServer Class)
Provides the value of the specified session parameter.
Syntax
public String getSessionParam(long sessionId, String name);
Remarks
This method provides access to session parameters, which are key-value pairs that store session-specific information. This method is used in event handlers to retrieve a session parameter value that was previously set using the SetSessionParam method.
SessionId is the unique identifier of the session with which the parameter name and value will be associated. This value is assigned by the class and is available in the SessionStart event as well as other events.
Name corresponds to the user-defined parameter name.
ListFile Method (DAVServer Class)
Passes information about a specific file to the class.
Syntax
public boolean listFile(long requestId, String parentId, String fileName, int attributes, long size, java.util.Date creationTime, java.util.Date lastAccessTime, java.util.Date lastModifiedTime, String ownerId);
Remarks
This method is used to pass information about a specific file when the ListDirectory event is handled.
The RequestId parameter must be set to the value received in the corresponding event handler. The parameters detailed below must be set if they were requested as indicated by the RequestedInfo parameter of the event.
This method returns true if the information was accepted; otherwise, false is returned.
ParentId must be set to the path of the parent of the file or directory relative to the server root. If the item is located in the root directory, the value should be empty.
FileName must be set to the item's file name (usually, human-readable) without any path.
Attributes should be set to indicate the type of the item by setting the corresponding attributes flags. The following flags are available:
ITEM_ATTR_FILE | 0x00000001 | The item is a file. |
ITEM_ATTR_DIRECTORY | 0x00000002 | The item is a directory. |
ITEM_ATTR_READONLY | 0x00000040 | The file is read-only.
DAVServer does not block operations based on this attribute, but it does communicate the status of items and directories to clients based on this attribute. |
ITEM_ATTR_ANY_FILE | 0x7FFFFFFF | A mask which includes any and all attributes. |
CreationTime should be set to the time the item was initially created.
LastAccessTime should be set to the most recent time the item was opened.
LastModifiedTime should be set to the most recent time the item was written.
Owner should be set to the identifier of the owner of the item.
Size should be set to the size of a file in bytes.
ListFolder Method (DAVServer Class)
Passes information about a specific directory to the class.
Syntax
public boolean listFolder(long requestId, String parentId, String fileName, int attributes, java.util.Date creationTime, java.util.Date lastAccessTime, java.util.Date lastModifiedTime, String owner);
Remarks
This method is used to pass information about a specific directory when the ListDirectory event is handled.
The RequestId parameter must be set to the value received in the corresponding event handler. The parameters detailed below must be set if they were requested as indicated by the RequestedInfo parameter of the event.
This method returns true if the information was accepted; otherwise, false is returned.
ParentId must be set to the path of the parent of the file or directory relative to the server root. If the item is located in the root directory, the value should be empty.
FileName must be set to the item's file name (usually, human-readable) without any path.
Attributes should be set to indicate the type of the item by setting the corresponding attributes flags. The following flags are available:
ITEM_ATTR_FILE | 0x00000001 | The item is a file. |
ITEM_ATTR_DIRECTORY | 0x00000002 | The item is a directory. |
ITEM_ATTR_READONLY | 0x00000040 | The file is read-only.
DAVServer does not block operations based on this attribute, but it does communicate the status of items and directories to clients based on this attribute. |
ITEM_ATTR_ANY_FILE | 0x7FFFFFFF | A mask which includes any and all attributes. |
CreationTime should be set to the time the item was initially created.
LastAccessTime should be set to the most recent time the item was opened.
LastModifiedTime should be set to the most recent time the item was written.
Owner should be set to the identifier of the owner of the item.
ProcessRequest Method (DAVServer Class)
Processes the request and sends the result.
Syntax
public void processRequest(Object request, Object response);
Remarks
When the ProcessingMode property is set to modeExternalServer or modeOffline, this method acts as the main entry point for the class and is used to process a specific request. This method should not be called when the class is running in the modeEmbeddedServer mode.
Note that when using the modeOffline mode, the class processes the request and its associated headers supplied via the Request and RequestHeaders properties, respectively, and therefore ignores the parameters of this method.
When using the modeExternalServer mode, Request and Response must be set to instances of the HttpServletRequest and HttpServletResponse classes that correspond to the request to be handled and response to be constructed, respectively.
Note that authentication occurs fully outside the scope of the class, and the logic that verifies these credentials is separate from any interaction with the class. Only once the request has been authenticated through this external verification should the Request be passed to this method.
SetSessionParam Method (DAVServer Class)
Sets a user-defined value as a session parameter.
Syntax
public void setSessionParam(long sessionId, String name, String value);
Remarks
This method assigns session parameters, which are key-value pairs that store information specific to the session. This method is used in event handlers to store session-specific data which can be retrieved later by calling the GetSessionParam method.
SessionId is the unique identifier of the session with which the parameter name and value will be associated. This value is assigned by the class and is available in the SessionStart event as well as other events.
Name and Value correspond to the user-defined parameter name and value, respectively.
StartListening Method (DAVServer Class)
Instructs the class to start listening for incoming connections.
Syntax
public void startListening();
Remarks
When the ProcessingMode property is set to modeEmbeddedServer, this method instructs the class to start listening for incoming connections on the port specified by LocalPort.
To stop listening for new connections, please refer to the StopListening method.
StopListening Method (DAVServer Class)
Instructs the class to stop listening for new connections.
Syntax
public void stopListening();
Remarks
When the ProcessingMode property is set to modeEmbeddedServer, this method instructs the class to stop listening for new connections. After being called, any new connection attempts will be rejected. Calling this method does not disconnect existing connections.
CheckAccess Event (DAVServer Class)
Fires when the class needs to create or open a file or directory.
Syntax
public class DefaultDAVServerEventListener implements DAVServerEventListener { ... public void checkAccess(DAVServerCheckAccessEvent e) {} ... } public class DAVServerCheckAccessEvent { public long sessionId; public String path; public String fileName; public int desiredOperation; public int resultCode; //read-write }
Remarks
This optional event fires when the class needs to create or open an existing file or directory. It can be used to control and optionally restrict access to files and directories. The event can be disabled by setting the FireCheckAccessEvent configuration setting to false, which can improve performance.
When an existing file is accessed, this event is fired only for this file and not for its parent directories. When a new file or directory is created, the event is first fired for the parent directory. When a file or directory is copied or moved into another directory, the event is first fired for the destination directory (i.e., the new parent).
SessionId specifies the unique identifier for the current session and can be obtained from the initial SessionStart event when the session is first opened.
Path identifies the path of the file or directory relative to the server root. If the item to be accessed is in the root directory, the value will be empty.
FileName identifies the name of the file or directory to be accessed.
DesiredOperation specifies which kind of operation is performed and can be one or more of the following:
ACCESS_TYPE_DELETE | 0x00000001 | The file or directory is being deleted. |
ACCESS_TYPE_RENAME | 0x00000002 | The file or directory is being renamed.
Renaming doesn't involve opening of a file for reading and is performed within the same directory. |
ACCESS_TYPE_MOVE | 0x00000004 | The file or directory is being moved.
The event is fired for a source file or directory. A separate event is also fired for a destination directory with the ACCESS_TYPE_WRITE flag. |
ACCESS_TYPE_READ | 0x00000008 | The file is being opened for reading or for reading and writing. |
ACCESS_TYPE_WRITE | 0x00000010 | The file is being opened for writing or for reading and writing.
For directories, this value means that a new file is about to be created in the directory or be moved into the directory. |
ACCESS_TYPE_ENUMERATE | 0x00000020 | The directory is being enumerated. |
ACCESS_TYPE_GET_ATTR | 0x00000040 | Information about the file or directory is requested. |
ACCESS_TYPE_SET_ATTR | 0x00000080 | An explicit operation of changing file times and attributes is performed. |
ACCESS_TYPE_BUILD_PATH | 0x00002000 | A human-readable path or a file's parent are being requested.
Use this check to provide access to a specific file or directory and prevent its parent directories from becoming known to a user. |
ACCESS_TYPE_GET_FILENAME | 0x00008000 | A request is made to get a filename. |
Usually, only one flag is set; however, when a file is opened, both ACCESS_TYPE_READ and ACCESS_TYPE_WRITE flags may be set.
ResultCode must be set to report the result of the check to the class. When this event is fired, the parameter will be set either to 0 (to permit access by default) for most types of desired operations, or to DAVSDK_ERR_ACCESS_DENIED for operations that must be forbidden by default for security reasons.
If access is permitted, this should be set to 0. If access is denied, this should be set to DAVSDK_ERR_ACCESS_DENIED. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource isn't available, etc.), this should be set to a non-zero value different from DAVSDK_ERR_ACCESS_DENIED.
CopyFile Event (DAVServer Class)
Fires when the class needs to copy a file or directory.
Syntax
public class DefaultDAVServerEventListener implements DAVServerEventListener { ... public void copyFile(DAVServerCopyFileEvent e) {} ... } public class DAVServerCopyFileEvent { public long sessionId; public String path; public String fileName; public String destParentPath; public String destFileName; public boolean overwriteExisting; public int resultCode; //read-write }
Remarks
This event fires when a request to copy a file or directory is received. When a directory with its contents is copied, this event is fired only once for the directory itself.
During recursive copying, if a file or directory cannot be copied, copying should continue, but the event handler should set the ResultCode parameter to a non-zero value to communicate an error.
SessionId specifies the unique identifier for the current session and can be obtained from the initial SessionStart event when the session is first opened.
Path identifies the path of the file or directory relative to the server root. If the item to be copied is in the root directory, the value will be empty.
FileName identifies the name of the file or directory to be copied.
DestParentPath contains the path of the new parent directory relative to the server root. If the item is to be copied to the root directory, the value will be empty.
DestFileName contains the name of the newly-copied file or directory.
OverwriteExisting specifies whether the handler should overwrite an existing file if one already exists. If this is false and a destination item exists, the event handler must return the DAVSDK_ERR_ALREADY_EXISTS error. If this is true, the following rules apply:
- If the destination item exists and is a file, it must be replaced by the copy of the source item, regardless of whether it is a file or directory.
- If the destination item exists and is a directory, the event handler must return the DAVSDK_ERR_ALREADY_EXISTS error, as a directory cannot be overwritten.
ResultCode provides an opportunity to report the operation as failed. This parameter will always be 0 when the event is fired, indicating the operation was successful. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource isn't available, security checks failed, etc.), this must be set to a non-zero value.
CreateDirectory Event (DAVServer Class)
Fires when the class needs to create a new directory.
Syntax
public class DefaultDAVServerEventListener implements DAVServerEventListener { ... public void createDirectory(DAVServerCreateDirectoryEvent e) {} ... } public class DAVServerCreateDirectoryEvent { public long sessionId; public String parentPath; public String fileName; public int resultCode; //read-write }
Remarks
This event fires when a request to create a new directory is received.
If a file or directory with the same name already exists, the event handler must return the DAVSDK_ERR_ALREADY_EXISTS error.
SessionId specifies the unique identifier for the current session and can be obtained from the initial SessionStart event when the session is first opened.
ParentPath identifies the path of the parent directory relative to the server root where the new directory should be created. If the item is to be created in the root directory, the value will be empty.
FileName identifies the name of the directory to be created.
ResultCode provides an opportunity to report the operation as failed. This parameter will always be 0 when the event is fired, indicating the operation was successful. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource isn't available, security checks failed, etc.), this must be set to a non-zero value.
CreateFile Event (DAVServer Class)
Fires when the class needs to create an empty file.
Syntax
public class DefaultDAVServerEventListener implements DAVServerEventListener { ... public void createFile(DAVServerCreateFileEvent e) {} ... } public class DAVServerCreateFileEvent { public long sessionId; public String parentPath; public String fileName; public boolean overwriteExisting; public int resultCode; //read-write }
Remarks
This event fires when the class needs to create a file that does not already exist.
SessionId specifies the unique identifier for the current session and can be obtained from the initial SessionStart event when the session is first opened.
ParentPath identifies the path of the parent directory relative to the server root where the new file should be created. If the item is to be created in the root directory, the value will be empty.
FileName identifies the name of the file to be created.
OverwriteExisting specifies whether the handler should overwrite an existing file if one already exists. If this is false and a destination item exists, the event handler must return the DAVSDK_ERR_ALREADY_EXISTS error. If this is true, the following rules apply:
- If the item exists and is a file, it must be replaced by the newly-created item, regardless of whether it is a file or directory.
- If the item exists and is a directory, the event handler must return the DAVSDK_ERR_ALREADY_EXISTS error, as a directory cannot be overwritten.
ResultCode provides an opportunity to report the operation as failed. This parameter will always be 0 when the event is fired, indicating the operation was successful. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource isn't available, security checks failed, etc.), this must be set to a non-zero value.
DeleteFile Event (DAVServer Class)
Fires when the class needs to delete a file or directory.
Syntax
public class DefaultDAVServerEventListener implements DAVServerEventListener { ... public void deleteFile(DAVServerDeleteFileEvent e) {} ... } public class DAVServerDeleteFileEvent { public long sessionId; public String path; public String fileName; public boolean recursive; public int resultCode; //read-write }
Remarks
This event fires when a request to delete a file or directory is received.
When deleting multiple items, such as a directory and its contents, failure to delete one of the items should not abort the operation; rather, it should continue with remaining items.
SessionId specifies the unique identifier for the current session and can be obtained from the initial SessionStart event when the session is first opened.
Path identifies the path of the file or directory relative to the server root. If the item to be deleted is in the root directory, the value will be empty.
FileName identifies the name of the file or directory to be deleted.
Recursive specifies whether directory contents may be removed if the item is a directory and it contains any children. If this is false and the directory contains subdirectories or files, the deletion should be stopped and the DAVSDK_ERR_DIR_NOT_EMPTY error should be reported. If this is true, all contents including subdirectories and their contents should be deleted recursively.
ResultCode provides an opportunity to report the operation as failed. This parameter will always be 0 when the event is fired, indicating the operation was successful. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource isn't available, security checks failed, etc.), this must be set to a non-zero value.
DeleteProperty Event (DAVServer Class)
Fires when the class needs to delete specific custom metadata of a file or directory.
Syntax
public class DefaultDAVServerEventListener implements DAVServerEventListener { ... public void deleteProperty(DAVServerDeletePropertyEvent e) {} ... } public class DAVServerDeletePropertyEvent { public long sessionId; public String path; public String fileName; public String namespace; public String propertyName; public int resultCode; //read-write }
Remarks
This event fires when a request to delete specific custom metadata of a file or directory is received.
Note that the class does not maintain these custom metadata properties internally. Developers making use of custom properties should maintain a dictionary or other data structure to store these property names and values, and within this event handler check to see if a corresponding property exists on the item that can be deleted.
SessionId specifies the unique identifier for the current session and can be obtained from the initial SessionStart event when the session is first opened.
Path identifies the path of the file or directory relative to the server root. If the item whose custom metadata is to be deleted is in the root directory, the value will be empty.
FileName identifies the name of the file or directory whose custom metadata is to be deleted.
Namespace and PropertyName identify the specific custom metadata property to be deleted.
ResultCode provides an opportunity to report the operation as failed. This parameter will always be 0 when the event is fired, indicating the operation was successful. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource isn't available, security checks failed, etc.), this must be set to a non-zero value.
Error Event (DAVServer Class)
Fires information about unhandled exceptions caught by the class.
Syntax
public class DefaultDAVServerEventListener implements DAVServerEventListener { ... public void error(DAVServerErrorEvent e) {} ... } public class DAVServerErrorEvent { public int errorCode; public String description; }
Remarks
This event fires when an unhandled exception is caught by the class, providing information about the error.
ErrorCode contains an error code and Description contains a textual description of the error. For a list of valid error codes and their descriptions, please refer to the Error Codes section.
GetFile Event (DAVServer Class)
Fires when the class needs to serve file data.
Syntax
public class DefaultDAVServerEventListener implements DAVServerEventListener { ... public void getFile(DAVServerGetFileEvent e) {} ... } public class DAVServerGetFileEvent { public long sessionId; public String path; public String fileName; public String localPath; //read-write }
Remarks
This event fires when a request to download file data is received and is the first of two events that can be used to determine what data is returned.
SessionId specifies the unique identifier for the current session and can be obtained from the initial SessionStart event when the session is first opened.
Path identifies the path of the file relative to the server root. If the file to be downloaded is in the root directory, the value will be empty.
FileName contains the name of the file to be downloaded.
LocalPath may optionally be set to a full path of a local file, in which case the file's contents will be returned as the download response. If this is not set, which is useful in cases where the response to the download request will not be the entire contents of a single file, the class will not immediately respond to the download request and will instead fire the ReadFile event, where developers have more control over exactly what data is returned in response to the download request.
Event Order During Download Operations
When a download request is received, the class fires a series of events in the following order. Note that certain details like the number of levels of directories within which the target file resides may impact how events fire.
- SessionStart - Fires when a client initiates a session with the class and helps associate a unique session identifier with the request.
- CheckAccess - Fires when a client attempts to read or list a file or directory, and provides an opportunity to check access and permissions (optional).
- GetFileInfo - Fires to access metadata regarding the file or directory being read or listed.
- GetFile - Fires to provide a simple way for the class to serve a file by providing a filepath (optional).
- GetProperty - Fires to access custom metadata regarding the file or directory being read or listed (optional).
- ReadFile - Fires if GetFile was not used to serve the file and provides full control over response data.
- SessionEnd - Fires when a client successfully ends a session and allows closing out the session identifier.
GetFileInfo Event (DAVServer Class)
Fires when the class needs to obtain information about a specific file or directory.
Syntax
public class DefaultDAVServerEventListener implements DAVServerEventListener { ... public void getFileInfo(DAVServerGetFileInfoEvent e) {} ... } public class DAVServerGetFileInfoEvent { public long sessionId; public String path; public String fileName; public int requestedInfo; public int attributes; //read-write public long size; //read-write public java.util.Date creationTime; //read-write public java.util.Date lastAccessTime; //read-write public java.util.Date lastModifiedTime; //read-write public String owner; //read-write public int resultCode; //read-write }
Remarks
This event fires when a request to obtain information about a file or directory is received, to check existence of the specified file or directory, or to determine whether the specified item is a directory. To handle this event, values should be supplied to each of the event parameters according to the type of needed information as specified in the RequestedInfo parameter.
This event may fire several times for the same file or directory when handling one request. If retrieval of item information is slow (e.g., from databases, remote cloud storages, etc.), all item information may need to be requested at once and cached for some time (several seconds or the duration of the session, whichever is shorter).
SessionId specifies the unique identifier for the current session and can be obtained from the initial SessionStart event when the session is first opened.
Path identifies the path of the file or directory relative to the server root. If the item whose information is being queried is in the root directory, the value will be empty.
FileName identifies the name of the file or directory whose information is being queried.
RequestedInfo specifies what information is requested and may contain one or more flags. The following flags are available:
ITEM_INFO_EXISTENCE | 0x00000000 | Item existence is checked.
This pseudo-flag with the numeric value 0 is used when the GetFileInfo event is used to check whether the given item exists. When the RequestedInfo parameter is 0, no file or directory information needs to be returned, and just an error should be reported if the item does not exist. |
ITEM_INFO_NAME | 0x00000001 | Item name is requested. |
ITEM_INFO_PARENTID | 0x00000002 | The parent of the item is requested. |
ITEM_INFO_SIZE | 0x00000008 | File size is requested.
If an item is a directory, set the corresponding parameter to 0. |
ITEM_INFO_ATTR | 0x00000010 | Attributes are requested.
If the class needs to find out whether the item is a file or a directory, this flag will be the only one set. During other requests, it may come in a combination with other flags. |
ITEM_INFO_TIMES | 0x00000020 | Times are requested. |
ITEM_INFO_OWNER | 0x00000040 | The owner of the file is requested. |
The parameters listed below must be set if they were requested as indicated by the RequestedInfo parameter of the event.
Attributes should be set to indicate the type of the item by setting the corresponding attributes flags. The following flags are available:
ITEM_ATTR_FILE | 0x00000001 | The item is a file. |
ITEM_ATTR_DIRECTORY | 0x00000002 | The item is a directory. |
ITEM_ATTR_READONLY | 0x00000040 | The file is read-only.
DAVServer does not block operations based on this attribute, but it does communicate the status of items and directories to clients based on this attribute. |
ITEM_ATTR_ANY_FILE | 0x7FFFFFFF | A mask which includes any and all attributes. |
Size should be set to the size of the file in bytes. If the item is a directory, no value should be supplied.
CreationTime should be set to the time the item was initially created.
LastAccessTime should be set to the most recent time the item was opened.
LastModifiedTime should be set to the most recent time the item was written.
Owner should be set to the identifier of the owner of the item.
ResultCode provides an opportunity to report the operation as failed. This parameter will always be 0 when the event is fired, indicating the operation was successful. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource isn't available, security checks failed, etc.), this must be set to a non-zero value.
GetFileLocks Event (DAVServer Class)
Fires when the class needs to obtain information about the existing locks of a file or directory.
Syntax
public class DefaultDAVServerEventListener implements DAVServerEventListener { ... public void getFileLocks(DAVServerGetFileLocksEvent e) {} ... } public class DAVServerGetFileLocksEvent { public long sessionId; public String path; public String fileName; public String lockToken; //read-write public java.util.Date expires; //read-write public int resultCode; //read-write }
Remarks
This event fires when a request to obtain information about the existing locks of a file or directory is received.
Note that the class does not maintain locks internally. Developers making use of locks should maintain a dictionary or other data structure to keep track of item lock information, and within this event handler check to see if a corresponding lock exists for the item with a value that can be returned.
SessionId specifies the unique identifier for the current session and can be obtained from the initial SessionStart event when the session is first opened.
Path identifies the path of the file or directory relative to the server root. If the item whose lock information is being queried is in the root directory, the value will be empty.
FileName identifies the name of the file or directory whose lock information is being queried.
LockToken must be set to the unique identifier of the lock.
Expires must be set to the time at which the lock will expire.
ResultCode provides an opportunity to report the operation as failed. This parameter will always be 0 when the event is fired, indicating the operation was successful. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource isn't available, security checks failed, etc.), this must be set to a non-zero value.
GetProperty Event (DAVServer Class)
Fires when the class needs to retrieve specific custom metadata about a file or directory.
Syntax
public class DefaultDAVServerEventListener implements DAVServerEventListener { ... public void getProperty(DAVServerGetPropertyEvent e) {} ... } public class DAVServerGetPropertyEvent { public long sessionId; public String path; public String fileName; public String namespace; public String propertyName; public String value; //read-write public int resultCode; //read-write }
Remarks
This event fires when a request for a specific custom metadata value of a file or directory is received.
Note that the class does not maintain these custom metadata properties internally. Developers making use of custom properties should maintain a dictionary or other data structure to store these property names and values, and within this event handler check to see if a corresponding property exists for the item with a value that can be returned.
SessionId specifies the unique identifier for the current session and can be obtained from the initial SessionStart event when the session is first opened.
Path identifies the path of the file or directory relative to the server root. If the item whose custom metadata is being queried is in the root directory, the value will be empty.
FileName identifies the name of the file or directory whose custom metadata is being queried.
Namespace and PropertyName identify the specific custom metadata property being requested.
Value should be set to the value of the requested custom metadata property. This typically requires checking an external data structure in which custom metadata properties are stored for each item.
ResultCode provides an opportunity to report the operation as failed. This parameter will always be 0 when the event is fired, indicating the operation was successful. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource isn't available, security checks failed, etc.), this must be set to a non-zero value.
GetQuotaInfo Event (DAVServer Class)
Fires when the class needs to obtain information about the storage.
Syntax
public class DefaultDAVServerEventListener implements DAVServerEventListener { ... public void getQuotaInfo(DAVServerGetQuotaInfoEvent e) {} ... } public class DAVServerGetQuotaInfoEvent { public long sessionId; public long availableSpace; //read-write public long totalSpace; //read-write public int resultCode; //read-write }
Remarks
This event fires when a request to retrieve information about the storage is received.
SessionId specifies the unique identifier for the current session and can be obtained from the initial SessionStart event when the session is first opened.
AvailableSpace indicates the amount of storage in bytes that is available for a user and corresponds to the quota-available-bytes property of the WebDAV quota extension.
TotalSpace indicates the maximum storage capacity in bytes that is available for a user and corresponds to the sum of the quota-available-bytes and quota-used-bytes properties of the WebDAV quota extension.
ResultCode must be set to report the result to the class. This will always be DAVSDK_ERR_NOT_IMPLEMENTED when the event is fired and should be set to 0 to indicate success. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource isn't available, security checks failed, etc.), this must be set to a non-zero value.
ListDirectory Event (DAVServer Class)
Fires when the class needs to enumerate the contents of a directory.
Syntax
public class DefaultDAVServerEventListener implements DAVServerEventListener { ... public void listDirectory(DAVServerListDirectoryEvent e) {} ... } public class DAVServerListDirectoryEvent { public long sessionId; public String parentPath; public String mask; public int requestedInfo; public int startAt; public String startAfter; public int maxFiles; public int orderBy; public boolean reverseOrder; public boolean recursive; public long requestId; public boolean listingComplete; //read-write public int resultCode; //read-write }
Remarks
This event fires when a request to enumerate the contents of a directory is received. To provide the directory's contents to the class, the ListFile or ListFolder methods should be called for each discovered file or subdirectory, respectively.
By default, the advanced filtering and ordering parameters, including Mask, StartAt, StartAfter, MaxFiles, OrderBy, and ReverseOrder, contain values that need to be handled. To meet this requirement, a listing of files and directories should be returned within this event in accordance with these values.
If the UseSimpleFileEnumeration configuration setting is enabled, the advanced filtering and ordering parameters can be safely ignored and the class will handle ordering and filtration automatically.
The StartAt, StartAfter, and MaxFiles parameters in particular are used when the client collects enumeration information in batches. When this happens, consequent requests to the class may occur in different sessions.
SessionId specifies the unique identifier for the current session and can be obtained from the initial SessionStart event when the session is first opened.
ParentPath identifies the path of the parent directory to enumerate relative to the server root. The value may be empty if the root directory is to be listed.
Mask may be empty, in which case all files and directories should be returned, or it may contain a file mask with wildcards that must be used to filter items by matching their human-readable names to the mask.
RequestedInfo specifies what information is requested and may contain one or more flags. The following flags are available:
ITEM_INFO_EXISTENCE | 0x00000000 | Item existence is checked.
This pseudo-flag with the numeric value 0 is used when the GetFileInfo event is used to check whether the given item exists. When the RequestedInfo parameter is 0, no file or directory information needs to be returned, and just an error should be reported if the item does not exist. |
ITEM_INFO_NAME | 0x00000001 | Item name is requested. |
ITEM_INFO_PARENTID | 0x00000002 | The parent of the item is requested. |
ITEM_INFO_SIZE | 0x00000008 | File size is requested.
If an item is a directory, set the corresponding parameter to 0. |
ITEM_INFO_ATTR | 0x00000010 | Attributes are requested.
If the class needs to find out whether the item is a file or a directory, this flag will be the only one set. During other requests, it may come in a combination with other flags. |
ITEM_INFO_TIMES | 0x00000020 | Times are requested. |
ITEM_INFO_OWNER | 0x00000040 | The owner of the file is requested. |
StartAt specifies the index of the first file or directory in the list of found items to return. It is set to 0 initially but may contain a non-zero value if the contents are requested by the client in batches. This has priority over the StartAfter parameter and may be set to -1 if StartAfter must be taken into account; in all other cases, this should be used and StartAfter must be ignored.
StartAfter specifies the last file or directory received by the class that was passed to the client in the previous call to the event handler (or during the previous enumeration). If no file or directory was found (e.g., the item was since deleted), an event handler should return items that would follow such an item after sorting is applied.
For example, given the files A.txt, B.txt, D.txt, and E.txt, and C.txt is passed in this parameter, enumeration should return D.txt and E.txt.
MaxFiles specifies the maximum number of items to return in a batch.
OrderBy specifies the order in which the items must be returned and may be one of the following values:
SORT_ORDER_NONE | 0x00000000 | No required sort order.
A handler is free to use any ordering, given that the sorting algorithm remains unchanged between calls. |
SORT_ORDER_NAME_FS | 0x00000002 | Sort by human-readable name and item attributes.
Directories should come in the list before files, and both files and directories should be sorted according their human-readable names, lexicographically. In recursive enumerations, an entity that resides in the subdirectory must come later than the subdirectory but before files that reside in the parent of that subdirectory. The following example helps demonstrate this idea.
|
SORT_ORDER_NAME_LEX | 0x00000003 | Sort by human-readable name, lexicographically.
Use common string comparison to match item names. |
SORT_ORDER_SIZE | 0x00000004 | Sort by item size, then by human-readable name. |
SORT_ORDER_MODIFICATION_TIME | 0x00000005 | Sort by item modification time, then by human-readable name. |
SORT_ORDER_CREATION_TIME | 0x00000006 | Sort by item creation time, then by human-readable name. |
ReverseOrder specifies whether the items should be returned in the opposite order than what is specified by the other advanced ordering and filtering parameters.
Recursive specifies whether items in subdirectories should be reported as well. This parameter may be true when the EnableRecursiveDirectoryListings configuration setting is enabled.
RequestId contains an unique identifier generated by the class that must be passed to the ListFile and ListFolder methods.
ListingComplete must be set to true if the last file or subdirectory has been reported to the class and there are no more items to report during this enumeration; otherwise, it must be set to false.
For example, if the class has requested 20 items by setting MaxFiles accordingly, and the directory to be enumerated contains exactly 20 files and subdirectories, this must be set to true. If the number of subitems is 21 or more, or if the total number is not known, this must be set to false.
ResultCode provides an opportunity to report the operation as failed. This parameter will always be 0 when the event is fired, indicating the operation was successful. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource isn't available, security checks failed, etc.), this must be set to a non-zero value.
ListProperties Event (DAVServer Class)
Fires when the class needs to enumerate the custom metadata of a file or directory.
Syntax
public class DefaultDAVServerEventListener implements DAVServerEventListener { ... public void listProperties(DAVServerListPropertiesEvent e) {} ... } public class DAVServerListPropertiesEvent { public long sessionId; public String path; public String fileName; public String namespaces; //read-write public String names; //read-write public int resultCode; //read-write }
Remarks
This event fires when a request to enumerate the custom metadata of a file or directory is received.
Note that the class does not maintain these custom metadata properties internally. Developers making use of custom properties should maintain a dictionary or other data structure to store these property names and values, and within this event handler check to see if a corresponding property exists for the item with a value that can be listed.
SessionId specifies the unique identifier for the current session and can be obtained from the initial SessionStart event when the session is first opened.
Path identifies the path of the file or directory relative to the server root. If the item whose custom metadata is to be listed is in the root directory, the value will be empty.
FileName identifies the name of the file or directory whose custom metadata is to be listed.
Namespaces should be set to a newline character (\n)-separated list of namespaces corresponding to each custom metadata property to be listed.
Names should be set to a newline character (\n)-separated list of names corresponding to each custom metadata property to be listed.
ResultCode provides an opportunity to report the operation as failed. This parameter will always be 0 when the event is fired, indicating the operation was successful. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource isn't available, security checks failed, etc.), this must be set to a non-zero value.
LockFile Event (DAVServer Class)
Fires when the class needs to lock a file or directory.
Syntax
public class DefaultDAVServerEventListener implements DAVServerEventListener { ... public void lockFile(DAVServerLockFileEvent e) {} ... } public class DAVServerLockFileEvent { public long sessionId; public String path; public String fileName; public String lockToken; public java.util.Date expires; public int resultCode; //read-write }
Remarks
This event fires when a request to lock a file or directory is received.
Note that the class does not maintain locks internally. Developers making use of locks should maintain a dictionary or other data structure to keep track of item lock information, and within this event handler add or update the lock information to the existing list.
SessionId specifies the unique identifier for the current session and can be obtained from the initial SessionStart event when the session is first opened.
Path identifies the path of the file or directory relative to the server root. If the item to be locked is in the root directory, the value will be empty.
FileName identifies the name of the file or directory to be locked.
LockToken specifies the unique identifier for the lock to be added or updated.
Expires identifies the time at which the lock will expire.
ResultCode provides an opportunity to report the result of the operation. This will always be DAVSDK_ERR_NOT_IMPLEMENTED when the event is fired and should be set to 0 to indicate success or DAVSDK_ERR_LOCK_FAILED to indicate that a lock could not be created or removed specifically due to a conflict with another lock. Any other non-zero value indicates the lock could not be created or removed for other reasons.
Log Event (DAVServer Class)
Fires once for each log message.
Syntax
public class DefaultDAVServerEventListener implements DAVServerEventListener { ... public void log(DAVServerLogEvent e) {} ... } public class DAVServerLogEvent { public int logLevel; public String message; }
Remarks
This event fires once for each log message generated by the class. The verbosity is controlled by the LogLevel setting.
0 (None) | No information is logged. |
1 (Errors) | Only errors are logged. |
2 (Warnings) | Errors and warnings are logged. |
3 (Information) | Errors, warnings, and informational messages are logged. |
4 (Debug) | Debug information is logged. |
Message is the log entry.
PutFile Event (DAVServer Class)
Fires when the class needs to store file data.
Syntax
public class DefaultDAVServerEventListener implements DAVServerEventListener { ... public void putFile(DAVServerPutFileEvent e) {} ... } public class DAVServerPutFileEvent { public long sessionId; public String path; public String fileName; public String localPath; //read-write }
Remarks
This event fires when a request to upload file data is received and is the first of two events that can be used to determine how data should be stored.
SessionId specifies the unique identifier for the current session and can be obtained from the initial SessionStart event when the session is first opened.
Path identifies the path of the file relative to the server root. If the file is to be uploaded in the root directory, the value will be empty.
FileName contains the name of the file to be uploaded.
LocalPath may optionally be set to a full path of a local file, in which case the contents of the client's request will be written to that file. If this is not set, which is useful in cases where the data should be stored in a different manner than writing the entire contents to a single file, the class will not immediately respond to the upload request and will instead fire the WriteFile event, where developers have full access to the upload contents and full control over how that data is stored.
Event Order During Upload Operations
When an upload request is received, the class fires a series of events in the following order. Note that certain details like the number of levels of directories within which the target file resides may impact how events fire.
- SessionStart - Fires when a client initiates a session with the class and helps associate a unique session identifier with the request.
- CheckAccess - Fires when a client attempts to list or write a file or directory and provides an opportunity to check access and permissions (optional).
- GetFileInfo - Fires to access metadata regarding the file or directory being written or listed.
- PutFile - Fires to provide a simple way for the class to store file data by setting a filepath (optional).
- GetFileLocks - Fires when the class needs to check or acquire locks to the file being written.
- CreateFile - Fires when the class is asked to create a file that does not already exist.
- WriteFile - Fires if PutFile was not used to store the file and provides full control over inbound upload data.
- SessionEnd - Fires when a client successfully ends a session and allows closing out the session identifier.
ReadFile Event (DAVServer Class)
Fires when the class needs to serve file data.
Syntax
public class DefaultDAVServerEventListener implements DAVServerEventListener { ... public void readFile(DAVServerReadFileEvent e) {} ... } public class DAVServerReadFileEvent { public long sessionId; public String path; public String fileName; public byte[] buffer; public long offset; public int length; public int bytesRead; //read-write public int resultCode; //read-write }
Remarks
This event fires when a request to download file data is received and that request was not already satisfied within the GetFile event.
Any failure to write to the data buffer in this event should be reported as an error.
SessionId specifies the unique identifier for the current session and can be obtained from the initial SessionStart event when the session is first opened.
Path identifies the path of the file relative to the server root. If the file to be downloaded is in the root directory, the value will be empty.
FileName contains the name of the file to be downloaded.
Buffer holds the block of data that will be returned in the response and should be filled through whatever custom logic is appropriate for the server's behavior.
Offset indicates how many bytes have already been transferred in prior firings of this event (which can occur when handling large sets of data) and provides the starting index for the current block of data.
Length indicates the size of the current block of data to be copied to the Buffer.
BytesRead must be set to the actual number of bytes copied into the Buffer at the end of the event.
ResultCode provides an opportunity to report the operation as failed. This parameter will always be 0 when the event is fired, indicating the operation was successful. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource isn't available, security checks failed, etc.), this must be set to a non-zero value.
Event Order During Download Operations
When a download request is received, the class fires a series of events in the following order. Note that certain details like the number of levels of directories within which the target file resides may impact how events fire.
- SessionStart - Fires when a client initiates a session with the class and helps associate a unique session identifier with the request.
- CheckAccess - Fires when a client attempts to read or list a file or directory, and provides an opportunity to check access and permissions (optional).
- GetFileInfo - Fires to access metadata regarding the file or directory being read or listed.
- GetFile - Fires to provide a simple way for the class to serve a file by providing a filepath (optional).
- GetProperty - Fires to access custom metadata regarding the file or directory being read or listed (optional).
- ReadFile - Fires if GetFile was not used to serve the file and provides full control over response data.
- SessionEnd - Fires when a client successfully ends a session and allows closing out the session identifier.
RenameFile Event (DAVServer Class)
Fires when the class needs to rename or move a file or directory.
Syntax
public class DefaultDAVServerEventListener implements DAVServerEventListener { ... public void renameFile(DAVServerRenameFileEvent e) {} ... } public class DAVServerRenameFileEvent { public long sessionId; public String path; public String fileName; public boolean moveItem; public String destParentPath; public String newFileName; public boolean overwriteExisting; public int resultCode; //read-write }
Remarks
This event fires when a request to rename or move a file or directory is received. When a directory with its contents is moved, this event is fired only once for the directory itself.
During recursive moving, if a file or directory cannot be moved, moving should continue, but the event handler should set the ResultCode parameter to a non-zero value to communicate an error.
SessionId specifies the unique identifier for the current session and can be obtained from the initial SessionStart event when the session is first opened.
Path identifies the path of the file or directory relative to the server root. If the item to be renamed or moved is in the root directory, the value will be empty.
FileName identifies the name of the file or directory to be renamed or moved.
MoveItem specifies whether the file or directory is to be moved to a new parent directory. If this is true, the new parent directory is identified by DestParentPath; otherwise, only the name of the item is to be changed, and DestParentPath must be ignored.
DestParentPath contains the path of the new parent directory relative to the server root, but only if MoveFile is true. If the item is to be moved to the root directory, the value will be empty.
NewFileName contains the name of the newly-moved file or directory. If the name should remain the same, the value will be empty.
OverwriteExisting specifies whether the handler should overwrite an existing file if one already exists. If this is false and a destination item exists, the event handler must return the DAVSDK_ERR_ALREADY_EXISTS error. If this is true, the following rules apply:
- If the destination item exists and is a file, it must be replaced by the source item, regardless of whether it is a file or directory.
- If the destination item exists and is a directory, the event handler must return the DAVSDK_ERR_ALREADY_EXISTS error, as a directory cannot be overwritten.
ResultCode provides an opportunity to report the operation as failed. This parameter will always be 0 when the event is fired, indicating the operation was successful. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource isn't available, security checks failed, etc.), this must be set to a non-zero value.
SessionEnd Event (DAVServer Class)
Fires when the class ends a session.
Syntax
public class DefaultDAVServerEventListener implements DAVServerEventListener { ... public void sessionEnd(DAVServerSessionEndEvent e) {} ... } public class DAVServerSessionEndEvent { public long sessionId; }
Remarks
This event fires when the class ends a previously started session. The class doesn't expect any errors to occur or be reported by handlers of this event.
SessionId specifies the unique identifier for the current session and can be obtained from the initial SessionStart event when the session is first opened.
SessionStart Event (DAVServer Class)
Fires when the class starts a session.
Syntax
public class DefaultDAVServerEventListener implements DAVServerEventListener { ... public void sessionStart(DAVServerSessionStartEvent e) {} ... } public class DAVServerSessionStartEvent { public long sessionId; public int resultCode; //read-write }
Remarks
This event fires when a new session with a connected client begins. The lifetime of a session is a single HTTP request and response, meaning once the response has been sent, the session ends.
The SetSessionParam and GetSessionParam methods may be used to set and retrieve custom data associated with the session from within this event and any other event.
SessionId is the unique identifier of the session, assigned by the class. It is provided as a parameter in all other events so that the operations for a particular client session may be tracked.
ResultCode provides an opportunity to report the operation as failed. This parameter will always be 0 when the event is fired, indicating the operation was successful. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource isn't available, security checks failed, etc.), this must be set to a non-zero value.
Reporting an error will abort the operation.
SetFileInfo Event (DAVServer Class)
Fires when the class needs to update times and attributes of a specific file or directory.
Syntax
public class DefaultDAVServerEventListener implements DAVServerEventListener { ... public void setFileInfo(DAVServerSetFileInfoEvent e) {} ... } public class DAVServerSetFileInfoEvent { public long sessionId; public String path; public String fileName; public int attributes; public java.util.Date creationTime; public java.util.Date lastModifiedTime; public java.util.Date lastAccessTime; public int resultCode; //read-write }
Remarks
This event fires when the class receives a request to update times and attributes of a file or directory. To handle this event, file information should be updated on the target file or directory in accordance with the parameters provided in this event.
Note that the class does not update last access time or last modification time times when a file or directory is accessed or updated; this event only fires in response to received requests.
SessionId specifies the unique identifier for the current session and can be obtained from the initial SessionStart event when the session is first opened.
Path identifies the path of the file or directory relative to the server root. If the item whose information is to be updated is in the root directory, the value will be empty.
FileName identifies the name of the file or directory whose information is to be updated.
Attributes may contain 0 if no attributes need to be updated or may be a combination of the following flags:
ITEM_ATTR_FILE | 0x00000001 | The item is a file. |
ITEM_ATTR_DIRECTORY | 0x00000002 | The item is a directory. |
ITEM_ATTR_READONLY | 0x00000040 | The file is read-only.
DAVServer does not block operations based on this attribute, but it does communicate the status of items and directories to clients based on this attribute. |
ITEM_ATTR_ANY_FILE | 0x7FFFFFFF | A mask which includes any and all attributes. |
CreationTime contains a new value for the creation time attribute of the item.
LastModifiedTime contains a new value for the modification time attribute of the item.
LastAccessTime contains a new value for the last access time attribute of the item.
ResultCode provides an opportunity to report the operation as failed. This parameter will always be 0 when the event is fired, indicating the operation was successful. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource isn't available, security checks failed, etc.), this must be set to a non-zero value.
SetFileSize Event (DAVServer Class)
Fires when the class needs to adjust the size of an open file.
Syntax
public class DefaultDAVServerEventListener implements DAVServerEventListener { ... public void setFileSize(DAVServerSetFileSizeEvent e) {} ... } public class DAVServerSetFileSizeEvent { public long sessionId; public String path; public String fileName; public long newSize; public int resultCode; //read-write }
Remarks
This event fires when the class needs to adjust the size of an open file. To handle this event, the size of the target file should be updated based on the NewSize parameter.
SessionId specifies the unique identifier for the current session and can be obtained from the initial SessionStart event when the session is first opened.
Path identifies the path of the file relative to the server root. If the file whose size is to be updated is in the root directory, the value will be empty.
FileName identifies the name of the file whose size is to be updated.
NewSize contains the new size of the file in bytes. The file size may be increased or decreased.
ResultCode provides an opportunity to report the operation as failed. This parameter will always be 0 when the event is fired, indicating the operation was successful. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource isn't available, security checks failed, etc.), this must be set to a non-zero value.
SetProperty Event (DAVServer Class)
Fires when the class needs to add or update custom metadata to a file or directory.
Syntax
public class DefaultDAVServerEventListener implements DAVServerEventListener { ... public void setProperty(DAVServerSetPropertyEvent e) {} ... } public class DAVServerSetPropertyEvent { public long sessionId; public String path; public String fileName; public String namespace; public String propertyName; public String value; public int resultCode; //read-write }
Remarks
This event fires when a request to add or update custom metadata to a file or directory is received.
Note that the class does not maintain these custom metadata properties internally. Developers making use of custom properties should maintain a dictionary or other data structure to store these property names and values, and within this event handler add or update the metadata value to the existing list.
SessionId specifies the unique identifier for the current session and can be obtained from the initial SessionStart event when the session is first opened.
Path identifies the path of the file or directory relative to the server root. If the item whose custom metadata is to be set is located in the root directory, the value will be empty.
FileName identifies the name of the file or directory whose custom metadata is to be set.
Namespace and PropertyName identify the name of the custom metadata property to be set.
Value contains the value of the specified custom metadata property for the file or directory.
ResultCode provides an opportunity to report the operation as failed. This parameter will always be 0 when the event is fired, indicating the operation was successful. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource isn't available, security checks failed, etc.), this must be set to a non-zero value.
UnknownRequest Event (DAVServer Class)
Fires when the class does not recognize the request.
Syntax
public class DefaultDAVServerEventListener implements DAVServerEventListener { ... public void unknownRequest(DAVServerUnknownRequestEvent e) {} ... } public class DAVServerUnknownRequestEvent { public long sessionId; public String httpMethod; public String URI; public String requestHeaders; public byte[] requestBody; public String responseHeaders; //read-write public byte[] responseBody; //read-write public int statusCode; //read-write }
Remarks
This event fires when a request that falls outside the operations understood by the class is received, providing access to the raw content of the request. Within this event, developers can implement any arbitrary logic to handle these unknown requests and then provide the full response headers and body to return to the client.
SessionId specifies the unique identifier for the current session and can be obtained from the initial SessionStart event when the session is first opened.
HttpMethod indicates the HTTP method used in the HTTP request that triggered this event.
URI indicates the URI that identifies the target resource in the HTTP request.
RequestHeaders contains the headers used in the HTTP request provided as name-value pairs.
RequestBody contains the raw content of the body of the HTTP request.
ResponseHeaders should be set to the names and values of headers returned to the client in the HTTP response. As per HTTP standard, header names and values should be separated by a colon, and separate headers are separate strings in the array.
ResponseBody should be set to the raw content that will be sent in the body of the HTTP response.
StatusCode should be set to an appropriate error code from the Error Codes page.
UnlockFile Event (DAVServer Class)
Fires when the class needs to unlock a file or directory.
Syntax
public class DefaultDAVServerEventListener implements DAVServerEventListener { ... public void unlockFile(DAVServerUnlockFileEvent e) {} ... } public class DAVServerUnlockFileEvent { public long sessionId; public String path; public String fileName; public String lockToken; public int resultCode; //read-write }
Remarks
This event fires when a request to unlock a file or directory is received.
If the lock did not exist when this event was fired, the event handler must return the DAVSDK_ERR_LOCK_VIOLATION.
Note that the class does not maintain locks internally. Developers making use of locks should maintain a dictionary or other data structure to keep track of item lock information, and within this event handler check to see if a corresponding lock exists on the item that can be deleted.
SessionId specifies the unique identifier for the current session and can be obtained from the initial SessionStart event when the session is first opened.
Path identifies the path of the file or directory relative to the server root. If the item to be unlocked is in the root directory, the value will be empty.
FileName identifies the name of the file or directory to be unlocked.
LockToken specifies the unique identifier for the lock to be removed.
ResultCode provides an opportunity to report the result of the operation. This will always be DAVSDK_ERR_NOT_IMPLEMENTED when the event is fired and should be set to 0 to indicate success or DAVSDK_ERR_LOCK_FAILED to indicate that a lock could not be created or removed specifically due to a conflict with another lock. Any other non-zero value indicates the lock could not be created or removed for other reasons.
UserAuthRequest Event (DAVServer Class)
Fires when the class attempts to authenticate a client.
Syntax
public class DefaultDAVServerEventListener implements DAVServerEventListener { ... public void userAuthRequest(DAVServerUserAuthRequestEvent e) {} ... } public class DAVServerUserAuthRequestEvent { public String connectionId; public String authMethod; public String user; public String password; //read-write public String realm; public String kerberosSPN; public boolean accept; //read-write }
Remarks
When the ProcessingMode property is set to modeEmbeddedServer, this event provides access to the authentication credentials that a client supplies when attempting to connect. Within this event, developers have the ability to validate credentials using whatever logic is appropriate. Note that the class does not directly validate or invalidate the credentials.
ConnectionId specifies the unique identifier that distinguishes this connection from other connections, even from the same client.
AuthMethod identifies the type of authentication the client is attempting to perform. This value is taken from the HTTP headers of the connection request.
User contains the user the client claims to be. If applicable, this value is taken from the HTTP headers of the connection request.
Password contains the password supplied by the client. If applicable, this value is taken from the HTTP headers of the connection request.
Realm indicates the authentication group for the client, e.g. for Kerberos authentication.
KerberosSPN indicates the Service Principal Name, or service that the client is attempting to authenticate for (when using Kerberos authentication).
Accept should be set to true in order to successfully authenticate the client or false in order to deny the client's connection request.
WriteFile Event (DAVServer Class)
Fires when the class needs to store file data.
Syntax
public class DefaultDAVServerEventListener implements DAVServerEventListener { ... public void writeFile(DAVServerWriteFileEvent e) {} ... } public class DAVServerWriteFileEvent { public long sessionId; public String path; public String fileName; public byte[] data; public long offset; public int length; public int resultCode; //read-write }
Remarks
This event fires when a request to upload file data is received and and that request was not already satisfied within the PutFile event.
Any failure to write any part of the data should be reported as an error.
SessionId specifies the unique identifier for the current session and can be obtained from the initial SessionStart event when the session is first opened.
Path identifies the path of the file relative to the server root. If the file is to be uploaded in the root directory, the value will be empty.
FileName contains the name of the file to be uploaded.
Data contains the block of data that the server should store. This data comes from the inbound request and the class imposes no restrictions on how this data should be treated.
Offset indicates how many bytes have already been transferred in prior firings of this event (which can occur when handling large sets of data) and provides the starting index for the current block of data.
Length indicates the size of the current block of data to be written.
ResultCode provides an opportunity to report the operation as failed. This parameter will always be 0 when the event is fired, indicating the operation was successful. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource isn't available, security checks failed, etc.), this must be set to a non-zero value.
Event Order During Upload Operations
When an upload request is received, the class fires a series of events in the following order. Note that certain details like the number of levels of directories within which the target file resides may impact how events fire.
- SessionStart - Fires when a client initiates a session with the class and helps associate a unique session identifier with the request.
- CheckAccess - Fires when a client attempts to list or write a file or directory and provides an opportunity to check access and permissions (optional).
- GetFileInfo - Fires to access metadata regarding the file or directory being written or listed.
- PutFile - Fires to provide a simple way for the class to store file data by setting a filepath (optional).
- GetFileLocks - Fires when the class needs to check or acquire locks to the file being written.
- CreateFile - Fires when the class is asked to create a file that does not already exist.
- WriteFile - Fires if PutFile was not used to store the file and provides full control over inbound upload data.
- SessionEnd - Fires when a client successfully ends a session and allows closing out the session identifier.
Certificate Type
This is the digital certificate being used.
Remarks
This type describes the current digital certificate. The certificate may be a public or private key. The fields are used to identify or select certificates.
- EffectiveDate
- ExpirationDate
- ExtendedKeyUsage
- Fingerprint
- FingerprintSHA1
- FingerprintSHA256
- Issuer
- KeyPassword
- PrivateKey
- PrivateKeyAvailable
- PrivateKeyContainer
- PublicKey
- PublicKeyAlgorithm
- PublicKeyLength
- SerialNumber
- SignatureAlgorithm
- Store
- StorePassword
- StoreType
- SubjectAltNames
- ThumbprintMD5
- ThumbprintSHA1
- ThumbprintSHA256
- Usage
- UsageFlags
- Version
- Subject
- Encoded
Fields
EffectiveDate
String (read-only)
Default Value: ""
The date on which this certificate becomes valid. Before this date, it is not valid. The date is localized to the system's time zone. The following example illustrates the format of an encoded date:
23-Jan-2000 15:00:00.
ExpirationDate
String (read-only)
Default Value: ""
The date on which the certificate expires. After this date, the certificate will no longer be valid. The date is localized to the system's time zone. The following example illustrates the format of an encoded date:
23-Jan-2001 15:00:00.
ExtendedKeyUsage
String (read-only)
Default Value: ""
A comma-delimited list of extended key usage identifiers. These are the same as ASN.1 object identifiers (OIDs).
Fingerprint
String (read-only)
Default Value: ""
The hex-encoded, 16-byte MD5 fingerprint of the certificate. This property is primarily used for keys which do not have a corresponding X.509 public certificate, such as PEM keys that only contain a private key. It is commonly used for SSH keys.
The following example illustrates the format: bc:2a:72:af:fe:58:17:43:7a:5f:ba:5a:7c:90:f7:02
FingerprintSHA1
String (read-only)
Default Value: ""
The hex-encoded, 20-byte SHA-1 fingerprint of the certificate. This property is primarily used for keys which do not have a corresponding X.509 public certificate, such as PEM keys that only contain a private key. It is commonly used for SSH keys.
The following example illustrates the format: 30:7b:fa:38:65:83:ff:da:b4:4e:07:3f:17:b8:a4:ed:80:be:ff:84
FingerprintSHA256
String (read-only)
Default Value: ""
The hex-encoded, 32-byte SHA-256 fingerprint of the certificate. This property is primarily used for keys which do not have a corresponding X.509 public certificate, such as PEM keys that only contain a private key. It is commonly used for SSH keys.
The following example illustrates the format: 6a:80:5c:33:a9:43:ea:b0:96:12:8a:64:96:30:ef:4a:8a:96:86:ce:f4:c7:be:10:24:8e:2b:60:9e:f3:59:53
Issuer
String (read-only)
Default Value: ""
The issuer of the certificate. This field contains a string representation of the name of the issuing authority for the certificate.
KeyPassword
String
Default Value: ""
The password for the certificate's private key (if any).
Some certificate stores may individually protect certificates' private keys, separate from the standard protection offered by the StorePassword. This field can be used to read such password-protected private keys.
Note: This property defaults to the value of StorePassword. To clear it, you must set the property to the empty string (""). It can be set at any time, but when the private key's password is different from the store's password, then it must be set before calling PrivateKey.
PrivateKey
String (read-only)
Default Value: ""
The private key of the certificate (if available). The key is provided as PEM/Base64-encoded data.
Note: The PrivateKey may be available but not exportable. In this case, PrivateKey returns an empty string.
PrivateKeyAvailable
boolean (read-only)
Default Value: False
Whether a PrivateKey is available for the selected certificate. If PrivateKeyAvailable is True, the certificate may be used for authentication purposes (e.g., server authentication).
PrivateKeyContainer
String (read-only)
Default Value: ""
The name of the PrivateKey container for the certificate (if available). This functionality is available only on Windows platforms.
PublicKey
String (read-only)
Default Value: ""
The public key of the certificate. The key is provided as PEM/Base64-encoded data.
PublicKeyAlgorithm
String (read-only)
Default Value: ""
The textual description of the certificate's public key algorithm. The property contains either the name of the algorithm (e.g., "RSA" or "RSA_DH") or an object identifier (OID) string representing the algorithm.
PublicKeyLength
int (read-only)
Default Value: 0
The length of the certificate's public key (in bits). Common values are 512, 1024, and 2048.
SerialNumber
String (read-only)
Default Value: ""
The serial number of the certificate encoded as a string. The number is encoded as a series of hexadecimal digits, with each pair representing a byte of the serial number.
SignatureAlgorithm
String (read-only)
Default Value: ""
The text description of the certificate's signature algorithm. The property contains either the name of the algorithm (e.g., "RSA" or "RSA_MD5RSA") or an object identifier (OID) string representing the algorithm.
Store
String
Default Value: "MY"
The name of the certificate store for the client certificate.
The StoreType field denotes the type of the certificate store specified by Store. If the store is password-protected, specify the password in StorePassword.
Store is used in conjunction with the Subject field to specify client certificates. If Store has a value, and Subject or Encoded is set, a search for a certificate is initiated. Please see the Subject field for details.
Designations of certificate stores are platform dependent.
The following designations are the most common User and Machine certificate stores in Windows:
MY | A certificate store holding personal certificates with their associated private keys. |
CA | Certifying authority certificates. |
ROOT | Root certificates. |
In Java, the certificate store normally is a file containing certificates and optional private keys.
When the certificate store type is cstPFXFile, this property must be set to the name of the file. When the type is cstPFXBlob, the property must be set to the binary contents of a PFX file (i.e., PKCS#12 certificate store).
StoreB
byte[]
Default Value: "MY"
The name of the certificate store for the client certificate.
The StoreType field denotes the type of the certificate store specified by Store. If the store is password-protected, specify the password in StorePassword.
Store is used in conjunction with the Subject field to specify client certificates. If Store has a value, and Subject or Encoded is set, a search for a certificate is initiated. Please see the Subject field for details.
Designations of certificate stores are platform dependent.
The following designations are the most common User and Machine certificate stores in Windows:
MY | A certificate store holding personal certificates with their associated private keys. |
CA | Certifying authority certificates. |
ROOT | Root certificates. |
In Java, the certificate store normally is a file containing certificates and optional private keys.
When the certificate store type is cstPFXFile, this property must be set to the name of the file. When the type is cstPFXBlob, the property must be set to the binary contents of a PFX file (i.e., PKCS#12 certificate store).
StorePassword
String
Default Value: ""
If the type of certificate store requires a password, this field is used to specify the password needed to open the certificate store.
StoreType
int
Default Value: 0
The type of certificate store for this certificate.
The class supports both public and private keys in a variety of formats. When the cstAuto value is used, the class will automatically determine the type. This field can take one of the following values:
0 (cstUser - default) | For Windows, this specifies that the certificate store is a certificate store owned by the current user.
Note: This store type is not available in Java. |
1 (cstMachine) | For Windows, this specifies that the certificate store is a machine store.
Note: This store type is not available in Java. |
2 (cstPFXFile) | The certificate store is the name of a PFX (PKCS#12) file containing certificates. |
3 (cstPFXBlob) | The certificate store is a string (binary or Base64-encoded) representing a certificate store in PFX (PKCS#12) format. |
4 (cstJKSFile) | The certificate store is the name of a Java Key Store (JKS) file containing certificates.
Note: This store type is only available in Java. |
5 (cstJKSBlob) | The certificate store is a string (binary or Base64-encoded) representing a certificate store in Java Key Store (JKS) format.
Note: This store type is only available in Java. |
6 (cstPEMKeyFile) | The certificate store is the name of a PEM-encoded file that contains a private key and an optional certificate. |
7 (cstPEMKeyBlob) | The certificate store is a string (binary or Base64-encoded) that contains a private key and an optional certificate. |
8 (cstPublicKeyFile) | The certificate store is the name of a file that contains a PEM- or DER-encoded public key certificate. |
9 (cstPublicKeyBlob) | The certificate store is a string (binary or Base64-encoded) that contains a PEM- or DER-encoded public key certificate. |
10 (cstSSHPublicKeyBlob) | The certificate store is a string (binary or Base64-encoded) that contains an SSH-style public key. |
11 (cstP7BFile) | The certificate store is the name of a PKCS#7 file containing certificates. |
12 (cstP7BBlob) | The certificate store is a string (binary) representing a certificate store in PKCS#7 format. |
13 (cstSSHPublicKeyFile) | The certificate store is the name of a file that contains an SSH-style public key. |
14 (cstPPKFile) | The certificate store is the name of a file that contains a PPK (PuTTY Private Key). |
15 (cstPPKBlob) | The certificate store is a string (binary) that contains a PPK (PuTTY Private Key). |
16 (cstXMLFile) | The certificate store is the name of a file that contains a certificate in XML format. |
17 (cstXMLBlob) | The certificate store is a string that contains a certificate in XML format. |
18 (cstJWKFile) | The certificate store is the name of a file that contains a JWK (JSON Web Key). |
19 (cstJWKBlob) | The certificate store is a string that contains a JWK (JSON Web Key). |
21 (cstBCFKSFile) | The certificate store is the name of a file that contains a BCFKS (Bouncy Castle FIPS Key Store).
Note: This store type is only available in Java and .NET. |
22 (cstBCFKSBlob) | The certificate store is a string (binary or Base64-encoded) representing a certificate store in BCFKS (Bouncy Castle FIPS Key Store) format.
Note: This store type is only available in Java and .NET. |
23 (cstPKCS11) | The certificate is present on a physical security key accessible via a PKCS#11 interface.
To use a security key, the necessary data must first be collected using the CertMgr class. The ListStoreCertificates method may be called after setting CertStoreType to cstPKCS11, CertStorePassword to the PIN, and CertStore to the full path of the PKCS#11 DLL. The certificate information returned in the CertList event's CertEncoded parameter may be saved for later use. When using a certificate, pass the previously saved security key information as the Store and set StorePassword to the PIN. Code Example. SSH Authentication with Security Key:
|
99 (cstAuto) | The store type is automatically detected from the input data. This setting may be used with both public and private keys and can detect any of the supported formats automatically. |
SubjectAltNames
String (read-only)
Default Value: ""
Comma-separated lists of alternative subject names for the certificate.
ThumbprintMD5
String (read-only)
Default Value: ""
The MD5 hash of the certificate. It is primarily used for X.509 certificates. If the hash does not already exist, it is automatically computed.
ThumbprintSHA1
String (read-only)
Default Value: ""
The SHA-1 hash of the certificate. It is primarily used for X.509 certificates. If the hash does not already exist, it is automatically computed.
ThumbprintSHA256
String (read-only)
Default Value: ""
The SHA-256 hash of the certificate. It is primarily used for X.509 certificates. If the hash does not already exist, it is automatically computed.
Usage
String (read-only)
Default Value: ""
The text description of UsageFlags.
This value will be one or more of the following strings and will be separated by commas:
- Digital Signature
- Non-Repudiation
- Key Encipherment
- Data Encipherment
- Key Agreement
- Certificate Signing
- CRL Signing
- Encipher Only
If the provider is OpenSSL, the value is a comma-separated list of X.509 certificate extension names.
UsageFlags
int (read-only)
Default Value: 0
The flags that show intended use for the certificate. The value of UsageFlags is a combination of the following flags:
0x80 | Digital Signature |
0x40 | Non-Repudiation |
0x20 | Key Encipherment |
0x10 | Data Encipherment |
0x08 | Key Agreement |
0x04 | Certificate Signing |
0x02 | CRL Signing |
0x01 | Encipher Only |
Please see the Usage field for a text representation of UsageFlags.
This functionality currently is not available when the provider is OpenSSL.
Version
String (read-only)
Default Value: ""
The certificate's version number. The possible values are the strings "V1", "V2", and "V3".
Subject
String
Default Value: ""
The subject of the certificate used for client authentication.
This field will be populated with the full subject of the loaded certificate. When loading a certificate, the subject is used to locate the certificate in the store.
If an exact match is not found, the store is searched for subjects containing the value of the property.
If a match is still not found, the property is set to an empty string, and no certificate is selected.
The special value "*" picks a random certificate in the certificate store.
The certificate subject is a comma-separated list of distinguished name fields and values. For instance, "CN=www.server.com, OU=test, C=US, E=example@email.com". Common fields and their meanings are as follows:
Field | Meaning |
CN | Common Name. This is commonly a hostname like www.server.com. |
O | Organization |
OU | Organizational Unit |
L | Locality |
S | State |
C | Country |
E | Email Address |
If a field value contains a comma, it must be quoted.
Encoded
String
Default Value: ""
The certificate (PEM/Base64 encoded). This field is used to assign a specific certificate. The Store and Subject fields also may be used to specify a certificate.
When Encoded is set, a search is initiated in the current Store for the private key of the certificate. If the key is found, Subject is updated to reflect the full subject of the selected certificate; otherwise, Subject is set to an empty string.
EncodedB
byte[]
Default Value: ""
The certificate (PEM/Base64 encoded). This field is used to assign a specific certificate. The Store and Subject fields also may be used to specify a certificate.
When Encoded is set, a search is initiated in the current Store for the private key of the certificate. If the key is found, Subject is updated to reflect the full subject of the selected certificate; otherwise, Subject is set to an empty string.
Constructors
public Certificate();
Creates a instance whose properties can be set.
public Certificate( certificateFile);
Opens CertificateFile and reads out the contents as an X.509 public key.
public Certificate( encoded);
Parses Encoded as an X.509 public key.
public Certificate( storeType, store, storePassword, subject);
StoreType identifies the type of certificate store to use. See for descriptions of the different certificate stores. Store is a file containing the certificate store. StorePassword is the password used to protect the store.
After the store has been successfully opened, the class will attempt to find the certificate identified by Subject . This can be either a complete or a substring match of the X.509 certificate's subject Distinguished Name (DN). The Subject parameter can also take an MD5, SHA-1, or SHA-256 thumbprint of the certificate to load in a "Thumbprint=value" format.
public Certificate( storeType, store, storePassword, subject, configurationString);
StoreType identifies the type of certificate store to use. See for descriptions of the different certificate stores. Store is a file containing the certificate store. StorePassword is the password used to protect the store.
ConfigurationString is a newline-separated list of name-value pairs that may be used to modify the default behavior. Possible values include "PersistPFXKey", which shows whether or not the PFX key is persisted after performing operations with the private key. This correlates to the PKCS12_NO_PERSIST_KEY CryptoAPI option. The default value is True (the key is persisted). "Thumbprint" - an MD5, SHA-1, or SHA-256 thumbprint of the certificate to load. When specified, this value is used to select the certificate in the store. This is applicable to the cstUser , cstMachine , cstPublicKeyFile , and cstPFXFile store types. "UseInternalSecurityAPI" shows whether the platform (default) or the internal security API is used when performing certificate-related operations.
After the store has been successfully opened, the class will attempt to find the certificate identified by Subject . This can be either a complete or a substring match of the X.509 certificate's subject Distinguished Name (DN). The Subject parameter can also take an MD5, SHA-1, or SHA-256 thumbprint of the certificate to load in a "Thumbprint=value" format.
public Certificate( storeType, store, storePassword, encoded);
StoreType identifies the type of certificate store to use. See for descriptions of the different certificate stores. Store is a file containing the certificate store. StorePassword is the password used to protect the store.
After the store has been successfully opened, the class will load Encoded as an X.509 certificate and search the opened store for a corresponding private key.
public Certificate( storeType, store, storePassword, subject);
StoreType identifies the type of certificate store to use. See for descriptions of the different certificate stores. Store is a byte array containing the certificate data. StorePassword is the password used to protect the store.
After the store has been successfully opened, the class will attempt to find the certificate identified by Subject . This can be either a complete or a substring match of the X.509 certificate's subject Distinguished Name (DN). The Subject parameter can also take an MD5, SHA-1, or SHA-256 thumbprint of the certificate to load in a "Thumbprint=value" format.
public Certificate( storeType, store, storePassword, subject, configurationString);
StoreType identifies the type of certificate store to use. See for descriptions of the different certificate stores. Store is a byte array containing the certificate data. StorePassword is the password used to protect the store.
After the store has been successfully opened, the class will attempt to find the certificate identified by Subject . This can be either a complete or a substring match of the X.509 certificate's subject Distinguished Name (DN). The Subject parameter can also take an MD5, SHA-1, or SHA-256 thumbprint of the certificate to load in a "Thumbprint=value" format.
public Certificate( storeType, store, storePassword, encoded);
StoreType identifies the type of certificate store to use. See for descriptions of the different certificate stores. Store is a byte array containing the certificate data. StorePassword is the password used to protect the store.
After the store has been successfully opened, the class will load Encoded as an X.509 certificate and search the opened store for a corresponding private key.
ServerSettings Type
The embedded HTTP server settings used by the class.
Remarks
This type describes the current embedded HTTP server settings used by the class. The fields are used to configure the server.
Fields
AllowedAuthMethods
String
Default Value: "None,Basic,Digest,NTLM,Kerberos"
Specifies the authentication schemes that the class will allow.
This field must be set to a valid comma-separated string of authentication scheme values that the embedded server will allow. Possible values are as follows:
- None: Unauthenticated connection requests will be allowed.
- Basic: HTTP Basic authentication is allowed.
- Digest: Digest authentication is allowed.
- NTLM: NTLM authentication is allowed.
- Kerberos: Windows Negotiate (Kerberos) authentication is allowed.
LocalHost
String
Default Value: ""
Specifies the name of the local host or user-assigned IP interface through which connections are initiated or accepted.
This field contains the name of the local host as obtained by the gethostname() system call, or if the user has assigned an IP address, the value of that address.
In multihomed hosts (machines with more than one IP interface) setting LocalHost to the IP address of an interface will make the class initiate connections (or accept in the case of server classes) only through that interface. It is recommended to provide an IP address rather than a hostname when setting this field to ensure the desired interface is used.
If the class is connected, the LocalHost field shows the IP address of the interface through which the connection is made in internet dotted format (aaa.bbb.ccc.ddd). In most cases, this is the address of the local host, except for multihomed hosts (machines with more than one IP interface).
Note: LocalHost is not persistent. You must always set it in code, and never in the property window.
LocalPort
int
Default Value: 0
Includes the Transmission Control Protocol (TCP) port in the local host where the class listens.
This field must be set before the class can start listening. If this is set to 0, then the TCP/IP subsystem will pick a port number at random.
The service port is not shared among servers, so two classes cannot be listening on the same port at the same time.
Timeout
int
Default Value: 60
Specifies the timeout in seconds for the class.
If this is set to 0, all operations will run uninterrupted until successful completion or an error condition is encountered.
If this is set to a positive value, the class will wait for the operation to complete before returning control.
If the timeout expires, and the operation is not yet complete, the class throws an exception.
Note that all timeouts are inactivity timeouts, meaning the timeout period is extended by the value specified in this field when any amount of data is successfully sent or received.
Constructors
public ServerSettings();
Creates an empty settings instance whose properties can be set.
Config Settings (DAVServer Class)
The class accepts one or more of the following configuration settings. Configuration settings are similar in functionality to properties, but they are rarely used. In order to avoid "polluting" the property namespace of the class, access to these internal properties is provided through the Config method.DAVServer Config Settings
When the setting is enabled (by default) and a client requests a recursive enumeration, the class fires the ListDirectory event just for the directory being enumerated.
When the setting is disabled, the class fires the ListDirectory event for each directory and all of its subdirectories separately, merging all results before serving the client's request. The event handler should then return all matching files and directories in whatever order, and the class will sort the list and select a range of files and directories to provide to the transport and a client. This mode can be slower when a directory contains many items, and the client makes "paged" requests for a small batch of items per request.
By default, this setting is enabled, meaning the CheckAccess event is fired, but this setting may be disabled to improve performance.
0 (None) | No information is logged. |
1 (Errors) | Only errors are logged. |
2 (Warnings) | Errors and warnings are logged. |
3 (Information) | Errors, warnings, and informational messages are logged. |
4 (Debug) | Debug information is logged. |
0 (None) | No information is logged. |
1 (Errors) | Only errors are logged. |
2 (Warnings) | Errors and warnings are logged. |
3 (Information) | Errors, warnings, and informational messages are logged. |
4 (Debug) | Debug information is logged. |
0 (None - Default) | No bodies are logged. |
1 (Text) | Only bodies of the data, for which the Content-Type header denotes a human-readable text format, are logged. Examples include text/*, all application/*json and all application/*xml values. |
2 (Binary) | Only bodies of the data, for which the Content-Type header does not denote a text format, are logged. |
3 (All) | All bodies are logged. |
By default, read-only mode is disabled.
By default, this setting is set to dav, meaning the class serves requests at the /server/dav endpoint.
Trappable Errors (DAVServer Class)
The class uses the error codes listed below. They are also available as constants for applications' convenience.Please refer to the Error Handling topic for more information.
DAVServer Errors
0 | DAVSDK_ERR_OK: Success. |
2 | DAVSDK_ERR_FILE_NOT_FOUND: File or directory not found. |
3 | DAVSDK_ERR_PATH_NOT_FOUND: Path or parent not found. |
4 | DAVSDK_ERR_PROPERTY_NOT_FOUND: Property not found. |
5 | DAVSDK_ERR_ACCESS_DENIED: Access Denied. Used to signal insufficient permissions for item access. |
6 | DAVSDK_ERR_INVALID_HANDLE: Invalid item handle. Used to signal an invalid value in various *Context and *Handle parameters. Can be returned by both the class's methods and application event handlers. |
29 | DAVSDK_ERR_WRITE_FAULT: The operation of writing the data to the backend storage has failed or has been denied by the storage. |
30 | DAVSDK_ERR_READ_FAULT: The operation of reading the data from the backend storage has failed or has been denied by the storage. |
31 | DAVSDK_ERR_GENERAL_FAILURE: General failure. The reason for the failure could not be determined. |
33 | DAVSDK_ERR_LOCK_VIOLATION: Lock violation. When reported by an event handler, should be used when the file is locked and the operation is not possible due to this lock. |
86 | DAVSDK_ERR_INVALID_PASSWORD: A password is missing or incorrect. Returned by the class in the REST API when an access is attempted to a share that is password-protected, but a password is either missing or incorrect. |
87 | DAVSDK_ERR_INVALID_PARAMETER: Invalid parameter. When returned by the class's method, indicates an unacceptable value of one of the parameters (please refer to the exception message for additional details). When reported by an event handler, should be used only to signal logical errors in the code (e.g. a negative position passed by the class during file reading/writing) and not to communicate something that an event handler cannot handle temporarily or permanently, e.g. due to the backend's limits or some external state. |
120 | DAVSDK_ERR_NOT_IMPLEMENTED: The requested operation is either not implemented by an application or has been disabled using the properties and settings. |
167 | DAVSDK_ERR_LOCK_FAILED: A Lock or Unlock operation failed. |
183 | DAVSDK_ERR_ALREADY_EXISTS: An item already exists. When reported by an event handler, should be used to indicate that the operation such as creation, moving, or copying of the item cannot be accomplished because at the destination, there already exists an item with the given name or Id. |
348 | DAVSDK_ERR_ITEM_READONLY: An item cannot be moved, deleted, or written to because it is read-only. |
995 | DAVSDK_ERR_OPERATION_ABORTED: An operation has been aborted on the transport level (e.g. due to the premature closing of a socket by the client). |
1127 | DAVSDK_ERR_DISK_OPERATION_FAILED: A catch-all error code that can be used to tell the class that a backend filesystem operation has failed. |
1296 | DAVSDK_ERR_CONTENT_BLOCKED: An upload or download operation was blocked by the application, likely due to invalid content. |
3060 | DAVSDK_ERR_CONDITION_NOT_SATISFIED: The HTTP request contained conditions (such as modification period, range of data in a file, or etag) that could not be satisfied. |