@@ -43,17 +43,17 @@ |
||
| 43 | 43 | * @param string $password |
| 44 | 44 | * @throws RSABadPEMFormat |
| 45 | 45 | */ |
| 46 | - public function __construct($pem_format, $password = null){ |
|
| 46 | + public function __construct($pem_format, $password = null) { |
|
| 47 | 47 | |
| 48 | 48 | $this->pem_format = $pem_format; |
| 49 | 49 | $this->rsa_imp = new \Crypt_RSA(); |
| 50 | 50 | |
| 51 | - if(!empty($password)) |
|
| 51 | + if (!empty($password)) |
|
| 52 | 52 | $this->rsa_imp->setPassword($password); |
| 53 | 53 | |
| 54 | 54 | $res = $this->rsa_imp->loadKey($this->pem_format, CRYPT_RSA_PRIVATE_FORMAT_PKCS1); |
| 55 | 55 | |
| 56 | - if(!$res) throw new RSABadPEMFormat(sprintf('pem %s',$pem_format )); |
|
| 56 | + if (!$res) throw new RSABadPEMFormat(sprintf('pem %s', $pem_format)); |
|
| 57 | 57 | |
| 58 | 58 | $this->n = $this->rsa_imp->modulus; |
| 59 | 59 | } |
@@ -48,12 +48,15 @@ |
||
| 48 | 48 | $this->pem_format = $pem_format; |
| 49 | 49 | $this->rsa_imp = new \Crypt_RSA(); |
| 50 | 50 | |
| 51 | - if(!empty($password)) |
|
| 52 | - $this->rsa_imp->setPassword($password); |
|
| 51 | + if(!empty($password)) { |
|
| 52 | + $this->rsa_imp->setPassword($password); |
|
| 53 | + } |
|
| 53 | 54 | |
| 54 | 55 | $res = $this->rsa_imp->loadKey($this->pem_format, CRYPT_RSA_PRIVATE_FORMAT_PKCS1); |
| 55 | 56 | |
| 56 | - if(!$res) throw new RSABadPEMFormat(sprintf('pem %s',$pem_format )); |
|
| 57 | + if(!$res) { |
|
| 58 | + throw new RSABadPEMFormat(sprintf('pem %s',$pem_format )); |
|
| 59 | + } |
|
| 57 | 60 | |
| 58 | 61 | $this->n = $this->rsa_imp->modulus; |
| 59 | 62 | } |
@@ -33,20 +33,20 @@ |
||
| 33 | 33 | * @param PublicKey $public_key |
| 34 | 34 | * @param PrivateKey $private_key |
| 35 | 35 | */ |
| 36 | - public function __construct(PublicKey $public_key, PrivateKey $private_key){ |
|
| 36 | + public function __construct(PublicKey $public_key, PrivateKey $private_key) { |
|
| 37 | 37 | |
| 38 | 38 | $this->private_key = $private_key; |
| 39 | - $this->public_key = $public_key; |
|
| 39 | + $this->public_key = $public_key; |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | 43 | * @return PublicKey |
| 44 | 44 | */ |
| 45 | - public function getPublic(){ return $this->public_key; } |
|
| 45 | + public function getPublic() { return $this->public_key; } |
|
| 46 | 46 | |
| 47 | 47 | /** |
| 48 | 48 | * @return PrivateKey |
| 49 | 49 | */ |
| 50 | - public function getPrivate(){ return $this->private_key; } |
|
| 50 | + public function getPrivate() { return $this->private_key; } |
|
| 51 | 51 | |
| 52 | 52 | } |
| 53 | 53 | \ No newline at end of file |
@@ -24,7 +24,7 @@ |
||
| 24 | 24 | * @param string $pem |
| 25 | 25 | * @return X509Certificate |
| 26 | 26 | */ |
| 27 | - static public function buildFromPEM($pem){ |
|
| 27 | + static public function buildFromPEM($pem) { |
|
| 28 | 28 | return new _X509Certificate($pem); |
| 29 | 29 | } |
| 30 | 30 | } |
| 31 | 31 | \ No newline at end of file |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | /** |
| 28 | 28 | * @var array |
| 29 | 29 | */ |
| 30 | - private $info = array(); |
|
| 30 | + private $info = array(); |
|
| 31 | 31 | |
| 32 | 32 | /** |
| 33 | 33 | * @var \File_X509|null |
@@ -39,11 +39,11 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | private $original_pem = null; |
| 41 | 41 | |
| 42 | - public function __construct($pem){ |
|
| 42 | + public function __construct($pem) { |
|
| 43 | 43 | |
| 44 | 44 | $this->file = new \File_X509(); |
| 45 | 45 | $this->info = $this->file->loadX509($pem); |
| 46 | - if($this->info === false) throw new InvalidX509CertificateException($pem); |
|
| 46 | + if ($this->info === false) throw new InvalidX509CertificateException($pem); |
|
| 47 | 47 | $this->original_pem = $pem; |
| 48 | 48 | } |
| 49 | 49 | |
@@ -55,8 +55,8 @@ discard block |
||
| 55 | 55 | return $this->original_pem; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - private function calculateThumbprint($alg){ |
|
| 59 | - $pem = str_replace( array("\n","\r"), '', trim($this->original_pem)); |
|
| 58 | + private function calculateThumbprint($alg) { |
|
| 59 | + $pem = str_replace(array("\n", "\r"), '', trim($this->original_pem)); |
|
| 60 | 60 | return strtoupper(hash($alg, base64_decode($pem))); |
| 61 | 61 | } |
| 62 | 62 | |
@@ -82,9 +82,9 @@ discard block |
||
| 82 | 82 | public function getPublicKey() |
| 83 | 83 | { |
| 84 | 84 | $pem = (string)$this->file->getPublicKey(); |
| 85 | - $pem = preg_replace('/\-+BEGIN PUBLIC KEY\-+/','',$pem); |
|
| 86 | - $pem = preg_replace('/\-+END PUBLIC KEY\-+/','',$pem); |
|
| 87 | - $pem = str_replace( array("\n","\r","\t"), '', trim($pem)); |
|
| 85 | + $pem = preg_replace('/\-+BEGIN PUBLIC KEY\-+/', '', $pem); |
|
| 86 | + $pem = preg_replace('/\-+END PUBLIC KEY\-+/', '', $pem); |
|
| 87 | + $pem = str_replace(array("\n", "\r", "\t"), '', trim($pem)); |
|
| 88 | 88 | return $pem; |
| 89 | 89 | } |
| 90 | 90 | |
@@ -43,7 +43,9 @@ |
||
| 43 | 43 | |
| 44 | 44 | $this->file = new \File_X509(); |
| 45 | 45 | $this->info = $this->file->loadX509($pem); |
| 46 | - if($this->info === false) throw new InvalidX509CertificateException($pem); |
|
| 46 | + if($this->info === false) { |
|
| 47 | + throw new InvalidX509CertificateException($pem); |
|
| 48 | + } |
|
| 47 | 49 | $this->original_pem = $pem; |
| 48 | 50 | } |
| 49 | 51 | |
@@ -22,7 +22,7 @@ |
||
| 22 | 22 | * Interface IJWK |
| 23 | 23 | * @package jwk |
| 24 | 24 | */ |
| 25 | -interface IJWK extends IReadOnlyJWK { |
|
| 25 | +interface IJWK extends IReadOnlyJWK { |
|
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | 28 | * @param string $kid |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | const Exponent = 'e'; |
| 37 | 37 | |
| 38 | - public static $public_key_params = array ( self::Modulus, self::Exponent); |
|
| 38 | + public static $public_key_params = array(self::Modulus, self::Exponent); |
|
| 39 | 39 | |
| 40 | 40 | /** |
| 41 | 41 | * The "d" (private exponent) parameter contains the private exponent |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | |
| 80 | 80 | |
| 81 | 81 | |
| 82 | - public static $producers_private_key_params = array ( |
|
| 82 | + public static $producers_private_key_params = array( |
|
| 83 | 83 | self::FirstPrimeFactor, |
| 84 | 84 | self::SecondPrimeFactor, |
| 85 | 85 | self::FirstFactorCRTExponent, |
@@ -1,16 +1,16 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Copyright 2015 OpenStack Foundation |
|
| 4 | - * Licensed under the Apache License, Version 2.0 (the "License"); |
|
| 5 | - * you may not use this file except in compliance with the License. |
|
| 6 | - * You may obtain a copy of the License at |
|
| 7 | - * http://www.apache.org/licenses/LICENSE-2.0 |
|
| 8 | - * Unless required by applicable law or agreed to in writing, software |
|
| 9 | - * distributed under the License is distributed on an "AS IS" BASIS, |
|
| 10 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
| 11 | - * See the License for the specific language governing permissions and |
|
| 12 | - * limitations under the License. |
|
| 13 | - **/ |
|
| 3 | + * Copyright 2015 OpenStack Foundation |
|
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
|
| 5 | + * you may not use this file except in compliance with the License. |
|
| 6 | + * You may obtain a copy of the License at |
|
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 |
|
| 8 | + * Unless required by applicable law or agreed to in writing, software |
|
| 9 | + * distributed under the License is distributed on an "AS IS" BASIS, |
|
| 10 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
| 11 | + * See the License for the specific language governing permissions and |
|
| 12 | + * limitations under the License. |
|
| 13 | + **/ |
|
| 14 | 14 | |
| 15 | 15 | namespace jwk; |
| 16 | 16 | |
@@ -40,14 +40,14 @@ discard block |
||
| 40 | 40 | protected function __construct(Key $secret, $headers = array()) |
| 41 | 41 | { |
| 42 | 42 | |
| 43 | - if(empty($secret)) |
|
| 43 | + if (empty($secret)) |
|
| 44 | 44 | throw new InvalidOctetSequenceJWKException('secret is not set!.'); |
| 45 | 45 | |
| 46 | 46 | $this->set[JSONWebKeyParameters::KeyType] = new StringOrURI(JSONWebKeyTypes::OctetSequence); |
| 47 | 47 | |
| 48 | 48 | parent::__construct($headers); |
| 49 | 49 | |
| 50 | - if(count($headers) === 0 ) return; |
|
| 50 | + if (count($headers) === 0) return; |
|
| 51 | 51 | |
| 52 | 52 | $b64 = new Base64UrlRepresentation(); |
| 53 | 53 | |
@@ -72,17 +72,17 @@ discard block |
||
| 72 | 72 | * @param string $use |
| 73 | 73 | * @return IJWK |
| 74 | 74 | */ |
| 75 | - static public function fromSecret(Key $key, $alg = null, $use = JSONWebKeyPublicKeyUseValues::Signature){ |
|
| 75 | + static public function fromSecret(Key $key, $alg = null, $use = JSONWebKeyPublicKeyUseValues::Signature) { |
|
| 76 | 76 | |
| 77 | 77 | $headers = array(); |
| 78 | 78 | |
| 79 | - if(!empty($alg)) { |
|
| 79 | + if (!empty($alg)) { |
|
| 80 | 80 | |
| 81 | 81 | $headers[JSONWebKeyParameters::Algorithm] = $alg; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | $headers[JSONWebKeyParameters::PublicKeyUse] = $use; |
| 85 | 85 | |
| 86 | - return new OctetSequenceJWK($key, $headers) ; |
|
| 86 | + return new OctetSequenceJWK($key, $headers); |
|
| 87 | 87 | } |
| 88 | 88 | } |
| 89 | 89 | \ No newline at end of file |
@@ -40,14 +40,17 @@ |
||
| 40 | 40 | protected function __construct(Key $secret, $headers = array()) |
| 41 | 41 | { |
| 42 | 42 | |
| 43 | - if(empty($secret)) |
|
| 44 | - throw new InvalidOctetSequenceJWKException('secret is not set!.'); |
|
| 43 | + if(empty($secret)) { |
|
| 44 | + throw new InvalidOctetSequenceJWKException('secret is not set!.'); |
|
| 45 | + } |
|
| 45 | 46 | |
| 46 | 47 | $this->set[JSONWebKeyParameters::KeyType] = new StringOrURI(JSONWebKeyTypes::OctetSequence); |
| 47 | 48 | |
| 48 | 49 | parent::__construct($headers); |
| 49 | 50 | |
| 50 | - if(count($headers) === 0 ) return; |
|
| 51 | + if(count($headers) === 0 ) { |
|
| 52 | + return; |
|
| 53 | + } |
|
| 51 | 54 | |
| 52 | 55 | $b64 = new Base64UrlRepresentation(); |
| 53 | 56 | |
@@ -1,16 +1,16 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Copyright 2015 OpenStack Foundation |
|
| 4 | - * Licensed under the Apache License, Version 2.0 (the "License"); |
|
| 5 | - * you may not use this file except in compliance with the License. |
|
| 6 | - * You may obtain a copy of the License at |
|
| 7 | - * http://www.apache.org/licenses/LICENSE-2.0 |
|
| 8 | - * Unless required by applicable law or agreed to in writing, software |
|
| 9 | - * distributed under the License is distributed on an "AS IS" BASIS, |
|
| 10 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
| 11 | - * See the License for the specific language governing permissions and |
|
| 12 | - * limitations under the License. |
|
| 13 | - **/ |
|
| 3 | + * Copyright 2015 OpenStack Foundation |
|
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
|
| 5 | + * you may not use this file except in compliance with the License. |
|
| 6 | + * You may obtain a copy of the License at |
|
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 |
|
| 8 | + * Unless required by applicable law or agreed to in writing, software |
|
| 9 | + * distributed under the License is distributed on an "AS IS" BASIS, |
|
| 10 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
| 11 | + * See the License for the specific language governing permissions and |
|
| 12 | + * limitations under the License. |
|
| 13 | + **/ |
|
| 14 | 14 | |
| 15 | 15 | namespace jwk; |
| 16 | 16 | |
@@ -46,8 +46,7 @@ discard block |
||
| 46 | 46 | * @param string $use |
| 47 | 47 | * @param null|string $kid |
| 48 | 48 | */ |
| 49 | - public function __construct |
|
| 50 | - ( |
|
| 49 | + public function __construct( |
|
| 51 | 50 | $alg = JSONWebSignatureAndEncryptionAlgorithms::RS256, |
| 52 | 51 | $use = JSONWebKeyPublicKeyUseValues::Signature, |
| 53 | 52 | $kid = null |
@@ -58,7 +57,7 @@ discard block |
||
| 58 | 57 | $this->kid = $kid; |
| 59 | 58 | } |
| 60 | 59 | |
| 61 | - public function getAlg(){ |
|
| 60 | + public function getAlg() { |
|
| 62 | 61 | return $this->alg; |
| 63 | 62 | } |
| 64 | 63 | |
@@ -1,16 +1,16 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Copyright 2015 OpenStack Foundation |
|
| 4 | - * Licensed under the Apache License, Version 2.0 (the "License"); |
|
| 5 | - * you may not use this file except in compliance with the License. |
|
| 6 | - * You may obtain a copy of the License at |
|
| 7 | - * http://www.apache.org/licenses/LICENSE-2.0 |
|
| 8 | - * Unless required by applicable law or agreed to in writing, software |
|
| 9 | - * distributed under the License is distributed on an "AS IS" BASIS, |
|
| 10 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
| 11 | - * See the License for the specific language governing permissions and |
|
| 12 | - * limitations under the License. |
|
| 13 | - **/ |
|
| 3 | + * Copyright 2015 OpenStack Foundation |
|
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
|
| 5 | + * you may not use this file except in compliance with the License. |
|
| 6 | + * You may obtain a copy of the License at |
|
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 |
|
| 8 | + * Unless required by applicable law or agreed to in writing, software |
|
| 9 | + * distributed under the License is distributed on an "AS IS" BASIS, |
|
| 10 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
| 11 | + * See the License for the specific language governing permissions and |
|
| 12 | + * limitations under the License. |
|
| 13 | + **/ |
|
| 14 | 14 | |
| 15 | 15 | namespace jwk; |
| 16 | 16 | |
@@ -36,15 +36,14 @@ |
||
| 36 | 36 | * @param string $alg |
| 37 | 37 | * @param string $use |
| 38 | 38 | */ |
| 39 | - public function __construct |
|
| 40 | - ( |
|
| 39 | + public function __construct( |
|
| 41 | 40 | $key_pem, |
| 42 | 41 | $password = self::WithoutPassword, |
| 43 | 42 | $alg = JSONWebSignatureAndEncryptionAlgorithms::RS256, |
| 44 | 43 | $use = JSONWebKeyPublicKeyUseValues::Signature |
| 45 | 44 | ) |
| 46 | 45 | { |
| 47 | - parent::__construct($key_pem , $alg, $use); |
|
| 46 | + parent::__construct($key_pem, $alg, $use); |
|
| 48 | 47 | $this->password = $password; |
| 49 | 48 | } |
| 50 | 49 | /** |
@@ -1,16 +1,16 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Copyright 2015 OpenStack Foundation |
|
| 4 | - * Licensed under the Apache License, Version 2.0 (the "License"); |
|
| 5 | - * you may not use this file except in compliance with the License. |
|
| 6 | - * You may obtain a copy of the License at |
|
| 7 | - * http://www.apache.org/licenses/LICENSE-2.0 |
|
| 8 | - * Unless required by applicable law or agreed to in writing, software |
|
| 9 | - * distributed under the License is distributed on an "AS IS" BASIS, |
|
| 10 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
| 11 | - * See the License for the specific language governing permissions and |
|
| 12 | - * limitations under the License. |
|
| 13 | - **/ |
|
| 3 | + * Copyright 2015 OpenStack Foundation |
|
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
|
| 5 | + * you may not use this file except in compliance with the License. |
|
| 6 | + * You may obtain a copy of the License at |
|
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 |
|
| 8 | + * Unless required by applicable law or agreed to in writing, software |
|
| 9 | + * distributed under the License is distributed on an "AS IS" BASIS, |
|
| 10 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
| 11 | + * See the License for the specific language governing permissions and |
|
| 12 | + * limitations under the License. |
|
| 13 | + **/ |
|
| 14 | 14 | |
| 15 | 15 | namespace jwk; |
| 16 | 16 | |