@@ -18,7 +18,7 @@ |
||
18 | 18 | * Class Base64UrlRepresentation |
19 | 19 | * @package utils |
20 | 20 | */ |
21 | -final class Base64UrlRepresentation implements IObjectRepresentation{ |
|
21 | +final class Base64UrlRepresentation implements IObjectRepresentation { |
|
22 | 22 | |
23 | 23 | const Padding = 4; |
24 | 24 | /** |
@@ -40,7 +40,9 @@ |
||
40 | 40 | $type = @RegisteredJWEJOSEHeaderNames::$registered_basic_headers_set_types[$header_name]; |
41 | 41 | if(!is_null($value)) |
42 | 42 | { |
43 | - if(is_null($type)) continue; |
|
43 | + if(is_null($type)) { |
|
44 | + continue; |
|
45 | + } |
|
44 | 46 | $class = new \ReflectionClass($type); |
45 | 47 | $value = $class->newInstanceArgs(array($value)); |
46 | 48 | } |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | */ |
22 | 22 | final class JWEJOSEHeaderFactory { |
23 | 23 | |
24 | - static protected function getProductClass(){ |
|
24 | + static protected function getProductClass() { |
|
25 | 25 | return '\jwe\impl\JWEJOSEHeader'; |
26 | 26 | } |
27 | 27 | |
@@ -30,16 +30,16 @@ discard block |
||
30 | 30 | * @return IJWEJOSEHeader |
31 | 31 | * @throws \ReflectionException |
32 | 32 | */ |
33 | - public static function build(array $raw_headers){ |
|
33 | + public static function build(array $raw_headers) { |
|
34 | 34 | |
35 | 35 | $args = array(); |
36 | 36 | |
37 | - foreach(RegisteredJWEJOSEHeaderNames::$registered_basic_headers_set as $header_name){ |
|
37 | + foreach (RegisteredJWEJOSEHeaderNames::$registered_basic_headers_set as $header_name) { |
|
38 | 38 | $value = isset($raw_headers[$header_name]) ? $raw_headers[$header_name] : null; |
39 | 39 | $type = @RegisteredJWEJOSEHeaderNames::$registered_basic_headers_set_types[$header_name]; |
40 | - if(!is_null($value)) |
|
40 | + if (!is_null($value)) |
|
41 | 41 | { |
42 | - if(is_null($type)) continue; |
|
42 | + if (is_null($type)) continue; |
|
43 | 43 | $class = new \ReflectionClass($type); |
44 | 44 | $value = $class->newInstanceArgs(array($value)); |
45 | 45 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | |
54 | 54 | // unregistered headers |
55 | 55 | |
56 | - foreach($raw_headers as $k => $v){ |
|
56 | + foreach ($raw_headers as $k => $v) { |
|
57 | 57 | $basic_header->addHeader(new JOSEHeaderParam($k, new JsonValue($v))); |
58 | 58 | } |
59 | 59 |
@@ -36,8 +36,7 @@ discard block |
||
36 | 36 | * @param StringOrURI|null $type |
37 | 37 | * @param StringOrURI|null $cty |
38 | 38 | */ |
39 | - public function __construct |
|
40 | - ( |
|
39 | + public function __construct( |
|
41 | 40 | StringOrURI $alg, |
42 | 41 | StringOrURI $enc, |
43 | 42 | JsonValue $kid = null, |
@@ -50,7 +49,7 @@ discard block |
||
50 | 49 | |
51 | 50 | $this->set[RegisteredJWEJOSEHeaderNames::EncryptionAlgorithm] = $enc; |
52 | 51 | |
53 | - if(!is_null($zip) && CompressionAlgorithms_Registry::getInstance()->get($zip->getValue())) |
|
52 | + if (!is_null($zip) && CompressionAlgorithms_Registry::getInstance()->get($zip->getValue())) |
|
54 | 53 | $this->set[RegisteredJWEJOSEHeaderNames::CompressionAlgorithm] = $zip; |
55 | 54 | } |
56 | 55 |
@@ -50,8 +50,9 @@ |
||
50 | 50 | |
51 | 51 | $this->set[RegisteredJWEJOSEHeaderNames::EncryptionAlgorithm] = $enc; |
52 | 52 | |
53 | - if(!is_null($zip) && CompressionAlgorithms_Registry::getInstance()->get($zip->getValue())) |
|
54 | - $this->set[RegisteredJWEJOSEHeaderNames::CompressionAlgorithm] = $zip; |
|
53 | + if(!is_null($zip) && CompressionAlgorithms_Registry::getInstance()->get($zip->getValue())) { |
|
54 | + $this->set[RegisteredJWEJOSEHeaderNames::CompressionAlgorithm] = $zip; |
|
55 | + } |
|
55 | 56 | } |
56 | 57 | |
57 | 58 | /** |
@@ -26,7 +26,7 @@ |
||
26 | 26 | * @param $size |
27 | 27 | * @return string |
28 | 28 | */ |
29 | - static public function build($size){ |
|
29 | + static public function build($size) { |
|
30 | 30 | |
31 | 31 | $generator = Utils_Registry::getInstance()->get(Utils_Registry::RandomNumberGeneratorService); |
32 | 32 | return $generator->invoke($size / 8); |
@@ -63,13 +63,13 @@ |
||
63 | 63 | * @throws JWEInvalidPayloadException |
64 | 64 | * @throws JWEInvalidRecipientKeyException |
65 | 65 | */ |
66 | - public function __construct(IJWK $key, StringOrURI $alg, StringOrURI $enc, $payload, JsonValue $zip = null) |
|
66 | + public function __construct(IJWK $key, StringOrURI $alg, StringOrURI $enc, $payload, JsonValue $zip = null) |
|
67 | 67 | { |
68 | 68 | |
69 | - if(is_null($key)) |
|
69 | + if (is_null($key)) |
|
70 | 70 | throw new JWEInvalidRecipientKeyException(); |
71 | 71 | |
72 | - if(is_null($payload)) |
|
72 | + if (is_null($payload)) |
|
73 | 73 | throw new JWEInvalidPayloadException('missing payload'); |
74 | 74 | |
75 | 75 | $this->key = $key; |
@@ -66,11 +66,13 @@ |
||
66 | 66 | public function __construct(IJWK $key, StringOrURI $alg, StringOrURI $enc, $payload, JsonValue $zip = null) |
67 | 67 | { |
68 | 68 | |
69 | - if(is_null($key)) |
|
70 | - throw new JWEInvalidRecipientKeyException(); |
|
69 | + if(is_null($key)) { |
|
70 | + throw new JWEInvalidRecipientKeyException(); |
|
71 | + } |
|
71 | 72 | |
72 | - if(is_null($payload)) |
|
73 | - throw new JWEInvalidPayloadException('missing payload'); |
|
73 | + if(is_null($payload)) { |
|
74 | + throw new JWEInvalidPayloadException('missing payload'); |
|
75 | + } |
|
74 | 76 | |
75 | 77 | $this->key = $key; |
76 | 78 | $this->alg = $alg; |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * The CEK MUST have a length equal to that required for the |
58 | 58 | * content encryption algorithm. |
59 | 59 | */ |
60 | - $rnd = $generator->invoke($enc->getMinKeyLen()/8); |
|
60 | + $rnd = $generator->invoke($enc->getMinKeyLen() / 8); |
|
61 | 61 | $cek = new _ContentEncryptionKey($enc->getName(), 'RAW', $rnd); |
62 | 62 | } |
63 | 63 | break; |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | * @param EncryptionAlgorithm $alg |
86 | 86 | * @return Key |
87 | 87 | */ |
88 | - static public function fromRaw($value, EncryptionAlgorithm $alg){ |
|
88 | + static public function fromRaw($value, EncryptionAlgorithm $alg) { |
|
89 | 89 | return new _ContentEncryptionKey($alg->getName(), 'RAW', $value); |
90 | 90 | } |
91 | 91 | } |
92 | 92 | \ No newline at end of file |
@@ -44,7 +44,7 @@ |
||
44 | 44 | * @param string $format |
45 | 45 | * @param string $value |
46 | 46 | */ |
47 | - public function __construct($alg, $format, $value){ |
|
47 | + public function __construct($alg, $format, $value) { |
|
48 | 48 | $this->alg = $alg; |
49 | 49 | $this->format = $format; |
50 | 50 | $this->value = $value; |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | const CompressionAlgorithm = 'zip'; |
65 | 65 | |
66 | 66 | |
67 | - public static $registered_basic_headers_set = array ( |
|
67 | + public static $registered_basic_headers_set = array( |
|
68 | 68 | self::Algorithm, |
69 | 69 | self::EncryptionAlgorithm, |
70 | 70 | self::KeyID, |
@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | self::ContentType, |
74 | 74 | ); |
75 | 75 | |
76 | - public static $registered_basic_headers_set_types = array ( |
|
77 | - self::Algorithm => JsonTypes::StringOrURI , |
|
76 | + public static $registered_basic_headers_set_types = array( |
|
77 | + self::Algorithm => JsonTypes::StringOrURI, |
|
78 | 78 | self::Type => JsonTypes::StringOrURI, |
79 | 79 | self::ContentType => JsonTypes::StringOrURI, |
80 | 80 | self::KeyID => JsonTypes::JsonValue, |
@@ -24,9 +24,9 @@ |
||
24 | 24 | |
25 | 25 | const KeyWrapping = 'wrap'; |
26 | 26 | |
27 | - const DirectKeyAgreement ='agree'; |
|
27 | + const DirectKeyAgreement = 'agree'; |
|
28 | 28 | |
29 | - const KeyAgreementWithKeyWrapping ='agree_wrap'; |
|
29 | + const KeyAgreementWithKeyWrapping = 'agree_wrap'; |
|
30 | 30 | |
31 | 31 | const DirectEncryption = 'dir'; |
32 | 32 | } |
33 | 33 | \ No newline at end of file |