PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 5.7.2
Defender Security – Malware Scanner, Login Security & Firewall v5.7.2
6.3.0 6.2.3 6.2.4 6.2.0 6.2.1 6.2.2 6.1.0 5.3.1 5.4.0 5.4.1 5.5.0 5.5.1 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1 5.9.0 6.0.0 6.0.1 3.0.1 3.1.0 All 141 releases
defender-security / lib / packages / Laravel / SerializableClosure / Serializers / Signed.php

Signed.php in Defender Security – Malware Scanner, Login Security & Firewall 5.7.2, at lib/packages/Laravel/SerializableClosure/Serializers/Signed.php

92 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace WPMU_DEV\Defender\Vendor\Laravel\SerializableClosure\Serializers;
4
5 use WPMU_DEV\Defender\Vendor\Laravel\SerializableClosure\Contracts\Serializable;
6 use WPMU_DEV\Defender\Vendor\Laravel\SerializableClosure\Exceptions\InvalidSignatureException;
7 use WPMU_DEV\Defender\Vendor\Laravel\SerializableClosure\Exceptions\MissingSecretKeyException;
8
9 class Signed implements Serializable
10 {
11 /**
12 * The signer that will sign and verify the closure's signature.
13 *
14 * @var \WPMU_DEV\Defender\Vendor\Laravel\SerializableClosure\Contracts\Signer|null
15 */
16 public static $signer;
17
18 /**
19 * The closure to be serialized/unserialized.
20 *
21 * @var \Closure
22 */
23 protected $closure;
24
25 /**
26 * Creates a new serializable closure instance.
27 *
28 * @param \Closure $closure
29 * @return void
30 */
31 public function __construct($closure)
32 {
33 $this->closure = $closure;
34 }
35
36 /**
37 * Resolve the closure with the given arguments.
38 *
39 * @return mixed
40 */
41 public function __invoke()
42 {
43 return call_user_func_array($this->closure, func_get_args());
44 }
45
46 /**
47 * Gets the closure.
48 *
49 * @return \Closure
50 */
51 public function getClosure()
52 {
53 return $this->closure;
54 }
55
56 /**
57 * Get the serializable representation of the closure.
58 *
59 * @return array
60 */
61 public function __serialize()
62 {
63 if (! static::$signer) {
64 throw new MissingSecretKeyException();
65 }
66
67 return static::$signer->sign(
68 serialize(new Native($this->closure))
69 );
70 }
71
72 /**
73 * Restore the closure after serialization.
74 *
75 * @param array $signature
76 * @return void
77 *
78 * @throws \WPMU_DEV\Defender\Vendor\Laravel\SerializableClosure\Exceptions\InvalidSignatureException
79 */
80 public function __unserialize($signature)
81 {
82 if (static::$signer && ! static::$signer->verify($signature)) {
83 throw new InvalidSignatureException();
84 }
85
86 /** @var \WPMU_DEV\Defender\Vendor\Laravel\SerializableClosure\Contracts\Serializable $serializable */
87 $serializable = unserialize($signature['serializable']);
88
89 $this->closure = $serializable->getClosure();
90 }
91 }
92