Overview

Packages

  • Token

Classes

  • Horde_Token
  • Horde_Token_Base
  • Horde_Token_Exception
  • Horde_Token_Exception_Expired
  • Horde_Token_Exception_Invalid
  • Horde_Token_Exception_Used
  • Horde_Token_File
  • Horde_Token_Null
  • Horde_Token_Sql
  • Horde_Token_Translation
  • Overview
  • Package
  • Class
  • Tree

Class Horde_Token_Base

The Horde_Token_Base:: class provides a common abstracted interface for a token implementation.

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

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

Direct known subclasses

Horde_Token_File, Horde_Token_Null, Horde_Token_Sql
Abstract
Package: Token
Category: Horde
Author: Max Kalika max@horde.org
Author: Chuck Hagenbuch chuck@horde.org
Located at Horde/Token/Base.php
Methods summary
public
# __construct( array $params )

Constructor.

Constructor.

Parameters

$params
<p>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)</p>
public boolean
# verify( string $token )

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.

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

$token
The value of the token to check.

Returns

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

Throws

Horde_Token_Exception
abstract public boolean
# exists( string $tokenID )

Does the token exist?

Does the token exist?

Parameters

$tokenID
Token ID.

Returns

boolean
True if the token exists.

Throws

Horde_Token_Exception
abstract public
# add( string $tokenID )

Add a token ID.

Add a token ID.

Parameters

$tokenID
Token ID to add.

Throws

Horde_Token_Exception
abstract public
# purge( )

Delete all expired connection IDs.

Delete all expired connection IDs.

Throws

Horde_Token_Exception
public string
# get( string $seed = '' )

Return a new signed token.

Return a new signed token.

Parameters

$seed
A unique ID to be included in the token.

Returns

string
The new token.
public boolean
# isValid( string $token, string $seed = '', integer $timeout = null, boolean $unique = false )

Validate a signed token.

Validate a signed token.

Parameters

$token
The signed token.
$seed
The unique ID of the token.
$timeout
<p>Timout of the token in seconds. Values below zero represent no timeout.</p>
$unique
Should validation of the token succeed only once?

Returns

boolean
True if the token was valid.
public array
# validate( string $token, string $seed = '', integer $timeout = null )

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

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

Parameters

$token
The signed token.
$seed
The unique ID of the token.
$timeout
<p>Timout of the token in seconds. Values below zero represent no timeout.</p>

Returns

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

Throws

Horde_Token_Exception
If the token was invalid.
public null
# validateUnique( string $token, string $seed = '' )

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

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

Parameters

$token
The signed token.
$seed
The unique ID of the token.

Returns

null

Throws

Horde_Token_Exception

If the token was invalid or has been used before.

public string
# getNonce( )

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

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

Returns

string
A string of 6 bytes.
API documentation generated by ApiGen