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 ( 356550...41f07f )
by sebastian
03:01
created
src/jwt/utils/JWTClaimSetSerializer.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/jwt/RegisteredJOSEHeaderNames.php 2 patches
Spacing   +3 added lines, -5 removed lines patch added patch discarded remove patch
@@ -203,17 +203,15 @@
 block discarded – undo
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
Please login to merge, or discard this 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/jws/JWSFactory.php 3 patches
Spacing   +9 added lines, -14 removed lines patch added patch discarded remove patch
@@ -39,31 +39,26 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -41,8 +41,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
61 62
                         $spec->getKey()->getAlgorithm()->getString()
62 63
                     )
63 64
                 );
65
+            }
64 66
 
65 67
             $header = new JOSEHeader
66 68
             (
Please login to merge, or discard this 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/jws/impl/specs/JWS_ParamsSpecification.php 3 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -54,12 +54,12 @@
 block discarded – undo
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;
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -56,11 +56,13 @@
 block discarded – undo
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;
Please login to merge, or discard this 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/jws/impl/JWS.php 3 patches
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@  discard block
 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 jws\impl;
16 16
 
@@ -305,11 +305,11 @@  discard block
 block discarded – undo
305 305
     }
306 306
 
307 307
      /**
308
-     * @param IJOSEHeader $header
309
-     * @param IJWSPayloadSpec $payload
310
-     * @param string $signature
311
-     * @return IJWS
312
-     */
308
+      * @param IJOSEHeader $header
309
+      * @param IJWSPayloadSpec $payload
310
+      * @param string $signature
311
+      * @return IJWS
312
+      */
313 313
     static public function fromHeaderClaimsAndSignature(IJOSEHeader $header, IJWSPayloadSpec $payload = null , $signature = '')
314 314
     {
315 315
         return new JWS($header, $payload, $signature );
Please login to merge, or discard this patch.
Spacing   +39 added lines, -51 removed lines patch added patch discarded remove patch
@@ -72,14 +72,14 @@  discard block
 block discarded – undo
72 72
 
73 73
         $claim_set = null;
74 74
 
75
-        if(!is_null($payload) && $payload->isClaimSet() && $payload instanceof IJWSPayloadClaimSetSpec) {
75
+        if (!is_null($payload) && $payload->isClaimSet() && $payload instanceof IJWSPayloadClaimSetSpec) {
76 76
             $header->addHeader(new JOSEHeaderParam(RegisteredJOSEHeaderNames::Type, new StringOrURI('JWT')));
77 77
             $claim_set = $payload->getClaimSet();
78 78
         }
79 79
 
80 80
         parent::__construct($header, $claim_set);
81 81
 
82
-        if(!is_null($payload))
82
+        if (!is_null($payload))
83 83
             $this->setPayload($payload);
84 84
 
85 85
         $this->signature = $signature;
@@ -100,21 +100,18 @@  discard block
 block discarded – undo
100 100
      */
101 101
     public function toCompactSerialization()
102 102
     {
103
-        if(!is_null($this->jwk->getId()))
103
+        if (!is_null($this->jwk->getId()))
104 104
             $this->header->addHeader(new JOSEHeaderParam(RegisteredJOSEHeaderNames::KeyID, $this->jwk->getId()));
105 105
 
106
-        if($this->jwk instanceof IAsymmetricJWK)
106
+        if ($this->jwk instanceof IAsymmetricJWK)
107 107
         {
108 108
             // we should add the public key on the header
109 109
             $public_key = clone $this->jwk;
110 110
 
111
-            $this->header->addHeader
112
-            (
113
-                new JOSEHeaderParam
114
-                (
111
+            $this->header->addHeader(
112
+                new JOSEHeaderParam(
115 113
                     RegisteredJOSEHeaderNames::JSONWebKey,
116
-                    new JsonValue
117
-                    (
114
+                    new JsonValue(
118 115
                         $public_key->setVisibility(JSONWebKeyVisibility::PublicOnly)
119 116
                     )
120 117
                 )
@@ -134,32 +131,32 @@  discard block
 block discarded – undo
134 131
     public function sign()
135 132
     {
136 133
 
137
-        if(is_null($this->jwk))
134
+        if (is_null($this->jwk))
138 135
             throw new JWSInvalidJWKException;
139 136
 
140
-        if($this->jwk->getKeyUse()->getString() !== JSONWebKeyPublicKeyUseValues::Signature)
137
+        if ($this->jwk->getKeyUse()->getString() !== JSONWebKeyPublicKeyUseValues::Signature)
141 138
             throw new JWSInvalidJWKException(sprintf('use %s not supported.', $this->jwk->getKeyUse()->getString()));
142 139
 
143 140
         $alg = DigitalSignatures_MACs_Registry::getInstance()->get($this->header->getAlgorithm()->getString());
144 141
 
145
-        if(is_null($alg))
146
-            throw new JWSNotSupportedAlgorithm(sprintf('alg %s.',$this->header->getAlgorithm()->getString()));
142
+        if (is_null($alg))
143
+            throw new JWSNotSupportedAlgorithm(sprintf('alg %s.', $this->header->getAlgorithm()->getString()));
147 144
 
148
-        $secured_input_bytes = JOSEHeaderSerializer::serialize($this->header) . IBasicJWT::SegmentSeparator .$this->getEncodedPayload();
145
+        $secured_input_bytes = JOSEHeaderSerializer::serialize($this->header).IBasicJWT::SegmentSeparator.$this->getEncodedPayload();
149 146
 
150
-        $key  = $this->jwk->getKey(JSONWebKeyKeyOperationsValues::ComputeDigitalSignatureOrMAC);
147
+        $key = $this->jwk->getKey(JSONWebKeyKeyOperationsValues::ComputeDigitalSignatureOrMAC);
151 148
 
152
-        if($alg instanceof DigitalSignatureAlgorithm)
149
+        if ($alg instanceof DigitalSignatureAlgorithm)
153 150
         {
154 151
             $this->signature = $alg->sign($key, $secured_input_bytes);
155 152
         }
156
-        else if($alg instanceof MAC_Algorithm )
153
+        else if ($alg instanceof MAC_Algorithm)
157 154
         {
158 155
             $this->signature = $alg->digest($key, $secured_input_bytes);
159 156
         }
160 157
         else
161 158
         {
162
-            throw new JWSNotSupportedAlgorithm(sprintf('alg %s.',$this->header->getAlgorithm()->getString()));
159
+            throw new JWSNotSupportedAlgorithm(sprintf('alg %s.', $this->header->getAlgorithm()->getString()));
163 160
         }
164 161
 
165 162
         return $this;
@@ -171,16 +168,16 @@  discard block
 block discarded – undo
171 168
      */
172 169
     public function getEncodedPayload()
173 170
     {
174
-        if(is_null($this->payload))
171
+        if (is_null($this->payload))
175 172
             throw new JWSInvalidPayloadException('payload is not set!');
176 173
 
177 174
         $enc_payload = '';
178 175
 
179
-        if($this->payload instanceof IJWSPayloadClaimSetSpec)
176
+        if ($this->payload instanceof IJWSPayloadClaimSetSpec)
180 177
         {
181 178
             $enc_payload = JWTClaimSetSerializer::serialize($this->payload->getClaimSet());
182 179
         }
183
-        else if($this->payload instanceof IJWSPayloadRawSpec)
180
+        else if ($this->payload instanceof IJWSPayloadRawSpec)
184 181
         {
185 182
             $enc_payload = JWTRawSerializer::serialize($this->payload->getRaw());
186 183
         }
@@ -234,27 +231,23 @@  discard block
 block discarded – undo
234 231
      */
235 232
     public function verify($original_alg)
236 233
     {
237
-        if(is_null($this->jwk))
234
+        if (is_null($this->jwk))
238 235
             throw new JWSInvalidJWKException;
239 236
 
240
-        if($this->jwk->getKeyUse()->getString() !== JSONWebKeyPublicKeyUseValues::Signature)
241
-            throw new JWSInvalidJWKException
242
-            (
243
-                sprintf
244
-                (
237
+        if ($this->jwk->getKeyUse()->getString() !== JSONWebKeyPublicKeyUseValues::Signature)
238
+            throw new JWSInvalidJWKException(
239
+                sprintf(
245 240
                     'use %s not supported ',
246 241
                     $this->jwk->getKeyUse()->getString()
247 242
                 )
248 243
             );
249 244
 
250
-        if(is_null($this->jwk->getAlgorithm()))
245
+        if (is_null($this->jwk->getAlgorithm()))
251 246
             throw new InvalidJWKAlgorithm('algorithm intended for use with the key is not set! ');
252 247
 
253
-        if(!is_null($this->jwk->getId()) && !is_null($this->header->getKeyID()) && $this->header->getKeyID()->getValue() != $this->jwk->getId()->getValue())
254
-            throw new JWSInvalidJWKException
255
-            (
256
-                sprintf
257
-                (
248
+        if (!is_null($this->jwk->getId()) && !is_null($this->header->getKeyID()) && $this->header->getKeyID()->getValue() != $this->jwk->getId()->getValue())
249
+            throw new JWSInvalidJWKException(
250
+                sprintf(
258 251
                     'original kid %s - current kid %s',
259 252
                     $this->header->getKeyID()->getValue(),
260 253
                     $this->jwk->getId()->getValue()
@@ -263,34 +256,30 @@  discard block
 block discarded – undo
263 256
 
264 257
         $alg = DigitalSignatures_MACs_Registry::getInstance()->get($original_alg);
265 258
 
266
-        if(is_null($alg))
259
+        if (is_null($alg))
267 260
             throw new JWSNotSupportedAlgorithm(sprintf('algo %s', $original_alg));
268 261
 
269 262
         $former_alg = $this->header->getAlgorithm()->getString();
270 263
 
271
-        if($former_alg != $original_alg)
272
-            throw new JWSNotSupportedAlgorithm
273
-            (
274
-                sprintf
275
-                (
264
+        if ($former_alg != $original_alg)
265
+            throw new JWSNotSupportedAlgorithm(
266
+                sprintf(
276 267
                     'former alg %s - original alg %s',
277 268
                     $former_alg,
278 269
                     $original_alg
279 270
                 )
280 271
             );
281 272
 
282
-        if($this->jwk->getAlgorithm()->getValue() !==  $original_alg)
283
-            throw new InvalidJWKAlgorithm
284
-            (
285
-                sprintf
286
-                (
273
+        if ($this->jwk->getAlgorithm()->getValue() !== $original_alg)
274
+            throw new InvalidJWKAlgorithm(
275
+                sprintf(
287 276
                     'mismatch between algorithm intended for use with the key %s and the cryptographic algorithm used to secure the JWS %s',
288 277
                     $this->jwk->getAlgorithm()->getValue(),
289 278
                     $original_alg
290 279
                 )
291 280
             );
292 281
 
293
-        $secured_input_bytes = JOSEHeaderSerializer::serialize($this->header) . IBasicJWT::SegmentSeparator .$this->getEncodedPayload();
282
+        $secured_input_bytes = JOSEHeaderSerializer::serialize($this->header).IBasicJWT::SegmentSeparator.$this->getEncodedPayload();
294 283
 
295 284
         // use public key / secret
296 285
         $key = $this->jwk->getKey(JSONWebKeyKeyOperationsValues::VerifyDigitalSignatureOrMAC);
@@ -311,9 +300,9 @@  discard block
 block discarded – undo
311 300
      * @param string $signature
312 301
      * @return IJWS
313 302
      */
314
-    static public function fromHeaderClaimsAndSignature(IJOSEHeader $header, IJWSPayloadSpec $payload = null , $signature = '')
303
+    static public function fromHeaderClaimsAndSignature(IJOSEHeader $header, IJWSPayloadSpec $payload = null, $signature = '')
315 304
     {
316
-        return new JWS($header, $payload, $signature );
305
+        return new JWS($header, $payload, $signature);
317 306
     }
318 307
 
319 308
     /**
@@ -321,9 +310,8 @@  discard block
 block discarded – undo
321 310
      */
322 311
     public function take()
323 312
     {
324
-        $payload = ($this->payload instanceof IJWSPayloadRawSpec) ?  $this->payload->getRaw() : $this->claim_set;
325
-        return array
326
-        (
313
+        $payload = ($this->payload instanceof IJWSPayloadRawSpec) ? $this->payload->getRaw() : $this->claim_set;
314
+        return array(
327 315
             $this->header,
328 316
             $payload,
329 317
             $this->signature
Please login to merge, or discard this patch.
Braces   +42 added lines, -32 removed lines patch added patch discarded remove patch
@@ -79,8 +79,9 @@  discard block
 block discarded – undo
79 79
 
80 80
         parent::__construct($header, $claim_set);
81 81
 
82
-        if(!is_null($payload))
83
-            $this->setPayload($payload);
82
+        if(!is_null($payload)) {
83
+                    $this->setPayload($payload);
84
+        }
84 85
 
85 86
         $this->signature = $signature;
86 87
     }
@@ -100,8 +101,9 @@  discard block
 block discarded – undo
100 101
      */
101 102
     public function toCompactSerialization()
102 103
     {
103
-        if(!is_null($this->jwk->getId()))
104
-            $this->header->addHeader(new JOSEHeaderParam(RegisteredJOSEHeaderNames::KeyID, $this->jwk->getId()));
104
+        if(!is_null($this->jwk->getId())) {
105
+                    $this->header->addHeader(new JOSEHeaderParam(RegisteredJOSEHeaderNames::KeyID, $this->jwk->getId()));
106
+        }
105 107
 
106 108
         if($this->jwk instanceof IAsymmetricJWK)
107 109
         {
@@ -134,16 +136,19 @@  discard block
 block discarded – undo
134 136
     public function sign()
135 137
     {
136 138
 
137
-        if(is_null($this->jwk))
138
-            throw new JWSInvalidJWKException;
139
+        if(is_null($this->jwk)) {
140
+                    throw new JWSInvalidJWKException;
141
+        }
139 142
 
140
-        if($this->jwk->getKeyUse()->getString() !== JSONWebKeyPublicKeyUseValues::Signature)
141
-            throw new JWSInvalidJWKException(sprintf('use %s not supported.', $this->jwk->getKeyUse()->getString()));
143
+        if($this->jwk->getKeyUse()->getString() !== JSONWebKeyPublicKeyUseValues::Signature) {
144
+                    throw new JWSInvalidJWKException(sprintf('use %s not supported.', $this->jwk->getKeyUse()->getString()));
145
+        }
142 146
 
143 147
         $alg = DigitalSignatures_MACs_Registry::getInstance()->get($this->header->getAlgorithm()->getString());
144 148
 
145
-        if(is_null($alg))
146
-            throw new JWSNotSupportedAlgorithm(sprintf('alg %s.',$this->header->getAlgorithm()->getString()));
149
+        if(is_null($alg)) {
150
+                    throw new JWSNotSupportedAlgorithm(sprintf('alg %s.',$this->header->getAlgorithm()->getString()));
151
+        }
147 152
 
148 153
         $secured_input_bytes = JOSEHeaderSerializer::serialize($this->header) . IBasicJWT::SegmentSeparator .$this->getEncodedPayload();
149 154
 
@@ -152,12 +157,10 @@  discard block
 block discarded – undo
152 157
         if($alg instanceof DigitalSignatureAlgorithm)
153 158
         {
154 159
             $this->signature = $alg->sign($key, $secured_input_bytes);
155
-        }
156
-        else if($alg instanceof MAC_Algorithm )
160
+        } else if($alg instanceof MAC_Algorithm )
157 161
         {
158 162
             $this->signature = $alg->digest($key, $secured_input_bytes);
159
-        }
160
-        else
163
+        } else
161 164
         {
162 165
             throw new JWSNotSupportedAlgorithm(sprintf('alg %s.',$this->header->getAlgorithm()->getString()));
163 166
         }
@@ -171,16 +174,16 @@  discard block
 block discarded – undo
171 174
      */
172 175
     public function getEncodedPayload()
173 176
     {
174
-        if(is_null($this->payload))
175
-            throw new JWSInvalidPayloadException('payload is not set!');
177
+        if(is_null($this->payload)) {
178
+                    throw new JWSInvalidPayloadException('payload is not set!');
179
+        }
176 180
 
177 181
         $enc_payload = '';
178 182
 
179 183
         if($this->payload instanceof IJWSPayloadClaimSetSpec)
180 184
         {
181 185
             $enc_payload = JWTClaimSetSerializer::serialize($this->payload->getClaimSet());
182
-        }
183
-        else if($this->payload instanceof IJWSPayloadRawSpec)
186
+        } else if($this->payload instanceof IJWSPayloadRawSpec)
184 187
         {
185 188
             $enc_payload = JWTRawSerializer::serialize($this->payload->getRaw());
186 189
         }
@@ -234,11 +237,12 @@  discard block
 block discarded – undo
234 237
      */
235 238
     public function verify($original_alg)
236 239
     {
237
-        if(is_null($this->jwk))
238
-            throw new JWSInvalidJWKException;
240
+        if(is_null($this->jwk)) {
241
+                    throw new JWSInvalidJWKException;
242
+        }
239 243
 
240
-        if($this->jwk->getKeyUse()->getString() !== JSONWebKeyPublicKeyUseValues::Signature)
241
-            throw new JWSInvalidJWKException
244
+        if($this->jwk->getKeyUse()->getString() !== JSONWebKeyPublicKeyUseValues::Signature) {
245
+                    throw new JWSInvalidJWKException
242 246
             (
243 247
                 sprintf
244 248
                 (
@@ -246,12 +250,14 @@  discard block
 block discarded – undo
246 250
                     $this->jwk->getKeyUse()->getString()
247 251
                 )
248 252
             );
253
+        }
249 254
 
250
-        if(is_null($this->jwk->getAlgorithm()))
251
-            throw new InvalidJWKAlgorithm('algorithm intended for use with the key is not set! ');
255
+        if(is_null($this->jwk->getAlgorithm())) {
256
+                    throw new InvalidJWKAlgorithm('algorithm intended for use with the key is not set! ');
257
+        }
252 258
 
253
-        if(!is_null($this->jwk->getId()) && !is_null($this->header->getKeyID()) && $this->header->getKeyID()->getValue() != $this->jwk->getId()->getValue())
254
-            throw new JWSInvalidJWKException
259
+        if(!is_null($this->jwk->getId()) && !is_null($this->header->getKeyID()) && $this->header->getKeyID()->getValue() != $this->jwk->getId()->getValue()) {
260
+                    throw new JWSInvalidJWKException
255 261
             (
256 262
                 sprintf
257 263
                 (
@@ -260,16 +266,18 @@  discard block
 block discarded – undo
260 266
                     $this->jwk->getId()->getValue()
261 267
                 )
262 268
             );
269
+        }
263 270
 
264 271
         $alg = DigitalSignatures_MACs_Registry::getInstance()->get($original_alg);
265 272
 
266
-        if(is_null($alg))
267
-            throw new JWSNotSupportedAlgorithm(sprintf('algo %s', $original_alg));
273
+        if(is_null($alg)) {
274
+                    throw new JWSNotSupportedAlgorithm(sprintf('algo %s', $original_alg));
275
+        }
268 276
 
269 277
         $former_alg = $this->header->getAlgorithm()->getString();
270 278
 
271
-        if($former_alg != $original_alg)
272
-            throw new JWSNotSupportedAlgorithm
279
+        if($former_alg != $original_alg) {
280
+                    throw new JWSNotSupportedAlgorithm
273 281
             (
274 282
                 sprintf
275 283
                 (
@@ -278,9 +286,10 @@  discard block
 block discarded – undo
278 286
                     $original_alg
279 287
                 )
280 288
             );
289
+        }
281 290
 
282
-        if($this->jwk->getAlgorithm()->getValue() !==  $original_alg)
283
-            throw new InvalidJWKAlgorithm
291
+        if($this->jwk->getAlgorithm()->getValue() !==  $original_alg) {
292
+                    throw new InvalidJWKAlgorithm
284 293
             (
285 294
                 sprintf
286 295
                 (
@@ -289,6 +298,7 @@  discard block
 block discarded – undo
289 298
                     $original_alg
290 299
                 )
291 300
             );
301
+        }
292 302
 
293 303
         $secured_input_bytes = JOSEHeaderSerializer::serialize($this->header) . IBasicJWT::SegmentSeparator .$this->getEncodedPayload();
294 304
 
Please login to merge, or discard this patch.
src/jws/payloads/JWSPayloadFactory .php 3 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -29,12 +29,12 @@  discard block
 block discarded – undo
29 29
      * @param mixed $content
30 30
      * @return IJWSPayloadSpec
31 31
      */
32
-    public static function build($content){
32
+    public static function build($content) {
33 33
 
34
-        if($content instanceof IJWTClaimSet){
34
+        if ($content instanceof IJWTClaimSet) {
35 35
             return new _JWSPayloadClaimSetSpec($content);
36 36
         }
37
-        else{
37
+        else {
38 38
             return new _JWSPayloadRawSpec($content);
39 39
         }
40 40
     }
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
     /**
57 57
      * @param IJWTClaimSet $claim_set
58 58
      */
59
-    public function __construct(IJWTClaimSet $claim_set){
59
+    public function __construct(IJWTClaimSet $claim_set) {
60 60
         $this->claim_set = $claim_set;
61 61
     }
62 62
 
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
     /**
102 102
      * @param string $raw
103 103
      */
104
-    public function __construct($raw){
104
+    public function __construct($raw) {
105 105
         $this->raw = $raw;
106 106
     }
107 107
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -33,8 +33,7 @@
 block discarded – undo
33 33
 
34 34
         if($content instanceof IJWTClaimSet){
35 35
             return new _JWSPayloadClaimSetSpec($content);
36
-        }
37
-        else{
36
+        } else{
38 37
             return new _JWSPayloadRawSpec($content);
39 38
         }
40 39
     }
Please login to merge, or discard this 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/jws/IJWS.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -72,5 +72,5 @@
 block discarded – undo
72 72
      * @param string $signature
73 73
      * @return IJWS
74 74
      */
75
-    static public function fromHeaderClaimsAndSignature(IJOSEHeader $header, IJWSPayloadSpec $payload = null , $signature = '');
75
+    static public function fromHeaderClaimsAndSignature(IJOSEHeader $header, IJWSPayloadSpec $payload = null, $signature = '');
76 76
 }
77 77
\ No newline at end of file
Please login to merge, or discard this patch.
src/utils/services/impl/RandomNumberGeneratorService.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@
 block discarded – undo
29 29
      */
30 30
     public function invoke()
31 31
     {
32
-        if(func_num_args() <= 0) throw new \RuntimeException('you must pass len as arg!');
32
+        if (func_num_args() <= 0) throw new \RuntimeException('you must pass len as arg!');
33 33
         $byte_len = func_get_arg(0);
34 34
         return ByteUtil::randomBytes($byte_len);
35 35
     }
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,9 @@
 block discarded – undo
29 29
      */
30 30
     public function invoke()
31 31
     {
32
-        if(func_num_args() <= 0) throw new \RuntimeException('you must pass len as arg!');
32
+        if(func_num_args() <= 0) {
33
+         throw new \RuntimeException('you must pass len as arg!');
34
+        }
33 35
         $byte_len = func_get_arg(0);
34 36
         return ByteUtil::randomBytes($byte_len);
35 37
     }
Please login to merge, or discard this patch.
src/utils/services/Utils_Registry.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -32,18 +32,18 @@  discard block
 block discarded – undo
32 32
 
33 33
     private $services = array();
34 34
 
35
-    private function __construct(){
35
+    private function __construct() {
36 36
 
37 37
         $this->services[self::RandomNumberGeneratorService] = new RandomNumberGeneratorService;
38 38
     }
39 39
 
40
-    private function __clone(){}
40
+    private function __clone() {}
41 41
 
42 42
     /**
43 43
      * @return Utils_Registry
44 44
      */
45
-    public static function getInstance(){
46
-        if(!is_object(self::$instance)){
45
+    public static function getInstance() {
46
+        if (!is_object(self::$instance)) {
47 47
             self::$instance = new Utils_Registry();
48 48
         }
49 49
         return self::$instance;
@@ -53,8 +53,8 @@  discard block
 block discarded – undo
53 53
      * @param string $service_name
54 54
      * @return null|IService
55 55
      */
56
-    public function get($service_name){
57
-        if(!array_key_exists($service_name,  $this->services))
56
+    public function get($service_name) {
57
+        if (!array_key_exists($service_name, $this->services))
58 58
             throw new \InvalidArgumentException('unknown service!');
59 59
 
60 60
         return $this->services[$service_name];
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
      * @param IService $service
66 66
      * @return $this
67 67
      */
68
-    public function add($service_name, IService $service){
68
+    public function add($service_name, IService $service) {
69 69
         $this->services[$service_name] = $service;
70 70
         return $this;
71 71
     }
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -54,8 +54,9 @@
 block discarded – undo
54 54
      * @return null|IService
55 55
      */
56 56
     public function get($service_name){
57
-        if(!array_key_exists($service_name,  $this->services))
58
-            throw new \InvalidArgumentException('unknown service!');
57
+        if(!array_key_exists($service_name,  $this->services)) {
58
+                    throw new \InvalidArgumentException('unknown service!');
59
+        }
59 60
 
60 61
         return $this->services[$service_name];
61 62
     }
Please login to merge, or discard this patch.