Exemple #1
0
 /**
  * Initialize from a PrivateKey object.
  *
  * @param PrivateKey $priv_key Private key
  * @throws \UnexpectedValueException
  * @return self
  */
 public static function fromPrivateKey(PrivateKey $priv_key)
 {
     if ($priv_key instanceof RSAPrivateKey) {
         return RSAPrivateKeyJWK::fromRSAPrivateKey($priv_key);
     }
     if ($priv_key instanceof ECPrivateKey) {
         return ECPrivateKeyJWK::fromECPrivateKey($priv_key);
     }
     throw new \UnexpectedValueException("Unsupported private key.");
 }