@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | */ |
| 90 | 90 | private function getNewNonce() |
| 91 | 91 | { |
| 92 | - if($this->head($this->newNonce)['status'] !== 200) throw LEConnectorException::NoNewNonceException(); |
|
| 92 | + if ($this->head($this->newNonce)['status'] !== 200) throw LEConnectorException::NoNewNonceException(); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | /** |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | */ |
| 104 | 104 | private function request($method, $URL, $data = null) |
| 105 | 105 | { |
| 106 | - if($this->accountDeactivated) throw LEConnectorException::AccountDeactivatedException(); |
|
| 106 | + if ($this->accountDeactivated) throw LEConnectorException::AccountDeactivatedException(); |
|
| 107 | 107 | |
| 108 | 108 | $headers = array('Accept: application/json', 'Content-Type: application/jose+json'); |
| 109 | 109 | $requestURL = preg_match('~^http~', $URL) ? $URL : $this->baseURL . $URL; |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | } |
| 131 | 131 | $response = curl_exec($handle); |
| 132 | 132 | |
| 133 | - if(curl_errno($handle)) { |
|
| 133 | + if (curl_errno($handle)) { |
|
| 134 | 134 | throw LEConnectorException::CurlErrorException(curl_error($handle)); |
| 135 | 135 | } |
| 136 | 136 | |
@@ -146,22 +146,22 @@ discard block |
||
| 146 | 146 | 'status' => $statusCode, |
| 147 | 147 | 'body' => $jsonbody === null ? $body : $jsonbody, |
| 148 | 148 | ); |
| 149 | - if($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 149 | + if ($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 150 | 150 | { |
| 151 | 151 | $this->log->debug($method . ' response received', $jsonresponse); |
| 152 | 152 | } |
| 153 | - elseif($this->log >= LEClient::LOG_DEBUG) LEFunctions::log($jsonresponse); |
|
| 153 | + elseif ($this->log >= LEClient::LOG_DEBUG) LEFunctions::log($jsonresponse); |
|
| 154 | 154 | |
| 155 | - if(preg_match('~Replay\-Nonce: (\S+)~i', $header, $matches)) |
|
| 155 | + if (preg_match('~Replay\-Nonce: (\S+)~i', $header, $matches)) |
|
| 156 | 156 | { |
| 157 | 157 | $this->nonce = trim($matches[1]); |
| 158 | 158 | } |
| 159 | 159 | else |
| 160 | 160 | { |
| 161 | - if($method == 'POST') $this->getNewNonce(); // Not expecting a new nonce with GET and HEAD requests. |
|
| 161 | + if ($method == 'POST') $this->getNewNonce(); // Not expecting a new nonce with GET and HEAD requests. |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | - if((($method == 'POST' OR $method == 'GET') AND $statusCode !== 200 AND $statusCode !== 201) OR |
|
| 164 | + if ((($method == 'POST' OR $method == 'GET') AND $statusCode !== 200 AND $statusCode !== 201) OR |
|
| 165 | 165 | ($method == 'HEAD' AND $statusCode !== 200)) |
| 166 | 166 | { |
| 167 | 167 | throw LEConnectorException::InvalidResponseException($jsonresponse); |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | */ |
| 219 | 219 | public function signRequestJWK($payload, $url, $privateKeyFile = '') |
| 220 | 220 | { |
| 221 | - if($privateKeyFile == '') $privateKeyFile = $this->accountKeys['private_key']; |
|
| 221 | + if ($privateKeyFile == '') $privateKeyFile = $this->accountKeys['private_key']; |
|
| 222 | 222 | $privateKey = openssl_pkey_get_private(file_get_contents($privateKeyFile)); |
| 223 | 223 | $details = openssl_pkey_get_details($privateKey); |
| 224 | 224 | |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | $payload64 = LEFunctions::Base64UrlSafeEncode(str_replace('\\/', '/', is_array($payload) ? json_encode($payload) : $payload)); |
| 237 | 237 | $protected64 = LEFunctions::Base64UrlSafeEncode(json_encode($protected)); |
| 238 | 238 | |
| 239 | - openssl_sign($protected64.'.'.$payload64, $signed, $privateKey, "SHA256"); |
|
| 239 | + openssl_sign($protected64 . '.' . $payload64, $signed, $privateKey, "SHA256"); |
|
| 240 | 240 | $signed64 = LEFunctions::Base64UrlSafeEncode($signed); |
| 241 | 241 | |
| 242 | 242 | $data = array( |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | */ |
| 261 | 261 | public function signRequestKid($payload, $kid, $url, $privateKeyFile = '') |
| 262 | 262 | { |
| 263 | - if($privateKeyFile == '') $privateKeyFile = $this->accountKeys['private_key']; |
|
| 263 | + if ($privateKeyFile == '') $privateKeyFile = $this->accountKeys['private_key']; |
|
| 264 | 264 | $privateKey = openssl_pkey_get_private(file_get_contents($privateKeyFile)); |
| 265 | 265 | $details = openssl_pkey_get_details($privateKey); |
| 266 | 266 | |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | $payload64 = LEFunctions::Base64UrlSafeEncode(str_replace('\\/', '/', is_array($payload) ? json_encode($payload) : $payload)); |
| 275 | 275 | $protected64 = LEFunctions::Base64UrlSafeEncode(json_encode($protected)); |
| 276 | 276 | |
| 277 | - openssl_sign($protected64.'.'.$payload64, $signed, $privateKey, "SHA256"); |
|
| 277 | + openssl_sign($protected64 . '.' . $payload64, $signed, $privateKey, "SHA256"); |
|
| 278 | 278 | $signed64 = LEFunctions::Base64UrlSafeEncode($signed); |
| 279 | 279 | |
| 280 | 280 | $data = array( |
@@ -66,13 +66,13 @@ discard block |
||
| 66 | 66 | $this->accountKeys = $accountKeys; |
| 67 | 67 | $this->log = $log; |
| 68 | 68 | |
| 69 | - if(!file_exists($this->accountKeys['private_key']) OR !file_exists($this->accountKeys['public_key'])) |
|
| 69 | + if (!file_exists($this->accountKeys['private_key']) OR !file_exists($this->accountKeys['public_key'])) |
|
| 70 | 70 | { |
| 71 | - if($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 71 | + if ($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 72 | 72 | { |
| 73 | 73 | $this->log->info('No account found, attempting to create account.'); |
| 74 | 74 | } |
| 75 | - else if($this->log >= LECLient::LOG_STATUS) LEFunctions::log('No account found, attempting to create account.', 'function LEAccount __construct'); |
|
| 75 | + else if ($this->log >= LECLient::LOG_STATUS) LEFunctions::log('No account found, attempting to create account.', 'function LEAccount __construct'); |
|
| 76 | 76 | |
| 77 | 77 | LEFunctions::RSAgenerateKeys(null, $this->accountKeys['private_key'], $this->accountKeys['public_key']); |
| 78 | 78 | $this->connector->accountURL = $this->createLEAccount($email); |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | { |
| 82 | 82 | $this->connector->accountURL = $this->getLEAccount(); |
| 83 | 83 | } |
| 84 | - if($this->connector->accountURL == false) throw LEAccountException::AccountNotFoundException(); |
|
| 84 | + if ($this->connector->accountURL == false) throw LEAccountException::AccountNotFoundException(); |
|
| 85 | 85 | $this->getLEAccountData(); |
| 86 | 86 | } |
| 87 | 87 | |
@@ -98,9 +98,9 @@ discard block |
||
| 98 | 98 | |
| 99 | 99 | $sign = $this->connector->signRequestJWK(array('contact' => $contact, 'termsOfServiceAgreed' => true), $this->connector->newAccount); |
| 100 | 100 | $post = $this->connector->post($this->connector->newAccount, $sign); |
| 101 | - if($post['status'] === 201) |
|
| 101 | + if ($post['status'] === 201) |
|
| 102 | 102 | { |
| 103 | - if(preg_match('~Location: (\S+)~i', $post['header'], $matches)) return trim($matches[1]); |
|
| 103 | + if (preg_match('~Location: (\S+)~i', $post['header'], $matches)) return trim($matches[1]); |
|
| 104 | 104 | } |
| 105 | 105 | return false; |
| 106 | 106 | } |
@@ -115,9 +115,9 @@ discard block |
||
| 115 | 115 | $sign = $this->connector->signRequestJWK(array('onlyReturnExisting' => true), $this->connector->newAccount); |
| 116 | 116 | $post = $this->connector->post($this->connector->newAccount, $sign); |
| 117 | 117 | |
| 118 | - if($post['status'] === 200) |
|
| 118 | + if ($post['status'] === 200) |
|
| 119 | 119 | { |
| 120 | - if(preg_match('~Location: (\S+)~i', $post['header'], $matches)) return trim($matches[1]); |
|
| 120 | + if (preg_match('~Location: (\S+)~i', $post['header'], $matches)) return trim($matches[1]); |
|
| 121 | 121 | } |
| 122 | 122 | return false; |
| 123 | 123 | } |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | { |
| 130 | 130 | $sign = $this->connector->signRequestKid(array('' => ''), $this->connector->accountURL, $this->connector->accountURL); |
| 131 | 131 | $post = $this->connector->post($this->connector->accountURL, $sign); |
| 132 | - if($post['status'] === 200) |
|
| 132 | + if ($post['status'] === 200) |
|
| 133 | 133 | { |
| 134 | 134 | $this->id = isset($post['body']['id']) ? $post['body']['id'] : ''; |
| 135 | 135 | $this->key = $post['body']['key']; |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | |
| 159 | 159 | $sign = $this->connector->signRequestKid(array('contact' => $contact), $this->connector->accountURL, $this->connector->accountURL); |
| 160 | 160 | $post = $this->connector->post($this->connector->accountURL, $sign); |
| 161 | - if($post['status'] === 200) |
|
| 161 | + if ($post['status'] === 200) |
|
| 162 | 162 | { |
| 163 | 163 | $this->id = isset($post['body']['id']) ? $post['body']['id'] : ''; |
| 164 | 164 | $this->key = $post['body']['key']; |
@@ -167,11 +167,11 @@ discard block |
||
| 167 | 167 | $this->initialIp = $post['body']['initialIp']; |
| 168 | 168 | $this->createdAt = $post['body']['createdAt']; |
| 169 | 169 | $this->status = $post['body']['status']; |
| 170 | - if($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 170 | + if ($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 171 | 171 | { |
| 172 | 172 | $this->log->info('Account data updated.'); |
| 173 | 173 | } |
| 174 | - else if($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Account data updated.', 'function updateAccount'); |
|
| 174 | + else if ($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Account data updated.', 'function updateAccount'); |
|
| 175 | 175 | return true; |
| 176 | 176 | } |
| 177 | 177 | else |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | */ |
| 188 | 188 | public function changeAccountKeys() |
| 189 | 189 | { |
| 190 | - LEFunctions::RSAgenerateKeys(null, $this->accountKeys['private_key'].'.new', $this->accountKeys['public_key'].'.new'); |
|
| 190 | + LEFunctions::RSAgenerateKeys(null, $this->accountKeys['private_key'] . '.new', $this->accountKeys['public_key'] . '.new'); |
|
| 191 | 191 | $oldPrivateKey = openssl_pkey_get_private(file_get_contents($this->accountKeys['private_key'])); |
| 192 | 192 | $oldDetails = openssl_pkey_get_details($oldPrivateKey); |
| 193 | 193 | $innerPayload = array('account' => $this->connector->accountURL, 'oldKey' => array( |
@@ -195,23 +195,23 @@ discard block |
||
| 195 | 195 | "n" => LEFunctions::Base64UrlSafeEncode($oldDetails["rsa"]["n"]), |
| 196 | 196 | "e" => LEFunctions::Base64UrlSafeEncode($oldDetails["rsa"]["e"]) |
| 197 | 197 | )); |
| 198 | - $outerPayload = $this->connector->signRequestJWK($innerPayload, $this->connector->keyChange, $this->accountKeys['private_key'].'.new'); |
|
| 198 | + $outerPayload = $this->connector->signRequestJWK($innerPayload, $this->connector->keyChange, $this->accountKeys['private_key'] . '.new'); |
|
| 199 | 199 | $sign = $this->connector->signRequestKid($outerPayload, $this->connector->accountURL, $this->connector->keyChange); |
| 200 | 200 | $post = $this->connector->post($this->connector->keyChange, $sign); |
| 201 | - if($post['status'] === 200) |
|
| 201 | + if ($post['status'] === 200) |
|
| 202 | 202 | { |
| 203 | 203 | unlink($this->accountKeys['private_key']); |
| 204 | 204 | unlink($this->accountKeys['public_key']); |
| 205 | - rename($this->accountKeys['private_key'].'.new', $this->accountKeys['private_key']); |
|
| 206 | - rename($this->accountKeys['public_key'].'.new', $this->accountKeys['public_key']); |
|
| 205 | + rename($this->accountKeys['private_key'] . '.new', $this->accountKeys['private_key']); |
|
| 206 | + rename($this->accountKeys['public_key'] . '.new', $this->accountKeys['public_key']); |
|
| 207 | 207 | |
| 208 | 208 | $this->getLEAccountData(); |
| 209 | 209 | |
| 210 | - if($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 210 | + if ($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 211 | 211 | { |
| 212 | 212 | $this->log->info('Account keys changed.'); |
| 213 | 213 | } |
| 214 | - elseif($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Account keys changed.', 'function changeAccountKey'); |
|
| 214 | + elseif ($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Account keys changed.', 'function changeAccountKey'); |
|
| 215 | 215 | return true; |
| 216 | 216 | } |
| 217 | 217 | else |
@@ -229,14 +229,14 @@ discard block |
||
| 229 | 229 | { |
| 230 | 230 | $sign = $this->connector->signRequestKid(array('status' => 'deactivated'), $this->connector->accountURL, $this->connector->accountURL); |
| 231 | 231 | $post = $this->connector->post($this->connector->accountURL, $sign); |
| 232 | - if($post['status'] === 200) |
|
| 232 | + if ($post['status'] === 200) |
|
| 233 | 233 | { |
| 234 | 234 | $this->connector->accountDeactivated = true; |
| 235 | - if($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 235 | + if ($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 236 | 236 | { |
| 237 | 237 | $this->log->info('Account deactivated.'); |
| 238 | 238 | } |
| 239 | - elseif($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Account deactivated.', 'function deactivateAccount'); |
|
| 239 | + elseif ($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Account deactivated.', 'function deactivateAccount'); |
|
| 240 | 240 | |
| 241 | 241 | return true; |
| 242 | 242 | } |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | $sign = $this->connector->signRequestKid('', $this->connector->accountURL, $this->authorizationURL); |
| 66 | 66 | $post = $this->connector->post($this->authorizationURL, $sign); |
| 67 | - if($post['status'] === 200) |
|
| 67 | + if ($post['status'] === 200) |
|
| 68 | 68 | { |
| 69 | 69 | $this->identifier = $post['body']['identifier']; |
| 70 | 70 | $this->status = $post['body']['status']; |
@@ -73,11 +73,11 @@ discard block |
||
| 73 | 73 | } |
| 74 | 74 | else |
| 75 | 75 | { |
| 76 | - if($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 76 | + if ($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 77 | 77 | { |
| 78 | 78 | $this->log->info('Cannot find authorization \'' . $authorizationURL . '\'.'); |
| 79 | 79 | } |
| 80 | - elseif($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Cannot find authorization \'' . $authorizationURL . '\'.', 'function LEAuthorization __construct'); |
|
| 80 | + elseif ($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Cannot find authorization \'' . $authorizationURL . '\'.', 'function LEAuthorization __construct'); |
|
| 81 | 81 | } |
| 82 | 82 | } |
| 83 | 83 | |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | { |
| 90 | 90 | $sign = $this->connector->signRequestKid('', $this->connector->accountURL, $this->authorizationURL); |
| 91 | 91 | $post = $this->connector->post($this->authorizationURL, $sign); |
| 92 | - if($post['status'] === 200) |
|
| 92 | + if ($post['status'] === 200) |
|
| 93 | 93 | { |
| 94 | 94 | $this->identifier = $post['body']['identifier']; |
| 95 | 95 | $this->status = $post['body']['status']; |
@@ -98,11 +98,11 @@ discard block |
||
| 98 | 98 | } |
| 99 | 99 | else |
| 100 | 100 | { |
| 101 | - if($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 101 | + if ($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 102 | 102 | { |
| 103 | 103 | $this->log->info('Cannot find authorization \'' . $this->authorizationURL . '\'.'); |
| 104 | 104 | } |
| 105 | - elseif($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Cannot find authorization \'' . $this->authorizationURL . '\'.', 'function updateData'); |
|
| 105 | + elseif ($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Cannot find authorization \'' . $this->authorizationURL . '\'.', 'function updateData'); |
|
| 106 | 106 | } |
| 107 | 107 | } |
| 108 | 108 | |
@@ -116,9 +116,9 @@ discard block |
||
| 116 | 116 | */ |
| 117 | 117 | public function getChallenge($type) |
| 118 | 118 | { |
| 119 | - foreach($this->challenges as $challenge) |
|
| 119 | + foreach ($this->challenges as $challenge) |
|
| 120 | 120 | { |
| 121 | - if($challenge['type'] == $type) return $challenge; |
|
| 121 | + if ($challenge['type'] == $type) return $challenge; |
|
| 122 | 122 | } |
| 123 | 123 | throw LEAuthorizationException::NoChallengeFoundException($type, $this->identifier['value']); |
| 124 | 124 | } |
@@ -38,10 +38,10 @@ |
||
| 38 | 38 | class LEOrderException extends LEException |
| 39 | 39 | { |
| 40 | 40 | public const INVALIDKEYTYPEEXCEPTION = 0x31; |
| 41 | - public const INVALIDORDERSTATUSEXCEPTION = 0x32; |
|
| 42 | - public const CREATEFAILEDEXCEPTION = 0x33; |
|
| 41 | + public const INVALIDORDERSTATUSEXCEPTION = 0x32; |
|
| 42 | + public const CREATEFAILEDEXCEPTION = 0x33; |
|
| 43 | 43 | public const INVALIDARGUMENTEXCEPTION = 0x34; |
| 44 | - public const INVALIDCONFIGURATIONEXCEPTION = 0x35; |
|
| 44 | + public const INVALIDCONFIGURATIONEXCEPTION = 0x35; |
|
| 45 | 45 | |
| 46 | 46 | public static function InvalidKeyTypeException(string $keyType) |
| 47 | 47 | { |
@@ -37,8 +37,8 @@ |
||
| 37 | 37 | */ |
| 38 | 38 | class LEClientException extends LEException |
| 39 | 39 | { |
| 40 | - public const INVALIDARGUMENTEXCEPTION = 0x01; |
|
| 41 | - public const INVALIDDIRECTORYEXCEPTION = 0x02; |
|
| 40 | + public const INVALIDARGUMENTEXCEPTION = 0x01; |
|
| 41 | + public const INVALIDDIRECTORYEXCEPTION = 0x02; |
|
| 42 | 42 | |
| 43 | 43 | public static function InvalidArgumentException(string $message) |
| 44 | 44 | { |
@@ -39,7 +39,7 @@ |
||
| 39 | 39 | { |
| 40 | 40 | public const INVALIDARGUMENTEXCEPTION = 0x51; |
| 41 | 41 | public const GENERATEKEYPAIREXCEPTION = 0x52; |
| 42 | - public const PHPVERSIONEXCEPTION = 0x53; |
|
| 42 | + public const PHPVERSIONEXCEPTION = 0x53; |
|
| 43 | 43 | |
| 44 | 44 | public static function InvalidArgumentException(string $message) |
| 45 | 45 | { |
@@ -37,7 +37,7 @@ |
||
| 37 | 37 | */ |
| 38 | 38 | class LEAccountException extends LEException |
| 39 | 39 | { |
| 40 | - public const ACCOUNTNOTFOUNDEEXCEPTION = 0x21; |
|
| 40 | + public const ACCOUNTNOTFOUNDEEXCEPTION = 0x21; |
|
| 41 | 41 | |
| 42 | 42 | public static function AccountNotFoundException() |
| 43 | 43 | { |
@@ -37,7 +37,7 @@ |
||
| 37 | 37 | */ |
| 38 | 38 | class LEAuthorizationException extends LEException |
| 39 | 39 | { |
| 40 | - public const NOCHALLENGEFOUNDEEXCEPTION = 0x41; |
|
| 40 | + public const NOCHALLENGEFOUNDEEXCEPTION = 0x41; |
|
| 41 | 41 | |
| 42 | 42 | public static function NoChallengeFoundException($type, $identifier) |
| 43 | 43 | { |
@@ -37,11 +37,11 @@ |
||
| 37 | 37 | */ |
| 38 | 38 | class LEConnectorException extends LEException |
| 39 | 39 | { |
| 40 | - public const NONEWNONCEEXCEPTION = 0x11; |
|
| 40 | + public const NONEWNONCEEXCEPTION = 0x11; |
|
| 41 | 41 | public const ACCOUNTDEACTIVATEDEXCEPTION = 0x12; |
| 42 | 42 | public const METHODNOTSUPPORTEDEXCEPTION = 0x13; |
| 43 | - public const CURLERROREXCEPTION = 0x14; |
|
| 44 | - public const INVALIDRESPONSEEXCEPTION = 0x15; |
|
| 43 | + public const CURLERROREXCEPTION = 0x14; |
|
| 44 | + public const INVALIDRESPONSEEXCEPTION = 0x15; |
|
| 45 | 45 | |
| 46 | 46 | public static function NoNewNonceException() |
| 47 | 47 | { |