\Horde_Token_Null

The Horde_Token_Null:: class provides a null implementation of the token driver.

Copyright 2010-2017 Horde LLC (http://www.horde.org/)

See the enclosed file LICENSE for license information (LGPL). If you did not receive this file, see http://www.horde.org/licenses/lgpl21.

Summary

Methods
Properties
Constants
__construct()
verify()
exists()
add()
purge()
get()
isValid()
validate()
validateUnique()
getNonce()
No public properties found
No constants found
_encodeRemoteAddress()
$_params
N/A
_decode()
_isExpired()
_hash()
No private properties found
N/A

Properties

$_params

$_params : array

Hash of parameters necessary to use the chosen backend.

Type

array

Methods

__construct()

__construct(array  $params) 

Constructor.

Parameters

array $params

Required parameters:

  • secret (string): The secret string used for signing tokens. Optional parameters:
  • token_lifetime (integer): The number of seconds after which tokens time out. Negative numbers represent "no timeout". The default is "-1".
  • timeout (integer): The period (in seconds) after which an id is purged. DEFAULT: 86400 (24 hours)

verify()

verify(string  $token) : boolean

Checks if the given token has been previously used. First purges all expired tokens. Then retrieves current tokens for the given ip address. If the specified token was not found, adds it.

Parameters

string $token

The value of the token to check.

Throws

\Horde_Token_Exception

Returns

boolean —

True if the token has not been used, false otherwise.

exists()

exists(string  $tokenID) : boolean

Does the token exist?

Parameters

string $tokenID

Token ID.

Returns

boolean —

True if the token exists.

add()

add(string  $tokenID) 

Add a token ID.

Parameters

string $tokenID

Token ID to add.

purge()

purge() 

Delete all expired connection IDs.

get()

get(string  $seed = '') : string

Return a new signed token.

Parameters

string $seed

A unique ID to be included in the token.

Returns

string —

The new token.

isValid()

isValid(string  $token, string  $seed = '', integer  $timeout = null, boolean  $unique = false) : boolean

Validate a signed token.

Parameters

string $token

The signed token.

string $seed

The unique ID of the token.

integer $timeout

Timout of the token in seconds. Values below zero represent no timeout.

boolean $unique

Should validation of the token succeed only once?

Returns

boolean —

True if the token was valid.

validate()

validate(string  $token, string  $seed = '', integer  $timeout = null) : array

Is the given token still valid? Throws an exception in case it is not.

Parameters

string $token

The signed token.

string $seed

The unique ID of the token.

integer $timeout

Timout of the token in seconds. Values below zero represent no timeout.

Throws

\Horde_Token_Exception

If the token was invalid.

Returns

array —

An array of two elements: The nonce and the hash.

validateUnique()

validateUnique(string  $token, string  $seed = '') : NULL

Is the given token valid and has never been used before? Throws an exception otherwise.

Parameters

string $token

The signed token.

string $seed

The unique ID of the token.

Throws

\Horde_Token_Exception

If the token was invalid or has been used before.

Returns

NULL

getNonce()

getNonce() : string

Return a "number used once" (a concatenation of a timestamp and a random numer).

Returns

string —

A string of 6 bytes.

_encodeRemoteAddress()

_encodeRemoteAddress() : string

Encodes the remote address.

Returns

string —

Encoded address.

_decode()

_decode(string  $token) : array

Decode a token into the prefixed nonce and the hash.

Parameters

string $token

The token to be decomposed.

Returns

array —

An array of two elements: The nonce and the hash.

_isExpired()

_isExpired(string  $nonce, integer  $timeout) : boolean

Has the nonce expired?

Parameters

string $nonce

The to be checked for expiration.

integer $timeout

The timeout that should be applied.

Returns

boolean —

True if the nonce expired.

_hash()

_hash(string  $text) : string

Sign the given text with the secret.

Parameters

string $text

The text to be signed.

Returns

string —

The hashed text.