ZenMagick 0.9.10


zenmagick.store.shared.services\ZMTokens
services\ZMTokens.php at line 30

Class ZMTokens

ZMObject
└─ZMTokens

public class ZMTokens
extends ZMObject

Token service.

Author:
DerManoMann

Fields inherited from org.zenmagick.core\ZMObject
properties_
Method Summary
void

__construct()

Create new instance.

void

clear(boolean all)

Clear all expired token.

protected string

createToken(int length)

Generate a random token.

static ZMToken

getNewToken(string resource, int lifetime)

Get a new token for the given resource.

ZMToken

getTokenForHash(string hash)

Get a token for the given hash.

array

getTokenForResource(string resource)

Get all token for a given resource.

static void

instance()

Get instance.

void

updateToken(ZMToken token, int lifetime)

Update a given token.

ZMToken

validateHash(string resource, string hash, boolean expire)

Check if hash is valid in context of the resource.

Methods inherited from org.zenmagick.core\ZMObject
__construct, attachMethod, get, getAttachedMethods, getProperties, getPropertyNames, set, singleton

Method Detail

services\ZMTokens.php at line 35

__construct

public void __construct()

Create new instance.


services\ZMTokens.php at line 154

clear

public void clear(boolean all)

Clear all expired token.

Parameters:
all - Optional flag to clear all token; default is false.

services\ZMTokens.php at line 60

createToken

protected string createToken(int length)

Generate a random token.

Parameters:
length - Optional length; default is 32.
Returns:
The token.

services\ZMTokens.php at line 79

getNewToken

public static ZMToken getNewToken(string resource, int lifetime)

Get a new token for the given resource.

Parameters:
resource - The resource.
lifetime - The lifetime of the new token (in seconds).
Returns:
A token.

services\ZMTokens.php at line 139

getTokenForHash

public ZMToken getTokenForHash(string hash)

Get a token for the given hash.

Parameters:
hash - The hash.
Returns:
A ZMToken or null.

services\ZMTokens.php at line 127

getTokenForResource

public array getTokenForResource(string resource)

Get all token for a given resource.

Parameters:
resource - The resource.
Returns:
A list of ZMToken.

services\ZMTokens.php at line 49

instance

public static void instance()

Get instance.


services\ZMTokens.php at line 95

updateToken

public void updateToken(ZMToken token, int lifetime)

Update a given token.

Parameters:
token - The token.
lifetime - The lifetime of the token (in seconds).

services\ZMTokens.php at line 109

validateHash

public ZMToken validateHash(string resource, string hash, boolean expire)

Check if hash is valid in context of the resource.

Parameters:
resource - The resource.
hash - The hash code.
expire - Optional flag to invalidate a matching token; default is true.
Returns:
A valid token or null.

ZenMagick 0.9.10