PHP 클래스 Horde_Token_Base, horde

Copyright 2010-2016 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.
저자: Max Kalika ([email protected])
저자: Chuck Hagenbuch ([email protected])
파일 보기 프로젝트 열기: horde/horde 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$_params array Hash of parameters necessary to use the chosen backend.

공개 메소드들

메소드 설명
__construct ( array $params ) Constructor.
add ( string $tokenID ) Add a token ID.
exists ( string $tokenID ) : boolean Does the token exist?
get ( string $seed = '' ) : string Return a new signed token.
getNonce ( ) : string Return a "number used once" (a concatenation of a timestamp and a random numer).
isValid ( string $token, string $seed = '', integer $timeout = null, boolean $unique = false ) : boolean Validate a signed token.
purge ( ) Delete all expired connection IDs.
validate ( string $token, string $seed = '', integer $timeout = null ) : array Is the given token still valid? Throws an exception in case it is not.
validateUnique ( string $token, string $seed = '' ) : null Is the given token valid and has never been used before? Throws an exception otherwise.
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.

보호된 메소드들

메소드 설명
_encodeRemoteAddress ( ) : string Encodes the remote address.

비공개 메소드들

메소드 설명
_decode ( string $token ) : array Decode a token into the prefixed nonce and the hash.
_hash ( string $text ) : string Sign the given text with the secret.
_isExpired ( string $nonce, integer $timeout ) : boolean Has the nonce expired?

메소드 상세

__construct() 공개 메소드

Constructor.
public __construct ( array $params )
$params array 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)

_encodeRemoteAddress() 보호된 메소드

Encodes the remote address.
protected _encodeRemoteAddress ( ) : string
리턴 string Encoded address.

add() 추상적인 공개 메소드

Add a token ID.
abstract public add ( string $tokenID )
$tokenID string Token ID to add.

exists() 추상적인 공개 메소드

Does the token exist?
abstract public exists ( string $tokenID ) : boolean
$tokenID string Token ID.
리턴 boolean True if the token exists.

get() 공개 메소드

Return a new signed token.
public get ( string $seed = '' ) : string
$seed string A unique ID to be included in the token.
리턴 string The new token.

getNonce() 공개 메소드

Return a "number used once" (a concatenation of a timestamp and a random numer).
public getNonce ( ) : string
리턴 string A string of 6 bytes.

isValid() 공개 메소드

Validate a signed token.
public isValid ( string $token, string $seed = '', integer $timeout = null, boolean $unique = false ) : boolean
$token string The signed token.
$seed string The unique ID of the token.
$timeout integer Timout of the token in seconds. Values below zero represent no timeout.
$unique boolean Should validation of the token succeed only once?
리턴 boolean True if the token was valid.

purge() 추상적인 공개 메소드

Delete all expired connection IDs.
abstract public purge ( )

validate() 공개 메소드

Is the given token still valid? Throws an exception in case it is not.
public validate ( string $token, string $seed = '', integer $timeout = null ) : array
$token string The signed token.
$seed string The unique ID of the token.
$timeout integer Timout of the token in seconds. Values below zero represent no timeout.
리턴 array An array of two elements: The nonce and the hash.

validateUnique() 공개 메소드

Is the given token valid and has never been used before? Throws an exception otherwise.
public validateUnique ( string $token, string $seed = '' ) : null
$token string The signed token.
$seed string The unique ID of the token.
리턴 null

verify() 공개 메소드

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.
public verify ( string $token ) : boolean
$token string The value of the token to check.
리턴 boolean True if the token has not been used, false otherwise.

프로퍼티 상세

$_params 보호되어 있는 프로퍼티

Hash of parameters necessary to use the chosen backend.
protected array $_params
리턴 array