Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
parametersigner.php
1
<?php
2
3
namespace
Bitrix\Main\Component
;
4
5
use
Bitrix\Main\Security
;
6
use
Bitrix\Main\Type\Date
;
7
use
Bitrix\Main\Type\DateTime
;
8
use
Bitrix\Main\Web\Uri
;
9
10
class
ParameterSigner
11
{
19
public
static
function
signParameters
($componentName, $parameters)
20
{
21
$signer =
new
Security\Sign\Signer
;
22
23
return
$signer->
sign
(
24
base64_encode(serialize($parameters)),
25
self::refineComponentName($componentName)
26
);
27
}
28
37
public
static
function
unsignParameters
($componentName, $signedParameters)
38
{
39
$signer =
new
Security\Sign\Signer
;
40
41
$unsignedParameters = $signer->
unsign
(
42
$signedParameters,
43
self::refineComponentName($componentName)
44
);
45
46
$decoded = base64_decode($unsignedParameters);
47
if
($decoded ===
false
)
48
{
49
return
[];
50
}
51
52
return
static::unserialize($decoded);
53
}
54
55
private
static
function
unserialize(
string
$str)
56
{
57
return
unserialize($str, [
'allowed_classes'
=> [
58
DateTime::class,
59
Date::class,
60
Uri::class,
61
\DateTime::class,
62
\DateTimeZone::class,
63
]]);
64
}
65
66
protected
static
function
refineComponentName
($componentName)
67
{
68
if
(!is_string($componentName))
69
{
70
return
null
;
71
}
72
73
return
str_replace(
':'
,
''
, $componentName);
74
}
75
}
Bitrix\Main\Component\ParameterSigner
Definition
parametersigner.php:11
Bitrix\Main\Component\ParameterSigner\signParameters
static signParameters($componentName, $parameters)
Definition
parametersigner.php:19
Bitrix\Main\Component\ParameterSigner\unsignParameters
static unsignParameters($componentName, $signedParameters)
Definition
parametersigner.php:37
Bitrix\Main\Component\ParameterSigner\refineComponentName
static refineComponentName($componentName)
Definition
parametersigner.php:66
Bitrix\Main\Security\Sign\Signer
Definition
signer.php:13
Bitrix\Main\Security\Sign\Signer\sign
sign($value, $salt=null)
Definition
signer.php:111
Bitrix\Main\Security\Sign\Signer\unsign
unsign($signedValue, $salt=null)
Definition
signer.php:153
Bitrix\Main\Type\Date
Definition
date.php:9
Bitrix\Main\Type\DateTime
Definition
datetime.php:9
Bitrix\Main\Web\Uri
Definition
uri.php:17
Bitrix\Main\Component
Definition
baseufcomponent.php:3
Bitrix\Main\Security
Definition
asymmetriccipher.php:8
modules
main
lib
component
parametersigner.php
Создано системой
1.10.0