40 $this->close(); |
40 $this->close(); |
41 } |
41 } |
42 |
42 |
43 public function close() { |
43 public function close() { |
44 $this->deleteSession(); |
44 $this->deleteSession(); |
45 $this->freeResources(); |
45 $this->freeResources(); |
46 } |
46 } |
47 |
47 |
48 private function getBaseUrl() { |
48 private function getBaseUrl() { |
49 return "https://$this->handleHost:$this->handlePort/api/"; |
49 return "https://$this->handleHost:$this->handlePort/api/"; |
50 } |
50 } |
58 } |
58 } |
59 |
59 |
60 private function getPrivateKeyRes() { |
60 private function getPrivateKeyRes() { |
61 if(is_null($this->privateKeyRes)) { |
61 if(is_null($this->privateKeyRes)) { |
62 $this->privateKeyRes = openssl_pkey_get_private($this->privateKeyOrCert, $this->pkpass); |
62 $this->privateKeyRes = openssl_pkey_get_private($this->privateKeyOrCert, $this->pkpass); |
63 } |
63 } |
64 return $this->privateKeyRes; |
64 return $this->privateKeyRes; |
65 } |
65 } |
66 |
66 |
67 private function freeResources() { |
67 private function freeResources() { |
68 if(!empty($this->privateKeyRes)) { |
68 if(!empty($this->privateKeyRes)) { |
91 if(is_file($keyContent)) { |
91 if(is_file($keyContent)) { |
92 $keyContent = file_get_contents($keyContent); |
92 $keyContent = file_get_contents($keyContent); |
93 } |
93 } |
94 $rsa->loadKey($keyContent); |
94 $rsa->loadKey($keyContent); |
95 $rsa->setSignatureMode(RSA::SIGNATURE_PKCS1); |
95 $rsa->setSignatureMode(RSA::SIGNATURE_PKCS1); |
96 |
96 |
97 return $rsa->sign($str); |
97 return $rsa->sign($str); |
98 |
98 |
99 } |
99 } |
100 |
100 |
101 |
101 |
234 $paginateJson = json_decode($paginateRes->getBody(), true); |
234 $paginateJson = json_decode($paginateRes->getBody(), true); |
235 |
235 |
236 $total = (int)$paginateJson['totalCount']; |
236 $total = (int)$paginateJson['totalCount']; |
237 |
237 |
238 $results = $paginateJson['handles']; |
238 $results = $paginateJson['handles']; |
239 |
239 |
240 return new LengthAwarePaginator($results, $total, $perPage, $page, [ |
240 return new LengthAwarePaginator($results, $total, $perPage, $page, [ |
241 'path' => Paginator::resolveCurrentPath(), |
241 'path' => Paginator::resolveCurrentPath(), |
242 'pageName' => $pageName, |
242 'pageName' => $pageName, |
243 ]); |
243 ]); |
244 |
244 |
245 } |
245 } |
246 |
246 |
247 public function deleteHandle($handle) { |
247 public function deleteHandle($handle) { |
248 $this->initSession(); |
248 $this->initSession(); |
249 |
249 |
|
250 if($handle === $this->adminId) { |
|
251 throw new \Exception("HandleClient: can not delete admin handle"); |
|
252 } |
250 $delUrl = $this->getBaseUrl()."handles/$handle"; |
253 $delUrl = $this->getBaseUrl()."handles/$handle"; |
251 $delRes = $this->httpClient->delete($delUrl, $this->guzzleOptions); |
254 $delRes = $this->httpClient->delete($delUrl, $this->guzzleOptions); |
252 |
255 |
253 Log::debug('Delete Handle: '.$delRes->getStatusCode().': '.$delRes->getReasonPhrase()); |
256 Log::debug('Delete Handle: '.$delRes->getStatusCode().': '.$delRes->getReasonPhrase()); |
254 } |
257 } |