PHP Class Horde\ManageSieve

Author: Richard Heyes ([email protected])
Author: Damian Fernandez Sosa ([email protected])
Author: Anish Mistry ([email protected])
Author: Jan Schneider ([email protected])
Datei anzeigen Open project: horde/horde Class Usage Examples

Public Properties

Property Type Description
$supportedAuthMethods array Can be overwritten if having problems with certain methods.
$supportedSASLAuthMethods array SASL authentication methods that require Auth_SASL.

Protected Properties

Property Type Description
$_logger string | array Logging handler.
$_maxReferralCount array Maximum number of referral loops
$_params array Parameters and connection information.
$_sock Horde\Socket\Client The socket client.
$_state integer One of the STATE_* constants.

Public Methods

Method Description
__construct ( array $params = [] ) Constructor.
connect ( string $host = null, string $port = null, array $context = null, boolean $secure = null ) Handles connecting to the server and checks the response validity.
disconnect ( boolean $sendLogoutCMD = true ) Disconnect from the Sieve server.
getActive ( ) : string Returns the active script.
getAuthMechs ( ) : array Returns the list of authentication methods the server supports.
getExtensions ( ) : array Returns the list of extensions the server supports.
getScript ( string $scriptname ) : string Retrieves a script.
hasAuthMech ( string $method ) : boolean Returns whether the server supports an authentication method.
hasExtension ( string $extension ) : boolean Returns whether the server supports an extension.
hasSpace ( string $scriptname, integer $size ) : boolean Checks if the server has space to store the script by the server.
installScript ( string $scriptname, string $script, boolean $makeactive = false ) Adds a script to the server.
listScripts ( ) : array Returns an indexed array of scripts currently on the server.
login ( string $user = null, string $password = null, string $authmethod = null, string $euser = null ) Logs into server.
removeScript ( string $scriptname ) Removes a script from the server.
setActive ( string $scriptname ) Sets the active script.
setLogger ( object $logger ) Passes a logger for debug logging.

Protected Methods

Method Description
_authCRAMMD5 ( string $user, string $pass, string $euser ) Authenticates the user using the CRAM-MD5 method.
_authDigestMD5 ( string $user, string $pass, string $euser ) Authenticates the user using the DIGEST-MD5 method.
_authEXTERNAL ( string $user, string $pass, string $euser ) Authenticates the user using the EXTERNAL method.
_authLOGIN ( string $user, string $pass, string $euser ) Authenticates the user using the LOGIN method.
_authPLAIN ( string $user, string $pass, string $euser ) Authenticates the user using the PLAIN method.
_checkAuthenticated ( ) Asserts that the client is in authenticated state.
_checkConnected ( ) Asserts that the client is in disconnected state.
_cmdAuthenticate ( string $uid, string $pwd, string $authmethod = null, string $euser = '' ) Handles the authentication using any known method.
_cmdCapability ( ) Sends the CAPABILITY command
_cmdDeleteScript ( string $scriptname ) Removes a script from the server.
_cmdGetScript ( string $scriptname ) : string Retrieves the contents of the named script.
_cmdListScripts ( ) : array Returns the list of scripts on the server.
_cmdLogout ( boolean $sendLogoutCMD = true ) Logs out of the server and terminates the connection.
_cmdPutScript ( string $scriptname, string $scriptdata ) Adds a script to the server.
_cmdSetActive ( string $scriptname ) Sets the active script, i.e. the one that gets run on new mail by the server.
_debug ( string $message ) Write debug text to the current log handler.
_doCmd ( string $cmd = '', boolean $auth = false ) : string Send a command and retrieves a response from the server.
_escape ( string $string ) : string Converts strings into RFC's quoted-string or literal-c2s form.
_getBestAuthMethod ( string $authmethod = null ) : string Returns the name of the best authentication method that the server has advertised.
_handleConnectAndLogin ( ) Connects to the server and logs in.
_parseCapability ( string $data ) Parses the response from the CAPABILITY command and stores the result in $_capability.
_recvBytes ( integer $length ) : string Receives a number of bytes from the server.
_recvLn ( ) : string Receives a single line from the server.
_sendCmd ( string $cmd ) Sends a command to the server
_sendStringResponse ( string $str ) Sends a string response to the server.

Method Details

__construct() public method

If username and password are provided connects to the server and logs in too.
public __construct ( array $params = [] )
$params array A hash of connection parameters: - host: Hostname of server (DEFAULT: localhost). Optionally prefixed with protocol scheme. - port: Port of server (DEFAULT: 4190). - user: Login username (optional). - password: Login password (optional). - authmethod: Type of login to perform (see $supportedAuthMethods) (DEFAULT: AUTH_AUTOMATIC). - euser: Effective user. If authenticating as an administrator, login as this user. - bypassauth: Skip the authentication phase. Useful if passing an already open socket. - secure: Security layer requested. One of: - true: (TLS if available/necessary) [DEFAULT] - false: (No encryption) - 'ssl': (Auto-detect SSL version) - 'sslv2': (Force SSL version 3) - 'sslv3': (Force SSL version 2) - 'tls': (TLS; started via protocol-level negotation over unencrypted channel) - 'tlsv1': (TLS version 1.x connection) - context: Additional options for stream_context_create(). - logger: A log handler, must implement debug().

_authCRAMMD5() protected method

Authenticates the user using the CRAM-MD5 method.
protected _authCRAMMD5 ( string $user, string $pass, string $euser )
$user string The userid to authenticate as.
$pass string The password to authenticate with.
$euser string The effective uid to authenticate as. Not used.

_authDigestMD5() protected method

Authenticates the user using the DIGEST-MD5 method.
protected _authDigestMD5 ( string $user, string $pass, string $euser )
$user string The userid to authenticate as.
$pass string The password to authenticate with.
$euser string The effective uid to authenticate as.

_authEXTERNAL() protected method

Authenticates the user using the EXTERNAL method.
protected _authEXTERNAL ( string $user, string $pass, string $euser )
$user string The userid to authenticate as.
$pass string The password to authenticate with.
$euser string The effective uid to authenticate as.

_authLOGIN() protected method

Authenticates the user using the LOGIN method.
protected _authLOGIN ( string $user, string $pass, string $euser )
$user string The userid to authenticate as.
$pass string The password to authenticate with.
$euser string The effective uid to authenticate as. Not used.

_authPLAIN() protected method

Authenticates the user using the PLAIN method.
protected _authPLAIN ( string $user, string $pass, string $euser )
$user string The userid to authenticate as.
$pass string The password to authenticate with.
$euser string The effective uid to authenticate as.

_checkAuthenticated() protected method

Asserts that the client is in authenticated state.
protected _checkAuthenticated ( )

_checkConnected() protected method

Asserts that the client is in disconnected state.
protected _checkConnected ( )

_cmdAuthenticate() protected method

Handles the authentication using any known method.
protected _cmdAuthenticate ( string $uid, string $pwd, string $authmethod = null, string $euser = '' )
$uid string The userid to authenticate as.
$pwd string The password to authenticate with.
$authmethod string The method to use. If empty, the class chooses the best (strongest) available method.
$euser string The effective uid to authenticate as.

_cmdCapability() protected method

Sends the CAPABILITY command
protected _cmdCapability ( )

_cmdDeleteScript() protected method

Removes a script from the server.
protected _cmdDeleteScript ( string $scriptname )
$scriptname string Name of the script to delete.

_cmdGetScript() protected method

Retrieves the contents of the named script.
protected _cmdGetScript ( string $scriptname ) : string
$scriptname string Name of the script to retrieve.
return string The script.

_cmdListScripts() protected method

Returns the list of scripts on the server.
protected _cmdListScripts ( ) : array
return array An array with the list of scripts in the first element and the active script in the second element.

_cmdLogout() protected method

Logs out of the server and terminates the connection.
protected _cmdLogout ( boolean $sendLogoutCMD = true )
$sendLogoutCMD boolean Whether to send LOGOUT command before disconnecting.

_cmdPutScript() protected method

Adds a script to the server.
protected _cmdPutScript ( string $scriptname, string $scriptdata )
$scriptname string Name of the new script.
$scriptdata string The new script.

_cmdSetActive() protected method

Sets the active script, i.e. the one that gets run on new mail by the server.
protected _cmdSetActive ( string $scriptname )
$scriptname string The name of the script to mark as active.

_debug() protected method

Write debug text to the current log handler.
protected _debug ( string $message )
$message string Debug message text.

_doCmd() protected method

Send a command and retrieves a response from the server.
protected _doCmd ( string $cmd = '', boolean $auth = false ) : string
$cmd string The command to send.
$auth boolean Whether this is an authentication command.
return string Reponse string if an OK response.

_escape() protected method

Converts strings into RFC's quoted-string or literal-c2s form.
protected _escape ( string $string ) : string
$string string The string to convert.
return string Result string.

_getBestAuthMethod() protected method

Returns the name of the best authentication method that the server has advertised.
protected _getBestAuthMethod ( string $authmethod = null ) : string
$authmethod string Only consider this method as available.
return string The name of the best supported authentication method.

_handleConnectAndLogin() protected method

Connects to the server and logs in.
protected _handleConnectAndLogin ( )

_parseCapability() protected method

Parses the response from the CAPABILITY command and stores the result in $_capability.
protected _parseCapability ( string $data )
$data string The response from the capability command.

_recvBytes() protected method

Receives a number of bytes from the server.
protected _recvBytes ( integer $length ) : string
$length integer Number of bytes to read.
return string The server response.

_recvLn() protected method

Receives a single line from the server.
protected _recvLn ( ) : string
return string The server response line.

_sendCmd() protected method

Sends a command to the server
protected _sendCmd ( string $cmd )
$cmd string The command to send.

_sendStringResponse() protected method

Sends a string response to the server.
protected _sendStringResponse ( string $str )
$str string The string to send.

connect() public method

Defaults from the constructor are used for missing parameters.
public connect ( string $host = null, string $port = null, array $context = null, boolean $secure = null )
$host string Hostname of server.
$port string Port of server.
$context array List of options to pass to stream_context_create().
$secure boolean Security layer requested. @see __construct().

disconnect() public method

Disconnect from the Sieve server.
public disconnect ( boolean $sendLogoutCMD = true )
$sendLogoutCMD boolean Whether to send LOGOUT command before disconnecting.

getActive() public method

Returns the active script.
public getActive ( ) : string
return string The active scriptname.

getAuthMechs() public method

Returns the list of authentication methods the server supports.
public getAuthMechs ( ) : array
return array List of authentication methods.

getExtensions() public method

Returns the list of extensions the server supports.
public getExtensions ( ) : array
return array List of extensions.

getScript() public method

Retrieves a script.
public getScript ( string $scriptname ) : string
$scriptname string The name of the script to be retrieved.
return string The script.

hasAuthMech() public method

Returns whether the server supports an authentication method.
public hasAuthMech ( string $method ) : boolean
$method string The method to check.
return boolean Whether the method is supported.

hasExtension() public method

Returns whether the server supports an extension.
public hasExtension ( string $extension ) : boolean
$extension string The extension to check.
return boolean Whether the extension is supported.

hasSpace() public method

Checks if the server has space to store the script by the server.
public hasSpace ( string $scriptname, integer $size ) : boolean
$scriptname string The name of the script to mark as active.
$size integer The size of the script.
return boolean True if there is space.

installScript() public method

Adds a script to the server.
public installScript ( string $scriptname, string $script, boolean $makeactive = false )
$scriptname string Name of the script.
$script string The script content.
$makeactive boolean Whether to make this the active script.

listScripts() public method

Returns an indexed array of scripts currently on the server.
public listScripts ( ) : array
return array Indexed array of scriptnames.

login() public method

Defaults from the constructor are used for missing parameters.
public login ( string $user = null, string $password = null, string $authmethod = null, string $euser = null )
$user string Login username.
$password string Login password.
$authmethod string Type of login method to use.
$euser string Effective UID (perform on behalf of $euser).

removeScript() public method

Removes a script from the server.
public removeScript ( string $scriptname )
$scriptname string Name of the script.

setActive() public method

Sets the active script.
public setActive ( string $scriptname )
$scriptname string The name of the script to be set as active.

setLogger() public method

Passes a logger for debug logging.
public setLogger ( object $logger )
$logger object A log handler, must implement debug().

Property Details

$_logger protected_oe property

Logging handler.
protected string|array $_logger
return string | array

$_maxReferralCount protected_oe property

Maximum number of referral loops
protected array $_maxReferralCount
return array

$_params protected_oe property

Parameters and connection information.
protected array $_params
return array

$_sock protected_oe property

The socket client.
protected Client,Horde\Socket $_sock
return Horde\Socket\Client

$_state protected_oe property

One of the STATE_* constants.
protected int $_state
return integer

$supportedAuthMethods public_oe property

Can be overwritten if having problems with certain methods.
public array $supportedAuthMethods
return array

$supportedSASLAuthMethods public_oe property

SASL authentication methods that require Auth_SASL.
public array $supportedSASLAuthMethods
return array