@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | * @param string $raw_input |
| 22 | 22 | * @return string |
| 23 | 23 | */ |
| 24 | - public static function serialize($raw_input){ |
|
| 24 | + public static function serialize($raw_input) { |
|
| 25 | 25 | $base64 = new Base64UrlRepresentation(); |
| 26 | 26 | return $base64->encode($raw_input); |
| 27 | 27 | } |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | * @param string $input |
| 31 | 31 | * @return string |
| 32 | 32 | */ |
| 33 | - public static function deserialize($input){ |
|
| 33 | + public static function deserialize($input) { |
|
| 34 | 34 | $base64 = new Base64UrlRepresentation(); |
| 35 | 35 | return $base64->decode($input); |
| 36 | 36 | } |
@@ -32,14 +32,14 @@ discard block |
||
| 32 | 32 | * @param array $raw_claims |
| 33 | 33 | * @return IJWTClaimSet |
| 34 | 34 | */ |
| 35 | - public static function build(array $raw_claims){ |
|
| 35 | + public static function build(array $raw_claims) { |
|
| 36 | 36 | |
| 37 | 37 | $args = array(); |
| 38 | 38 | |
| 39 | - foreach(RegisteredJWTClaimNames::$registered_claim_set as $claim_name){ |
|
| 39 | + foreach (RegisteredJWTClaimNames::$registered_claim_set as $claim_name) { |
|
| 40 | 40 | $value = isset($raw_claims[$claim_name]) ? $raw_claims[$claim_name] : null; |
| 41 | 41 | $type = RegisteredJWTClaimNames::$registered_claim_set_types[$claim_name]; |
| 42 | - if(!is_null($value)) |
|
| 42 | + if (!is_null($value)) |
|
| 43 | 43 | { |
| 44 | 44 | $class = new ReflectionClass($type); |
| 45 | 45 | $value = $class->newInstanceArgs(array($value)); |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | |
| 55 | 55 | // unregistered claims |
| 56 | 56 | |
| 57 | - foreach($raw_claims as $k => $v){ |
|
| 57 | + foreach ($raw_claims as $k => $v) { |
|
| 58 | 58 | $claim_set->addClaim(new JWTClaim($k, new JsonValue($v))); |
| 59 | 59 | } |
| 60 | 60 | |
@@ -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 |
@@ -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 | } |
@@ -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; |
@@ -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 | |
@@ -29,12 +29,12 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 | |
@@ -72,5 +72,5 @@ |
||
| 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 |