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])
Afficher le fichier Open project: horde/horde Class Usage Examples

Méthodes publiques

Свойство Type Description
$supportedAuthMethods array Can be overwritten if having problems with certain methods.
$supportedSASLAuthMethods array SASL authentication methods that require Auth_SASL.

Protected Properties

Свойство 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.

Méthodes publiques

Méthode 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.

Méthodes protégées

Méthode 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 méthode

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 méthode

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 méthode

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 méthode

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 méthode

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 méthode

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 méthode

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

_checkConnected() protected méthode

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

_cmdAuthenticate() protected méthode

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 méthode

Sends the CAPABILITY command
protected _cmdCapability ( )

_cmdDeleteScript() protected méthode

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

_cmdGetScript() protected méthode

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

_cmdListScripts() protected méthode

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

_cmdLogout() protected méthode

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 méthode

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 méthode

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 méthode

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

_doCmd() protected méthode

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.
Résultat string Reponse string if an OK response.

_escape() protected méthode

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

_getBestAuthMethod() protected méthode

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.
Résultat string The name of the best supported authentication method.

_handleConnectAndLogin() protected méthode

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

_parseCapability() protected méthode

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 méthode

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

_recvLn() protected méthode

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

_sendCmd() protected méthode

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

_sendStringResponse() protected méthode

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

connect() public méthode

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 méthode

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

getActive() public méthode

Returns the active script.
public getActive ( ) : string
Résultat string The active scriptname.

getAuthMechs() public méthode

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

getExtensions() public méthode

Returns the list of extensions the server supports.
public getExtensions ( ) : array
Résultat array List of extensions.

getScript() public méthode

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

hasAuthMech() public méthode

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

hasExtension() public méthode

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

hasSpace() public méthode

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.
Résultat boolean True if there is space.

installScript() public méthode

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 méthode

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

login() public méthode

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 méthode

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

setActive() public méthode

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

setLogger() public méthode

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
Résultat string | array

$_maxReferralCount protected_oe property

Maximum number of referral loops
protected array $_maxReferralCount
Résultat array

$_params protected_oe property

Parameters and connection information.
protected array $_params
Résultat array

$_sock protected_oe property

The socket client.
protected Client,Horde\Socket $_sock
Résultat Horde\Socket\Client

$_state protected_oe property

One of the STATE_* constants.
protected int $_state
Résultat integer

$supportedAuthMethods public_oe property

Can be overwritten if having problems with certain methods.
public array $supportedAuthMethods
Résultat array

$supportedSASLAuthMethods public_oe property

SASL authentication methods that require Auth_SASL.
public array $supportedSASLAuthMethods
Résultat array