示例#1
0
文件: JWS.php 项目: sop/jwx
 /**
  * Initialize from the parts of a compact serialization.
  *
  * @param array $parts
  * @throws \UnexpectedValueException
  * @return self
  */
 public static function fromParts(array $parts)
 {
     if (count($parts) != 3) {
         throw new \UnexpectedValueException("Invalid JWS compact serialization.");
     }
     $header = Header::fromJSON(Base64::urlDecode($parts[0]));
     $b64 = $header->hasB64Payload() ? $header->B64Payload()->value() : true;
     $payload = $b64 ? Base64::urlDecode($parts[1]) : $parts[1];
     $signature_input = $parts[0] . "." . $parts[1];
     $signature = Base64::urlDecode($parts[2]);
     return new self($header, $payload, $signature_input, $signature);
 }
示例#2
0
 /**
  * Get the parameter value as a decoded string.
  *
  * @return string
  */
 public function string()
 {
     return Base64::urlDecode($this->value());
 }
示例#3
0
文件: JWT.php 项目: sop/jwx
 /**
  * Get JWT header.
  *
  * @return JOSE
  */
 public function header()
 {
     $header = Header::fromJSON(Base64::urlDecode($this->_parts[0]));
     return new JOSE($header);
 }
示例#4
0
文件: JWE.php 项目: sop/jwx
 /**
  * Initialize from parts of compact serialization.
  *
  * @param array $parts
  * @throws \UnexpectedValueException
  * @return self
  */
 public static function fromParts(array $parts)
 {
     if (count($parts) != 5) {
         throw new \UnexpectedValueException("Invalid JWE compact serialization.");
     }
     $header = Header::fromJSON(Base64::urlDecode($parts[0]));
     $encrypted_key = Base64::urlDecode($parts[1]);
     $iv = Base64::urlDecode($parts[2]);
     $ciphertext = Base64::urlDecode($parts[3]);
     $auth_tag = Base64::urlDecode($parts[4]);
     return new self($header, $encrypted_key, $iv, $ciphertext, $auth_tag);
 }
示例#5
0
 /**
  * Get coordinate in octet string representation.
  *
  * @return string
  */
 public function coordinateOctets()
 {
     return Base64::urlDecode($this->_value);
 }
示例#6
0
 /**
  * Get the symmetric key.
  *
  * @return string
  */
 public function key()
 {
     return Base64::urlDecode($this->keyValueParameter()->value());
 }
示例#7
0
 /**
  * Get value as a number.
  *
  * @return BigInt
  */
 public function number()
 {
     return BigInt::fromBase256(Base64::urlDecode($this->value()));
 }