GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 7b80be...59f4b4 )
by Joni
04:49
created
lib/JWX/Util/BigInt.php 2 patches
Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -9,86 +9,86 @@
 block discarded – undo
9 9
  */
10 10
 class BigInt
11 11
 {
12
-    /**
13
-     * Number.
14
-     *
15
-     * @var resource|\GMP $_num
16
-     */
17
-    protected $_num;
12
+	/**
13
+	 * Number.
14
+	 *
15
+	 * @var resource|\GMP $_num
16
+	 */
17
+	protected $_num;
18 18
     
19
-    /**
20
-     * Constructor.
21
-     *
22
-     * @param resource|\GMP $num GMP number
23
-     */
24
-    protected function __construct($num)
25
-    {
26
-        $this->_num = $num;
27
-    }
19
+	/**
20
+	 * Constructor.
21
+	 *
22
+	 * @param resource|\GMP $num GMP number
23
+	 */
24
+	protected function __construct($num)
25
+	{
26
+		$this->_num = $num;
27
+	}
28 28
     
29
-    /**
30
-     * Initialize from a base10 number.
31
-     *
32
-     * @param string|int $number
33
-     * @return self
34
-     */
35
-    public static function fromBase10($number): self
36
-    {
37
-        $num = gmp_init($number, 10);
38
-        return new self($num);
39
-    }
29
+	/**
30
+	 * Initialize from a base10 number.
31
+	 *
32
+	 * @param string|int $number
33
+	 * @return self
34
+	 */
35
+	public static function fromBase10($number): self
36
+	{
37
+		$num = gmp_init($number, 10);
38
+		return new self($num);
39
+	}
40 40
     
41
-    /**
42
-     * Initialize from a base256 number.
43
-     *
44
-     * Base64 number is an octet string of big endian, most significant word
45
-     * first integer.
46
-     *
47
-     * @param string $octets
48
-     * @return self
49
-     */
50
-    public static function fromBase256(string $octets): self
51
-    {
52
-        $num = gmp_import($octets, 1, GMP_MSW_FIRST | GMP_BIG_ENDIAN);
53
-        return new self($num);
54
-    }
41
+	/**
42
+	 * Initialize from a base256 number.
43
+	 *
44
+	 * Base64 number is an octet string of big endian, most significant word
45
+	 * first integer.
46
+	 *
47
+	 * @param string $octets
48
+	 * @return self
49
+	 */
50
+	public static function fromBase256(string $octets): self
51
+	{
52
+		$num = gmp_import($octets, 1, GMP_MSW_FIRST | GMP_BIG_ENDIAN);
53
+		return new self($num);
54
+	}
55 55
     
56
-    /**
57
-     * Convert to base10 string.
58
-     *
59
-     * @return string
60
-     */
61
-    public function base10(): string
62
-    {
63
-        return gmp_strval($this->_num, 10);
64
-    }
56
+	/**
57
+	 * Convert to base10 string.
58
+	 *
59
+	 * @return string
60
+	 */
61
+	public function base10(): string
62
+	{
63
+		return gmp_strval($this->_num, 10);
64
+	}
65 65
     
66
-    /**
67
-     * Convert to base16 string.
68
-     *
69
-     * @return string
70
-     */
71
-    public function base16(): string
72
-    {
73
-        return gmp_strval($this->_num, 16);
74
-    }
66
+	/**
67
+	 * Convert to base16 string.
68
+	 *
69
+	 * @return string
70
+	 */
71
+	public function base16(): string
72
+	{
73
+		return gmp_strval($this->_num, 16);
74
+	}
75 75
     
76
-    /**
77
-     * Convert to base256 string.
78
-     *
79
-     * @return string
80
-     */
81
-    public function base256(): string
82
-    {
83
-        return gmp_export($this->_num, 1, GMP_MSW_FIRST | GMP_BIG_ENDIAN);
84
-    }
76
+	/**
77
+	 * Convert to base256 string.
78
+	 *
79
+	 * @return string
80
+	 */
81
+	public function base256(): string
82
+	{
83
+		return gmp_export($this->_num, 1, GMP_MSW_FIRST | GMP_BIG_ENDIAN);
84
+	}
85 85
     
86
-    /**
87
-     *
88
-     * @return string
89
-     */
90
-    public function __toString()
91
-    {
92
-        return $this->base10();
93
-    }
86
+	/**
87
+	 *
88
+	 * @return string
89
+	 */
90
+	public function __toString()
91
+	{
92
+		return $this->base10();
93
+	}
94 94
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
      */
50 50
     public static function fromBase256(string $octets): self
51 51
     {
52
-        $num = gmp_import($octets, 1, GMP_MSW_FIRST | GMP_BIG_ENDIAN);
52
+        $num = gmp_import($octets, 1, GMP_MSW_FIRST|GMP_BIG_ENDIAN);
53 53
         return new self($num);
54 54
     }
55 55
     
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
      */
81 81
     public function base256(): string
82 82
     {
83
-        return gmp_export($this->_num, 1, GMP_MSW_FIRST | GMP_BIG_ENDIAN);
83
+        return gmp_export($this->_num, 1, GMP_MSW_FIRST|GMP_BIG_ENDIAN);
84 84
     }
85 85
     
86 86
     /**
Please login to merge, or discard this patch.
lib/JWX/JWK/Asymmetric/PrivateKeyJWK.php 1 patch
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -18,46 +18,46 @@
 block discarded – undo
18 18
  */
19 19
 abstract class PrivateKeyJWK extends JWK
20 20
 {
21
-    /**
22
-     * Get the public key component of the asymmetric key pair.
23
-     *
24
-     * @return PublicKeyJWK
25
-     */
26
-    abstract public function publicKey(): PublicKeyJWK;
21
+	/**
22
+	 * Get the public key component of the asymmetric key pair.
23
+	 *
24
+	 * @return PublicKeyJWK
25
+	 */
26
+	abstract public function publicKey(): PublicKeyJWK;
27 27
     
28
-    /**
29
-     * Convert private key to PEM.
30
-     *
31
-     * @return PEM
32
-     */
33
-    abstract public function toPEM(): PEM;
28
+	/**
29
+	 * Convert private key to PEM.
30
+	 *
31
+	 * @return PEM
32
+	 */
33
+	abstract public function toPEM(): PEM;
34 34
     
35
-    /**
36
-     * Initialize from a PrivateKey object.
37
-     *
38
-     * @param PrivateKey $priv_key Private key
39
-     * @throws \UnexpectedValueException
40
-     * @return self
41
-     */
42
-    public static function fromPrivateKey(PrivateKey $priv_key): PrivateKeyJWK
43
-    {
44
-        if ($priv_key instanceof RSAPrivateKey) {
45
-            return RSAPrivateKeyJWK::fromRSAPrivateKey($priv_key);
46
-        }
47
-        if ($priv_key instanceof ECPrivateKey) {
48
-            return ECPrivateKeyJWK::fromECPrivateKey($priv_key);
49
-        }
50
-        throw new \UnexpectedValueException("Unsupported private key.");
51
-    }
35
+	/**
36
+	 * Initialize from a PrivateKey object.
37
+	 *
38
+	 * @param PrivateKey $priv_key Private key
39
+	 * @throws \UnexpectedValueException
40
+	 * @return self
41
+	 */
42
+	public static function fromPrivateKey(PrivateKey $priv_key): PrivateKeyJWK
43
+	{
44
+		if ($priv_key instanceof RSAPrivateKey) {
45
+			return RSAPrivateKeyJWK::fromRSAPrivateKey($priv_key);
46
+		}
47
+		if ($priv_key instanceof ECPrivateKey) {
48
+			return ECPrivateKeyJWK::fromECPrivateKey($priv_key);
49
+		}
50
+		throw new \UnexpectedValueException("Unsupported private key.");
51
+	}
52 52
     
53
-    /**
54
-     * Initialize from a PrivateKeyInfo object.
55
-     *
56
-     * @param PrivateKeyInfo $pki PrivateKeyInfo
57
-     * @return self
58
-     */
59
-    public static function fromPrivateKeyInfo(PrivateKeyInfo $pki): PrivateKeyJWK
60
-    {
61
-        return self::fromPrivateKey($pki->privateKey());
62
-    }
53
+	/**
54
+	 * Initialize from a PrivateKeyInfo object.
55
+	 *
56
+	 * @param PrivateKeyInfo $pki PrivateKeyInfo
57
+	 * @return self
58
+	 */
59
+	public static function fromPrivateKeyInfo(PrivateKeyInfo $pki): PrivateKeyJWK
60
+	{
61
+		return self::fromPrivateKey($pki->privateKey());
62
+	}
63 63
 }
Please login to merge, or discard this patch.
lib/JWX/JWK/Asymmetric/PublicKeyJWK.php 1 patch
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -18,39 +18,39 @@
 block discarded – undo
18 18
  */
19 19
 abstract class PublicKeyJWK extends JWK
20 20
 {
21
-    /**
22
-     * Convert public key to PEM.
23
-     *
24
-     * @return PEM
25
-     */
26
-    abstract public function toPEM(): PEM;
21
+	/**
22
+	 * Convert public key to PEM.
23
+	 *
24
+	 * @return PEM
25
+	 */
26
+	abstract public function toPEM(): PEM;
27 27
     
28
-    /**
29
-     * Initialize from a PublicKey object.
30
-     *
31
-     * @param PublicKey $pub_key Public key
32
-     * @throws \UnexpectedValueException
33
-     * @return self
34
-     */
35
-    public static function fromPublicKey(PublicKey $pub_key): PublicKeyJWK
36
-    {
37
-        if ($pub_key instanceof RSAPublicKey) {
38
-            return RSAPublicKeyJWK::fromRSAPublicKey($pub_key);
39
-        }
40
-        if ($pub_key instanceof ECPublicKey) {
41
-            return ECPublicKeyJWK::fromECPublicKey($pub_key);
42
-        }
43
-        throw new \UnexpectedValueException("Unsupported public key.");
44
-    }
28
+	/**
29
+	 * Initialize from a PublicKey object.
30
+	 *
31
+	 * @param PublicKey $pub_key Public key
32
+	 * @throws \UnexpectedValueException
33
+	 * @return self
34
+	 */
35
+	public static function fromPublicKey(PublicKey $pub_key): PublicKeyJWK
36
+	{
37
+		if ($pub_key instanceof RSAPublicKey) {
38
+			return RSAPublicKeyJWK::fromRSAPublicKey($pub_key);
39
+		}
40
+		if ($pub_key instanceof ECPublicKey) {
41
+			return ECPublicKeyJWK::fromECPublicKey($pub_key);
42
+		}
43
+		throw new \UnexpectedValueException("Unsupported public key.");
44
+	}
45 45
     
46
-    /**
47
-     * Initialize from a PublicKeyInfo object.
48
-     *
49
-     * @param PublicKeyInfo $pki Public key info
50
-     * @return self
51
-     */
52
-    public static function fromPublicKeyInfo(PublicKeyInfo $pki): PublicKeyJWK
53
-    {
54
-        return self::fromPublicKey($pki->publicKey());
55
-    }
46
+	/**
47
+	 * Initialize from a PublicKeyInfo object.
48
+	 *
49
+	 * @param PublicKeyInfo $pki Public key info
50
+	 * @return self
51
+	 */
52
+	public static function fromPublicKeyInfo(PublicKeyInfo $pki): PublicKeyJWK
53
+	{
54
+		return self::fromPublicKey($pki->publicKey());
55
+	}
56 56
 }
Please login to merge, or discard this patch.
lib/JWX/JWK/JWK.php 1 patch
Indentation   +169 added lines, -169 removed lines patch added patch discarded remove patch
@@ -14,187 +14,187 @@
 block discarded – undo
14 14
  */
15 15
 class JWK implements \Countable, \IteratorAggregate
16 16
 {
17
-    use TypedJWK;
17
+	use TypedJWK;
18 18
     
19
-    /**
20
-     * Parameters.
21
-     *
22
-     * @var JWKParameter[] $_parameters
23
-     */
24
-    protected $_parameters;
19
+	/**
20
+	 * Parameters.
21
+	 *
22
+	 * @var JWKParameter[] $_parameters
23
+	 */
24
+	protected $_parameters;
25 25
     
26
-    /**
27
-     * Constructor.
28
-     *
29
-     * @param JWKParameter ...$params
30
-     */
31
-    public function __construct(JWKParameter ...$params)
32
-    {
33
-        $this->_parameters = array();
34
-        foreach ($params as $param) {
35
-            $this->_parameters[$param->name()] = $param;
36
-        }
37
-    }
26
+	/**
27
+	 * Constructor.
28
+	 *
29
+	 * @param JWKParameter ...$params
30
+	 */
31
+	public function __construct(JWKParameter ...$params)
32
+	{
33
+		$this->_parameters = array();
34
+		foreach ($params as $param) {
35
+			$this->_parameters[$param->name()] = $param;
36
+		}
37
+	}
38 38
     
39
-    /**
40
-     * Initialize from an array representing a JSON object.
41
-     *
42
-     * @param array $members
43
-     * @return self
44
-     */
45
-    public static function fromArray(array $members): self
46
-    {
47
-        $params = array();
48
-        foreach ($members as $name => $value) {
49
-            $params[] = JWKParameter::fromNameAndValue($name, $value);
50
-        }
51
-        return new static(...$params);
52
-    }
39
+	/**
40
+	 * Initialize from an array representing a JSON object.
41
+	 *
42
+	 * @param array $members
43
+	 * @return self
44
+	 */
45
+	public static function fromArray(array $members): self
46
+	{
47
+		$params = array();
48
+		foreach ($members as $name => $value) {
49
+			$params[] = JWKParameter::fromNameAndValue($name, $value);
50
+		}
51
+		return new static(...$params);
52
+	}
53 53
     
54
-    /**
55
-     * Initialize from a JSON string.
56
-     *
57
-     * @param string $json
58
-     * @throws \UnexpectedValueException
59
-     * @return self
60
-     */
61
-    public static function fromJSON(string $json): self
62
-    {
63
-        $members = json_decode($json, true, 32, JSON_BIGINT_AS_STRING);
64
-        if (!is_array($members)) {
65
-            throw new \UnexpectedValueException("Invalid JSON.");
66
-        }
67
-        return static::fromArray($members);
68
-    }
54
+	/**
55
+	 * Initialize from a JSON string.
56
+	 *
57
+	 * @param string $json
58
+	 * @throws \UnexpectedValueException
59
+	 * @return self
60
+	 */
61
+	public static function fromJSON(string $json): self
62
+	{
63
+		$members = json_decode($json, true, 32, JSON_BIGINT_AS_STRING);
64
+		if (!is_array($members)) {
65
+			throw new \UnexpectedValueException("Invalid JSON.");
66
+		}
67
+		return static::fromArray($members);
68
+	}
69 69
     
70
-    /**
71
-     * Initialize from another JWK.
72
-     *
73
-     * Allows casting to subclass by late static binding.
74
-     *
75
-     * @param JWK $jwk
76
-     * @return self
77
-     */
78
-    public static function fromJWK(JWK $jwk): self
79
-    {
80
-        return new static(...array_values($jwk->_parameters));
81
-    }
70
+	/**
71
+	 * Initialize from another JWK.
72
+	 *
73
+	 * Allows casting to subclass by late static binding.
74
+	 *
75
+	 * @param JWK $jwk
76
+	 * @return self
77
+	 */
78
+	public static function fromJWK(JWK $jwk): self
79
+	{
80
+		return new static(...array_values($jwk->_parameters));
81
+	}
82 82
     
83
-    /**
84
-     * Get self with parameters added.
85
-     *
86
-     * @param JWKParameter ...$params
87
-     * @return self
88
-     */
89
-    public function withParameters(JWKParameter ...$params): self
90
-    {
91
-        $obj = clone $this;
92
-        foreach ($params as $param) {
93
-            $obj->_parameters[$param->name()] = $param;
94
-        }
95
-        return $obj;
96
-    }
83
+	/**
84
+	 * Get self with parameters added.
85
+	 *
86
+	 * @param JWKParameter ...$params
87
+	 * @return self
88
+	 */
89
+	public function withParameters(JWKParameter ...$params): self
90
+	{
91
+		$obj = clone $this;
92
+		foreach ($params as $param) {
93
+			$obj->_parameters[$param->name()] = $param;
94
+		}
95
+		return $obj;
96
+	}
97 97
     
98
-    /**
99
-     * Get all parameters.
100
-     *
101
-     * @return JWKParameter[]
102
-     */
103
-    public function parameters(): array
104
-    {
105
-        return $this->_parameters;
106
-    }
98
+	/**
99
+	 * Get all parameters.
100
+	 *
101
+	 * @return JWKParameter[]
102
+	 */
103
+	public function parameters(): array
104
+	{
105
+		return $this->_parameters;
106
+	}
107 107
     
108
-    /**
109
-     * Get self with given key ID added to parameters.
110
-     *
111
-     * @param string $id Key ID as a string
112
-     * @return self
113
-     */
114
-    public function withKeyID(string $id): self
115
-    {
116
-        return $this->withParameters(new KeyIDParameter($id));
117
-    }
108
+	/**
109
+	 * Get self with given key ID added to parameters.
110
+	 *
111
+	 * @param string $id Key ID as a string
112
+	 * @return self
113
+	 */
114
+	public function withKeyID(string $id): self
115
+	{
116
+		return $this->withParameters(new KeyIDParameter($id));
117
+	}
118 118
     
119
-    /**
120
-     * Whether parameters are present.
121
-     *
122
-     * Returns false if any of the given parameters is not set.
123
-     *
124
-     * @param string ...$names Parameter names
125
-     * @return bool
126
-     */
127
-    public function has(string ...$names): bool
128
-    {
129
-        foreach ($names as $name) {
130
-            if (!isset($this->_parameters[$name])) {
131
-                return false;
132
-            }
133
-        }
134
-        return true;
135
-    }
119
+	/**
120
+	 * Whether parameters are present.
121
+	 *
122
+	 * Returns false if any of the given parameters is not set.
123
+	 *
124
+	 * @param string ...$names Parameter names
125
+	 * @return bool
126
+	 */
127
+	public function has(string ...$names): bool
128
+	{
129
+		foreach ($names as $name) {
130
+			if (!isset($this->_parameters[$name])) {
131
+				return false;
132
+			}
133
+		}
134
+		return true;
135
+	}
136 136
     
137
-    /**
138
-     * Get a parameter.
139
-     *
140
-     * @param string $name Parameter name
141
-     * @throws \LogicException
142
-     * @return JWKParameter
143
-     */
144
-    public function get(string $name): JWKParameter
145
-    {
146
-        if (!$this->has($name)) {
147
-            throw new \LogicException("Parameter $name doesn't exists.");
148
-        }
149
-        return $this->_parameters[$name];
150
-    }
137
+	/**
138
+	 * Get a parameter.
139
+	 *
140
+	 * @param string $name Parameter name
141
+	 * @throws \LogicException
142
+	 * @return JWKParameter
143
+	 */
144
+	public function get(string $name): JWKParameter
145
+	{
146
+		if (!$this->has($name)) {
147
+			throw new \LogicException("Parameter $name doesn't exists.");
148
+		}
149
+		return $this->_parameters[$name];
150
+	}
151 151
     
152
-    /**
153
-     * Convert to array.
154
-     *
155
-     * @return array Parameter values keyed by parameter names
156
-     */
157
-    public function toArray(): array
158
-    {
159
-        $a = array();
160
-        foreach ($this->_parameters as $param) {
161
-            $a[$param->name()] = $param->value();
162
-        }
163
-        return $a;
164
-    }
152
+	/**
153
+	 * Convert to array.
154
+	 *
155
+	 * @return array Parameter values keyed by parameter names
156
+	 */
157
+	public function toArray(): array
158
+	{
159
+		$a = array();
160
+		foreach ($this->_parameters as $param) {
161
+			$a[$param->name()] = $param->value();
162
+		}
163
+		return $a;
164
+	}
165 165
     
166
-    /**
167
-     * Convert to JSON.
168
-     *
169
-     * @return string
170
-     */
171
-    public function toJSON(): string
172
-    {
173
-        $data = $this->toArray();
174
-        if (empty($data)) {
175
-            return "";
176
-        }
177
-        return json_encode((object) $data, JSON_UNESCAPED_SLASHES);
178
-    }
166
+	/**
167
+	 * Convert to JSON.
168
+	 *
169
+	 * @return string
170
+	 */
171
+	public function toJSON(): string
172
+	{
173
+		$data = $this->toArray();
174
+		if (empty($data)) {
175
+			return "";
176
+		}
177
+		return json_encode((object) $data, JSON_UNESCAPED_SLASHES);
178
+	}
179 179
     
180
-    /**
181
-     * Get the number of parameters.
182
-     *
183
-     * @see \Countable::count()
184
-     */
185
-    public function count(): int
186
-    {
187
-        return count($this->_parameters);
188
-    }
180
+	/**
181
+	 * Get the number of parameters.
182
+	 *
183
+	 * @see \Countable::count()
184
+	 */
185
+	public function count(): int
186
+	{
187
+		return count($this->_parameters);
188
+	}
189 189
     
190
-    /**
191
-     * Get iterator for the parameters.
192
-     *
193
-     * @see \IteratorAggregate::getIterator()
194
-     * @return \ArrayIterator
195
-     */
196
-    public function getIterator(): \ArrayIterator
197
-    {
198
-        return new \ArrayIterator($this->_parameters);
199
-    }
190
+	/**
191
+	 * Get iterator for the parameters.
192
+	 *
193
+	 * @see \IteratorAggregate::getIterator()
194
+	 * @return \ArrayIterator
195
+	 */
196
+	public function getIterator(): \ArrayIterator
197
+	{
198
+		return new \ArrayIterator($this->_parameters);
199
+	}
200 200
 }
Please login to merge, or discard this patch.
lib/JWX/JWK/RSA/RSAPrivateKeyJWK.php 1 patch
Indentation   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -29,126 +29,126 @@
 block discarded – undo
29 29
  */
30 30
 class RSAPrivateKeyJWK extends PrivateKeyJWK
31 31
 {
32
-    /**
33
-     * Parameter names managed by this class.
34
-     *
35
-     * @internal
36
-     *
37
-     * @var string[]
38
-     */
39
-    const MANAGED_PARAMS = array(
40
-        /* @formatter:off */
41
-        JWKParameter::PARAM_KEY_TYPE,
42
-        JWKParameter::PARAM_MODULUS,
43
-        JWKParameter::PARAM_EXPONENT,
44
-        JWKParameter::PARAM_PRIVATE_EXPONENT,
45
-        JWKParameter::PARAM_FIRST_PRIME_FACTOR,
46
-        JWKParameter::PARAM_SECOND_PRIME_FACTOR,
47
-        JWKParameter::PARAM_FIRST_FACTOR_CRT_EXPONENT,
48
-        JWKParameter::PARAM_SECOND_FACTOR_CRT_EXPONENT,
49
-        JWKParameter::PARAM_FIRST_CRT_COEFFICIENT
50
-        /* @formatter:on */
51
-    );
32
+	/**
33
+	 * Parameter names managed by this class.
34
+	 *
35
+	 * @internal
36
+	 *
37
+	 * @var string[]
38
+	 */
39
+	const MANAGED_PARAMS = array(
40
+		/* @formatter:off */
41
+		JWKParameter::PARAM_KEY_TYPE,
42
+		JWKParameter::PARAM_MODULUS,
43
+		JWKParameter::PARAM_EXPONENT,
44
+		JWKParameter::PARAM_PRIVATE_EXPONENT,
45
+		JWKParameter::PARAM_FIRST_PRIME_FACTOR,
46
+		JWKParameter::PARAM_SECOND_PRIME_FACTOR,
47
+		JWKParameter::PARAM_FIRST_FACTOR_CRT_EXPONENT,
48
+		JWKParameter::PARAM_SECOND_FACTOR_CRT_EXPONENT,
49
+		JWKParameter::PARAM_FIRST_CRT_COEFFICIENT
50
+		/* @formatter:on */
51
+	);
52 52
     
53
-    /**
54
-     * Constructor.
55
-     *
56
-     * @param JWKParameter ...$params
57
-     * @throws \UnexpectedValueException If missing required parameter
58
-     */
59
-    public function __construct(JWKParameter ...$params)
60
-    {
61
-        parent::__construct(...$params);
62
-        foreach (self::MANAGED_PARAMS as $name) {
63
-            if (!$this->has($name)) {
64
-                throw new \UnexpectedValueException("Missing '$name' parameter.");
65
-            }
66
-        }
67
-        if ($this->keyTypeParameter()->value() != KeyTypeParameter::TYPE_RSA) {
68
-            throw new \UnexpectedValueException("Invalid key type.");
69
-        }
70
-        // cast private exponent to correct class
71
-        $key = JWKParameter::PARAM_PRIVATE_EXPONENT;
72
-        $this->_parameters[$key] = new PrivateExponentParameter(
73
-            $this->_parameters[$key]->value());
74
-    }
53
+	/**
54
+	 * Constructor.
55
+	 *
56
+	 * @param JWKParameter ...$params
57
+	 * @throws \UnexpectedValueException If missing required parameter
58
+	 */
59
+	public function __construct(JWKParameter ...$params)
60
+	{
61
+		parent::__construct(...$params);
62
+		foreach (self::MANAGED_PARAMS as $name) {
63
+			if (!$this->has($name)) {
64
+				throw new \UnexpectedValueException("Missing '$name' parameter.");
65
+			}
66
+		}
67
+		if ($this->keyTypeParameter()->value() != KeyTypeParameter::TYPE_RSA) {
68
+			throw new \UnexpectedValueException("Invalid key type.");
69
+		}
70
+		// cast private exponent to correct class
71
+		$key = JWKParameter::PARAM_PRIVATE_EXPONENT;
72
+		$this->_parameters[$key] = new PrivateExponentParameter(
73
+			$this->_parameters[$key]->value());
74
+	}
75 75
     
76
-    /**
77
-     * Initialize from RSAPrivateKey.
78
-     *
79
-     * @param RSAPrivateKey $pk
80
-     * @return self
81
-     */
82
-    public static function fromRSAPrivateKey(RSAPrivateKey $pk): self
83
-    {
84
-        $n = ModulusParameter::fromNumber($pk->modulus());
85
-        $e = ExponentParameter::fromNumber($pk->publicExponent());
86
-        $d = PrivateExponentParameter::fromNumber($pk->privateExponent());
87
-        $p = FirstPrimeFactorParameter::fromNumber($pk->prime1());
88
-        $q = SecondPrimeFactorParameter::fromNumber($pk->prime2());
89
-        $dp = FirstFactorCRTExponentParameter::fromNumber($pk->exponent1());
90
-        $dq = SecondFactorCRTExponentParameter::fromNumber($pk->exponent2());
91
-        $qi = FirstCRTCoefficientParameter::fromNumber($pk->coefficient());
92
-        $key_type = new KeyTypeParameter(KeyTypeParameter::TYPE_RSA);
93
-        return new self($key_type, $n, $e, $d, $p, $q, $dp, $dq, $qi);
94
-    }
76
+	/**
77
+	 * Initialize from RSAPrivateKey.
78
+	 *
79
+	 * @param RSAPrivateKey $pk
80
+	 * @return self
81
+	 */
82
+	public static function fromRSAPrivateKey(RSAPrivateKey $pk): self
83
+	{
84
+		$n = ModulusParameter::fromNumber($pk->modulus());
85
+		$e = ExponentParameter::fromNumber($pk->publicExponent());
86
+		$d = PrivateExponentParameter::fromNumber($pk->privateExponent());
87
+		$p = FirstPrimeFactorParameter::fromNumber($pk->prime1());
88
+		$q = SecondPrimeFactorParameter::fromNumber($pk->prime2());
89
+		$dp = FirstFactorCRTExponentParameter::fromNumber($pk->exponent1());
90
+		$dq = SecondFactorCRTExponentParameter::fromNumber($pk->exponent2());
91
+		$qi = FirstCRTCoefficientParameter::fromNumber($pk->coefficient());
92
+		$key_type = new KeyTypeParameter(KeyTypeParameter::TYPE_RSA);
93
+		return new self($key_type, $n, $e, $d, $p, $q, $dp, $dq, $qi);
94
+	}
95 95
     
96
-    /**
97
-     * Initialize from PEM.
98
-     *
99
-     * @param PEM $pem
100
-     * @return self
101
-     */
102
-    public static function fromPEM(PEM $pem): self
103
-    {
104
-        return self::fromRSAPrivateKey(RSAPrivateKey::fromPEM($pem));
105
-    }
96
+	/**
97
+	 * Initialize from PEM.
98
+	 *
99
+	 * @param PEM $pem
100
+	 * @return self
101
+	 */
102
+	public static function fromPEM(PEM $pem): self
103
+	{
104
+		return self::fromRSAPrivateKey(RSAPrivateKey::fromPEM($pem));
105
+	}
106 106
     
107
-    /**
108
-     * Get public key component.
109
-     *
110
-     * @return RSAPublicKeyJWK
111
-     */
112
-    public function publicKey(): PublicKeyJWK
113
-    {
114
-        $kty = $this->keyTypeParameter();
115
-        $n = $this->modulusParameter();
116
-        $e = $this->exponentParameter();
117
-        return new RSAPublicKeyJWK($kty, $n, $e);
118
-    }
107
+	/**
108
+	 * Get public key component.
109
+	 *
110
+	 * @return RSAPublicKeyJWK
111
+	 */
112
+	public function publicKey(): PublicKeyJWK
113
+	{
114
+		$kty = $this->keyTypeParameter();
115
+		$n = $this->modulusParameter();
116
+		$e = $this->exponentParameter();
117
+		return new RSAPublicKeyJWK($kty, $n, $e);
118
+	}
119 119
     
120
-    /**
121
-     * Convert JWK to PEM.
122
-     *
123
-     * @return PEM
124
-     */
125
-    public function toPEM(): PEM
126
-    {
127
-        $n = $this->modulusParameter()
128
-            ->number()
129
-            ->base10();
130
-        $e = $this->exponentParameter()
131
-            ->number()
132
-            ->base10();
133
-        $d = $this->privateExponentParameter()
134
-            ->number()
135
-            ->base10();
136
-        $p = $this->firstPrimeFactorParameter()
137
-            ->number()
138
-            ->base10();
139
-        $q = $this->secondPrimeFactorParameter()
140
-            ->number()
141
-            ->base10();
142
-        $dp = $this->firstFactorCRTExponentParameter()
143
-            ->number()
144
-            ->base10();
145
-        $dq = $this->secondFactorCRTExponentParameter()
146
-            ->number()
147
-            ->base10();
148
-        $qi = $this->firstCRTCoefficientParameter()
149
-            ->number()
150
-            ->base10();
151
-        $pk = new RSAPrivateKey($n, $e, $d, $p, $q, $dp, $dq, $qi);
152
-        return PrivateKeyInfo::fromPrivateKey($pk)->toPEM();
153
-    }
120
+	/**
121
+	 * Convert JWK to PEM.
122
+	 *
123
+	 * @return PEM
124
+	 */
125
+	public function toPEM(): PEM
126
+	{
127
+		$n = $this->modulusParameter()
128
+			->number()
129
+			->base10();
130
+		$e = $this->exponentParameter()
131
+			->number()
132
+			->base10();
133
+		$d = $this->privateExponentParameter()
134
+			->number()
135
+			->base10();
136
+		$p = $this->firstPrimeFactorParameter()
137
+			->number()
138
+			->base10();
139
+		$q = $this->secondPrimeFactorParameter()
140
+			->number()
141
+			->base10();
142
+		$dp = $this->firstFactorCRTExponentParameter()
143
+			->number()
144
+			->base10();
145
+		$dq = $this->secondFactorCRTExponentParameter()
146
+			->number()
147
+			->base10();
148
+		$qi = $this->firstCRTCoefficientParameter()
149
+			->number()
150
+			->base10();
151
+		$pk = new RSAPrivateKey($n, $e, $d, $p, $q, $dp, $dq, $qi);
152
+		return PrivateKeyInfo::fromPrivateKey($pk)->toPEM();
153
+	}
154 154
 }
Please login to merge, or discard this patch.
lib/JWX/JWK/RSA/RSAPublicKeyJWK.php 1 patch
Indentation   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -22,79 +22,79 @@
 block discarded – undo
22 22
  */
23 23
 class RSAPublicKeyJWK extends PublicKeyJWK
24 24
 {
25
-    /**
26
-     * Parameter names managed by this class.
27
-     *
28
-     * @internal
29
-     *
30
-     * @var string[]
31
-     */
32
-    const MANAGED_PARAMS = array(
33
-        /* @formatter:off */
34
-        JWKParameter::PARAM_KEY_TYPE,
35
-        JWKParameter::PARAM_MODULUS,
36
-        JWKParameter::PARAM_EXPONENT
37
-        /* @formatter:on */
38
-    );
25
+	/**
26
+	 * Parameter names managed by this class.
27
+	 *
28
+	 * @internal
29
+	 *
30
+	 * @var string[]
31
+	 */
32
+	const MANAGED_PARAMS = array(
33
+		/* @formatter:off */
34
+		JWKParameter::PARAM_KEY_TYPE,
35
+		JWKParameter::PARAM_MODULUS,
36
+		JWKParameter::PARAM_EXPONENT
37
+		/* @formatter:on */
38
+	);
39 39
     
40
-    /**
41
-     * Constructor.
42
-     *
43
-     * @param JWKParameter ...$params
44
-     * @throws \UnexpectedValueException If missing required parameter
45
-     */
46
-    public function __construct(JWKParameter ...$params)
47
-    {
48
-        parent::__construct(...$params);
49
-        foreach (self::MANAGED_PARAMS as $name) {
50
-            if (!$this->has($name)) {
51
-                throw new \UnexpectedValueException("Missing '$name' parameter.");
52
-            }
53
-        }
54
-        if ($this->keyTypeParameter()->value() != KeyTypeParameter::TYPE_RSA) {
55
-            throw new \UnexpectedValueException("Invalid key type.");
56
-        }
57
-    }
40
+	/**
41
+	 * Constructor.
42
+	 *
43
+	 * @param JWKParameter ...$params
44
+	 * @throws \UnexpectedValueException If missing required parameter
45
+	 */
46
+	public function __construct(JWKParameter ...$params)
47
+	{
48
+		parent::__construct(...$params);
49
+		foreach (self::MANAGED_PARAMS as $name) {
50
+			if (!$this->has($name)) {
51
+				throw new \UnexpectedValueException("Missing '$name' parameter.");
52
+			}
53
+		}
54
+		if ($this->keyTypeParameter()->value() != KeyTypeParameter::TYPE_RSA) {
55
+			throw new \UnexpectedValueException("Invalid key type.");
56
+		}
57
+	}
58 58
     
59
-    /**
60
-     * Initialize from RSAPublicKey.
61
-     *
62
-     * @param RSAPublicKey $pk
63
-     * @return self
64
-     */
65
-    public static function fromRSAPublicKey(RSAPublicKey $pk): self
66
-    {
67
-        $n = ModulusParameter::fromNumber($pk->modulus());
68
-        $e = ExponentParameter::fromNumber($pk->publicExponent());
69
-        $key_type = new KeyTypeParameter(KeyTypeParameter::TYPE_RSA);
70
-        return new self($key_type, $n, $e);
71
-    }
59
+	/**
60
+	 * Initialize from RSAPublicKey.
61
+	 *
62
+	 * @param RSAPublicKey $pk
63
+	 * @return self
64
+	 */
65
+	public static function fromRSAPublicKey(RSAPublicKey $pk): self
66
+	{
67
+		$n = ModulusParameter::fromNumber($pk->modulus());
68
+		$e = ExponentParameter::fromNumber($pk->publicExponent());
69
+		$key_type = new KeyTypeParameter(KeyTypeParameter::TYPE_RSA);
70
+		return new self($key_type, $n, $e);
71
+	}
72 72
     
73
-    /**
74
-     * Initialize from PEM.
75
-     *
76
-     * @param PEM $pem
77
-     * @return self
78
-     */
79
-    public static function fromPEM(PEM $pem): self
80
-    {
81
-        return self::fromRSAPublicKey(RSAPublicKey::fromPEM($pem));
82
-    }
73
+	/**
74
+	 * Initialize from PEM.
75
+	 *
76
+	 * @param PEM $pem
77
+	 * @return self
78
+	 */
79
+	public static function fromPEM(PEM $pem): self
80
+	{
81
+		return self::fromRSAPublicKey(RSAPublicKey::fromPEM($pem));
82
+	}
83 83
     
84
-    /**
85
-     * Convert JWK to PEM.
86
-     *
87
-     * @return PEM
88
-     */
89
-    public function toPEM(): PEM
90
-    {
91
-        $n = $this->modulusParameter()
92
-            ->number()
93
-            ->base10();
94
-        $e = $this->exponentParameter()
95
-            ->number()
96
-            ->base10();
97
-        $pk = new RSAPublicKey($n, $e);
98
-        return PublicKeyInfo::fromPublicKey($pk)->toPEM();
99
-    }
84
+	/**
85
+	 * Convert JWK to PEM.
86
+	 *
87
+	 * @return PEM
88
+	 */
89
+	public function toPEM(): PEM
90
+	{
91
+		$n = $this->modulusParameter()
92
+			->number()
93
+			->base10();
94
+		$e = $this->exponentParameter()
95
+			->number()
96
+			->base10();
97
+		$pk = new RSAPublicKey($n, $e);
98
+		return PublicKeyInfo::fromPublicKey($pk)->toPEM();
99
+	}
100 100
 }
Please login to merge, or discard this patch.
lib/JWX/JWK/TypedJWK.php 1 patch
Indentation   +563 added lines, -563 removed lines patch added patch discarded remove patch
@@ -11,567 +11,567 @@
 block discarded – undo
11 11
  */
12 12
 trait TypedJWK
13 13
 {
14
-    /**
15
-     * Whether parameters are present.
16
-     *
17
-     * @param string ...$names Parameter names
18
-     * @return bool
19
-     */
20
-    abstract public function has(string ...$names): bool;
21
-    
22
-    /**
23
-     * Get a parameter.
24
-     *
25
-     * @param string $name Parameter name
26
-     * @return JWKParameter
27
-     */
28
-    abstract public function get(string $name): JWKParameter;
29
-    
30
-    /**
31
-     * Check whether the algorithm parameter is present.
32
-     *
33
-     * @return bool
34
-     */
35
-    public function hasAlgorithmParameter(): bool
36
-    {
37
-        return $this->has(Parameter\JWKParameter::P_ALG);
38
-    }
39
-    
40
-    /**
41
-     * Get the algorithm parameter.
42
-     *
43
-     * @throws \UnexpectedValueException If the parameter has a wrong class
44
-     * @throws \LogicException If the parameter is not present
45
-     * @return Parameter\AlgorithmParameter
46
-     */
47
-    public function algorithmParameter(): Parameter\AlgorithmParameter
48
-    {
49
-        return self::_checkType($this->get(Parameter\JWKParameter::P_ALG),
50
-            Parameter\AlgorithmParameter::class);
51
-    }
52
-    
53
-    /**
54
-     * Check whether the curve parameter is present.
55
-     *
56
-     * @return bool
57
-     */
58
-    public function hasCurveParameter(): bool
59
-    {
60
-        return $this->has(Parameter\JWKParameter::P_CRV);
61
-    }
62
-    
63
-    /**
64
-     * Get the curve parameter.
65
-     *
66
-     * @throws \UnexpectedValueException If the parameter has a wrong class
67
-     * @throws \LogicException If the parameter is not present
68
-     * @return Parameter\CurveParameter
69
-     */
70
-    public function curveParameter(): Parameter\CurveParameter
71
-    {
72
-        return self::_checkType($this->get(Parameter\JWKParameter::P_CRV),
73
-            Parameter\CurveParameter::class);
74
-    }
75
-    
76
-    /**
77
-     * Check whether the ECC private key parameter is present.
78
-     *
79
-     * @return bool
80
-     */
81
-    public function hasECCPrivateKeyParameter(): bool
82
-    {
83
-        return $this->has(Parameter\JWKParameter::P_ECC_D);
84
-    }
85
-    
86
-    /**
87
-     * Get the ECC private key parameter.
88
-     *
89
-     * @throws \UnexpectedValueException If the parameter has a wrong class
90
-     * @throws \LogicException If the parameter is not present
91
-     * @return Parameter\ECCPrivateKeyParameter
92
-     */
93
-    public function ECCPrivateKeyParameter(): Parameter\ECCPrivateKeyParameter
94
-    {
95
-        return self::_checkType($this->get(Parameter\JWKParameter::P_ECC_D),
96
-            Parameter\ECCPrivateKeyParameter::class);
97
-    }
98
-    
99
-    /**
100
-     * Check whether the exponent parameter is present.
101
-     *
102
-     * @return bool
103
-     */
104
-    public function hasExponentParameter(): bool
105
-    {
106
-        return $this->has(Parameter\JWKParameter::P_E);
107
-    }
108
-    
109
-    /**
110
-     * Get the exponent parameter.
111
-     *
112
-     * @throws \UnexpectedValueException If the parameter has a wrong class
113
-     * @throws \LogicException If the parameter is not present
114
-     * @return Parameter\ExponentParameter
115
-     */
116
-    public function exponentParameter(): Parameter\ExponentParameter
117
-    {
118
-        return self::_checkType($this->get(Parameter\JWKParameter::P_E),
119
-            Parameter\ExponentParameter::class);
120
-    }
121
-    
122
-    /**
123
-     * Check whether the first CRT coefficient parameter is present.
124
-     *
125
-     * @return bool
126
-     */
127
-    public function hasFirstCRTCoefficientParameter(): bool
128
-    {
129
-        return $this->has(Parameter\JWKParameter::P_QI);
130
-    }
131
-    
132
-    /**
133
-     * Get the first CRT coefficient parameter.
134
-     *
135
-     * @throws \UnexpectedValueException If the parameter has a wrong class
136
-     * @throws \LogicException If the parameter is not present
137
-     * @return Parameter\FirstCRTCoefficientParameter
138
-     */
139
-    public function firstCRTCoefficientParameter(): Parameter\FirstCRTCoefficientParameter
140
-    {
141
-        return self::_checkType($this->get(Parameter\JWKParameter::P_QI),
142
-            Parameter\FirstCRTCoefficientParameter::class);
143
-    }
144
-    
145
-    /**
146
-     * Check whether the first factor CRT exponent parameter is present.
147
-     *
148
-     * @return bool
149
-     */
150
-    public function hasFirstFactorCRTExponentParameter(): bool
151
-    {
152
-        return $this->has(Parameter\JWKParameter::P_DP);
153
-    }
154
-    
155
-    /**
156
-     * Get the first factor CRT exponent parameter.
157
-     *
158
-     * @throws \UnexpectedValueException If the parameter has a wrong class
159
-     * @throws \LogicException If the parameter is not present
160
-     * @return Parameter\FirstFactorCRTExponentParameter
161
-     */
162
-    public function firstFactorCRTExponentParameter(): Parameter\FirstFactorCRTExponentParameter
163
-    {
164
-        return self::_checkType($this->get(Parameter\JWKParameter::P_DP),
165
-            Parameter\FirstFactorCRTExponentParameter::class);
166
-    }
167
-    
168
-    /**
169
-     * Check whether the first prime factor parameter is present.
170
-     *
171
-     * @return bool
172
-     */
173
-    public function hasFirstPrimeFactorParameter(): bool
174
-    {
175
-        return $this->has(Parameter\JWKParameter::P_P);
176
-    }
177
-    
178
-    /**
179
-     * Get the first prime factor parameter.
180
-     *
181
-     * @throws \UnexpectedValueException If the parameter has a wrong class
182
-     * @throws \LogicException If the parameter is not present
183
-     * @return Parameter\FirstPrimeFactorParameter
184
-     */
185
-    public function firstPrimeFactorParameter(): Parameter\FirstPrimeFactorParameter
186
-    {
187
-        return self::_checkType($this->get(Parameter\JWKParameter::P_P),
188
-            Parameter\FirstPrimeFactorParameter::class);
189
-    }
190
-    
191
-    /**
192
-     * Check whether the key ID parameter is present.
193
-     *
194
-     * @return bool
195
-     */
196
-    public function hasKeyIDParameter(): bool
197
-    {
198
-        return $this->has(Parameter\JWKParameter::P_KID);
199
-    }
200
-    
201
-    /**
202
-     * Get the key ID parameter.
203
-     *
204
-     * @throws \UnexpectedValueException If the parameter has a wrong class
205
-     * @throws \LogicException If the parameter is not present
206
-     * @return Parameter\KeyIDParameter
207
-     */
208
-    public function keyIDParameter(): Parameter\KeyIDParameter
209
-    {
210
-        return self::_checkType($this->get(Parameter\JWKParameter::P_KID),
211
-            Parameter\KeyIDParameter::class);
212
-    }
213
-    
214
-    /**
215
-     * Check whether the key operations parameter is present.
216
-     *
217
-     * @return bool
218
-     */
219
-    public function hasKeyOperationsParameter(): bool
220
-    {
221
-        return $this->has(Parameter\JWKParameter::P_KEY_OPS);
222
-    }
223
-    
224
-    /**
225
-     * Get the key operations parameter.
226
-     *
227
-     * @throws \UnexpectedValueException If the parameter has a wrong class
228
-     * @throws \LogicException If the parameter is not present
229
-     * @return Parameter\KeyOperationsParameter
230
-     */
231
-    public function keyOperationsParameter(): Parameter\KeyOperationsParameter
232
-    {
233
-        return self::_checkType($this->get(Parameter\JWKParameter::P_KEY_OPS),
234
-            Parameter\KeyOperationsParameter::class);
235
-    }
236
-    
237
-    /**
238
-     * Check whether the key type parameter is present.
239
-     *
240
-     * @return bool
241
-     */
242
-    public function hasKeyTypeParameter(): bool
243
-    {
244
-        return $this->has(Parameter\JWKParameter::P_KTY);
245
-    }
246
-    
247
-    /**
248
-     * Get the key type parameter.
249
-     *
250
-     * @throws \UnexpectedValueException If the parameter has a wrong class
251
-     * @throws \LogicException If the parameter is not present
252
-     * @return Parameter\KeyTypeParameter
253
-     */
254
-    public function keyTypeParameter(): Parameter\KeyTypeParameter
255
-    {
256
-        return self::_checkType($this->get(Parameter\JWKParameter::P_KTY),
257
-            Parameter\KeyTypeParameter::class);
258
-    }
259
-    
260
-    /**
261
-     * Check whether the key value parameter is present.
262
-     *
263
-     * @return bool
264
-     */
265
-    public function hasKeyValueParameter(): bool
266
-    {
267
-        return $this->has(Parameter\JWKParameter::P_K);
268
-    }
269
-    
270
-    /**
271
-     * Get the key value parameter.
272
-     *
273
-     * @throws \UnexpectedValueException If the parameter has a wrong class
274
-     * @throws \LogicException If the parameter is not present
275
-     * @return Parameter\KeyValueParameter
276
-     */
277
-    public function keyValueParameter(): Parameter\KeyValueParameter
278
-    {
279
-        return self::_checkType($this->get(Parameter\JWKParameter::P_K),
280
-            Parameter\KeyValueParameter::class);
281
-    }
282
-    
283
-    /**
284
-     * Check whether the modulus parameter is present.
285
-     *
286
-     * @return bool
287
-     */
288
-    public function hasModulusParameter(): bool
289
-    {
290
-        return $this->has(Parameter\JWKParameter::P_N);
291
-    }
292
-    
293
-    /**
294
-     * Get the modulus parameter.
295
-     *
296
-     * @throws \UnexpectedValueException If the parameter has a wrong class
297
-     * @throws \LogicException If the parameter is not present
298
-     * @return Parameter\ModulusParameter
299
-     */
300
-    public function modulusParameter(): Parameter\ModulusParameter
301
-    {
302
-        return self::_checkType($this->get(Parameter\JWKParameter::P_N),
303
-            Parameter\ModulusParameter::class);
304
-    }
305
-    
306
-    /**
307
-     * Check whether the other primes info parameter is present.
308
-     *
309
-     * @return bool
310
-     */
311
-    public function hasOtherPrimesInfoParameter(): bool
312
-    {
313
-        return $this->has(Parameter\JWKParameter::P_OTH);
314
-    }
315
-    
316
-    /**
317
-     * Get the other primes info parameter.
318
-     *
319
-     * @throws \UnexpectedValueException If the parameter has a wrong class
320
-     * @throws \LogicException If the parameter is not present
321
-     * @return Parameter\OtherPrimesInfoParameter
322
-     */
323
-    public function otherPrimesInfoParameter(): Parameter\OtherPrimesInfoParameter
324
-    {
325
-        return self::_checkType($this->get(Parameter\JWKParameter::P_OTH),
326
-            Parameter\OtherPrimesInfoParameter::class);
327
-    }
328
-    
329
-    /**
330
-     * Check whether the private exponent parameter is present.
331
-     *
332
-     * @return bool
333
-     */
334
-    public function hasPrivateExponentParameter(): bool
335
-    {
336
-        return $this->has(Parameter\JWKParameter::P_RSA_D);
337
-    }
338
-    
339
-    /**
340
-     * Get the private exponent parameter.
341
-     *
342
-     * @throws \UnexpectedValueException If the parameter has a wrong class
343
-     * @throws \LogicException If the parameter is not present
344
-     * @return Parameter\PrivateExponentParameter
345
-     */
346
-    public function privateExponentParameter(): Parameter\PrivateExponentParameter
347
-    {
348
-        return self::_checkType($this->get(Parameter\JWKParameter::P_RSA_D),
349
-            Parameter\PrivateExponentParameter::class);
350
-    }
351
-    
352
-    /**
353
-     * Check whether the public key use parameter is present.
354
-     *
355
-     * @return bool
356
-     */
357
-    public function hasPublicKeyUseParameter(): bool
358
-    {
359
-        return $this->has(Parameter\JWKParameter::P_USE);
360
-    }
361
-    
362
-    /**
363
-     * Get the public key use parameter.
364
-     *
365
-     * @throws \UnexpectedValueException If the parameter has a wrong class
366
-     * @throws \LogicException If the parameter is not present
367
-     * @return Parameter\PublicKeyUseParameter
368
-     */
369
-    public function publicKeyUseParameter(): Parameter\PublicKeyUseParameter
370
-    {
371
-        return self::_checkType($this->get(Parameter\JWKParameter::P_USE),
372
-            Parameter\PublicKeyUseParameter::class);
373
-    }
374
-    
375
-    /**
376
-     * Check whether the second factor CRT exponent parameter is present.
377
-     *
378
-     * @return bool
379
-     */
380
-    public function hasSecondFactorCRTExponentParameter(): bool
381
-    {
382
-        return $this->has(Parameter\JWKParameter::P_DQ);
383
-    }
384
-    
385
-    /**
386
-     * Get the second factor CRT exponent parameter.
387
-     *
388
-     * @throws \UnexpectedValueException If the parameter has a wrong class
389
-     * @throws \LogicException If the parameter is not present
390
-     * @return Parameter\SecondFactorCRTExponentParameter
391
-     */
392
-    public function secondFactorCRTExponentParameter(): Parameter\SecondFactorCRTExponentParameter
393
-    {
394
-        return self::_checkType($this->get(Parameter\JWKParameter::P_DQ),
395
-            Parameter\SecondFactorCRTExponentParameter::class);
396
-    }
397
-    
398
-    /**
399
-     * Check whether the second prime factor parameter is present.
400
-     *
401
-     * @return bool
402
-     */
403
-    public function hasSecondPrimeFactorParameter(): bool
404
-    {
405
-        return $this->has(Parameter\JWKParameter::P_Q);
406
-    }
407
-    
408
-    /**
409
-     * Get the second prime factor parameter.
410
-     *
411
-     * @throws \UnexpectedValueException If the parameter has a wrong class
412
-     * @throws \LogicException If the parameter is not present
413
-     * @return Parameter\SecondPrimeFactorParameter
414
-     */
415
-    public function secondPrimeFactorParameter(): Parameter\SecondPrimeFactorParameter
416
-    {
417
-        return self::_checkType($this->get(Parameter\JWKParameter::P_Q),
418
-            Parameter\SecondPrimeFactorParameter::class);
419
-    }
420
-    
421
-    /**
422
-     * Check whether the X.509 certificate chain parameter is present.
423
-     *
424
-     * @return bool
425
-     */
426
-    public function hasX509CertificateChainParameter(): bool
427
-    {
428
-        return $this->has(Parameter\JWKParameter::P_X5C);
429
-    }
430
-    
431
-    /**
432
-     * Get the X.509 certificate chain parameter.
433
-     *
434
-     * @throws \UnexpectedValueException If the parameter has a wrong class
435
-     * @throws \LogicException If the parameter is not present
436
-     * @return Parameter\X509CertificateChainParameter
437
-     */
438
-    public function X509CertificateChainParameter(): Parameter\X509CertificateChainParameter
439
-    {
440
-        return self::_checkType($this->get(Parameter\JWKParameter::P_X5C),
441
-            Parameter\X509CertificateChainParameter::class);
442
-    }
443
-    
444
-    /**
445
-     * Check whether the X.509 certificate SHA-1 thumbprint parameter is
446
-     * present.
447
-     *
448
-     * @return bool
449
-     */
450
-    public function hasX509CertificateSHA1ThumbprintParameter(): bool
451
-    {
452
-        return $this->has(Parameter\JWKParameter::P_X5T);
453
-    }
454
-    
455
-    /**
456
-     * Get the X.509 certificate SHA-1 thumbprint parameter.
457
-     *
458
-     * @throws \UnexpectedValueException If the parameter has a wrong class
459
-     * @throws \LogicException If the parameter is not present
460
-     * @return Parameter\X509CertificateSHA1ThumbprintParameter
461
-     */
462
-    public function X509CertificateSHA1ThumbprintParameter(): Parameter\X509CertificateSHA1ThumbprintParameter
463
-    {
464
-        return self::_checkType($this->get(Parameter\JWKParameter::P_X5T),
465
-            Parameter\X509CertificateSHA1ThumbprintParameter::class);
466
-    }
467
-    
468
-    /**
469
-     * Check whether the X.509 certificate SHA-256 thumbprint parameter is
470
-     * present.
471
-     *
472
-     * @return bool
473
-     */
474
-    public function hasX509CertificateSHA256ThumbprintParameter(): bool
475
-    {
476
-        return $this->has(Parameter\JWKParameter::P_X5TS256);
477
-    }
478
-    
479
-    /**
480
-     * Get the X.509 certificate SHA-256 thumbprint parameter.
481
-     *
482
-     * @throws \UnexpectedValueException If the parameter has a wrong class
483
-     * @throws \LogicException If the parameter is not present
484
-     * @return Parameter\X509CertificateSHA256ThumbprintParameter
485
-     */
486
-    public function X509CertificateSHA256ThumbprintParameter(): Parameter\X509CertificateSHA256ThumbprintParameter
487
-    {
488
-        return self::_checkType($this->get(Parameter\JWKParameter::P_X5TS256),
489
-            Parameter\X509CertificateSHA256ThumbprintParameter::class);
490
-    }
491
-    
492
-    /**
493
-     * Check whether the X.509 URL parameter is present.
494
-     *
495
-     * @return bool
496
-     */
497
-    public function hasX509URLParameter(): bool
498
-    {
499
-        return $this->has(Parameter\JWKParameter::P_X5U);
500
-    }
501
-    
502
-    /**
503
-     * Get the X.509 URL parameter.
504
-     *
505
-     * @throws \UnexpectedValueException If the parameter has a wrong class
506
-     * @throws \LogicException If the parameter is not present
507
-     * @return Parameter\X509URLParameter
508
-     */
509
-    public function X509URLParameter(): Parameter\X509URLParameter
510
-    {
511
-        return self::_checkType($this->get(Parameter\JWKParameter::P_X5U),
512
-            Parameter\X509URLParameter::class);
513
-    }
514
-    
515
-    /**
516
-     * Check whether the X coordinate parameter is present.
517
-     *
518
-     * @return bool
519
-     */
520
-    public function hasXCoordinateParameter(): bool
521
-    {
522
-        return $this->has(Parameter\JWKParameter::P_X);
523
-    }
524
-    
525
-    /**
526
-     * Get the X coordinate parameter.
527
-     *
528
-     * @throws \UnexpectedValueException If the parameter has a wrong class
529
-     * @throws \LogicException If the parameter is not present
530
-     * @return Parameter\XCoordinateParameter
531
-     */
532
-    public function XCoordinateParameter(): Parameter\XCoordinateParameter
533
-    {
534
-        return self::_checkType($this->get(Parameter\JWKParameter::P_X),
535
-            Parameter\XCoordinateParameter::class);
536
-    }
537
-    
538
-    /**
539
-     * Check whether the Y coordinate parameter is present.
540
-     *
541
-     * @return bool
542
-     */
543
-    public function hasYCoordinateParameter(): bool
544
-    {
545
-        return $this->has(Parameter\JWKParameter::P_Y);
546
-    }
547
-    
548
-    /**
549
-     * Get the Y coordinate parameter.
550
-     *
551
-     * @throws \UnexpectedValueException If the parameter has a wrong class
552
-     * @throws \LogicException If the parameter is not present
553
-     * @return Parameter\YCoordinateParameter
554
-     */
555
-    public function YCoordinateParameter(): Parameter\YCoordinateParameter
556
-    {
557
-        return self::_checkType($this->get(Parameter\JWKParameter::P_Y),
558
-            Parameter\YCoordinateParameter::class);
559
-    }
560
-    
561
-    /**
562
-     * Check that the parameter is an instance of the given class.
563
-     *
564
-     * @param Parameter\JWKParameter $param Parameter
565
-     * @param string $cls Class name
566
-     * @throws \UnexpectedValueException
567
-     * @return Parameter\JWKParameter
568
-     */
569
-    private static function _checkType(Parameter\JWKParameter $param, string $cls): Parameter\JWKParameter
570
-    {
571
-        if (!$param instanceof $cls) {
572
-            throw new \UnexpectedValueException(
573
-                "$cls expected, got " . get_class($param));
574
-        }
575
-        return $param;
576
-    }
14
+	/**
15
+	 * Whether parameters are present.
16
+	 *
17
+	 * @param string ...$names Parameter names
18
+	 * @return bool
19
+	 */
20
+	abstract public function has(string ...$names): bool;
21
+    
22
+	/**
23
+	 * Get a parameter.
24
+	 *
25
+	 * @param string $name Parameter name
26
+	 * @return JWKParameter
27
+	 */
28
+	abstract public function get(string $name): JWKParameter;
29
+    
30
+	/**
31
+	 * Check whether the algorithm parameter is present.
32
+	 *
33
+	 * @return bool
34
+	 */
35
+	public function hasAlgorithmParameter(): bool
36
+	{
37
+		return $this->has(Parameter\JWKParameter::P_ALG);
38
+	}
39
+    
40
+	/**
41
+	 * Get the algorithm parameter.
42
+	 *
43
+	 * @throws \UnexpectedValueException If the parameter has a wrong class
44
+	 * @throws \LogicException If the parameter is not present
45
+	 * @return Parameter\AlgorithmParameter
46
+	 */
47
+	public function algorithmParameter(): Parameter\AlgorithmParameter
48
+	{
49
+		return self::_checkType($this->get(Parameter\JWKParameter::P_ALG),
50
+			Parameter\AlgorithmParameter::class);
51
+	}
52
+    
53
+	/**
54
+	 * Check whether the curve parameter is present.
55
+	 *
56
+	 * @return bool
57
+	 */
58
+	public function hasCurveParameter(): bool
59
+	{
60
+		return $this->has(Parameter\JWKParameter::P_CRV);
61
+	}
62
+    
63
+	/**
64
+	 * Get the curve parameter.
65
+	 *
66
+	 * @throws \UnexpectedValueException If the parameter has a wrong class
67
+	 * @throws \LogicException If the parameter is not present
68
+	 * @return Parameter\CurveParameter
69
+	 */
70
+	public function curveParameter(): Parameter\CurveParameter
71
+	{
72
+		return self::_checkType($this->get(Parameter\JWKParameter::P_CRV),
73
+			Parameter\CurveParameter::class);
74
+	}
75
+    
76
+	/**
77
+	 * Check whether the ECC private key parameter is present.
78
+	 *
79
+	 * @return bool
80
+	 */
81
+	public function hasECCPrivateKeyParameter(): bool
82
+	{
83
+		return $this->has(Parameter\JWKParameter::P_ECC_D);
84
+	}
85
+    
86
+	/**
87
+	 * Get the ECC private key parameter.
88
+	 *
89
+	 * @throws \UnexpectedValueException If the parameter has a wrong class
90
+	 * @throws \LogicException If the parameter is not present
91
+	 * @return Parameter\ECCPrivateKeyParameter
92
+	 */
93
+	public function ECCPrivateKeyParameter(): Parameter\ECCPrivateKeyParameter
94
+	{
95
+		return self::_checkType($this->get(Parameter\JWKParameter::P_ECC_D),
96
+			Parameter\ECCPrivateKeyParameter::class);
97
+	}
98
+    
99
+	/**
100
+	 * Check whether the exponent parameter is present.
101
+	 *
102
+	 * @return bool
103
+	 */
104
+	public function hasExponentParameter(): bool
105
+	{
106
+		return $this->has(Parameter\JWKParameter::P_E);
107
+	}
108
+    
109
+	/**
110
+	 * Get the exponent parameter.
111
+	 *
112
+	 * @throws \UnexpectedValueException If the parameter has a wrong class
113
+	 * @throws \LogicException If the parameter is not present
114
+	 * @return Parameter\ExponentParameter
115
+	 */
116
+	public function exponentParameter(): Parameter\ExponentParameter
117
+	{
118
+		return self::_checkType($this->get(Parameter\JWKParameter::P_E),
119
+			Parameter\ExponentParameter::class);
120
+	}
121
+    
122
+	/**
123
+	 * Check whether the first CRT coefficient parameter is present.
124
+	 *
125
+	 * @return bool
126
+	 */
127
+	public function hasFirstCRTCoefficientParameter(): bool
128
+	{
129
+		return $this->has(Parameter\JWKParameter::P_QI);
130
+	}
131
+    
132
+	/**
133
+	 * Get the first CRT coefficient parameter.
134
+	 *
135
+	 * @throws \UnexpectedValueException If the parameter has a wrong class
136
+	 * @throws \LogicException If the parameter is not present
137
+	 * @return Parameter\FirstCRTCoefficientParameter
138
+	 */
139
+	public function firstCRTCoefficientParameter(): Parameter\FirstCRTCoefficientParameter
140
+	{
141
+		return self::_checkType($this->get(Parameter\JWKParameter::P_QI),
142
+			Parameter\FirstCRTCoefficientParameter::class);
143
+	}
144
+    
145
+	/**
146
+	 * Check whether the first factor CRT exponent parameter is present.
147
+	 *
148
+	 * @return bool
149
+	 */
150
+	public function hasFirstFactorCRTExponentParameter(): bool
151
+	{
152
+		return $this->has(Parameter\JWKParameter::P_DP);
153
+	}
154
+    
155
+	/**
156
+	 * Get the first factor CRT exponent parameter.
157
+	 *
158
+	 * @throws \UnexpectedValueException If the parameter has a wrong class
159
+	 * @throws \LogicException If the parameter is not present
160
+	 * @return Parameter\FirstFactorCRTExponentParameter
161
+	 */
162
+	public function firstFactorCRTExponentParameter(): Parameter\FirstFactorCRTExponentParameter
163
+	{
164
+		return self::_checkType($this->get(Parameter\JWKParameter::P_DP),
165
+			Parameter\FirstFactorCRTExponentParameter::class);
166
+	}
167
+    
168
+	/**
169
+	 * Check whether the first prime factor parameter is present.
170
+	 *
171
+	 * @return bool
172
+	 */
173
+	public function hasFirstPrimeFactorParameter(): bool
174
+	{
175
+		return $this->has(Parameter\JWKParameter::P_P);
176
+	}
177
+    
178
+	/**
179
+	 * Get the first prime factor parameter.
180
+	 *
181
+	 * @throws \UnexpectedValueException If the parameter has a wrong class
182
+	 * @throws \LogicException If the parameter is not present
183
+	 * @return Parameter\FirstPrimeFactorParameter
184
+	 */
185
+	public function firstPrimeFactorParameter(): Parameter\FirstPrimeFactorParameter
186
+	{
187
+		return self::_checkType($this->get(Parameter\JWKParameter::P_P),
188
+			Parameter\FirstPrimeFactorParameter::class);
189
+	}
190
+    
191
+	/**
192
+	 * Check whether the key ID parameter is present.
193
+	 *
194
+	 * @return bool
195
+	 */
196
+	public function hasKeyIDParameter(): bool
197
+	{
198
+		return $this->has(Parameter\JWKParameter::P_KID);
199
+	}
200
+    
201
+	/**
202
+	 * Get the key ID parameter.
203
+	 *
204
+	 * @throws \UnexpectedValueException If the parameter has a wrong class
205
+	 * @throws \LogicException If the parameter is not present
206
+	 * @return Parameter\KeyIDParameter
207
+	 */
208
+	public function keyIDParameter(): Parameter\KeyIDParameter
209
+	{
210
+		return self::_checkType($this->get(Parameter\JWKParameter::P_KID),
211
+			Parameter\KeyIDParameter::class);
212
+	}
213
+    
214
+	/**
215
+	 * Check whether the key operations parameter is present.
216
+	 *
217
+	 * @return bool
218
+	 */
219
+	public function hasKeyOperationsParameter(): bool
220
+	{
221
+		return $this->has(Parameter\JWKParameter::P_KEY_OPS);
222
+	}
223
+    
224
+	/**
225
+	 * Get the key operations parameter.
226
+	 *
227
+	 * @throws \UnexpectedValueException If the parameter has a wrong class
228
+	 * @throws \LogicException If the parameter is not present
229
+	 * @return Parameter\KeyOperationsParameter
230
+	 */
231
+	public function keyOperationsParameter(): Parameter\KeyOperationsParameter
232
+	{
233
+		return self::_checkType($this->get(Parameter\JWKParameter::P_KEY_OPS),
234
+			Parameter\KeyOperationsParameter::class);
235
+	}
236
+    
237
+	/**
238
+	 * Check whether the key type parameter is present.
239
+	 *
240
+	 * @return bool
241
+	 */
242
+	public function hasKeyTypeParameter(): bool
243
+	{
244
+		return $this->has(Parameter\JWKParameter::P_KTY);
245
+	}
246
+    
247
+	/**
248
+	 * Get the key type parameter.
249
+	 *
250
+	 * @throws \UnexpectedValueException If the parameter has a wrong class
251
+	 * @throws \LogicException If the parameter is not present
252
+	 * @return Parameter\KeyTypeParameter
253
+	 */
254
+	public function keyTypeParameter(): Parameter\KeyTypeParameter
255
+	{
256
+		return self::_checkType($this->get(Parameter\JWKParameter::P_KTY),
257
+			Parameter\KeyTypeParameter::class);
258
+	}
259
+    
260
+	/**
261
+	 * Check whether the key value parameter is present.
262
+	 *
263
+	 * @return bool
264
+	 */
265
+	public function hasKeyValueParameter(): bool
266
+	{
267
+		return $this->has(Parameter\JWKParameter::P_K);
268
+	}
269
+    
270
+	/**
271
+	 * Get the key value parameter.
272
+	 *
273
+	 * @throws \UnexpectedValueException If the parameter has a wrong class
274
+	 * @throws \LogicException If the parameter is not present
275
+	 * @return Parameter\KeyValueParameter
276
+	 */
277
+	public function keyValueParameter(): Parameter\KeyValueParameter
278
+	{
279
+		return self::_checkType($this->get(Parameter\JWKParameter::P_K),
280
+			Parameter\KeyValueParameter::class);
281
+	}
282
+    
283
+	/**
284
+	 * Check whether the modulus parameter is present.
285
+	 *
286
+	 * @return bool
287
+	 */
288
+	public function hasModulusParameter(): bool
289
+	{
290
+		return $this->has(Parameter\JWKParameter::P_N);
291
+	}
292
+    
293
+	/**
294
+	 * Get the modulus parameter.
295
+	 *
296
+	 * @throws \UnexpectedValueException If the parameter has a wrong class
297
+	 * @throws \LogicException If the parameter is not present
298
+	 * @return Parameter\ModulusParameter
299
+	 */
300
+	public function modulusParameter(): Parameter\ModulusParameter
301
+	{
302
+		return self::_checkType($this->get(Parameter\JWKParameter::P_N),
303
+			Parameter\ModulusParameter::class);
304
+	}
305
+    
306
+	/**
307
+	 * Check whether the other primes info parameter is present.
308
+	 *
309
+	 * @return bool
310
+	 */
311
+	public function hasOtherPrimesInfoParameter(): bool
312
+	{
313
+		return $this->has(Parameter\JWKParameter::P_OTH);
314
+	}
315
+    
316
+	/**
317
+	 * Get the other primes info parameter.
318
+	 *
319
+	 * @throws \UnexpectedValueException If the parameter has a wrong class
320
+	 * @throws \LogicException If the parameter is not present
321
+	 * @return Parameter\OtherPrimesInfoParameter
322
+	 */
323
+	public function otherPrimesInfoParameter(): Parameter\OtherPrimesInfoParameter
324
+	{
325
+		return self::_checkType($this->get(Parameter\JWKParameter::P_OTH),
326
+			Parameter\OtherPrimesInfoParameter::class);
327
+	}
328
+    
329
+	/**
330
+	 * Check whether the private exponent parameter is present.
331
+	 *
332
+	 * @return bool
333
+	 */
334
+	public function hasPrivateExponentParameter(): bool
335
+	{
336
+		return $this->has(Parameter\JWKParameter::P_RSA_D);
337
+	}
338
+    
339
+	/**
340
+	 * Get the private exponent parameter.
341
+	 *
342
+	 * @throws \UnexpectedValueException If the parameter has a wrong class
343
+	 * @throws \LogicException If the parameter is not present
344
+	 * @return Parameter\PrivateExponentParameter
345
+	 */
346
+	public function privateExponentParameter(): Parameter\PrivateExponentParameter
347
+	{
348
+		return self::_checkType($this->get(Parameter\JWKParameter::P_RSA_D),
349
+			Parameter\PrivateExponentParameter::class);
350
+	}
351
+    
352
+	/**
353
+	 * Check whether the public key use parameter is present.
354
+	 *
355
+	 * @return bool
356
+	 */
357
+	public function hasPublicKeyUseParameter(): bool
358
+	{
359
+		return $this->has(Parameter\JWKParameter::P_USE);
360
+	}
361
+    
362
+	/**
363
+	 * Get the public key use parameter.
364
+	 *
365
+	 * @throws \UnexpectedValueException If the parameter has a wrong class
366
+	 * @throws \LogicException If the parameter is not present
367
+	 * @return Parameter\PublicKeyUseParameter
368
+	 */
369
+	public function publicKeyUseParameter(): Parameter\PublicKeyUseParameter
370
+	{
371
+		return self::_checkType($this->get(Parameter\JWKParameter::P_USE),
372
+			Parameter\PublicKeyUseParameter::class);
373
+	}
374
+    
375
+	/**
376
+	 * Check whether the second factor CRT exponent parameter is present.
377
+	 *
378
+	 * @return bool
379
+	 */
380
+	public function hasSecondFactorCRTExponentParameter(): bool
381
+	{
382
+		return $this->has(Parameter\JWKParameter::P_DQ);
383
+	}
384
+    
385
+	/**
386
+	 * Get the second factor CRT exponent parameter.
387
+	 *
388
+	 * @throws \UnexpectedValueException If the parameter has a wrong class
389
+	 * @throws \LogicException If the parameter is not present
390
+	 * @return Parameter\SecondFactorCRTExponentParameter
391
+	 */
392
+	public function secondFactorCRTExponentParameter(): Parameter\SecondFactorCRTExponentParameter
393
+	{
394
+		return self::_checkType($this->get(Parameter\JWKParameter::P_DQ),
395
+			Parameter\SecondFactorCRTExponentParameter::class);
396
+	}
397
+    
398
+	/**
399
+	 * Check whether the second prime factor parameter is present.
400
+	 *
401
+	 * @return bool
402
+	 */
403
+	public function hasSecondPrimeFactorParameter(): bool
404
+	{
405
+		return $this->has(Parameter\JWKParameter::P_Q);
406
+	}
407
+    
408
+	/**
409
+	 * Get the second prime factor parameter.
410
+	 *
411
+	 * @throws \UnexpectedValueException If the parameter has a wrong class
412
+	 * @throws \LogicException If the parameter is not present
413
+	 * @return Parameter\SecondPrimeFactorParameter
414
+	 */
415
+	public function secondPrimeFactorParameter(): Parameter\SecondPrimeFactorParameter
416
+	{
417
+		return self::_checkType($this->get(Parameter\JWKParameter::P_Q),
418
+			Parameter\SecondPrimeFactorParameter::class);
419
+	}
420
+    
421
+	/**
422
+	 * Check whether the X.509 certificate chain parameter is present.
423
+	 *
424
+	 * @return bool
425
+	 */
426
+	public function hasX509CertificateChainParameter(): bool
427
+	{
428
+		return $this->has(Parameter\JWKParameter::P_X5C);
429
+	}
430
+    
431
+	/**
432
+	 * Get the X.509 certificate chain parameter.
433
+	 *
434
+	 * @throws \UnexpectedValueException If the parameter has a wrong class
435
+	 * @throws \LogicException If the parameter is not present
436
+	 * @return Parameter\X509CertificateChainParameter
437
+	 */
438
+	public function X509CertificateChainParameter(): Parameter\X509CertificateChainParameter
439
+	{
440
+		return self::_checkType($this->get(Parameter\JWKParameter::P_X5C),
441
+			Parameter\X509CertificateChainParameter::class);
442
+	}
443
+    
444
+	/**
445
+	 * Check whether the X.509 certificate SHA-1 thumbprint parameter is
446
+	 * present.
447
+	 *
448
+	 * @return bool
449
+	 */
450
+	public function hasX509CertificateSHA1ThumbprintParameter(): bool
451
+	{
452
+		return $this->has(Parameter\JWKParameter::P_X5T);
453
+	}
454
+    
455
+	/**
456
+	 * Get the X.509 certificate SHA-1 thumbprint parameter.
457
+	 *
458
+	 * @throws \UnexpectedValueException If the parameter has a wrong class
459
+	 * @throws \LogicException If the parameter is not present
460
+	 * @return Parameter\X509CertificateSHA1ThumbprintParameter
461
+	 */
462
+	public function X509CertificateSHA1ThumbprintParameter(): Parameter\X509CertificateSHA1ThumbprintParameter
463
+	{
464
+		return self::_checkType($this->get(Parameter\JWKParameter::P_X5T),
465
+			Parameter\X509CertificateSHA1ThumbprintParameter::class);
466
+	}
467
+    
468
+	/**
469
+	 * Check whether the X.509 certificate SHA-256 thumbprint parameter is
470
+	 * present.
471
+	 *
472
+	 * @return bool
473
+	 */
474
+	public function hasX509CertificateSHA256ThumbprintParameter(): bool
475
+	{
476
+		return $this->has(Parameter\JWKParameter::P_X5TS256);
477
+	}
478
+    
479
+	/**
480
+	 * Get the X.509 certificate SHA-256 thumbprint parameter.
481
+	 *
482
+	 * @throws \UnexpectedValueException If the parameter has a wrong class
483
+	 * @throws \LogicException If the parameter is not present
484
+	 * @return Parameter\X509CertificateSHA256ThumbprintParameter
485
+	 */
486
+	public function X509CertificateSHA256ThumbprintParameter(): Parameter\X509CertificateSHA256ThumbprintParameter
487
+	{
488
+		return self::_checkType($this->get(Parameter\JWKParameter::P_X5TS256),
489
+			Parameter\X509CertificateSHA256ThumbprintParameter::class);
490
+	}
491
+    
492
+	/**
493
+	 * Check whether the X.509 URL parameter is present.
494
+	 *
495
+	 * @return bool
496
+	 */
497
+	public function hasX509URLParameter(): bool
498
+	{
499
+		return $this->has(Parameter\JWKParameter::P_X5U);
500
+	}
501
+    
502
+	/**
503
+	 * Get the X.509 URL parameter.
504
+	 *
505
+	 * @throws \UnexpectedValueException If the parameter has a wrong class
506
+	 * @throws \LogicException If the parameter is not present
507
+	 * @return Parameter\X509URLParameter
508
+	 */
509
+	public function X509URLParameter(): Parameter\X509URLParameter
510
+	{
511
+		return self::_checkType($this->get(Parameter\JWKParameter::P_X5U),
512
+			Parameter\X509URLParameter::class);
513
+	}
514
+    
515
+	/**
516
+	 * Check whether the X coordinate parameter is present.
517
+	 *
518
+	 * @return bool
519
+	 */
520
+	public function hasXCoordinateParameter(): bool
521
+	{
522
+		return $this->has(Parameter\JWKParameter::P_X);
523
+	}
524
+    
525
+	/**
526
+	 * Get the X coordinate parameter.
527
+	 *
528
+	 * @throws \UnexpectedValueException If the parameter has a wrong class
529
+	 * @throws \LogicException If the parameter is not present
530
+	 * @return Parameter\XCoordinateParameter
531
+	 */
532
+	public function XCoordinateParameter(): Parameter\XCoordinateParameter
533
+	{
534
+		return self::_checkType($this->get(Parameter\JWKParameter::P_X),
535
+			Parameter\XCoordinateParameter::class);
536
+	}
537
+    
538
+	/**
539
+	 * Check whether the Y coordinate parameter is present.
540
+	 *
541
+	 * @return bool
542
+	 */
543
+	public function hasYCoordinateParameter(): bool
544
+	{
545
+		return $this->has(Parameter\JWKParameter::P_Y);
546
+	}
547
+    
548
+	/**
549
+	 * Get the Y coordinate parameter.
550
+	 *
551
+	 * @throws \UnexpectedValueException If the parameter has a wrong class
552
+	 * @throws \LogicException If the parameter is not present
553
+	 * @return Parameter\YCoordinateParameter
554
+	 */
555
+	public function YCoordinateParameter(): Parameter\YCoordinateParameter
556
+	{
557
+		return self::_checkType($this->get(Parameter\JWKParameter::P_Y),
558
+			Parameter\YCoordinateParameter::class);
559
+	}
560
+    
561
+	/**
562
+	 * Check that the parameter is an instance of the given class.
563
+	 *
564
+	 * @param Parameter\JWKParameter $param Parameter
565
+	 * @param string $cls Class name
566
+	 * @throws \UnexpectedValueException
567
+	 * @return Parameter\JWKParameter
568
+	 */
569
+	private static function _checkType(Parameter\JWKParameter $param, string $cls): Parameter\JWKParameter
570
+	{
571
+		if (!$param instanceof $cls) {
572
+			throw new \UnexpectedValueException(
573
+				"$cls expected, got " . get_class($param));
574
+		}
575
+		return $param;
576
+	}
577 577
 }
Please login to merge, or discard this patch.
lib/JWX/JWK/Symmetric/SymmetricKeyJWK.php 1 patch
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -17,60 +17,60 @@
 block discarded – undo
17 17
  */
18 18
 class SymmetricKeyJWK extends JWK
19 19
 {
20
-    /**
21
-     * Parameter names managed by this class.
22
-     *
23
-     * @internal
24
-     *
25
-     * @var string[]
26
-     */
27
-    const MANAGED_PARAMS = array(
28
-        /* @formatter:off */
29
-        JWKParameter::PARAM_KEY_TYPE, 
30
-        JWKParameter::PARAM_KEY_VALUE
31
-        /* @formatter:on */
32
-    );
20
+	/**
21
+	 * Parameter names managed by this class.
22
+	 *
23
+	 * @internal
24
+	 *
25
+	 * @var string[]
26
+	 */
27
+	const MANAGED_PARAMS = array(
28
+		/* @formatter:off */
29
+		JWKParameter::PARAM_KEY_TYPE, 
30
+		JWKParameter::PARAM_KEY_VALUE
31
+		/* @formatter:on */
32
+	);
33 33
     
34
-    /**
35
-     * Constructor.
36
-     *
37
-     * @param JWKParameter ...$params
38
-     * @throws \UnexpectedValueException If missing required parameter
39
-     */
40
-    public function __construct(JWKParameter ...$params)
41
-    {
42
-        parent::__construct(...$params);
43
-        foreach (self::MANAGED_PARAMS as $name) {
44
-            if (!$this->has($name)) {
45
-                throw new \UnexpectedValueException("Missing '$name' parameter.");
46
-            }
47
-        }
48
-        if ($this->keyTypeParameter()->value() != KeyTypeParameter::TYPE_OCT) {
49
-            throw new \UnexpectedValueException("Invalid key type.");
50
-        }
51
-    }
34
+	/**
35
+	 * Constructor.
36
+	 *
37
+	 * @param JWKParameter ...$params
38
+	 * @throws \UnexpectedValueException If missing required parameter
39
+	 */
40
+	public function __construct(JWKParameter ...$params)
41
+	{
42
+		parent::__construct(...$params);
43
+		foreach (self::MANAGED_PARAMS as $name) {
44
+			if (!$this->has($name)) {
45
+				throw new \UnexpectedValueException("Missing '$name' parameter.");
46
+			}
47
+		}
48
+		if ($this->keyTypeParameter()->value() != KeyTypeParameter::TYPE_OCT) {
49
+			throw new \UnexpectedValueException("Invalid key type.");
50
+		}
51
+	}
52 52
     
53
-    /**
54
-     * Initialize from a key string.
55
-     *
56
-     * @param string $key Symmetric key
57
-     * @param JWKParameter ...$params Optional additional parameters
58
-     * @return self
59
-     */
60
-    public static function fromKey(string $key, JWKParameter ...$params): self
61
-    {
62
-        $params[] = new KeyTypeParameter(KeyTypeParameter::TYPE_OCT);
63
-        $params[] = KeyValueParameter::fromString($key);
64
-        return new self(...$params);
65
-    }
53
+	/**
54
+	 * Initialize from a key string.
55
+	 *
56
+	 * @param string $key Symmetric key
57
+	 * @param JWKParameter ...$params Optional additional parameters
58
+	 * @return self
59
+	 */
60
+	public static function fromKey(string $key, JWKParameter ...$params): self
61
+	{
62
+		$params[] = new KeyTypeParameter(KeyTypeParameter::TYPE_OCT);
63
+		$params[] = KeyValueParameter::fromString($key);
64
+		return new self(...$params);
65
+	}
66 66
     
67
-    /**
68
-     * Get the symmetric key.
69
-     *
70
-     * @return string
71
-     */
72
-    public function key(): string
73
-    {
74
-        return Base64::urlDecode($this->keyValueParameter()->value());
75
-    }
67
+	/**
68
+	 * Get the symmetric key.
69
+	 *
70
+	 * @return string
71
+	 */
72
+	public function key(): string
73
+	{
74
+		return Base64::urlDecode($this->keyValueParameter()->value());
75
+	}
76 76
 }
Please login to merge, or discard this patch.
lib/JWX/JWK/EC/ECPrivateKeyJWK.php 1 patch
Indentation   +98 added lines, -98 removed lines patch added patch discarded remove patch
@@ -26,107 +26,107 @@
 block discarded – undo
26 26
  */
27 27
 class ECPrivateKeyJWK extends PrivateKeyJWK
28 28
 {
29
-    /**
30
-     * Parameter names managed by this class.
31
-     *
32
-     * @internal
33
-     *
34
-     * @var string[]
35
-     */
36
-    const MANAGED_PARAMS = array(
37
-        /* @formatter:off */
38
-        JWKParameter::PARAM_KEY_TYPE, 
39
-        JWKParameter::PARAM_CURVE, 
40
-        JWKParameter::PARAM_X_COORDINATE, 
41
-        JWKParameter::PARAM_ECC_PRIVATE_KEY
42
-        /* @formatter:on */
43
-    );
29
+	/**
30
+	 * Parameter names managed by this class.
31
+	 *
32
+	 * @internal
33
+	 *
34
+	 * @var string[]
35
+	 */
36
+	const MANAGED_PARAMS = array(
37
+		/* @formatter:off */
38
+		JWKParameter::PARAM_KEY_TYPE, 
39
+		JWKParameter::PARAM_CURVE, 
40
+		JWKParameter::PARAM_X_COORDINATE, 
41
+		JWKParameter::PARAM_ECC_PRIVATE_KEY
42
+		/* @formatter:on */
43
+	);
44 44
     
45
-    /**
46
-     * Constructor.
47
-     *
48
-     * @param JWKParameter ...$params
49
-     * @throws \UnexpectedValueException If missing required parameter
50
-     */
51
-    public function __construct(JWKParameter ...$params)
52
-    {
53
-        parent::__construct(...$params);
54
-        foreach (self::MANAGED_PARAMS as $name) {
55
-            if (!$this->has($name)) {
56
-                throw new \UnexpectedValueException("Missing '$name' parameter.");
57
-            }
58
-        }
59
-        if ($this->keyTypeParameter()->value() != KeyTypeParameter::TYPE_EC) {
60
-            throw new \UnexpectedValueException("Invalid key type.");
61
-        }
62
-        // cast ECC private key parameter to correct class
63
-        $key = JWKParameter::PARAM_ECC_PRIVATE_KEY;
64
-        $this->_parameters[$key] = new ECCPrivateKeyParameter(
65
-            $this->_parameters[$key]->value());
66
-    }
45
+	/**
46
+	 * Constructor.
47
+	 *
48
+	 * @param JWKParameter ...$params
49
+	 * @throws \UnexpectedValueException If missing required parameter
50
+	 */
51
+	public function __construct(JWKParameter ...$params)
52
+	{
53
+		parent::__construct(...$params);
54
+		foreach (self::MANAGED_PARAMS as $name) {
55
+			if (!$this->has($name)) {
56
+				throw new \UnexpectedValueException("Missing '$name' parameter.");
57
+			}
58
+		}
59
+		if ($this->keyTypeParameter()->value() != KeyTypeParameter::TYPE_EC) {
60
+			throw new \UnexpectedValueException("Invalid key type.");
61
+		}
62
+		// cast ECC private key parameter to correct class
63
+		$key = JWKParameter::PARAM_ECC_PRIVATE_KEY;
64
+		$this->_parameters[$key] = new ECCPrivateKeyParameter(
65
+			$this->_parameters[$key]->value());
66
+	}
67 67
     
68
-    /**
69
-     * Initialize from ECPrivateKey.
70
-     *
71
-     * @param ECPrivateKey $pk
72
-     * @throws \UnexpectedValueException
73
-     * @return self
74
-     */
75
-    public static function fromECPrivateKey(ECPrivateKey $pk): self
76
-    {
77
-        if (!$pk->hasNamedCurve()) {
78
-            throw new \UnexpectedValueException("No curve name.");
79
-        }
80
-        $curve = CurveParameter::fromOID($pk->namedCurve());
81
-        $pubkey = $pk->publicKey();
82
-        list($x, $y) = $pubkey->curvePointOctets();
83
-        $xcoord = XCoordinateParameter::fromString($x);
84
-        $ycoord = YCoordinateParameter::fromString($y);
85
-        $priv = ECCPrivateKeyParameter::fromString($pk->privateKeyOctets());
86
-        $key_type = new KeyTypeParameter(KeyTypeParameter::TYPE_EC);
87
-        return new self($key_type, $curve, $xcoord, $ycoord, $priv);
88
-    }
68
+	/**
69
+	 * Initialize from ECPrivateKey.
70
+	 *
71
+	 * @param ECPrivateKey $pk
72
+	 * @throws \UnexpectedValueException
73
+	 * @return self
74
+	 */
75
+	public static function fromECPrivateKey(ECPrivateKey $pk): self
76
+	{
77
+		if (!$pk->hasNamedCurve()) {
78
+			throw new \UnexpectedValueException("No curve name.");
79
+		}
80
+		$curve = CurveParameter::fromOID($pk->namedCurve());
81
+		$pubkey = $pk->publicKey();
82
+		list($x, $y) = $pubkey->curvePointOctets();
83
+		$xcoord = XCoordinateParameter::fromString($x);
84
+		$ycoord = YCoordinateParameter::fromString($y);
85
+		$priv = ECCPrivateKeyParameter::fromString($pk->privateKeyOctets());
86
+		$key_type = new KeyTypeParameter(KeyTypeParameter::TYPE_EC);
87
+		return new self($key_type, $curve, $xcoord, $ycoord, $priv);
88
+	}
89 89
     
90
-    /**
91
-     * Initialize from PEM.
92
-     *
93
-     * @param PEM $pem
94
-     * @return self
95
-     */
96
-    public static function fromPEM(PEM $pem): self
97
-    {
98
-        return self::fromECPrivateKey(ECPrivateKey::fromPEM($pem));
99
-    }
90
+	/**
91
+	 * Initialize from PEM.
92
+	 *
93
+	 * @param PEM $pem
94
+	 * @return self
95
+	 */
96
+	public static function fromPEM(PEM $pem): self
97
+	{
98
+		return self::fromECPrivateKey(ECPrivateKey::fromPEM($pem));
99
+	}
100 100
     
101
-    /**
102
-     * Get the public key component of the EC private key.
103
-     *
104
-     * @return ECPublicKeyJWK
105
-     */
106
-    public function publicKey(): PublicKeyJWK
107
-    {
108
-        $kty = $this->keyTypeParameter();
109
-        $curve = $this->curveParameter();
110
-        $xcoord = $this->XCoordinateParameter();
111
-        $ycoord = $this->YCoordinateParameter();
112
-        return new ECPublicKeyJWK($kty, $curve, $xcoord, $ycoord);
113
-    }
101
+	/**
102
+	 * Get the public key component of the EC private key.
103
+	 *
104
+	 * @return ECPublicKeyJWK
105
+	 */
106
+	public function publicKey(): PublicKeyJWK
107
+	{
108
+		$kty = $this->keyTypeParameter();
109
+		$curve = $this->curveParameter();
110
+		$xcoord = $this->XCoordinateParameter();
111
+		$ycoord = $this->YCoordinateParameter();
112
+		return new ECPublicKeyJWK($kty, $curve, $xcoord, $ycoord);
113
+	}
114 114
     
115
-    /**
116
-     * Convert EC private key to PEM.
117
-     *
118
-     * @return PEM
119
-     */
120
-    public function toPEM(): PEM
121
-    {
122
-        $curve_oid = CurveParameter::nameToOID($this->curveParameter()->value());
123
-        $x = ECConversion::octetsToNumber(
124
-            $this->XCoordinateParameter()->coordinateOctets());
125
-        $y = ECConversion::octetsToNumber(
126
-            $this->YCoordinateParameter()->coordinateOctets());
127
-        $pubkey = ECPublicKey::fromCoordinates($x, $y, $curve_oid);
128
-        $priv = $this->ECCPrivateKeyParameter()->privateKeyOctets();
129
-        $ec = new ECPrivateKey($priv, $curve_oid, $pubkey->ECPoint());
130
-        return $ec->privateKeyInfo()->toPEM();
131
-    }
115
+	/**
116
+	 * Convert EC private key to PEM.
117
+	 *
118
+	 * @return PEM
119
+	 */
120
+	public function toPEM(): PEM
121
+	{
122
+		$curve_oid = CurveParameter::nameToOID($this->curveParameter()->value());
123
+		$x = ECConversion::octetsToNumber(
124
+			$this->XCoordinateParameter()->coordinateOctets());
125
+		$y = ECConversion::octetsToNumber(
126
+			$this->YCoordinateParameter()->coordinateOctets());
127
+		$pubkey = ECPublicKey::fromCoordinates($x, $y, $curve_oid);
128
+		$priv = $this->ECCPrivateKeyParameter()->privateKeyOctets();
129
+		$ec = new ECPrivateKey($priv, $curve_oid, $pubkey->ECPoint());
130
+		return $ec->privateKeyInfo()->toPEM();
131
+	}
132 132
 }
Please login to merge, or discard this patch.