public static function deserialize($input) { $parts = explode(IBasicJWT::SegmentSeparator, $input); if (count($parts) !== 5) { throw new JWEInvalidCompactFormatException(); } $header = JWEJOSEHeaderSerializer::deserialize($parts[0]); $enc_cek = JWTRawSerializer::deserialize($parts[1]); $iv = JWTRawSerializer::deserialize($parts[2]); $cipher_text = JWTRawSerializer::deserialize($parts[3]); $tag = JWTRawSerializer::deserialize($parts[4]); return array($header, $enc_cek, $iv, $cipher_text, $tag); }
/** * @param string $input * @return array * @throws InvalidJWTException */ public static function deserialize($input) { $e_parts = explode(IBasicJWT::SegmentSeparator, $input); if (count($e_parts) < 2) { throw new InvalidJWTException(sprintf('%s has only 2 or less encoded parts!')); } $e_header = $e_parts[0]; $e_payload = $e_parts[1]; $e_signature = count($e_parts) > 2 ? $e_parts[2] : ''; $header = JOSEHeaderSerializer::deserialize($e_header); $payload = $header->getType()->getString() === 'JWT' ? JWTClaimSetSerializer::deserialize($e_payload) : JWTRawSerializer::deserialize($e_payload); $signature = !empty($e_signature) ? JWTRawSerializer::deserialize($e_signature) : ''; return array($header, $payload, $signature); }
/** * @return string * @throws JWSInvalidPayloadException */ public function getEncodedPayload() { if (is_null($this->payload)) { throw new JWSInvalidPayloadException('payload is not set!'); } $enc_payload = ''; if ($this->payload->isClaimSet() && $this->payload instanceof IJWSPayloadClaimSetSpec) { $enc_payload = JWTClaimSetSerializer::serialize($this->payload->getClaimSet()); } else { $enc_payload = JWTRawSerializer::serialize($this->payload->getRaw()); } return $enc_payload; }
public static function deserialize($input) { $json = JWTRawSerializer::deserialize($input); $raw_claims = json_decode($json, true); return JWTClaimSetFactory::build($raw_claims); }
/** * @param string $input * @return IJWEJOSEHeader */ public static function deserialize($input) { $json = JWTRawSerializer::deserialize($input); $raw_headers = json_decode($json, true); return JWEJOSEHeaderFactory::build($raw_headers); }