Exemple #1
0
Fichier : JWS.php Projet : 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);
 }
Exemple #2
0
 /**
  * Get the parameter value as a decoded string.
  *
  * @return string
  */
 public function string()
 {
     return Base64::urlDecode($this->value());
 }
Exemple #3
0
Fichier : JWT.php Projet : sop/jwx
 /**
  * Get JWT header.
  *
  * @return JOSE
  */
 public function header()
 {
     $header = Header::fromJSON(Base64::urlDecode($this->_parts[0]));
     return new JOSE($header);
 }
Exemple #4
0
Fichier : JWE.php Projet : 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);
 }
Exemple #5
0
 /**
  * Get coordinate in octet string representation.
  *
  * @return string
  */
 public function coordinateOctets()
 {
     return Base64::urlDecode($this->_value);
 }
Exemple #6
0
 /**
  * Get the symmetric key.
  *
  * @return string
  */
 public function key()
 {
     return Base64::urlDecode($this->keyValueParameter()->value());
 }
Exemple #7
0
 /**
  * Get value as a number.
  *
  * @return BigInt
  */
 public function number()
 {
     return BigInt::fromBase256(Base64::urlDecode($this->value()));
 }