@@ -39,18 +39,18 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | public function sign(PrivateKey $private_key, $message) |
| 41 | 41 | { |
| 42 | - if(!($private_key instanceof RSAPrivateKey)) throw new InvalidKeyTypeAlgorithmException; |
|
| 42 | + if (!($private_key instanceof RSAPrivateKey)) throw new InvalidKeyTypeAlgorithmException; |
|
| 43 | 43 | |
| 44 | - if($this->getMinKeyLen() > $private_key->getBitLength()) |
|
| 45 | - throw new InvalidKeyLengthAlgorithmException(sprintf('min len %s - cur len %s.',$this->getMinKeyLen(), $private_key->getBitLength())); |
|
| 44 | + if ($this->getMinKeyLen() > $private_key->getBitLength()) |
|
| 45 | + throw new InvalidKeyLengthAlgorithmException(sprintf('min len %s - cur len %s.', $this->getMinKeyLen(), $private_key->getBitLength())); |
|
| 46 | 46 | |
| 47 | - if($private_key->hasPassword()){ |
|
| 47 | + if ($private_key->hasPassword()) { |
|
| 48 | 48 | $this->rsa_impl->setPassword($private_key->getPassword()); |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | $res = $this->rsa_impl->loadKey($private_key->getEncoded()); |
| 52 | 52 | |
| 53 | - if(!$res) |
|
| 53 | + if (!$res) |
|
| 54 | 54 | throw new InvalidKeyTypeAlgorithmException; |
| 55 | 55 | |
| 56 | 56 | $this->rsa_impl->setHash($this->getHashingAlgorithm()); |
@@ -69,14 +69,14 @@ discard block |
||
| 69 | 69 | */ |
| 70 | 70 | public function verify(Key $key, $message, $signature) |
| 71 | 71 | { |
| 72 | - if(!($key instanceof RSAPublicKey)) throw new InvalidKeyTypeAlgorithmException; |
|
| 72 | + if (!($key instanceof RSAPublicKey)) throw new InvalidKeyTypeAlgorithmException; |
|
| 73 | 73 | |
| 74 | - if($this->getMinKeyLen() > $key->getBitLength()) |
|
| 75 | - throw new InvalidKeyLengthAlgorithmException(sprintf('min len %s - cur len %s.',$this->getMinKeyLen(), $key->getBitLength())); |
|
| 74 | + if ($this->getMinKeyLen() > $key->getBitLength()) |
|
| 75 | + throw new InvalidKeyLengthAlgorithmException(sprintf('min len %s - cur len %s.', $this->getMinKeyLen(), $key->getBitLength())); |
|
| 76 | 76 | |
| 77 | 77 | $res = $this->rsa_impl->loadKey($key->getEncoded()); |
| 78 | 78 | |
| 79 | - if(!$res) throw new InvalidKeyTypeAlgorithmException; |
|
| 79 | + if (!$res) throw new InvalidKeyTypeAlgorithmException; |
|
| 80 | 80 | |
| 81 | 81 | $this->rsa_impl->setHash($this->getHashingAlgorithm()); |
| 82 | 82 | $this->rsa_impl->setMGFHash($this->getHashingAlgorithm()); |
@@ -39,10 +39,13 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | public function sign(PrivateKey $private_key, $message) |
| 41 | 41 | { |
| 42 | - if(!($private_key instanceof RSAPrivateKey)) throw new InvalidKeyTypeAlgorithmException; |
|
| 42 | + if(!($private_key instanceof RSAPrivateKey)) { |
|
| 43 | + throw new InvalidKeyTypeAlgorithmException; |
|
| 44 | + } |
|
| 43 | 45 | |
| 44 | - if($this->getMinKeyLen() > $private_key->getBitLength()) |
|
| 45 | - throw new InvalidKeyLengthAlgorithmException(sprintf('min len %s - cur len %s.',$this->getMinKeyLen(), $private_key->getBitLength())); |
|
| 46 | + if($this->getMinKeyLen() > $private_key->getBitLength()) { |
|
| 47 | + throw new InvalidKeyLengthAlgorithmException(sprintf('min len %s - cur len %s.',$this->getMinKeyLen(), $private_key->getBitLength())); |
|
| 48 | + } |
|
| 46 | 49 | |
| 47 | 50 | if($private_key->hasPassword()){ |
| 48 | 51 | $this->rsa_impl->setPassword($private_key->getPassword()); |
@@ -50,8 +53,9 @@ discard block |
||
| 50 | 53 | |
| 51 | 54 | $res = $this->rsa_impl->loadKey($private_key->getEncoded()); |
| 52 | 55 | |
| 53 | - if(!$res) |
|
| 54 | - throw new InvalidKeyTypeAlgorithmException; |
|
| 56 | + if(!$res) { |
|
| 57 | + throw new InvalidKeyTypeAlgorithmException; |
|
| 58 | + } |
|
| 55 | 59 | |
| 56 | 60 | $this->rsa_impl->setHash($this->getHashingAlgorithm()); |
| 57 | 61 | $this->rsa_impl->setMGFHash($this->getHashingAlgorithm()); |
@@ -69,14 +73,19 @@ discard block |
||
| 69 | 73 | */ |
| 70 | 74 | public function verify(Key $key, $message, $signature) |
| 71 | 75 | { |
| 72 | - if(!($key instanceof RSAPublicKey)) throw new InvalidKeyTypeAlgorithmException; |
|
| 76 | + if(!($key instanceof RSAPublicKey)) { |
|
| 77 | + throw new InvalidKeyTypeAlgorithmException; |
|
| 78 | + } |
|
| 73 | 79 | |
| 74 | - if($this->getMinKeyLen() > $key->getBitLength()) |
|
| 75 | - throw new InvalidKeyLengthAlgorithmException(sprintf('min len %s - cur len %s.',$this->getMinKeyLen(), $key->getBitLength())); |
|
| 80 | + if($this->getMinKeyLen() > $key->getBitLength()) { |
|
| 81 | + throw new InvalidKeyLengthAlgorithmException(sprintf('min len %s - cur len %s.',$this->getMinKeyLen(), $key->getBitLength())); |
|
| 82 | + } |
|
| 76 | 83 | |
| 77 | 84 | $res = $this->rsa_impl->loadKey($key->getEncoded()); |
| 78 | 85 | |
| 79 | - if(!$res) throw new InvalidKeyTypeAlgorithmException; |
|
| 86 | + if(!$res) { |
|
| 87 | + throw new InvalidKeyTypeAlgorithmException; |
|
| 88 | + } |
|
| 80 | 89 | |
| 81 | 90 | $this->rsa_impl->setHash($this->getHashingAlgorithm()); |
| 82 | 91 | $this->rsa_impl->setMGFHash($this->getHashingAlgorithm()); |
@@ -31,17 +31,17 @@ discard block |
||
| 31 | 31 | */ |
| 32 | 32 | private $rsa_imp; |
| 33 | 33 | |
| 34 | - private function __construct(){ |
|
| 34 | + private function __construct() { |
|
| 35 | 35 | $this->rsa_imp = new RSA(); |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - private function __clone(){} |
|
| 38 | + private function __clone() {} |
|
| 39 | 39 | |
| 40 | 40 | /** |
| 41 | 41 | * @return RSAFacade |
| 42 | 42 | */ |
| 43 | - public static function getInstance(){ |
|
| 44 | - if(!is_object(self::$instance)){ |
|
| 43 | + public static function getInstance() { |
|
| 44 | + if (!is_object(self::$instance)) { |
|
| 45 | 45 | self::$instance = new RSAFacade(); |
| 46 | 46 | } |
| 47 | 47 | return self::$instance; |
@@ -51,12 +51,12 @@ discard block |
||
| 51 | 51 | * @param $bits |
| 52 | 52 | * @return KeyPair |
| 53 | 53 | */ |
| 54 | - public function buildKeyPair($bits){ |
|
| 54 | + public function buildKeyPair($bits) { |
|
| 55 | 55 | $this->rsa_imp->setPrivateKeyFormat(RSA::PRIVATE_FORMAT_PKCS1); |
| 56 | 56 | $this->rsa_imp->setPublicKeyFormat(RSA::PUBLIC_FORMAT_PKCS1); |
| 57 | 57 | |
| 58 | 58 | $list = $this->rsa_imp->createKey($bits); |
| 59 | - return new KeyPair( new _RSAPublicKeyPEMFormat($list['publickey']), new _RSAPrivateKeyPEMFormat($list['privatekey'])); |
|
| 59 | + return new KeyPair(new _RSAPublicKeyPEMFormat($list['publickey']), new _RSAPrivateKeyPEMFormat($list['privatekey'])); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /** |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | * @param BigInteger $e |
| 65 | 65 | * @return RSAPublicKey |
| 66 | 66 | */ |
| 67 | - public function buildPublicKey(BigInteger $n, BigInteger $e){ |
|
| 67 | + public function buildPublicKey(BigInteger $n, BigInteger $e) { |
|
| 68 | 68 | $public_key_pem = $this->rsa_imp->_convertPublicKey($n, $e); |
| 69 | 69 | return new _RSAPublicKeyPEMFormat($public_key_pem); |
| 70 | 70 | } |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | * @param \Math_BigInteger $d |
| 75 | 75 | * @return RSAPrivateKey |
| 76 | 76 | */ |
| 77 | - public function buildMinimalPrivateKey(\Math_BigInteger $n, \Math_BigInteger $d){ |
|
| 77 | + public function buildMinimalPrivateKey(\Math_BigInteger $n, \Math_BigInteger $d) { |
|
| 78 | 78 | $this->rsa_imp->modulus = $n; |
| 79 | 79 | $this->rsa_imp->exponent = $d; |
| 80 | 80 | $private_key_pem = $this->rsa_imp->_getPrivatePublicKey(); |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | BigInteger $q, |
| 100 | 100 | BigInteger $dp, |
| 101 | 101 | BigInteger $dq, |
| 102 | - BigInteger $qi){ |
|
| 102 | + BigInteger $qi) { |
|
| 103 | 103 | |
| 104 | 104 | $private_key_pem = $this->rsa_imp->_convertPrivateKey( |
| 105 | 105 | $n, |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | * @return RSAPrivateKey |
| 119 | 119 | * @throws RSABadPEMFormat |
| 120 | 120 | */ |
| 121 | - public function buildPrivateKeyFromPEM($private_key_pem, $password = null){ |
|
| 121 | + public function buildPrivateKeyFromPEM($private_key_pem, $password = null) { |
|
| 122 | 122 | return new _RSAPrivateKeyPEMFormat($private_key_pem, $password); |
| 123 | 123 | } |
| 124 | 124 | |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | * @return RSAPublicKey |
| 128 | 128 | * @throws RSABadPEMFormat |
| 129 | 129 | */ |
| 130 | - public function buildPublicKeyFromPEM($public_key_pem){ |
|
| 130 | + public function buildPublicKeyFromPEM($public_key_pem) { |
|
| 131 | 131 | return new _RSAPublicKeyPEMFormat($public_key_pem); |
| 132 | 132 | } |
| 133 | 133 | |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | /** |
| 44 | 44 | * @return null|string |
| 45 | 45 | */ |
| 46 | - public function getPassword():?string{ |
|
| 46 | + public function getPassword(): ?string{ |
|
| 47 | 47 | return $this->password; |
| 48 | 48 | } |
| 49 | 49 | |
@@ -59,19 +59,19 @@ discard block |
||
| 59 | 59 | * @param string $password |
| 60 | 60 | * @throws RSABadPEMFormat |
| 61 | 61 | */ |
| 62 | - public function __construct($pem_format, $password = null){ |
|
| 62 | + public function __construct($pem_format, $password = null) { |
|
| 63 | 63 | |
| 64 | 64 | $this->pem_format = $pem_format; |
| 65 | 65 | $this->rsa_imp = new RSA(); |
| 66 | 66 | |
| 67 | - if(!empty($password)) { |
|
| 67 | + if (!empty($password)) { |
|
| 68 | 68 | $this->password = trim($password); |
| 69 | 69 | $this->rsa_imp->setPassword($this->password); |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | $res = $this->rsa_imp->loadKey($this->pem_format, RSA::PRIVATE_FORMAT_PKCS1); |
| 73 | 73 | |
| 74 | - if(!$res) throw new RSABadPEMFormat(sprintf('pem %s',$pem_format )); |
|
| 74 | + if (!$res) throw new RSABadPEMFormat(sprintf('pem %s', $pem_format)); |
|
| 75 | 75 | |
| 76 | 76 | $this->n = $this->rsa_imp->modulus; |
| 77 | 77 | } |
@@ -71,7 +71,9 @@ |
||
| 71 | 71 | |
| 72 | 72 | $res = $this->rsa_imp->loadKey($this->pem_format, RSA::PRIVATE_FORMAT_PKCS1); |
| 73 | 73 | |
| 74 | - if(!$res) throw new RSABadPEMFormat(sprintf('pem %s',$pem_format )); |
|
| 74 | + if(!$res) { |
|
| 75 | + throw new RSABadPEMFormat(sprintf('pem %s',$pem_format )); |
|
| 76 | + } |
|
| 75 | 77 | |
| 76 | 78 | $this->n = $this->rsa_imp->modulus; |
| 77 | 79 | } |
@@ -32,11 +32,11 @@ discard block |
||
| 32 | 32 | * @param string $password |
| 33 | 33 | * @throws RSABadPEMFormat |
| 34 | 34 | */ |
| 35 | - public function __construct($pem_format, $password = null){ |
|
| 35 | + public function __construct($pem_format, $password = null) { |
|
| 36 | 36 | |
| 37 | 37 | parent::__construct($pem_format, $password); |
| 38 | 38 | $this->d = $this->rsa_imp->exponent; |
| 39 | - if($this->d->toString() === $this->e->toString()) |
|
| 39 | + if ($this->d->toString() === $this->e->toString()) |
|
| 40 | 40 | throw new RSABadPEMFormat(sprintf('pem %s is a public key!', $pem_format)); |
| 41 | 41 | } |
| 42 | 42 | |
@@ -71,9 +71,9 @@ discard block |
||
| 71 | 71 | */ |
| 72 | 72 | public function getStrippedEncoded(): string |
| 73 | 73 | { |
| 74 | - $pem = preg_replace('/\-+BEGIN RSA PRIVATE KEY\-+/','',$this->getEncoded()); |
|
| 75 | - $pem = preg_replace('/\-+END RSA PRIVATE KEY\-+/','',$pem); |
|
| 76 | - $pem = str_replace( array("\n","\r","\t"), '', trim($pem)); |
|
| 74 | + $pem = preg_replace('/\-+BEGIN RSA PRIVATE KEY\-+/', '', $this->getEncoded()); |
|
| 75 | + $pem = preg_replace('/\-+END RSA PRIVATE KEY\-+/', '', $pem); |
|
| 76 | + $pem = str_replace(array("\n", "\r", "\t"), '', trim($pem)); |
|
| 77 | 77 | return $pem; |
| 78 | 78 | } |
| 79 | 79 | |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * @param string $password |
| 33 | 33 | * @throws RSABadPEMFormat |
| 34 | 34 | */ |
| 35 | - public function __construct($pem_format, $password = null){ |
|
| 35 | + public function __construct($pem_format, $password = null) { |
|
| 36 | 36 | parent::__construct($pem_format, $password); |
| 37 | 37 | $this->e = $this->rsa_imp->publicExponent; |
| 38 | 38 | } |
@@ -83,9 +83,9 @@ discard block |
||
| 83 | 83 | */ |
| 84 | 84 | public function getStrippedEncoded(): string |
| 85 | 85 | { |
| 86 | - $pem = preg_replace('/\-+BEGIN PUBLIC KEY\-+/','', $this->getEncoded()); |
|
| 87 | - $pem = preg_replace('/\-+END PUBLIC KEY\-+/','',$pem); |
|
| 88 | - $pem = str_replace( array("\n","\r","\t"), '', trim($pem)); |
|
| 86 | + $pem = preg_replace('/\-+BEGIN PUBLIC KEY\-+/', '', $this->getEncoded()); |
|
| 87 | + $pem = preg_replace('/\-+END PUBLIC KEY\-+/', '', $pem); |
|
| 88 | + $pem = str_replace(array("\n", "\r", "\t"), '', trim($pem)); |
|
| 89 | 89 | return $pem; |
| 90 | 90 | } |
| 91 | 91 | } |
| 92 | 92 | \ No newline at end of file |
@@ -21,7 +21,7 @@ |
||
| 21 | 21 | /** |
| 22 | 22 | * @return null|string |
| 23 | 23 | */ |
| 24 | - public function getPassword():?string; |
|
| 24 | + public function getPassword(): ?string; |
|
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | 27 | * @return bool |
@@ -59,32 +59,32 @@ discard block |
||
| 59 | 59 | { |
| 60 | 60 | parent::__construct($headers); |
| 61 | 61 | |
| 62 | - if(count($headers) === 0 ) return; |
|
| 62 | + if (count($headers) === 0) return; |
|
| 63 | 63 | |
| 64 | 64 | // certificates |
| 65 | - if(in_array(PublicJSONWebKeyParameters::X_509CertificateChain, $headers) && is_array($headers[PublicJSONWebKeyParameters::X_509CertificateChain])){ |
|
| 65 | + if (in_array(PublicJSONWebKeyParameters::X_509CertificateChain, $headers) && is_array($headers[PublicJSONWebKeyParameters::X_509CertificateChain])) { |
|
| 66 | 66 | |
| 67 | 67 | // json array |
| 68 | - foreach($headers[PublicJSONWebKeyParameters::X_509CertificateChain] as $x509_pem){ |
|
| 69 | - $this->x509_certificates_chain[] = X509CertificateFactory::buildFromPEM($x509_pem); |
|
| 68 | + foreach ($headers[PublicJSONWebKeyParameters::X_509CertificateChain] as $x509_pem) { |
|
| 69 | + $this->x509_certificates_chain[] = X509CertificateFactory::buildFromPEM($x509_pem); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - if($this->checkX509CertMismatch()){ |
|
| 72 | + if ($this->checkX509CertMismatch()) { |
|
| 73 | 73 | throw new X509CertMismatchException; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | $this->set[PublicJSONWebKeyParameters::X_509CertificateChain] = new JsonArray($headers[PublicJSONWebKeyParameters::X_509CertificateChain]); |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - if(in_array(PublicJSONWebKeyParameters::X_509CertificateSHA_1_Thumbprint, $headers)){ |
|
| 80 | - $this->set[PublicJSONWebKeyParameters::X_509CertificateSHA_1_Thumbprint] = new StringOrURI($headers[PublicJSONWebKeyParameters::X_509CertificateSHA_1_Thumbprint]) ; |
|
| 79 | + if (in_array(PublicJSONWebKeyParameters::X_509CertificateSHA_1_Thumbprint, $headers)) { |
|
| 80 | + $this->set[PublicJSONWebKeyParameters::X_509CertificateSHA_1_Thumbprint] = new StringOrURI($headers[PublicJSONWebKeyParameters::X_509CertificateSHA_1_Thumbprint]); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - if(in_array(PublicJSONWebKeyParameters::X_509CertificateSHA_256_Thumbprint, $headers)){ |
|
| 83 | + if (in_array(PublicJSONWebKeyParameters::X_509CertificateSHA_256_Thumbprint, $headers)) { |
|
| 84 | 84 | $this->set[PublicJSONWebKeyParameters::X_509CertificateSHA_256_Thumbprint] = new StringOrURI($headers[PublicJSONWebKeyParameters::X_509CertificateSHA_256_Thumbprint]); |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - if(in_array(PublicJSONWebKeyParameters::X_509Url, $headers)){ |
|
| 87 | + if (in_array(PublicJSONWebKeyParameters::X_509Url, $headers)) { |
|
| 88 | 88 | $this->set[PublicJSONWebKeyParameters::X_509Url] = new StringOrURI($headers[PublicJSONWebKeyParameters::X_509Url]); |
| 89 | 89 | } |
| 90 | 90 | } |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | */ |
| 105 | 105 | public function setVisibility($visibility) |
| 106 | 106 | { |
| 107 | - if(!in_array($visibility, JSONWebKeyVisibility::$valid_values)) |
|
| 107 | + if (!in_array($visibility, JSONWebKeyVisibility::$valid_values)) |
|
| 108 | 108 | throw new InvalidJWKVisibilityException; |
| 109 | 109 | $this->visibility = $visibility; |
| 110 | 110 | return $this; |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | /** |
| 130 | 130 | * @return null | X509Certificate |
| 131 | 131 | */ |
| 132 | - public function getX509LeafCertificate(){ |
|
| 132 | + public function getX509LeafCertificate() { |
|
| 133 | 133 | return count($this->x509_certificates_chain) > 0 ? $this->x509_certificates_chain[0] : null; |
| 134 | 134 | } |
| 135 | 135 | |
@@ -148,10 +148,10 @@ discard block |
||
| 148 | 148 | */ |
| 149 | 149 | public function getX509CertificateSha1Thumbprint($fallback_on_x5c = false) |
| 150 | 150 | { |
| 151 | - $res = is_null($this[PublicJSONWebKeyParameters::X_509CertificateSHA_1_Thumbprint])? null : $this[PublicJSONWebKeyParameters::X_509CertificateSHA_1_Thumbprint]->getString(); |
|
| 152 | - if(empty($res) && $fallback_on_x5c){ |
|
| 151 | + $res = is_null($this[PublicJSONWebKeyParameters::X_509CertificateSHA_1_Thumbprint]) ? null : $this[PublicJSONWebKeyParameters::X_509CertificateSHA_1_Thumbprint]->getString(); |
|
| 152 | + if (empty($res) && $fallback_on_x5c) { |
|
| 153 | 153 | $x509 = $this->getX509LeafCertificate(); |
| 154 | - if(!is_null($x509)){ |
|
| 154 | + if (!is_null($x509)) { |
|
| 155 | 155 | return $x509->getSHA_1_Thumbprint(); |
| 156 | 156 | } |
| 157 | 157 | } |
@@ -164,10 +164,10 @@ discard block |
||
| 164 | 164 | */ |
| 165 | 165 | public function getX509CertificateSha256Thumbprint($fallback_on_x5c = false) |
| 166 | 166 | { |
| 167 | - $res = is_null($this[PublicJSONWebKeyParameters::X_509CertificateSHA_256_Thumbprint])? null : $this[PublicJSONWebKeyParameters::X_509CertificateSHA_256_Thumbprint]->getString(); |
|
| 168 | - if(empty($res) && $fallback_on_x5c){ |
|
| 167 | + $res = is_null($this[PublicJSONWebKeyParameters::X_509CertificateSHA_256_Thumbprint]) ? null : $this[PublicJSONWebKeyParameters::X_509CertificateSHA_256_Thumbprint]->getString(); |
|
| 168 | + if (empty($res) && $fallback_on_x5c) { |
|
| 169 | 169 | $x509 = $this->getX509LeafCertificate(); |
| 170 | - if(!is_null($x509)){ |
|
| 170 | + if (!is_null($x509)) { |
|
| 171 | 171 | return $x509->getSHA_256_Thumbprint(); |
| 172 | 172 | } |
| 173 | 173 | } |
@@ -179,13 +179,13 @@ discard block |
||
| 179 | 179 | */ |
| 180 | 180 | public function getX509Url() |
| 181 | 181 | { |
| 182 | - return is_null($this[PublicJSONWebKeyParameters::X_509Url])? null : $this[PublicJSONWebKeyParameters::X_509Url]->getString(); |
|
| 182 | + return is_null($this[PublicJSONWebKeyParameters::X_509Url]) ? null : $this[PublicJSONWebKeyParameters::X_509Url]->getString(); |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | /** |
| 186 | 186 | * @return bool |
| 187 | 187 | */ |
| 188 | - protected function checkX509CertMismatch(){ |
|
| 188 | + protected function checkX509CertMismatch() { |
|
| 189 | 189 | $x509 = $this->getX509LeafCertificate(); |
| 190 | 190 | return !is_null($x509) && $x509->getPublicKey() !== $this->public_key->getStrippedEncoded(); |
| 191 | 191 | } |
@@ -195,13 +195,13 @@ discard block |
||
| 195 | 195 | * @return $this |
| 196 | 196 | * @throws X509CertMismatchException |
| 197 | 197 | */ |
| 198 | - public function setX509CertificateChain(array $x5c){ |
|
| 198 | + public function setX509CertificateChain(array $x5c) { |
|
| 199 | 199 | // json array |
| 200 | - foreach($x5c as $x509_pem){ |
|
| 200 | + foreach ($x5c as $x509_pem) { |
|
| 201 | 201 | array_push($this->x509_certificates_chain, X509CertificateFactory::buildFromPEM($x509_pem)); |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | - if($this->checkX509CertMismatch()){ |
|
| 204 | + if ($this->checkX509CertMismatch()) { |
|
| 205 | 205 | throw new X509CertMismatchException; |
| 206 | 206 | } |
| 207 | 207 | |