@@ -40,8 +40,7 @@ discard block |
||
| 40 | 40 | * @param JsonValue $id |
| 41 | 41 | * @param NumericDate $nbf |
| 42 | 42 | */ |
| 43 | - public function __construct |
|
| 44 | - ( |
|
| 43 | + public function __construct( |
|
| 45 | 44 | StringOrURI $issuer = null, |
| 46 | 45 | StringOrURI $subject = null, |
| 47 | 46 | StringOrURI $audience = null, |
@@ -135,7 +134,7 @@ discard block |
||
| 135 | 134 | public function getClaims() |
| 136 | 135 | { |
| 137 | 136 | $claims = array(); |
| 138 | - foreach($this->set as $k => $v) |
|
| 137 | + foreach ($this->set as $k => $v) |
|
| 139 | 138 | { |
| 140 | 139 | array_push($claims, new JWTClaim($k, $v)); |
| 141 | 140 | } |
@@ -260,7 +259,6 @@ discard block |
||
| 260 | 259 | public function getClaimByName($claim_name) |
| 261 | 260 | { |
| 262 | 261 | return isset($this->set[$claim_name]) ? |
| 263 | - $this->set[$claim_name] : |
|
| 264 | - null; |
|
| 262 | + $this->set[$claim_name] : null; |
|
| 265 | 263 | } |
| 266 | 264 | } |
| 267 | 265 | \ No newline at end of file |
@@ -33,8 +33,7 @@ discard block |
||
| 33 | 33 | * @param JsonValue|null $kid |
| 34 | 34 | * @param StringOrURI|null $cty |
| 35 | 35 | */ |
| 36 | - public function __construct |
|
| 37 | - ( |
|
| 36 | + public function __construct( |
|
| 38 | 37 | StringOrURI $alg, |
| 39 | 38 | StringOrURI $type = null, |
| 40 | 39 | JsonValue $kid = null, |
@@ -96,7 +95,7 @@ discard block |
||
| 96 | 95 | public function getHeaderByName($name) |
| 97 | 96 | { |
| 98 | 97 | $value = $this[$name]; |
| 99 | - if(is_null($value)) return null; |
|
| 98 | + if (is_null($value)) return null; |
|
| 100 | 99 | return new JOSEHeaderParam($name, $value); |
| 101 | 100 | } |
| 102 | 101 | } |
| 103 | 102 | \ No newline at end of file |
@@ -37,10 +37,8 @@ discard block |
||
| 37 | 37 | protected function __construct(IJWTClaimSet $claim_set) |
| 38 | 38 | { |
| 39 | 39 | |
| 40 | - parent::__construct |
|
| 41 | - ( |
|
| 42 | - new JOSEHeader |
|
| 43 | - ( |
|
| 40 | + parent::__construct( |
|
| 41 | + new JOSEHeader( |
|
| 44 | 42 | new StringOrURI('none'), |
| 45 | 43 | new StringOrURI('JWT') |
| 46 | 44 | ), |
@@ -75,7 +73,7 @@ discard block |
||
| 75 | 73 | { |
| 76 | 74 | list($header, $payload, $signature) = JWTSerializer::deserialize($compact_serialization); |
| 77 | 75 | |
| 78 | - if(!($payload instanceof IJWTClaimSet)) |
|
| 76 | + if (!($payload instanceof IJWTClaimSet)) |
|
| 79 | 77 | throw new \RuntimeException('Invalid payload type!'); |
| 80 | 78 | |
| 81 | 79 | $jwt = new UnsecuredJWT($payload); |
@@ -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 | |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | class JOSEHeaderFactory { |
| 27 | 27 | |
| 28 | - static protected function getProductClass(){ |
|
| 28 | + static protected function getProductClass() { |
|
| 29 | 29 | return '\jwt\impl\JOSEHeader'; |
| 30 | 30 | } |
| 31 | 31 | |
@@ -38,12 +38,12 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | $args = array(); |
| 40 | 40 | |
| 41 | - foreach(RegisteredJOSEHeaderNames::$registered_basic_headers_set as $header_name){ |
|
| 41 | + foreach (RegisteredJOSEHeaderNames::$registered_basic_headers_set as $header_name) { |
|
| 42 | 42 | $value = isset($raw_headers[$header_name]) ? $raw_headers[$header_name] : null; |
| 43 | 43 | $type = @RegisteredJOSEHeaderNames::$registered_basic_headers_set_types[$header_name]; |
| 44 | - if(!is_null($value)) |
|
| 44 | + if (!is_null($value)) |
|
| 45 | 45 | { |
| 46 | - if(is_null($type)) continue; |
|
| 46 | + if (is_null($type)) continue; |
|
| 47 | 47 | $class = new \ReflectionClass($type); |
| 48 | 48 | $value = $class->newInstanceArgs(array($value)); |
| 49 | 49 | } |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | // unregistered headers |
| 59 | 59 | |
| 60 | - foreach($raw_headers as $k => $v){ |
|
| 60 | + foreach ($raw_headers as $k => $v) { |
|
| 61 | 61 | $basic_header->addHeader(new JOSEHeaderParam($k, new JsonValue($v))); |
| 62 | 62 | } |
| 63 | 63 | |
@@ -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 | } |