decode() 공개 메소드

public decode ( string $value ) : string
$value string
리턴 string
예제 #1
0
 /**
  * @param string $jwt
  * @return Token
  */
 public function deserialize($jwt)
 {
     $token = new Token();
     list($encodedHeader, $encodedPayload, $encodedSignature) = explode('.', $jwt);
     $decodedHeader = $this->encoding->decode($encodedHeader);
     $decodedPayload = $this->encoding->decode($encodedPayload);
     $decodedSignature = $this->encoding->decode($encodedSignature);
     foreach ($this->parseHeaders($decodedHeader) as $header) {
         $token->addHeader($header);
     }
     foreach ($this->parsePayload($decodedPayload) as $claim) {
         $token->addClaim($claim);
     }
     $token->setSignature($decodedSignature);
     return $token;
 }
예제 #2
0
파일: Compact.php 프로젝트: emarref/jwt
 /**
  * @param string $jwt
  *
  * @return Token
  * @throws \InvalidArgumentException
  */
 public function deserialize($jwt)
 {
     $token = new Token();
     if (empty($jwt)) {
         throw new \InvalidArgumentException('Not a valid JWT string passed for deserialization');
     }
     list($encodedHeader, $encodedPayload, $encodedSignature) = array_pad(explode('.', $jwt, 3), 3, null);
     $decodedHeader = $this->encoding->decode($encodedHeader);
     $decodedPayload = $this->encoding->decode($encodedPayload);
     $decodedSignature = $this->encoding->decode($encodedSignature);
     foreach ($this->parseHeaders($decodedHeader) as $header) {
         $token->addHeader($header);
     }
     foreach ($this->parsePayload($decodedPayload) as $claim) {
         $token->addClaim($claim);
     }
     $token->setSignature($decodedSignature);
     return $token;
 }