@@ -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 |
@@ -37,41 +37,36 @@ discard block |
||
37 | 37 | static public function build(IJWE_Specification $spec) |
38 | 38 | { |
39 | 39 | |
40 | - if($spec instanceof IJWE_ParamsSpecification) |
|
40 | + if ($spec instanceof IJWE_ParamsSpecification) |
|
41 | 41 | { |
42 | 42 | |
43 | - if($spec->getRecipientKey()->getKeyUse()->getString() !== JSONWebKeyPublicKeyUseValues::Encryption) |
|
44 | - throw new InvalidJWKType |
|
45 | - ( |
|
46 | - sprintf |
|
47 | - ( |
|
43 | + if ($spec->getRecipientKey()->getKeyUse()->getString() !== JSONWebKeyPublicKeyUseValues::Encryption) |
|
44 | + throw new InvalidJWKType( |
|
45 | + sprintf( |
|
48 | 46 | 'use %s not supported (should be "enc")', |
49 | 47 | $spec->getRecipientKey()->getKeyUse()->getString() |
50 | 48 | ) |
51 | 49 | ); |
52 | 50 | |
53 | - if($spec->getAlg()->getString() !== $spec->getRecipientKey()->getAlgorithm()->getString()) |
|
54 | - throw new InvalidJWKAlgorithm |
|
55 | - ( |
|
56 | - sprintf |
|
57 | - ( |
|
51 | + if ($spec->getAlg()->getString() !== $spec->getRecipientKey()->getAlgorithm()->getString()) |
|
52 | + throw new InvalidJWKAlgorithm( |
|
53 | + sprintf( |
|
58 | 54 | 'mismatch between algorithm intended for use with the key %s and the cryptographic algorithm used to encrypt or determine the value of the CEK %s', |
59 | 55 | $spec->getAlg()->getString(), |
60 | 56 | $spec->getRecipientKey()->getAlgorithm()->getString() |
61 | 57 | ) |
62 | 58 | ); |
63 | 59 | |
64 | - $header = new JWEJOSEHeader |
|
65 | - ( |
|
60 | + $header = new JWEJOSEHeader( |
|
66 | 61 | $spec->getAlg(), |
67 | 62 | $spec->getEnc(), |
68 | 63 | $spec->getRecipientKey()->getId() |
69 | 64 | ); |
70 | 65 | |
71 | 66 | //set zip alg |
72 | - $zip = $spec->getZip(); |
|
67 | + $zip = $spec->getZip(); |
|
73 | 68 | |
74 | - if(!is_null($zip)) |
|
69 | + if (!is_null($zip)) |
|
75 | 70 | $header->setCompressionAlgorithm($zip); |
76 | 71 | |
77 | 72 | $jwe = JWE::fromHeaderAndPayload($header, $spec->getPayload()); |
@@ -81,7 +76,7 @@ discard block |
||
81 | 76 | return $jwe; |
82 | 77 | } |
83 | 78 | |
84 | - if($spec instanceof IJWE_CompactFormatSpecification) |
|
79 | + if ($spec instanceof IJWE_CompactFormatSpecification) |
|
85 | 80 | { |
86 | 81 | return JWE::fromCompactSerialization($spec->getCompactFormat()); |
87 | 82 | } |
@@ -27,7 +27,7 @@ |
||
27 | 27 | /** |
28 | 28 | * @param string $secret |
29 | 29 | */ |
30 | - public function __construct($secret){ |
|
30 | + public function __construct($secret) { |
|
31 | 31 | $this->secret = $secret; |
32 | 32 | } |
33 | 33 |
@@ -24,7 +24,7 @@ |
||
24 | 24 | * @param string $pem |
25 | 25 | * @return X509Certificate |
26 | 26 | */ |
27 | - static public function buildFromPEM($pem){ |
|
27 | + static public function buildFromPEM($pem) { |
|
28 | 28 | return new _X509Certificate($pem); |
29 | 29 | } |
30 | 30 | } |
31 | 31 | \ No newline at end of file |
@@ -22,7 +22,7 @@ |
||
22 | 22 | * Interface IJWK |
23 | 23 | * @package jwk |
24 | 24 | */ |
25 | -interface IJWK extends IReadOnlyJWK { |
|
25 | +interface IJWK extends IReadOnlyJWK { |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * @param string $kid |
@@ -35,7 +35,7 @@ discard block |
||
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 |
||
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, |
@@ -40,14 +40,14 @@ discard block |
||
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 |
||
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 |