/** * @param array $headers * @throws X509CertMismatchException */ protected function __construct(array $headers = array()) { parent::__construct($headers); if (count($headers) === 0) { return; } // certificates if (in_array(PublicJSONWebKeyParameters::X_509CertificateChain, $headers) && is_array($headers[PublicJSONWebKeyParameters::X_509CertificateChain])) { // json array foreach ($headers[PublicJSONWebKeyParameters::X_509CertificateChain] as $x509_pem) { array_push($this->x509_certificates_chain, X509CertificateFactory::buildFromPEM($x509_pem)); } if ($this->checkX509CertMismatch()) { throw new X509CertMismatchException(); } $this->set[PublicJSONWebKeyParameters::X_509CertificateChain] = new JsonArray($headers[PublicJSONWebKeyParameters::X_509CertificateChain]); } if (in_array(PublicJSONWebKeyParameters::X_509CertificateSHA_1_Thumbprint, $headers)) { $this->set[PublicJSONWebKeyParameters::X_509CertificateSHA_1_Thumbprint] = new StringOrURI($headers[PublicJSONWebKeyParameters::X_509CertificateSHA_1_Thumbprint]); } if (in_array(PublicJSONWebKeyParameters::X_509CertificateSHA_256_Thumbprint, $headers)) { $this->set[PublicJSONWebKeyParameters::X_509CertificateSHA_256_Thumbprint] = new StringOrURI($headers[PublicJSONWebKeyParameters::X_509CertificateSHA_256_Thumbprint]); } if (in_array(PublicJSONWebKeyParameters::X_509Url, $headers)) { $this->set[PublicJSONWebKeyParameters::X_509Url] = new StringOrURI($headers[PublicJSONWebKeyParameters::X_509Url]); } }
protected function __construct(Key $secret, $headers = array()) { if (empty($secret)) { throw new InvalidOctetSequenceJWKException('secret is not set!.'); } $this->set[JSONWebKeyParameters::KeyType] = new StringOrURI(JSONWebKeyTypes::OctetSequence); parent::__construct($headers); if (count($headers) === 0) { return; } $b64 = new Base64UrlRepresentation(); $this->key = $secret; $this->set[OctetSequenceKeysParameters::Key] = new StringOrURI($b64->encode($secret->getEncoded())); }