@@ -1,16 +1,16 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Copyright 2015 OpenStack Foundation |
|
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 | - * you may not use this file except in compliance with the License. |
|
6 | - * You may obtain a copy of the License at |
|
7 | - * http://www.apache.org/licenses/LICENSE-2.0 |
|
8 | - * Unless required by applicable law or agreed to in writing, software |
|
9 | - * distributed under the License is distributed on an "AS IS" BASIS, |
|
10 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
11 | - * See the License for the specific language governing permissions and |
|
12 | - * limitations under the License. |
|
13 | - **/ |
|
3 | + * Copyright 2015 OpenStack Foundation |
|
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 | + * you may not use this file except in compliance with the License. |
|
6 | + * You may obtain a copy of the License at |
|
7 | + * http://www.apache.org/licenses/LICENSE-2.0 |
|
8 | + * Unless required by applicable law or agreed to in writing, software |
|
9 | + * distributed under the License is distributed on an "AS IS" BASIS, |
|
10 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
11 | + * See the License for the specific language governing permissions and |
|
12 | + * limitations under the License. |
|
13 | + **/ |
|
14 | 14 | |
15 | 15 | namespace jwt\utils; |
16 | 16 |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | */ |
26 | 26 | class JOSEHeaderFactory { |
27 | 27 | |
28 | - static protected function getProductClass(){ |
|
28 | + static protected function getProductClass() { |
|
29 | 29 | return '\jwt\impl\JOSEHeader'; |
30 | 30 | } |
31 | 31 | |
@@ -38,12 +38,12 @@ discard block |
||
38 | 38 | |
39 | 39 | $args = array(); |
40 | 40 | |
41 | - foreach(RegisteredJOSEHeaderNames::$registered_basic_headers_set as $header_name){ |
|
41 | + foreach (RegisteredJOSEHeaderNames::$registered_basic_headers_set as $header_name) { |
|
42 | 42 | $value = isset($raw_headers[$header_name]) ? $raw_headers[$header_name] : null; |
43 | 43 | $type = @RegisteredJOSEHeaderNames::$registered_basic_headers_set_types[$header_name]; |
44 | - if(!is_null($value)) |
|
44 | + if (!is_null($value)) |
|
45 | 45 | { |
46 | - if(is_null($type)) continue; |
|
46 | + if (is_null($type)) continue; |
|
47 | 47 | $class = new \ReflectionClass($type); |
48 | 48 | $value = $class->newInstanceArgs(array($value)); |
49 | 49 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | |
58 | 58 | // unregistered headers |
59 | 59 | |
60 | - foreach($raw_headers as $k => $v){ |
|
60 | + foreach ($raw_headers as $k => $v) { |
|
61 | 61 | $basic_header->addHeader(new JOSEHeaderParam($k, new JsonValue($v))); |
62 | 62 | } |
63 | 63 |
@@ -43,7 +43,9 @@ |
||
43 | 43 | $type = @RegisteredJOSEHeaderNames::$registered_basic_headers_set_types[$header_name]; |
44 | 44 | if(!is_null($value)) |
45 | 45 | { |
46 | - if(is_null($type)) continue; |
|
46 | + if(is_null($type)) { |
|
47 | + continue; |
|
48 | + } |
|
47 | 49 | $class = new \ReflectionClass($type); |
48 | 50 | $value = $class->newInstanceArgs(array($value)); |
49 | 51 | } |
@@ -1,16 +1,16 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Copyright 2015 OpenStack Foundation |
|
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 | - * you may not use this file except in compliance with the License. |
|
6 | - * You may obtain a copy of the License at |
|
7 | - * http://www.apache.org/licenses/LICENSE-2.0 |
|
8 | - * Unless required by applicable law or agreed to in writing, software |
|
9 | - * distributed under the License is distributed on an "AS IS" BASIS, |
|
10 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
11 | - * See the License for the specific language governing permissions and |
|
12 | - * limitations under the License. |
|
13 | - **/ |
|
3 | + * Copyright 2015 OpenStack Foundation |
|
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 | + * you may not use this file except in compliance with the License. |
|
6 | + * You may obtain a copy of the License at |
|
7 | + * http://www.apache.org/licenses/LICENSE-2.0 |
|
8 | + * Unless required by applicable law or agreed to in writing, software |
|
9 | + * distributed under the License is distributed on an "AS IS" BASIS, |
|
10 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
11 | + * See the License for the specific language governing permissions and |
|
12 | + * limitations under the License. |
|
13 | + **/ |
|
14 | 14 | |
15 | 15 | namespace jwt\utils; |
16 | 16 | use jwt\IJWTClaimSet; |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * @param IJWTClaimSet $claim_set |
27 | 27 | * @return string |
28 | 28 | */ |
29 | - public static function serialize(IJWTClaimSet $claim_set){ |
|
29 | + public static function serialize(IJWTClaimSet $claim_set) { |
|
30 | 30 | $json = $claim_set->toJson(); |
31 | 31 | return JWTRawSerializer::serialize($json); |
32 | 32 | } |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * @param $input |
36 | 36 | * @return IJWTClaimSet |
37 | 37 | */ |
38 | - public static function deserialize($input){ |
|
38 | + public static function deserialize($input) { |
|
39 | 39 | $json = JWTRawSerializer::deserialize($input); |
40 | 40 | $raw_claims = json_decode($json, true); |
41 | 41 |
@@ -203,17 +203,15 @@ |
||
203 | 203 | const Critical = 'crit'; |
204 | 204 | |
205 | 205 | |
206 | - public static $registered_basic_headers_set = array |
|
207 | - ( |
|
206 | + public static $registered_basic_headers_set = array( |
|
208 | 207 | self::Algorithm, |
209 | 208 | self::Type, |
210 | 209 | self::KeyID, |
211 | 210 | self::ContentType, |
212 | 211 | ); |
213 | 212 | |
214 | - public static $registered_basic_headers_set_types = array |
|
215 | - ( |
|
216 | - self::Algorithm => JsonTypes::StringOrURI , |
|
213 | + public static $registered_basic_headers_set_types = array( |
|
214 | + self::Algorithm => JsonTypes::StringOrURI, |
|
217 | 215 | self::Type => JsonTypes::StringOrURI, |
218 | 216 | self::ContentType => JsonTypes::StringOrURI, |
219 | 217 | self::KeyID => JsonTypes::JsonValue |
@@ -1,16 +1,16 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Copyright 2015 OpenStack Foundation |
|
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 | - * you may not use this file except in compliance with the License. |
|
6 | - * You may obtain a copy of the License at |
|
7 | - * http://www.apache.org/licenses/LICENSE-2.0 |
|
8 | - * Unless required by applicable law or agreed to in writing, software |
|
9 | - * distributed under the License is distributed on an "AS IS" BASIS, |
|
10 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
11 | - * See the License for the specific language governing permissions and |
|
12 | - * limitations under the License. |
|
13 | - **/ |
|
3 | + * Copyright 2015 OpenStack Foundation |
|
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 | + * you may not use this file except in compliance with the License. |
|
6 | + * You may obtain a copy of the License at |
|
7 | + * http://www.apache.org/licenses/LICENSE-2.0 |
|
8 | + * Unless required by applicable law or agreed to in writing, software |
|
9 | + * distributed under the License is distributed on an "AS IS" BASIS, |
|
10 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
11 | + * See the License for the specific language governing permissions and |
|
12 | + * limitations under the License. |
|
13 | + **/ |
|
14 | 14 | |
15 | 15 | namespace jwt; |
16 | 16 | /** |
@@ -1,16 +1,16 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Copyright 2015 OpenStack Foundation |
|
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 | - * you may not use this file except in compliance with the License. |
|
6 | - * You may obtain a copy of the License at |
|
7 | - * http://www.apache.org/licenses/LICENSE-2.0 |
|
8 | - * Unless required by applicable law or agreed to in writing, software |
|
9 | - * distributed under the License is distributed on an "AS IS" BASIS, |
|
10 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
11 | - * See the License for the specific language governing permissions and |
|
12 | - * limitations under the License. |
|
13 | - **/ |
|
3 | + * Copyright 2015 OpenStack Foundation |
|
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 | + * you may not use this file except in compliance with the License. |
|
6 | + * You may obtain a copy of the License at |
|
7 | + * http://www.apache.org/licenses/LICENSE-2.0 |
|
8 | + * Unless required by applicable law or agreed to in writing, software |
|
9 | + * distributed under the License is distributed on an "AS IS" BASIS, |
|
10 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
11 | + * See the License for the specific language governing permissions and |
|
12 | + * limitations under the License. |
|
13 | + **/ |
|
14 | 14 | |
15 | 15 | namespace jws; |
16 | 16 |
@@ -1,16 +1,16 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Copyright 2015 OpenStack Foundation |
|
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 | - * you may not use this file except in compliance with the License. |
|
6 | - * You may obtain a copy of the License at |
|
7 | - * http://www.apache.org/licenses/LICENSE-2.0 |
|
8 | - * Unless required by applicable law or agreed to in writing, software |
|
9 | - * distributed under the License is distributed on an "AS IS" BASIS, |
|
10 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
11 | - * See the License for the specific language governing permissions and |
|
12 | - * limitations under the License. |
|
13 | - **/ |
|
3 | + * Copyright 2015 OpenStack Foundation |
|
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 | + * you may not use this file except in compliance with the License. |
|
6 | + * You may obtain a copy of the License at |
|
7 | + * http://www.apache.org/licenses/LICENSE-2.0 |
|
8 | + * Unless required by applicable law or agreed to in writing, software |
|
9 | + * distributed under the License is distributed on an "AS IS" BASIS, |
|
10 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
11 | + * See the License for the specific language governing permissions and |
|
12 | + * limitations under the License. |
|
13 | + **/ |
|
14 | 14 | |
15 | 15 | namespace jws; |
16 | 16 |
@@ -1,16 +1,16 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Copyright 2015 OpenStack Foundation |
|
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 | - * you may not use this file except in compliance with the License. |
|
6 | - * You may obtain a copy of the License at |
|
7 | - * http://www.apache.org/licenses/LICENSE-2.0 |
|
8 | - * Unless required by applicable law or agreed to in writing, software |
|
9 | - * distributed under the License is distributed on an "AS IS" BASIS, |
|
10 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
11 | - * See the License for the specific language governing permissions and |
|
12 | - * limitations under the License. |
|
13 | - **/ |
|
3 | + * Copyright 2015 OpenStack Foundation |
|
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 | + * you may not use this file except in compliance with the License. |
|
6 | + * You may obtain a copy of the License at |
|
7 | + * http://www.apache.org/licenses/LICENSE-2.0 |
|
8 | + * Unless required by applicable law or agreed to in writing, software |
|
9 | + * distributed under the License is distributed on an "AS IS" BASIS, |
|
10 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
11 | + * See the License for the specific language governing permissions and |
|
12 | + * limitations under the License. |
|
13 | + **/ |
|
14 | 14 | |
15 | 15 | namespace jws; |
16 | 16 |
@@ -39,31 +39,26 @@ discard block |
||
39 | 39 | static public function build(IJWS_Specification $spec) |
40 | 40 | { |
41 | 41 | |
42 | - if($spec instanceof IJWS_ParamsSpecification) |
|
42 | + if ($spec instanceof IJWS_ParamsSpecification) |
|
43 | 43 | { |
44 | - if($spec->getKey()->getKeyUse()->getString() !== JSONWebKeyPublicKeyUseValues::Signature) |
|
45 | - throw new InvalidJWKType |
|
46 | - ( |
|
47 | - sprintf |
|
48 | - ( |
|
44 | + if ($spec->getKey()->getKeyUse()->getString() !== JSONWebKeyPublicKeyUseValues::Signature) |
|
45 | + throw new InvalidJWKType( |
|
46 | + sprintf( |
|
49 | 47 | 'use % not supported (sig)', |
50 | 48 | $spec->getKey()->getKeyUse()->getString() |
51 | 49 | ) |
52 | 50 | ); |
53 | 51 | |
54 | - if($spec->getAlg()->getString() !== $spec->getKey()->getAlgorithm()->getString()) |
|
55 | - throw new InvalidJWKAlgorithm |
|
56 | - ( |
|
57 | - sprintf |
|
58 | - ( |
|
52 | + if ($spec->getAlg()->getString() !== $spec->getKey()->getAlgorithm()->getString()) |
|
53 | + throw new InvalidJWKAlgorithm( |
|
54 | + sprintf( |
|
59 | 55 | 'mismatch between algorithm intended for use with the key %s and the cryptographic algorithm used to secure the JWS %s', |
60 | 56 | $spec->getAlg()->getString(), |
61 | 57 | $spec->getKey()->getAlgorithm()->getString() |
62 | 58 | ) |
63 | 59 | ); |
64 | 60 | |
65 | - $header = new JOSEHeader |
|
66 | - ( |
|
61 | + $header = new JOSEHeader( |
|
67 | 62 | $spec->getAlg(), |
68 | 63 | new StringOrURI('JWT'), |
69 | 64 | $spec->getKey()->getId() |
@@ -73,7 +68,7 @@ discard block |
||
73 | 68 | $jws->setKey($spec->getKey()); |
74 | 69 | return $jws; |
75 | 70 | } |
76 | - if($spec instanceof IJWS_CompactFormatSpecification) |
|
71 | + if ($spec instanceof IJWS_CompactFormatSpecification) |
|
77 | 72 | { |
78 | 73 | return JWS::fromCompactSerialization($spec->getCompactFormat()); |
79 | 74 | } |
@@ -41,8 +41,8 @@ discard block |
||
41 | 41 | |
42 | 42 | if($spec instanceof IJWS_ParamsSpecification) |
43 | 43 | { |
44 | - if($spec->getKey()->getKeyUse()->getString() !== JSONWebKeyPublicKeyUseValues::Signature) |
|
45 | - throw new InvalidJWKType |
|
44 | + if($spec->getKey()->getKeyUse()->getString() !== JSONWebKeyPublicKeyUseValues::Signature) { |
|
45 | + throw new InvalidJWKType |
|
46 | 46 | ( |
47 | 47 | sprintf |
48 | 48 | ( |
@@ -50,9 +50,10 @@ discard block |
||
50 | 50 | $spec->getKey()->getKeyUse()->getString() |
51 | 51 | ) |
52 | 52 | ); |
53 | + } |
|
53 | 54 | |
54 | - if($spec->getAlg()->getString() !== $spec->getKey()->getAlgorithm()->getString()) |
|
55 | - throw new InvalidJWKAlgorithm |
|
55 | + if($spec->getAlg()->getString() !== $spec->getKey()->getAlgorithm()->getString()) { |
|
56 | + throw new InvalidJWKAlgorithm |
|
56 | 57 | ( |
57 | 58 | sprintf |
58 | 59 | ( |
@@ -61,6 +62,7 @@ discard block |
||
61 | 62 | $spec->getKey()->getAlgorithm()->getString() |
62 | 63 | ) |
63 | 64 | ); |
65 | + } |
|
64 | 66 | |
65 | 67 | $header = new JOSEHeader |
66 | 68 | ( |
@@ -1,16 +1,16 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Copyright 2015 OpenStack Foundation |
|
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 | - * you may not use this file except in compliance with the License. |
|
6 | - * You may obtain a copy of the License at |
|
7 | - * http://www.apache.org/licenses/LICENSE-2.0 |
|
8 | - * Unless required by applicable law or agreed to in writing, software |
|
9 | - * distributed under the License is distributed on an "AS IS" BASIS, |
|
10 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
11 | - * See the License for the specific language governing permissions and |
|
12 | - * limitations under the License. |
|
13 | - **/ |
|
3 | + * Copyright 2015 OpenStack Foundation |
|
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 | + * you may not use this file except in compliance with the License. |
|
6 | + * You may obtain a copy of the License at |
|
7 | + * http://www.apache.org/licenses/LICENSE-2.0 |
|
8 | + * Unless required by applicable law or agreed to in writing, software |
|
9 | + * distributed under the License is distributed on an "AS IS" BASIS, |
|
10 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
11 | + * See the License for the specific language governing permissions and |
|
12 | + * limitations under the License. |
|
13 | + **/ |
|
14 | 14 | |
15 | 15 | namespace jws\impl\specs; |
16 | 16 |
@@ -54,12 +54,12 @@ |
||
54 | 54 | * @throws InvalidJWKType |
55 | 55 | * @throws JWSInvalidPayloadException |
56 | 56 | */ |
57 | - public function __construct(IJWK $key, StringOrURI $alg, $payload, $signature = ''){ |
|
57 | + public function __construct(IJWK $key, StringOrURI $alg, $payload, $signature = '') { |
|
58 | 58 | |
59 | - if(is_null($key)) |
|
59 | + if (is_null($key)) |
|
60 | 60 | throw new InvalidJWKType(); |
61 | 61 | |
62 | - if(is_null($payload)) |
|
62 | + if (is_null($payload)) |
|
63 | 63 | throw new JWSInvalidPayloadException('missing payload'); |
64 | 64 | |
65 | 65 | $this->key = $key; |
@@ -56,11 +56,13 @@ |
||
56 | 56 | */ |
57 | 57 | public function __construct(IJWK $key, StringOrURI $alg, $payload, $signature = ''){ |
58 | 58 | |
59 | - if(is_null($key)) |
|
60 | - throw new InvalidJWKType(); |
|
59 | + if(is_null($key)) { |
|
60 | + throw new InvalidJWKType(); |
|
61 | + } |
|
61 | 62 | |
62 | - if(is_null($payload)) |
|
63 | - throw new JWSInvalidPayloadException('missing payload'); |
|
63 | + if(is_null($payload)) { |
|
64 | + throw new JWSInvalidPayloadException('missing payload'); |
|
65 | + } |
|
64 | 66 | |
65 | 67 | $this->key = $key; |
66 | 68 | $this->alg = $alg; |
@@ -1,16 +1,16 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Copyright 2015 OpenStack Foundation |
|
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 | - * you may not use this file except in compliance with the License. |
|
6 | - * You may obtain a copy of the License at |
|
7 | - * http://www.apache.org/licenses/LICENSE-2.0 |
|
8 | - * Unless required by applicable law or agreed to in writing, software |
|
9 | - * distributed under the License is distributed on an "AS IS" BASIS, |
|
10 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
11 | - * See the License for the specific language governing permissions and |
|
12 | - * limitations under the License. |
|
13 | - **/ |
|
3 | + * Copyright 2015 OpenStack Foundation |
|
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 | + * you may not use this file except in compliance with the License. |
|
6 | + * You may obtain a copy of the License at |
|
7 | + * http://www.apache.org/licenses/LICENSE-2.0 |
|
8 | + * Unless required by applicable law or agreed to in writing, software |
|
9 | + * distributed under the License is distributed on an "AS IS" BASIS, |
|
10 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
11 | + * See the License for the specific language governing permissions and |
|
12 | + * limitations under the License. |
|
13 | + **/ |
|
14 | 14 | |
15 | 15 | namespace jws\impl\specs; |
16 | 16 |
@@ -31,7 +31,7 @@ |
||
31 | 31 | /** |
32 | 32 | * @param string $compact_format |
33 | 33 | */ |
34 | - public function __construct($compact_format){ |
|
34 | + public function __construct($compact_format) { |
|
35 | 35 | $this->compact_format = $compact_format; |
36 | 36 | } |
37 | 37 |