Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
parametersigner.php
1<?php
2
4
9
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}
static signParameters($componentName, $parameters)
static unsignParameters($componentName, $signedParameters)
static refineComponentName($componentName)
sign($value, $salt=null)
Definition signer.php:111
unsign($signedValue, $salt=null)
Definition signer.php:153