Открытые члены | |
__construct (SigningAlgorithm $algorithm=null) | |
setKey ($value) | |
getSeparator () | |
setSeparator ($value) | |
sign ($value, $time, $salt=null) | |
unsign ($signedValue, $salt=null) | |
getSignature ($value, $timestamp, $salt=null) | |
validate ($value, $timestamp, $signature, $salt=null) | |
pack (array $values) | |
unpack ($value, $limit=2) | |
Защищенные члены | |
getTimeStamp ($time) | |
Защищенные данные | |
$signer = null | |
См. определение в файле timesigner.php строка 12
__construct | ( | SigningAlgorithm | $algorithm = null | ) |
Creates new TimeSigner object. If you want use your own signing algorithm - you can this
SigningAlgorithm | $algorithm | Custom signing algorithm. |
См. определение в файле timesigner.php строка 22
getSeparator | ( | ) |
Return separator, used for packing/unpacking
См. определение в файле timesigner.php строка 45
getSignature | ( | $value, | |
$timestamp, | |||
$salt = null ) |
Return message signature
string | $value | Message. |
int | $timestamp | Expire timestamp. |
null | $salt | Salt (if needed). |
ArgumentTypeException |
См. определение в файле timesigner.php строка 155
|
protected |
Return timestamp parsed from English textual datetime description
string | int | $time | Timestamp or datetime description (presented in format accepted by strtotime). |
Bitrix\Main\ArgumentTypeException
Bitrix\Main\ArgumentException
См. определение в файле timesigner.php строка 195
pack | ( | array | $values | ) |
Pack array values to single string: pack(['test', 'all', 'values']) -> 'test.all.values'
array | $values | Values for packing. |
См. определение в файле timesigner.php строка 224
setKey | ( | $value | ) |
Set key for signing
string | $value | Key. |
Bitrix\Main\ArgumentTypeException
См. определение в файле timesigner.php строка 34
setSeparator | ( | $value | ) |
Set separator, used for packing/unpacking
string | $value | Separator. |
Bitrix\Main\ArgumentTypeException
См. определение в файле timesigner.php строка 57
sign | ( | $value, | |
$time, | |||
$salt = null ) |
Sign message with expired time, return string in format: {message}{separator}{expired timestamp}{separator}{signature}
Simple example: // If salt needed $foo = (new TimeSigner)->sign('test', '+1 hour', 'my_salt');
// Otherwise $bar = (new TimeSigner)->sign('test', '+1 day');
string | $value | Message for signing. |
string | $time | Timestamp or datetime description (presented in format accepted by strtotime). |
string | null | $salt | Salt, if needed. |
См. определение в файле timesigner.php строка 81
unpack | ( | $value, | |
$limit = 2 ) |
Unpack values from string (something like rsplit). Simple example for separator ".": // Unpack all values: unpack('test.all.values', 0) -> ['test', 'all', 'values']
// Unpack 2 values (by default). First element containing the rest of string. unpack('test.all.values') -> ['test.all', 'values']
// Exception if separator is missing unpack('test.all values', 3) -> throws BadSignatureException
string | $value | String for unpacking. |
int | $limit | If $limit === 0 - unpack all values, default - 2. |
BadSignatureException |
См. определение в файле timesigner.php строка 248
unsign | ( | $signedValue, | |
$salt = null ) |
Check message signature and it lifetime. If everything is OK - return original message.
Simple example: $signer = new TimeSigner;
// Sing message for 1 second $signedValue = $signer->sign('test', '+1 second');
// Or sign with expiring on some magic timestamp (e.g. 01.01.2030) $signedValue = $signer->sign('test', 1893445200);
// Get original message with checking echo $signer->unsign($signedValue); // Output: 'test'
// Try to unsigning not signed value echo $signer->unsign('test'); //throw BadSignatureException with message 'Separator not found in value'
// Or with invalid sign echo $signer->unsign('test.invalid_sign');
// Or invalid salt echo $signer->unsign($signedValue, 'invalid_salt'); //throw BadSignatureException with message 'Signature does not match'
// Or expired lifetime echo $signer->unsign($signedValue); //throw BadSignatureException with message 'Signature timestamp expired (1403039921 < 1403040024)'
string | $signedValue | Signed value, must be in format: {message}{separator}{expired timestamp}{separator}{signature}. |
string | null | $salt | Salt, if used while signing. |
BadSignatureException |
См. определение в файле timesigner.php строка 127
validate | ( | $value, | |
$timestamp, | |||
$signature, | |||
$salt = null ) |
Simply validation of message signature
string | $value | Message. |
int | $timestamp | Expire timestamp. |
string | $signature | Signature. |
string | null | $salt | Salt, if used while signing. |
См. определение в файле timesigner.php строка 173
|
protected |
См. определение в файле timesigner.php строка 15