PHP Class Zend_Form_Element_Hash

Inheritance: extends Zend_Form_Element_Xhtml
显示文件 Open project: kimai/kimai Class Usage Examples

Public Properties

Property Type Description
$helper string Use formHidden view helper by default

Protected Properties

Property Type Description
$_hash mixed Actual hash used.
$_salt string Salt for CSRF token
$_session Zend_Session_Namespace
$_timeout integer TTL for CSRF token

Public Methods

Method Description
__construct ( string | array | Zend_Config $spec, array | Zend_Config $options = null ) : void Constructor
getHash ( ) : string Retrieve CSRF token
getLabel ( ) : null Override getLabel() to always be empty
getSalt ( ) : string Retrieve salt for CSRF token
getSession ( ) : Zend_Session_Namespace Get session object
getSessionName ( ) : string Get session namespace for CSRF token
getTimeout ( ) : integer Get CSRF session token timeout
initCsrfToken ( ) : void Initialize CSRF token in session
initCsrfValidator ( ) : Zend_Form_Element_Hash Initialize CSRF validator
render ( Zend_View_Interface $view = null ) : string Render CSRF token in form
setSalt ( string $salt ) : Zend_Form_Element_Hash Salt for CSRF token
setSession ( Zend_Session_Namespace $session ) : Zend_Form_Element_Hash Set session object
setTimeout ( integer $ttl ) : Zend_Form_Element_Hash Set timeout for CSRF session token

Protected Methods

Method Description
_generateHash ( ) : void Generate CSRF token

Method Details

__construct() public method

Creates session namespace for CSRF token, and adds validator for CSRF token.
public __construct ( string | array | Zend_Config $spec, array | Zend_Config $options = null ) : void
$spec string | array | Zend_Config
$options array | Zend_Config
return void

_generateHash() protected method

Generates CSRF token and stores both in {@link $_hash} and element value.
protected _generateHash ( ) : void
return void

getHash() public method

If no CSRF token currently exists, generates one.
public getHash ( ) : string
return string

getLabel() public method

Override getLabel() to always be empty
public getLabel ( ) : null
return null

getSalt() public method

Retrieve salt for CSRF token
public getSalt ( ) : string
return string

getSession() public method

Instantiate session object if none currently exists
public getSession ( ) : Zend_Session_Namespace
return Zend_Session_Namespace

getSessionName() public method

Generates a session namespace based on salt, element name, and class.
public getSessionName ( ) : string
return string

getTimeout() public method

Get CSRF session token timeout
public getTimeout ( ) : integer
return integer

initCsrfToken() public method

Initialize CSRF token in session
public initCsrfToken ( ) : void
return void

initCsrfValidator() public method

Creates Session namespace, and initializes CSRF token in session. Additionally, adds validator for validating CSRF token.
public initCsrfValidator ( ) : Zend_Form_Element_Hash
return Zend_Form_Element_Hash

render() public method

Render CSRF token in form
public render ( Zend_View_Interface $view = null ) : string
$view Zend_View_Interface
return string

setSalt() public method

Salt for CSRF token
public setSalt ( string $salt ) : Zend_Form_Element_Hash
$salt string
return Zend_Form_Element_Hash

setSession() public method

Set session object
public setSession ( Zend_Session_Namespace $session ) : Zend_Form_Element_Hash
$session Zend_Session_Namespace
return Zend_Form_Element_Hash

setTimeout() public method

Set timeout for CSRF session token
public setTimeout ( integer $ttl ) : Zend_Form_Element_Hash
$ttl integer
return Zend_Form_Element_Hash

Property Details

$_hash protected_oe property

Actual hash used.
protected mixed $_hash
return mixed

$_salt protected_oe property

Salt for CSRF token
protected string $_salt
return string

$_session protected_oe property

protected Zend_Session_Namespace $_session
return Zend_Session_Namespace

$_timeout protected_oe property

TTL for CSRF token
protected int $_timeout
return integer

$helper public_oe property

Use formHidden view helper by default
public string $helper
return string