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 ( 1f9c3d...35fc1b )
by sebastian
03:29
created
src/jwk/IAsymmetricJWK.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@
 block discarded – undo
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 jwk;
16 16
 
Please login to merge, or discard this patch.
src/jwk/RSAKeysParameters.php 2 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@
 block discarded – undo
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 jwk;
16 16
 use jwa\JSONWebSignatureAndEncryptionAlgorithms;
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
      */
36 36
     const Exponent = 'e';
37 37
 
38
-    public static $public_key_params = array ( self::Modulus, self::Exponent);
38
+    public static $public_key_params = array(self::Modulus, self::Exponent);
39 39
 
40 40
     /**
41 41
      * The "d" (private exponent) parameter contains the private exponent
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 
80 80
 
81 81
 
82
-    public static $producers_private_key_params = array (
82
+    public static $producers_private_key_params = array(
83 83
         self::FirstPrimeFactor,
84 84
         self::SecondPrimeFactor,
85 85
         self::FirstFactorCRTExponent,
Please login to merge, or discard this patch.
src/jwk/JSONWebKeyKeyOperationsValues.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@
 block discarded – undo
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 jwk;
16 16
 
Please login to merge, or discard this patch.
src/jwk/JSONWebKeyTypes.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@
 block discarded – undo
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 jwk;
16 16
 
Please login to merge, or discard this patch.
src/jwk/impl/OctetSequenceJWK.php 3 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@
 block discarded – undo
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 jwk\impl;
16 16
 
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -40,14 +40,14 @@  discard block
 block discarded – undo
40 40
     protected function __construct(Key $secret, $headers = array())
41 41
     {
42 42
 
43
-        if(empty($secret))
43
+        if (empty($secret))
44 44
             throw new InvalidOctetSequenceJWKException('secret is not set!.');
45 45
 
46 46
         $this->set[JSONWebKeyParameters::KeyType] = new StringOrURI(JSONWebKeyTypes::OctetSequence);
47 47
 
48 48
         parent::__construct($headers);
49 49
 
50
-        if(count($headers) === 0 ) return;
50
+        if (count($headers) === 0) return;
51 51
 
52 52
         $b64 = new Base64UrlRepresentation();
53 53
 
@@ -72,17 +72,17 @@  discard block
 block discarded – undo
72 72
      * @param string $use
73 73
      * @return IJWK
74 74
      */
75
-    static public function fromSecret(Key $key, $alg = null, $use = JSONWebKeyPublicKeyUseValues::Signature){
75
+    static public function fromSecret(Key $key, $alg = null, $use = JSONWebKeyPublicKeyUseValues::Signature) {
76 76
 
77 77
         $headers = array();
78 78
 
79
-        if(!empty($alg)) {
79
+        if (!empty($alg)) {
80 80
 
81 81
             $headers[JSONWebKeyParameters::Algorithm] = $alg;
82 82
         }
83 83
 
84 84
         $headers[JSONWebKeyParameters::PublicKeyUse] = $use;
85 85
 
86
-        return new OctetSequenceJWK($key, $headers) ;
86
+        return new OctetSequenceJWK($key, $headers);
87 87
     }
88 88
 }
89 89
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -40,14 +40,17 @@
 block discarded – undo
40 40
     protected function __construct(Key $secret, $headers = array())
41 41
     {
42 42
 
43
-        if(empty($secret))
44
-            throw new InvalidOctetSequenceJWKException('secret is not set!.');
43
+        if(empty($secret)) {
44
+                    throw new InvalidOctetSequenceJWKException('secret is not set!.');
45
+        }
45 46
 
46 47
         $this->set[JSONWebKeyParameters::KeyType] = new StringOrURI(JSONWebKeyTypes::OctetSequence);
47 48
 
48 49
         parent::__construct($headers);
49 50
 
50
-        if(count($headers) === 0 ) return;
51
+        if(count($headers) === 0 ) {
52
+         return;
53
+        }
51 54
 
52 55
         $b64 = new Base64UrlRepresentation();
53 56
 
Please login to merge, or discard this patch.
src/jwk/impl/JWKSpecification.php 2 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@
 block discarded – undo
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 jwk\impl;
16 16
 
Please login to merge, or discard this patch.
Spacing   +2 added lines, -3 removed lines patch added patch discarded remove patch
@@ -46,8 +46,7 @@  discard block
 block discarded – undo
46 46
      * @param string $use
47 47
      * @param null|string $kid
48 48
      */
49
-    public function __construct
50
-    (
49
+    public function __construct(
51 50
         $alg = JSONWebSignatureAndEncryptionAlgorithms::RS256,
52 51
         $use = JSONWebKeyPublicKeyUseValues::Signature,
53 52
         $kid = null
@@ -58,7 +57,7 @@  discard block
 block discarded – undo
58 57
         $this->kid  = $kid;
59 58
     }
60 59
 
61
-    public function getAlg(){
60
+    public function getAlg() {
62 61
         return $this->alg;
63 62
     }
64 63
 
Please login to merge, or discard this patch.
src/jwk/impl/RSAJWKPEMPrivateKeySpecification.php 2 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@
 block discarded – undo
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 jwk\impl;
16 16
 
Please login to merge, or discard this patch.
Spacing   +2 added lines, -3 removed lines patch added patch discarded remove patch
@@ -36,15 +36,14 @@
 block discarded – undo
36 36
      * @param string $alg
37 37
      * @param string $use
38 38
      */
39
-    public function __construct
40
-    (
39
+    public function __construct(
41 40
         $key_pem,
42 41
         $password = self::WithoutPassword,
43 42
         $alg = JSONWebSignatureAndEncryptionAlgorithms::RS256,
44 43
         $use = JSONWebKeyPublicKeyUseValues::Signature
45 44
     )
46 45
     {
47
-        parent::__construct($key_pem , $alg, $use);
46
+        parent::__construct($key_pem, $alg, $use);
48 47
         $this->password = $password;
49 48
     }
50 49
     /**
Please login to merge, or discard this patch.
src/jwk/impl/OctetSequenceJWKFactory.php 3 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@
 block discarded – undo
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 jwk\impl;
16 16
 
Please login to merge, or discard this patch.
Spacing   +15 added lines, -23 removed lines patch added patch discarded remove patch
@@ -41,28 +41,24 @@  discard block
 block discarded – undo
41 41
     static public function build(IJWKSpecification $spec)
42 42
     {
43 43
 
44
-        if(is_null($spec)) throw new \InvalidArgumentException('missing spec param');
44
+        if (is_null($spec)) throw new \InvalidArgumentException('missing spec param');
45 45
 
46
-        $algorithm = DigitalSignatures_MACs_Registry::getInstance()->get
47
-        (
46
+        $algorithm = DigitalSignatures_MACs_Registry::getInstance()->get(
48 47
             $spec->getAlg()
49 48
         );
50 49
 
51
-        if(is_null($algorithm))
52
-            $algorithm = ContentEncryptionAlgorithms_Registry::getInstance()->get
53
-            (
50
+        if (is_null($algorithm))
51
+            $algorithm = ContentEncryptionAlgorithms_Registry::getInstance()->get(
54 52
                 $spec->getAlg()
55 53
             );
56 54
 
57
-        if(is_null($algorithm))
58
-            $algorithm = KeyManagementAlgorithms_Registry::getInstance()->get
59
-            (
55
+        if (is_null($algorithm))
56
+            $algorithm = KeyManagementAlgorithms_Registry::getInstance()->get(
60 57
                 $spec->getAlg()
61 58
             );
62 59
 
63
-        if(is_null($algorithm))
64
-            throw new InvalidJWKAlgorithm
65
-            (
60
+        if (is_null($algorithm))
61
+            throw new InvalidJWKAlgorithm(
66 62
                 sprintf(
67 63
                     'alg %s not supported!',
68 64
                     $spec->getAlg()
@@ -70,31 +66,27 @@  discard block
 block discarded – undo
70 66
             );
71 67
 
72 68
 
73
-        if($algorithm->getKeyType() !== JSONWebKeyTypes::OctetSequence)
74
-            throw new InvalidJWKAlgorithm
75
-            (
76
-                sprintf
77
-                (
69
+        if ($algorithm->getKeyType() !== JSONWebKeyTypes::OctetSequence)
70
+            throw new InvalidJWKAlgorithm(
71
+                sprintf(
78 72
                     'key type %s not supported!',
79 73
                     $algorithm->getKeyType()
80 74
                 )
81 75
             );
82 76
 
83
-        if(!($spec instanceof OctetSequenceJWKSpecification)) throw new JWKInvalidSpecException;
77
+        if (!($spec instanceof OctetSequenceJWKSpecification)) throw new JWKInvalidSpecException;
84 78
 
85 79
         $shared_secret = $spec->getSharedSecret();
86 80
         $secret_len    = strlen($shared_secret);
87 81
 
88
-        if($secret_len === 0 )
82
+        if ($secret_len === 0)
89 83
         {
90 84
             $generator = Utils_Registry::getInstance()->get(Utils_Registry::RandomNumberGeneratorService);
91 85
             $shared_secret = $generator->invoke($algorithm->getMinKeyLen() / 8);
92 86
         }
93 87
 
94
-        return OctetSequenceJWK::fromSecret
95
-        (
96
-            new SymmetricSharedKey
97
-            (
88
+        return OctetSequenceJWK::fromSecret(
89
+            new SymmetricSharedKey(
98 90
                 $shared_secret
99 91
             ),
100 92
             $spec->getAlg(),
Please login to merge, or discard this patch.
Braces   +18 added lines, -10 removed lines patch added patch discarded remove patch
@@ -41,37 +41,42 @@  discard block
 block discarded – undo
41 41
     static public function build(IJWKSpecification $spec)
42 42
     {
43 43
 
44
-        if(is_null($spec)) throw new \InvalidArgumentException('missing spec param');
44
+        if(is_null($spec)) {
45
+         throw new \InvalidArgumentException('missing spec param');
46
+        }
45 47
 
46 48
         $algorithm = DigitalSignatures_MACs_Registry::getInstance()->get
47 49
         (
48 50
             $spec->getAlg()
49 51
         );
50 52
 
51
-        if(is_null($algorithm))
52
-            $algorithm = ContentEncryptionAlgorithms_Registry::getInstance()->get
53
+        if(is_null($algorithm)) {
54
+                    $algorithm = ContentEncryptionAlgorithms_Registry::getInstance()->get
53 55
             (
54 56
                 $spec->getAlg()
55 57
             );
58
+        }
56 59
 
57
-        if(is_null($algorithm))
58
-            $algorithm = KeyManagementAlgorithms_Registry::getInstance()->get
60
+        if(is_null($algorithm)) {
61
+                    $algorithm = KeyManagementAlgorithms_Registry::getInstance()->get
59 62
             (
60 63
                 $spec->getAlg()
61 64
             );
65
+        }
62 66
 
63
-        if(is_null($algorithm))
64
-            throw new InvalidJWKAlgorithm
67
+        if(is_null($algorithm)) {
68
+                    throw new InvalidJWKAlgorithm
65 69
             (
66 70
                 sprintf(
67 71
                     'alg %s not supported!',
68 72
                     $spec->getAlg()
69 73
                 )
70 74
             );
75
+        }
71 76
 
72 77
 
73
-        if($algorithm->getKeyType() !== JSONWebKeyTypes::OctetSequence)
74
-            throw new InvalidJWKAlgorithm
78
+        if($algorithm->getKeyType() !== JSONWebKeyTypes::OctetSequence) {
79
+                    throw new InvalidJWKAlgorithm
75 80
             (
76 81
                 sprintf
77 82
                 (
@@ -79,8 +84,11 @@  discard block
 block discarded – undo
79 84
                     $algorithm->getKeyType()
80 85
                 )
81 86
             );
87
+        }
82 88
 
83
-        if(!($spec instanceof OctetSequenceJWKSpecification)) throw new JWKInvalidSpecException;
89
+        if(!($spec instanceof OctetSequenceJWKSpecification)) {
90
+         throw new JWKInvalidSpecException;
91
+        }
84 92
 
85 93
         $shared_secret = $spec->getSharedSecret();
86 94
         $secret_len    = strlen($shared_secret);
Please login to merge, or discard this patch.
src/jwk/impl/JWKSet.php 3 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@
 block discarded – undo
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 jwk\impl;
16 16
 
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -42,11 +42,11 @@  discard block
 block discarded – undo
42 42
      * @param JWK[] $keys
43 43
      * @throws JWKInvalidIdentifierException
44 44
      */
45
-    public function __construct(array $keys = array()){
45
+    public function __construct(array $keys = array()) {
46 46
 
47 47
         $this->set[JWKSetParameters::Keys] = new JsonArray(array());
48 48
 
49
-        foreach($keys as $k){
49
+        foreach ($keys as $k) {
50 50
             $this->addKey($k);
51 51
         }
52 52
     }
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
      */
57 57
     public function getKeys()
58 58
     {
59
-        if(isset($this->set[JWKSetParameters::Keys]))
59
+        if (isset($this->set[JWKSetParameters::Keys]))
60 60
             return $this->set[JWKSetParameters::Keys]->getValue();
61 61
         return array();
62 62
     }
@@ -70,18 +70,18 @@  discard block
 block discarded – undo
70 70
     {
71 71
         $id = $key->getId();
72 72
 
73
-        if(empty($id))
73
+        if (empty($id))
74 74
             throw new JWKInvalidIdentifierException('key id is empty!');
75 75
 
76
-        if(array_key_exists($id->getValue(), $this->keys_ids))
76
+        if (array_key_exists($id->getValue(), $this->keys_ids))
77 77
             throw new JWKInvalidIdentifierException(sprintf('id %s already exists!'), $key->getId()->getValue());
78 78
 
79
-        if(!isset($this->set[JWKSetParameters::Keys]))
79
+        if (!isset($this->set[JWKSetParameters::Keys]))
80 80
             $this->set[JWKSetParameters::Keys] = new JsonArray(array());
81 81
 
82 82
         $keys = $this->set[JWKSetParameters::Keys];
83 83
         $keys->append($key);
84
-        $this->set[JWKSetParameters::Keys] = $keys ;
84
+        $this->set[JWKSetParameters::Keys] = $keys;
85 85
         $this->keys_ids[$id->getValue()] = $key;
86 86
     }
87 87
 
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
      */
92 92
     public function getKeyById($kid)
93 93
     {
94
-        if(!array_key_exists($kid, $this->keys_ids)) return null;
94
+        if (!array_key_exists($kid, $this->keys_ids)) return null;
95 95
         return $this->keys_ids[$kid];
96 96
     }
97 97
 
@@ -101,27 +101,27 @@  discard block
 block discarded – undo
101 101
      * @throws InvalidJWKAlgorithm
102 102
      * @throws JWKInvalidIdentifierException
103 103
      */
104
-    static public function fromJson($json){
105
-        $json = str_replace( array("\n","\r","\t"), '', trim($json));
104
+    static public function fromJson($json) {
105
+        $json = str_replace(array("\n", "\r", "\t"), '', trim($json));
106 106
         $res  = json_decode($json, true);
107
-        if(!isset($res[JWKSetParameters::Keys])) throw new JWKInvalidIdentifierException;
107
+        if (!isset($res[JWKSetParameters::Keys])) throw new JWKInvalidIdentifierException;
108 108
         $keys = $res[JWKSetParameters::Keys];
109 109
         $jwk_set = new JWKSet;
110
-        foreach($keys as $key){
110
+        foreach ($keys as $key) {
111 111
             $kty = @$key[JSONWebKeyParameters::KeyType];
112 112
             $kid = @$key[JSONWebKeyParameters::KeyId];
113 113
             $use = @$key[JSONWebKeyParameters::PublicKeyUse];
114 114
             $alg = @$key[JSONWebKeyParameters::Algorithm];
115
-            if(empty($alg)) $alg = JSONWebSignatureAndEncryptionAlgorithms::RS256;
115
+            if (empty($alg)) $alg = JSONWebSignatureAndEncryptionAlgorithms::RS256;
116 116
 
117
-            if(empty($kty) || empty($kid) || empty($use)) continue;
117
+            if (empty($kty) || empty($kid) || empty($use)) continue;
118 118
 
119
-            if(!in_array($kty, JSONWebKeyTypes::$supported_keys)) continue;
119
+            if (!in_array($kty, JSONWebKeyTypes::$supported_keys)) continue;
120 120
 
121 121
             $n        = @$key[RSAKeysParameters::Modulus];
122 122
             $e        = @$key[RSAKeysParameters::Exponent];
123 123
             $x5c      = @$key[PublicJSONWebKeyParameters::X_509CertificateChain];
124
-            if(is_null($x5c)) $x5c = array();
124
+            if (is_null($x5c)) $x5c = array();
125 125
             $x5u      = @$key[PublicJSONWebKeyParameters::X_509Url];
126 126
             $x5t      = @$key[PublicJSONWebKeyParameters::X_509CertificateSHA_1_Thumbprint];
127 127
             $x5t_S256 = @$key[PublicJSONWebKeyParameters::X_509CertificateSHA_256_Thumbprint];
Please login to merge, or discard this patch.
Braces   +30 added lines, -14 removed lines patch added patch discarded remove patch
@@ -56,8 +56,9 @@  discard block
 block discarded – undo
56 56
      */
57 57
     public function getKeys()
58 58
     {
59
-        if(isset($this->set[JWKSetParameters::Keys]))
60
-            return $this->set[JWKSetParameters::Keys]->getValue();
59
+        if(isset($this->set[JWKSetParameters::Keys])) {
60
+                    return $this->set[JWKSetParameters::Keys]->getValue();
61
+        }
61 62
         return array();
62 63
     }
63 64
 
@@ -70,14 +71,17 @@  discard block
 block discarded – undo
70 71
     {
71 72
         $id = $key->getId();
72 73
 
73
-        if(empty($id))
74
-            throw new JWKInvalidIdentifierException('key id is empty!');
74
+        if(empty($id)) {
75
+                    throw new JWKInvalidIdentifierException('key id is empty!');
76
+        }
75 77
 
76
-        if(array_key_exists($id->getValue(), $this->keys_ids))
77
-            throw new JWKInvalidIdentifierException(sprintf('id %s already exists!'), $key->getId()->getValue());
78
+        if(array_key_exists($id->getValue(), $this->keys_ids)) {
79
+                    throw new JWKInvalidIdentifierException(sprintf('id %s already exists!'), $key->getId()->getValue());
80
+        }
78 81
 
79
-        if(!isset($this->set[JWKSetParameters::Keys]))
80
-            $this->set[JWKSetParameters::Keys] = new JsonArray(array());
82
+        if(!isset($this->set[JWKSetParameters::Keys])) {
83
+                    $this->set[JWKSetParameters::Keys] = new JsonArray(array());
84
+        }
81 85
 
82 86
         $keys = $this->set[JWKSetParameters::Keys];
83 87
         $keys->append($key);
@@ -91,7 +95,9 @@  discard block
 block discarded – undo
91 95
      */
92 96
     public function getKeyById($kid)
93 97
     {
94
-        if(!array_key_exists($kid, $this->keys_ids)) return null;
98
+        if(!array_key_exists($kid, $this->keys_ids)) {
99
+         return null;
100
+        }
95 101
         return $this->keys_ids[$kid];
96 102
     }
97 103
 
@@ -104,7 +110,9 @@  discard block
 block discarded – undo
104 110
     static public function fromJson($json){
105 111
         $json = str_replace( array("\n","\r","\t"), '', trim($json));
106 112
         $res  = json_decode($json, true);
107
-        if(!isset($res[JWKSetParameters::Keys])) throw new JWKInvalidIdentifierException;
113
+        if(!isset($res[JWKSetParameters::Keys])) {
114
+         throw new JWKInvalidIdentifierException;
115
+        }
108 116
         $keys = $res[JWKSetParameters::Keys];
109 117
         $jwk_set = new JWKSet;
110 118
         foreach($keys as $key){
@@ -112,16 +120,24 @@  discard block
 block discarded – undo
112 120
             $kid = @$key[JSONWebKeyParameters::KeyId];
113 121
             $use = @$key[JSONWebKeyParameters::PublicKeyUse];
114 122
             $alg = @$key[JSONWebKeyParameters::Algorithm];
115
-            if(empty($alg)) $alg = JSONWebSignatureAndEncryptionAlgorithms::RS256;
123
+            if(empty($alg)) {
124
+             $alg = JSONWebSignatureAndEncryptionAlgorithms::RS256;
125
+            }
116 126
 
117
-            if(empty($kty) || empty($kid) || empty($use)) continue;
127
+            if(empty($kty) || empty($kid) || empty($use)) {
128
+             continue;
129
+            }
118 130
 
119
-            if(!in_array($kty, JSONWebKeyTypes::$supported_keys)) continue;
131
+            if(!in_array($kty, JSONWebKeyTypes::$supported_keys)) {
132
+             continue;
133
+            }
120 134
 
121 135
             $n        = @$key[RSAKeysParameters::Modulus];
122 136
             $e        = @$key[RSAKeysParameters::Exponent];
123 137
             $x5c      = @$key[PublicJSONWebKeyParameters::X_509CertificateChain];
124
-            if(is_null($x5c)) $x5c = array();
138
+            if(is_null($x5c)) {
139
+             $x5c = array();
140
+            }
125 141
             $x5u      = @$key[PublicJSONWebKeyParameters::X_509Url];
126 142
             $x5t      = @$key[PublicJSONWebKeyParameters::X_509CertificateSHA_1_Thumbprint];
127 143
             $x5t_S256 = @$key[PublicJSONWebKeyParameters::X_509CertificateSHA_256_Thumbprint];
Please login to merge, or discard this patch.