@@ -45,37 +45,37 @@ |
||
| 45 | 45 | |
| 46 | 46 | case 'server.index.load.custom': |
| 47 | 47 | switch ($data['name']) { |
| 48 | - case 'files_get_recipients': |
|
| 49 | - RecipientHandler::doGetRecipients(); |
|
| 50 | - break; |
|
| 48 | + case 'files_get_recipients': |
|
| 49 | + RecipientHandler::doGetRecipients(); |
|
| 50 | + break; |
|
| 51 | 51 | |
| 52 | - case 'download_file': |
|
| 53 | - DownloadHandler::doDownload(); |
|
| 54 | - break; |
|
| 52 | + case 'download_file': |
|
| 53 | + DownloadHandler::doDownload(); |
|
| 54 | + break; |
|
| 55 | 55 | |
| 56 | - case 'upload_file': |
|
| 57 | - UploadHandler::doUpload(); |
|
| 58 | - break; |
|
| 56 | + case 'upload_file': |
|
| 57 | + UploadHandler::doUpload(); |
|
| 58 | + break; |
|
| 59 | 59 | |
| 60 | - case 'form': |
|
| 61 | - if (isset($_GET['backend'])) { |
|
| 62 | - $backend = urldecode($_GET["backend"]); |
|
| 63 | - } |
|
| 64 | - else { |
|
| 65 | - $backend = ''; |
|
| 66 | - } |
|
| 67 | - $backendstore = Files\Backend\BackendStore::getInstance(); |
|
| 60 | + case 'form': |
|
| 61 | + if (isset($_GET['backend'])) { |
|
| 62 | + $backend = urldecode($_GET["backend"]); |
|
| 63 | + } |
|
| 64 | + else { |
|
| 65 | + $backend = ''; |
|
| 66 | + } |
|
| 67 | + $backendstore = Files\Backend\BackendStore::getInstance(); |
|
| 68 | 68 | |
| 69 | - if ($backendstore->backendExists($backend)) { |
|
| 70 | - $backendInstance = $backendstore->getInstanceOfBackend($backend); |
|
| 71 | - $formdata = $backendInstance->getFormConfig(); |
|
| 69 | + if ($backendstore->backendExists($backend)) { |
|
| 70 | + $backendInstance = $backendstore->getInstanceOfBackend($backend); |
|
| 71 | + $formdata = $backendInstance->getFormConfig(); |
|
| 72 | 72 | |
| 73 | - exit($formdata); |
|
| 74 | - } |
|
| 73 | + exit($formdata); |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - exit("Specified backend does not exist!"); |
|
| 76 | + exit("Specified backend does not exist!"); |
|
| 77 | 77 | |
| 78 | - break; |
|
| 78 | + break; |
|
| 79 | 79 | } |
| 80 | 80 | break; |
| 81 | 81 | } |
@@ -15,31 +15,31 @@ |
||
| 15 | 15 | $tag = $this->peek(); |
| 16 | 16 | |
| 17 | 17 | switch ($tag) { |
| 18 | - case 0: |
|
| 19 | - $res['otherName'] = $this->oid(-6); |
|
| 20 | - break; |
|
| 21 | - |
|
| 22 | - case 1: |
|
| 23 | - $res['rfc822Name'] = $this->next(-22); |
|
| 24 | - break; |
|
| 25 | - |
|
| 26 | - case 2: |
|
| 27 | - $res['dNSName'] = $this->next(-22); |
|
| 28 | - break; |
|
| 29 | - |
|
| 30 | - case 4: |
|
| 31 | - $this->next(4); |
|
| 32 | - $res['directoryName'] = $this->name(); |
|
| 33 | - $res['directoryName_'] = $this->nameasstring($res['directoryName']); |
|
| 34 | - break; |
|
| 35 | - |
|
| 36 | - case 6: |
|
| 37 | - $res['uniformResourceIdentifier'] = $this->next(-22); |
|
| 38 | - break; |
|
| 39 | - |
|
| 40 | - default: |
|
| 41 | - throw new \Exception("Unsupported GeneralName: {$tag}"); |
|
| 42 | -# trigger_error("Unsupported GeneralName: $tag", E_USER_ERROR); |
|
| 18 | + case 0: |
|
| 19 | + $res['otherName'] = $this->oid(-6); |
|
| 20 | + break; |
|
| 21 | + |
|
| 22 | + case 1: |
|
| 23 | + $res['rfc822Name'] = $this->next(-22); |
|
| 24 | + break; |
|
| 25 | + |
|
| 26 | + case 2: |
|
| 27 | + $res['dNSName'] = $this->next(-22); |
|
| 28 | + break; |
|
| 29 | + |
|
| 30 | + case 4: |
|
| 31 | + $this->next(4); |
|
| 32 | + $res['directoryName'] = $this->name(); |
|
| 33 | + $res['directoryName_'] = $this->nameasstring($res['directoryName']); |
|
| 34 | + break; |
|
| 35 | + |
|
| 36 | + case 6: |
|
| 37 | + $res['uniformResourceIdentifier'] = $this->next(-22); |
|
| 38 | + break; |
|
| 39 | + |
|
| 40 | + default: |
|
| 41 | + throw new \Exception("Unsupported GeneralName: {$tag}"); |
|
| 42 | + # trigger_error("Unsupported GeneralName: $tag", E_USER_ERROR); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | return $res; |
@@ -25,9 +25,11 @@ |
||
| 25 | 25 | * @return bool true on success or false on failure |
| 26 | 26 | */ |
| 27 | 27 | public function execute() { |
| 28 | - foreach ($this->data as $actionType => $actionData) try { |
|
| 28 | + foreach ($this->data as $actionType => $actionData) { |
|
| 29 | + try { |
|
| 29 | 30 | if (!isset($actionType)) |
| 30 | 31 | continue; |
| 32 | + } |
|
| 31 | 33 | switch ($actionType) { |
| 32 | 34 | case 'certificate': |
| 33 | 35 | $data = $this->verifyCertificate($actionData); |
@@ -29,62 +29,62 @@ |
||
| 29 | 29 | if (!isset($actionType)) |
| 30 | 30 | continue; |
| 31 | 31 | switch ($actionType) { |
| 32 | - case 'certificate': |
|
| 33 | - $data = $this->verifyCertificate($actionData); |
|
| 34 | - $response = [ |
|
| 35 | - 'type' => 3, |
|
| 36 | - 'status' => $data['status'], |
|
| 37 | - 'message' => $data['message'], |
|
| 38 | - 'data' => $data['data'], |
|
| 39 | - ]; |
|
| 40 | - $this->addActionData('certificate', $response); |
|
| 41 | - $GLOBALS['bus']->addData($this->getResponseData()); |
|
| 42 | - break; |
|
| 32 | + case 'certificate': |
|
| 33 | + $data = $this->verifyCertificate($actionData); |
|
| 34 | + $response = [ |
|
| 35 | + 'type' => 3, |
|
| 36 | + 'status' => $data['status'], |
|
| 37 | + 'message' => $data['message'], |
|
| 38 | + 'data' => $data['data'], |
|
| 39 | + ]; |
|
| 40 | + $this->addActionData('certificate', $response); |
|
| 41 | + $GLOBALS['bus']->addData($this->getResponseData()); |
|
| 42 | + break; |
|
| 43 | 43 | |
| 44 | - case 'passphrase': |
|
| 45 | - $data = $this->verifyPassphrase($actionData); |
|
| 46 | - $response = [ |
|
| 47 | - 'type' => 3, |
|
| 48 | - 'status' => $data['status'], |
|
| 49 | - ]; |
|
| 50 | - $this->addActionData('passphrase', $response); |
|
| 51 | - $GLOBALS['bus']->addData($this->getResponseData()); |
|
| 52 | - break; |
|
| 44 | + case 'passphrase': |
|
| 45 | + $data = $this->verifyPassphrase($actionData); |
|
| 46 | + $response = [ |
|
| 47 | + 'type' => 3, |
|
| 48 | + 'status' => $data['status'], |
|
| 49 | + ]; |
|
| 50 | + $this->addActionData('passphrase', $response); |
|
| 51 | + $GLOBALS['bus']->addData($this->getResponseData()); |
|
| 52 | + break; |
|
| 53 | 53 | |
| 54 | - case 'changepassphrase': |
|
| 55 | - $data = $this->changePassphrase($actionData); |
|
| 56 | - if ($data === CHANGE_PASSPHRASE_SUCCESS) { |
|
| 57 | - // Reset cached passphrase. |
|
| 58 | - $encryptionStore = EncryptionStore::getInstance(); |
|
| 59 | - withPHPSession(function () use ($encryptionStore) { |
|
| 60 | - $encryptionStore->add('smime', ''); |
|
| 61 | - }); |
|
| 62 | - } |
|
| 63 | - $response = [ |
|
| 64 | - 'type' => 3, |
|
| 65 | - 'code' => $data, |
|
| 66 | - ]; |
|
| 67 | - $this->addActionData('changepassphrase', $response); |
|
| 68 | - $GLOBALS['bus']->addData($this->getResponseData()); |
|
| 69 | - break; |
|
| 54 | + case 'changepassphrase': |
|
| 55 | + $data = $this->changePassphrase($actionData); |
|
| 56 | + if ($data === CHANGE_PASSPHRASE_SUCCESS) { |
|
| 57 | + // Reset cached passphrase. |
|
| 58 | + $encryptionStore = EncryptionStore::getInstance(); |
|
| 59 | + withPHPSession(function () use ($encryptionStore) { |
|
| 60 | + $encryptionStore->add('smime', ''); |
|
| 61 | + }); |
|
| 62 | + } |
|
| 63 | + $response = [ |
|
| 64 | + 'type' => 3, |
|
| 65 | + 'code' => $data, |
|
| 66 | + ]; |
|
| 67 | + $this->addActionData('changepassphrase', $response); |
|
| 68 | + $GLOBALS['bus']->addData($this->getResponseData()); |
|
| 69 | + break; |
|
| 70 | 70 | |
| 71 | - case 'list': |
|
| 72 | - $data = $this->getPublicCertificates(); |
|
| 73 | - $this->addActionData('list', $data); |
|
| 74 | - $GLOBALS['bus']->addData($this->getResponseData()); |
|
| 75 | - break; |
|
| 71 | + case 'list': |
|
| 72 | + $data = $this->getPublicCertificates(); |
|
| 73 | + $this->addActionData('list', $data); |
|
| 74 | + $GLOBALS['bus']->addData($this->getResponseData()); |
|
| 75 | + break; |
|
| 76 | 76 | |
| 77 | - case 'delete': |
|
| 78 | - // FIXME: handle multiple deletes? Separate function? |
|
| 79 | - $entryid = $actionData['entryid']; |
|
| 80 | - $root = mapi_msgstore_openentry($this->store); |
|
| 81 | - mapi_folder_deletemessages($root, [hex2bin($entryid)]); |
|
| 77 | + case 'delete': |
|
| 78 | + // FIXME: handle multiple deletes? Separate function? |
|
| 79 | + $entryid = $actionData['entryid']; |
|
| 80 | + $root = mapi_msgstore_openentry($this->store); |
|
| 81 | + mapi_folder_deletemessages($root, [hex2bin($entryid)]); |
|
| 82 | 82 | |
| 83 | - $this->sendFeedback(true); |
|
| 84 | - break; |
|
| 83 | + $this->sendFeedback(true); |
|
| 84 | + break; |
|
| 85 | 85 | |
| 86 | - default: |
|
| 87 | - $this->handleUnknownActionType($actionType); |
|
| 86 | + default: |
|
| 87 | + $this->handleUnknownActionType($actionType); |
|
| 88 | 88 | } |
| 89 | 89 | } |
| 90 | 90 | catch (Exception $e) { |
@@ -33,14 +33,14 @@ |
||
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | switch ($this->status) { |
| 36 | - case 'good': |
|
| 37 | - return OCSP_CERT_STATUS_GOOD; |
|
| 36 | + case 'good': |
|
| 37 | + return OCSP_CERT_STATUS_GOOD; |
|
| 38 | 38 | |
| 39 | - case 'revoked': |
|
| 40 | - return OCSP_CERT_STATUS_REVOKED; |
|
| 39 | + case 'revoked': |
|
| 40 | + return OCSP_CERT_STATUS_REVOKED; |
|
| 41 | 41 | |
| 42 | - default: |
|
| 43 | - return OCSP_CERT_STATUS_UNKOWN; |
|
| 42 | + default: |
|
| 43 | + return OCSP_CERT_STATUS_UNKOWN; |
|
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | 46 | } |
@@ -98,8 +98,9 @@ |
||
| 98 | 98 | // Get messages from certificates |
| 99 | 99 | foreach ($privateCerts as $privateCert) { |
| 100 | 100 | $privateCertMessage = mapi_msgstore_openentry($store, $privateCert[PR_ENTRYID]); |
| 101 | - if ($privateCertMessage === false) |
|
| 102 | - continue; |
|
| 101 | + if ($privateCertMessage === false) { |
|
| 102 | + continue; |
|
| 103 | + } |
|
| 103 | 104 | $pkcs12 = ""; |
| 104 | 105 | $certs = []; |
| 105 | 106 | // Read pkcs12 cert from message |
@@ -96,7 +96,8 @@ |
||
| 96 | 96 | <div class="disclaimer"> |
| 97 | 97 | <?php include '/etc/grommunio-web/disclaimer.html'; ?> |
| 98 | 98 | </div> |
| 99 | - <?php } elseif (file_exists('disclaimer.html')) { ?> |
|
| 99 | + <?php } |
|
| 100 | +elseif (file_exists('disclaimer.html')) { ?> |
|
| 100 | 101 | <div class="disclaimer"> |
| 101 | 102 | <?php include 'disclaimer.html'; ?> |
| 102 | 103 | </div> |
@@ -186,7 +186,8 @@ |
||
| 186 | 186 | // Read message properties |
| 187 | 187 | try { |
| 188 | 188 | $messageProps = mapi_getprops($this->mapiMessage, [PR_SUBJECT, PR_MESSAGE_CLASS]); |
| 189 | - } catch (Exception $ex) { |
|
| 189 | + } |
|
| 190 | + catch (Exception $ex) { |
|
| 190 | 191 | $this->logErrorAndThrow("Error on getting MAPI message properties", $ex); |
| 191 | 192 | } |
| 192 | 193 | |
@@ -25,9 +25,10 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | public $ConnectionId = null; |
| 27 | 27 | |
| 28 | - function __construct($serviceEndpoint) |
|
| 29 | - {
|
|
| 30 | - if (!str_ends_with($serviceEndpoint, '/')) $serviceEndpoint .= '/'; |
|
| 28 | + function __construct($serviceEndpoint) { |
|
| 29 | + if (!str_ends_with($serviceEndpoint, '/')) { |
|
| 30 | + $serviceEndpoint .= '/'; |
|
| 31 | + } |
|
| 31 | 32 | $this->ServiceEndpoint = $serviceEndpoint; |
| 32 | 33 | } |
| 33 | 34 | |
@@ -40,7 +41,7 @@ discard block |
||
| 40 | 41 | * |
| 41 | 42 | * @return bool |
| 42 | 43 | */ |
| 43 | - public function loginWithToken($pfxFile, $pfxPassword, $userName) {
|
|
| 44 | + public function loginWithToken($pfxFile, $pfxPassword, $userName) { |
|
| 44 | 45 | try {
|
| 45 | 46 | $issuer = gethostname(); |
| 46 | 47 | $tokenGenerator = new \Kendox\TokenGenerator($issuer, $pfxFile, $pfxPassword); |
@@ -53,7 +54,8 @@ discard block |
||
| 53 | 54 | $result = $this->post("Authentication/LogonWithToken", $logonParameters);
|
| 54 | 55 | $this->ConnectionId = $result->LogonWithTokenResult->ConnectionId; |
| 55 | 56 | return true; |
| 56 | - } catch(\Exception $ex) {
|
|
| 57 | + } |
|
| 58 | + catch(\Exception $ex) {
|
|
| 57 | 59 | throw new \Exception("Token-Login failed: ".$ex->getMessage());
|
| 58 | 60 | } |
| 59 | 61 | } |
@@ -63,7 +65,7 @@ discard block |
||
| 63 | 65 | * |
| 64 | 66 | * @return bool |
| 65 | 67 | */ |
| 66 | - public function logout() {
|
|
| 68 | + public function logout() { |
|
| 67 | 69 | try {
|
| 68 | 70 | $logoutParameters = [ |
| 69 | 71 | "connectionId" => $this->ConnectionId |
@@ -71,7 +73,8 @@ discard block |
||
| 71 | 73 | $result = $this->post("Authentication/Logout", $logoutParameters);
|
| 72 | 74 | $this->ConnectionId = null; |
| 73 | 75 | return true; |
| 74 | - } catch(\Exception $ex) {
|
|
| 76 | + } |
|
| 77 | + catch(\Exception $ex) {
|
|
| 75 | 78 | throw new \Exception("Token-Login failed: ".$ex->getMessage());
|
| 76 | 79 | } |
| 77 | 80 | } |
@@ -85,7 +88,7 @@ discard block |
||
| 85 | 88 | * |
| 86 | 89 | * @return array The data result as an array |
| 87 | 90 | */ |
| 88 | - public function userTableQuery($userTableName, $whereClauseElements, $addColumnHeaders) {
|
|
| 91 | + public function userTableQuery($userTableName, $whereClauseElements, $addColumnHeaders) { |
|
| 89 | 92 | try {
|
| 90 | 93 | $parameters = [ |
| 91 | 94 | "connectionId" => $this->ConnectionId, |
@@ -94,9 +97,12 @@ discard block |
||
| 94 | 97 | "addColumnHeaders" => $addColumnHeaders |
| 95 | 98 | ]; |
| 96 | 99 | $result = $this->post("UserTable/UserTableGetRecords", $parameters);
|
| 97 | - if (!isset($result->UserTableGetRecordsResult)) throw new \Exception("Unexpected result");
|
|
| 100 | + if (!isset($result->UserTableGetRecordsResult)) { |
|
| 101 | + throw new \Exception("Unexpected result"); |
|
| 102 | + } |
|
| 98 | 103 | return $result->UserTableGetRecordsResult; |
| 99 | - } catch(\Exception $ex) {
|
|
| 104 | + } |
|
| 105 | + catch(\Exception $ex) {
|
|
| 100 | 106 | throw new \Exception("User table query failed: ".$ex->getMessage());
|
| 101 | 107 | } |
| 102 | 108 | } |
@@ -105,7 +111,7 @@ discard block |
||
| 105 | 111 | * Uploading a file |
| 106 | 112 | * @param string $file Path and file name of file to upload |
| 107 | 113 | */ |
| 108 | - public function uploadFile($file) {
|
|
| 114 | + public function uploadFile($file) { |
|
| 109 | 115 | $content = file_get_contents($file); |
| 110 | 116 | return $this->uploadContent($content); |
| 111 | 117 | } |
@@ -114,12 +120,12 @@ discard block |
||
| 114 | 120 | * Uploading a stream of data |
| 115 | 121 | * @param Stream $stream Stream of content to upload |
| 116 | 122 | */ |
| 117 | - public function uploadStream($stream) {
|
|
| 123 | + public function uploadStream($stream) { |
|
| 118 | 124 | $content = stream_get_contents($stream); |
| 119 | 125 | return $this->uploadContent($content); |
| 120 | 126 | } |
| 121 | 127 | |
| 122 | - private function uploadContent($content) {
|
|
| 128 | + private function uploadContent($content) { |
|
| 123 | 129 | $base64 = base64_encode($content); |
| 124 | 130 | $uploadParameters = [ |
| 125 | 131 | "connectionId" => $this->ConnectionId, |
@@ -137,8 +143,7 @@ discard block |
||
| 137 | 143 | * |
| 138 | 144 | * @return object Returns object with data. If service returns an error an exception will be thrown with detailed information |
| 139 | 145 | */ |
| 140 | - private function post($path, $data) |
|
| 141 | - {
|
|
| 146 | + private function post($path, $data) { |
|
| 142 | 147 | $ch = curl_init(); |
| 143 | 148 | //curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); |
| 144 | 149 | curl_setopt($ch, CURLOPT_URL, $this->ServiceEndpoint.$path); |
@@ -154,8 +159,7 @@ discard block |
||
| 154 | 159 | |
| 155 | 160 | } |
| 156 | 161 | |
| 157 | - private function handleJsonResult($json) |
|
| 158 | - {
|
|
| 162 | + private function handleJsonResult($json) { |
|
| 159 | 163 | if ($json === FALSE) {
|
| 160 | 164 | throw new \Exception("No valid JSON has been returned from service.");
|
| 161 | 165 | } |
@@ -44,8 +44,7 @@ discard block |
||
| 44 | 44 | private $PfxFile, /** |
| 45 | 45 | * Password for PFX-File (Certificate) |
| 46 | 46 | */ |
| 47 | - private $PfxPassword) |
|
| 48 | - {
|
|
| 47 | + private $PfxPassword) { |
|
| 49 | 48 | $this->loadCertificateFromPfx(); |
| 50 | 49 | } |
| 51 | 50 | |
@@ -56,8 +55,7 @@ discard block |
||
| 56 | 55 | * |
| 57 | 56 | * @return string Token in XML format |
| 58 | 57 | */ |
| 59 | - public function generateToken($userEMail) |
|
| 60 | - {
|
|
| 58 | + public function generateToken($userEMail) { |
|
| 61 | 59 | try {
|
| 62 | 60 | $now = new \DateTime("now", new \DateTimeZone("utc"));
|
| 63 | 61 | $guid = $this->createGUID(); |
@@ -73,7 +71,8 @@ discard block |
||
| 73 | 71 | xmlwriter_end_element($writer); |
| 74 | 72 | xmlwriter_end_element($writer); |
| 75 | 73 | return xmlwriter_output_memory($writer); |
| 76 | - } catch(\Exception $ex) {
|
|
| 74 | + } |
|
| 75 | + catch(\Exception $ex) {
|
|
| 77 | 76 | throw new \Exception("Generating token failed: ".$ex->getMessage());
|
| 78 | 77 | } |
| 79 | 78 | } |
@@ -81,21 +80,27 @@ discard block |
||
| 81 | 80 | /** |
| 82 | 81 | * Loads the X509-certificate from PFX-File |
| 83 | 82 | */ |
| 84 | - private function loadCertificateFromPfx() |
|
| 85 | - {
|
|
| 86 | - if ($this->PfxFile == null) throw new \Exception("No PFX-File available.");
|
|
| 87 | - if (!file_exists($this->PfxFile)) throw new \Exception("PFX-File not found.");
|
|
| 88 | - if (empty($this->PfxPassword)) throw new \Exception("Password not set for PFX-File.");
|
|
| 83 | + private function loadCertificateFromPfx() { |
|
| 84 | + if ($this->PfxFile == null) { |
|
| 85 | + throw new \Exception("No PFX-File available."); |
|
| 86 | + } |
|
| 87 | + if (!file_exists($this->PfxFile)) { |
|
| 88 | + throw new \Exception("PFX-File not found."); |
|
| 89 | + } |
|
| 90 | + if (empty($this->PfxPassword)) { |
|
| 91 | + throw new \Exception("Password not set for PFX-File."); |
|
| 92 | + } |
|
| 89 | 93 | $pfxContent = file_get_contents($this->PfxFile); |
| 90 | 94 | $results = []; |
| 91 | 95 | $read = openssl_pkcs12_read($pfxContent, $results, $this->PfxPassword); |
| 92 | - if ($read == false) throw new \Exception("Error on reading PFX-File: ".openssl_error_string());
|
|
| 96 | + if ($read == false) { |
|
| 97 | + throw new \Exception("Error on reading PFX-File: ".openssl_error_string()); |
|
| 98 | + } |
|
| 93 | 99 | $this->Certificate = $results['pkey'].$results['cert']; |
| 94 | 100 | $this->CertPrivateKey = $results['pkey']; |
| 95 | 101 | } |
| 96 | 102 | |
| 97 | - private function writeSignedInfo($writer, $userEMail, $time, $uniqueId) |
|
| 98 | - {
|
|
| 103 | + private function writeSignedInfo($writer, $userEMail, $time, $uniqueId) { |
|
| 99 | 104 | $utcTime = $time->format('Y-m-d H:i:s');
|
| 100 | 105 | $utcTime = str_replace(" ", "T", $utcTime)."Z";
|
| 101 | 106 | xmlwriter_start_element($writer, "SignedInfo"); |
@@ -136,8 +141,7 @@ discard block |
||
| 136 | 141 | * |
| 137 | 142 | * @return string |
| 138 | 143 | */ |
| 139 | - function SignXmlString($signedInfoXml) |
|
| 140 | - {
|
|
| 144 | + function SignXmlString($signedInfoXml) { |
|
| 141 | 145 | try {
|
| 142 | 146 | $data = iconv('utf-8', 'utf-16le', $signedInfoXml);
|
| 143 | 147 | $privateKey = \phpseclib3\Crypt\RSA::loadFormat('PKCS8', $this->CertPrivateKey)
|
@@ -145,7 +149,8 @@ discard block |
||
| 145 | 149 | ->withHash('sha512');
|
| 146 | 150 | $base64 = base64_encode($privateKey->sign($data)); |
| 147 | 151 | return $base64; |
| 148 | - } catch (\Exception $ex) {
|
|
| 152 | + } |
|
| 153 | + catch (\Exception $ex) {
|
|
| 149 | 154 | throw new \Exception("XML signing failed: ".$ex->getMessage());
|
| 150 | 155 | } |
| 151 | 156 | } |
@@ -154,10 +159,10 @@ discard block |
||
| 154 | 159 | * Creates a unique ID |
| 155 | 160 | * @return string |
| 156 | 161 | */ |
| 157 | - private function createGUID(){
|
|
| 162 | + private function createGUID() { |
|
| 158 | 163 | if (function_exists('com_create_guid')){
|
| 159 | 164 | return com_create_guid(); |
| 160 | - } |
|
| 165 | + } |
|
| 161 | 166 | else {
|
| 162 | 167 | mt_srand((double)microtime()*10000); |
| 163 | 168 | $charid = strtoupper(md5(uniqid(random_int(0, mt_getrandmax()), true))); |