@@ -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); |
@@ -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> |
@@ -908,14 +908,14 @@ |
||
| 908 | 908 | // Do not show contacts' folders in the AB list view for which |
| 909 | 909 | // the user has permissions, but hasn't added them to the folder hierarchy. |
| 910 | 910 | if (!empty($sharedUserSetting) && |
| 911 | - !isset($sharedUserSetting['all']) && |
|
| 912 | - !isset($sharedUserSetting['contact']) && |
|
| 913 | - in_array($mainUserEntryId, array_column($grants, 'userid'))) { |
|
| 911 | + !isset($sharedUserSetting['all']) && |
|
| 912 | + !isset($sharedUserSetting['contact']) && |
|
| 913 | + in_array($mainUserEntryId, array_column($grants, 'userid'))) { |
|
| 914 | 914 | continue; |
| 915 | 915 | } |
| 916 | 916 | if (isset($sharedUserSetting['all']) || |
| 917 | - isset($sharedUserSetting['contact']) || |
|
| 918 | - in_array($mainUserEntryId, array_column($grants, 'userid'))) |
|
| 917 | + isset($sharedUserSetting['contact']) || |
|
| 918 | + in_array($mainUserEntryId, array_column($grants, 'userid'))) |
|
| 919 | 919 | { |
| 920 | 920 | $this->addFolder($folders, [ |
| 921 | 921 | // Postfix display name of every contact folder with respective owner name |
@@ -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 | |
@@ -1,171 +1,171 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace Kendox; |
| 3 | 3 | |
| 4 | - require_once("class.kendox-token-generator.php");
|
|
| 4 | + require_once("class.kendox-token-generator.php");
|
|
| 5 | 5 | |
| 6 | - class Client |
|
| 7 | - {
|
|
| 6 | + class Client |
|
| 7 | + {
|
|
| 8 | 8 | |
| 9 | - /** |
|
| 10 | - * Generated token for user |
|
| 11 | - * |
|
| 12 | - * @var StdClass |
|
| 13 | - */ |
|
| 14 | - public $Token = null; |
|
| 9 | + /** |
|
| 10 | + * Generated token for user |
|
| 11 | + * |
|
| 12 | + * @var StdClass |
|
| 13 | + */ |
|
| 14 | + public $Token = null; |
|
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * URL of Kendox Service Endpoint |
|
| 18 | - * @var string |
|
| 19 | - */ |
|
| 20 | - public $ServiceEndpoint = null; |
|
| 16 | + /** |
|
| 17 | + * URL of Kendox Service Endpoint |
|
| 18 | + * @var string |
|
| 19 | + */ |
|
| 20 | + public $ServiceEndpoint = null; |
|
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * Connection Id returned from service on successful login |
|
| 24 | - * @var string |
|
| 25 | - */ |
|
| 26 | - public $ConnectionId = null; |
|
| 22 | + /** |
|
| 23 | + * Connection Id returned from service on successful login |
|
| 24 | + * @var string |
|
| 25 | + */ |
|
| 26 | + public $ConnectionId = null; |
|
| 27 | 27 | |
| 28 | - function __construct($serviceEndpoint) |
|
| 29 | - {
|
|
| 30 | - if (!str_ends_with($serviceEndpoint, '/')) $serviceEndpoint .= '/'; |
|
| 31 | - $this->ServiceEndpoint = $serviceEndpoint; |
|
| 32 | - } |
|
| 28 | + function __construct($serviceEndpoint) |
|
| 29 | + {
|
|
| 30 | + if (!str_ends_with($serviceEndpoint, '/')) $serviceEndpoint .= '/'; |
|
| 31 | + $this->ServiceEndpoint = $serviceEndpoint; |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * Login to kendox service by creating a user based token, signed by Kendox trusted certificate |
|
| 36 | - * |
|
| 37 | - * @param string $pfxFile The full path and file name of the PFX-File (certificate) |
|
| 38 | - * @param string $pfxPassword The password used for reading the PFX-File (certificate) |
|
| 39 | - * @param string $userName Username for token generation |
|
| 40 | - * |
|
| 41 | - * @return bool |
|
| 42 | - */ |
|
| 43 | - public function loginWithToken($pfxFile, $pfxPassword, $userName) {
|
|
| 44 | - try {
|
|
| 45 | - $issuer = gethostname(); |
|
| 46 | - $tokenGenerator = new \Kendox\TokenGenerator($issuer, $pfxFile, $pfxPassword); |
|
| 47 | - $this->Token = $tokenGenerator->generateToken($userName); |
|
| 48 | - $logonParameters = [ |
|
| 49 | - "tenantName" => "", |
|
| 50 | - "token" => $this->Token, |
|
| 51 | - "tokenType" => "InfoShareToken" |
|
| 52 | - ]; |
|
| 53 | - $result = $this->post("Authentication/LogonWithToken", $logonParameters);
|
|
| 54 | - $this->ConnectionId = $result->LogonWithTokenResult->ConnectionId; |
|
| 55 | - return true; |
|
| 56 | - } catch(\Exception $ex) {
|
|
| 57 | - throw new \Exception("Token-Login failed: ".$ex->getMessage());
|
|
| 58 | - } |
|
| 59 | - } |
|
| 34 | + /** |
|
| 35 | + * Login to kendox service by creating a user based token, signed by Kendox trusted certificate |
|
| 36 | + * |
|
| 37 | + * @param string $pfxFile The full path and file name of the PFX-File (certificate) |
|
| 38 | + * @param string $pfxPassword The password used for reading the PFX-File (certificate) |
|
| 39 | + * @param string $userName Username for token generation |
|
| 40 | + * |
|
| 41 | + * @return bool |
|
| 42 | + */ |
|
| 43 | + public function loginWithToken($pfxFile, $pfxPassword, $userName) {
|
|
| 44 | + try {
|
|
| 45 | + $issuer = gethostname(); |
|
| 46 | + $tokenGenerator = new \Kendox\TokenGenerator($issuer, $pfxFile, $pfxPassword); |
|
| 47 | + $this->Token = $tokenGenerator->generateToken($userName); |
|
| 48 | + $logonParameters = [ |
|
| 49 | + "tenantName" => "", |
|
| 50 | + "token" => $this->Token, |
|
| 51 | + "tokenType" => "InfoShareToken" |
|
| 52 | + ]; |
|
| 53 | + $result = $this->post("Authentication/LogonWithToken", $logonParameters);
|
|
| 54 | + $this->ConnectionId = $result->LogonWithTokenResult->ConnectionId; |
|
| 55 | + return true; |
|
| 56 | + } catch(\Exception $ex) {
|
|
| 57 | + throw new \Exception("Token-Login failed: ".$ex->getMessage());
|
|
| 58 | + } |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * Logout from kendox |
|
| 63 | - * |
|
| 64 | - * @return bool |
|
| 65 | - */ |
|
| 66 | - public function logout() {
|
|
| 67 | - try {
|
|
| 68 | - $logoutParameters = [ |
|
| 69 | - "connectionId" => $this->ConnectionId |
|
| 70 | - ]; |
|
| 71 | - $result = $this->post("Authentication/Logout", $logoutParameters);
|
|
| 72 | - $this->ConnectionId = null; |
|
| 73 | - return true; |
|
| 74 | - } catch(\Exception $ex) {
|
|
| 75 | - throw new \Exception("Token-Login failed: ".$ex->getMessage());
|
|
| 76 | - } |
|
| 77 | - } |
|
| 61 | + /** |
|
| 62 | + * Logout from kendox |
|
| 63 | + * |
|
| 64 | + * @return bool |
|
| 65 | + */ |
|
| 66 | + public function logout() {
|
|
| 67 | + try {
|
|
| 68 | + $logoutParameters = [ |
|
| 69 | + "connectionId" => $this->ConnectionId |
|
| 70 | + ]; |
|
| 71 | + $result = $this->post("Authentication/Logout", $logoutParameters);
|
|
| 72 | + $this->ConnectionId = null; |
|
| 73 | + return true; |
|
| 74 | + } catch(\Exception $ex) {
|
|
| 75 | + throw new \Exception("Token-Login failed: ".$ex->getMessage());
|
|
| 76 | + } |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - /** |
|
| 80 | - * Performs a user table query and fetch the result records |
|
| 81 | - * |
|
| 82 | - * @param $userTableName The name of the user table |
|
| 83 | - * @param $whereClauseElements Array with fields "ColumnName", "RelationalOperator" and "Value" for filter defintion of the query |
|
| 84 | - * @param $addColumnHeaders Add column headers to result? |
|
| 85 | - * |
|
| 86 | - * @return array The data result as an array |
|
| 87 | - */ |
|
| 88 | - public function userTableQuery($userTableName, $whereClauseElements, $addColumnHeaders) {
|
|
| 89 | - try {
|
|
| 90 | - $parameters = [ |
|
| 91 | - "connectionId" => $this->ConnectionId, |
|
| 92 | - "userTable" => $userTableName, |
|
| 93 | - "whereClauseElements" => $whereClauseElements, |
|
| 94 | - "addColumnHeaders" => $addColumnHeaders |
|
| 95 | - ]; |
|
| 96 | - $result = $this->post("UserTable/UserTableGetRecords", $parameters);
|
|
| 97 | - if (!isset($result->UserTableGetRecordsResult)) throw new \Exception("Unexpected result");
|
|
| 98 | - return $result->UserTableGetRecordsResult; |
|
| 99 | - } catch(\Exception $ex) {
|
|
| 100 | - throw new \Exception("User table query failed: ".$ex->getMessage());
|
|
| 101 | - } |
|
| 102 | - } |
|
| 79 | + /** |
|
| 80 | + * Performs a user table query and fetch the result records |
|
| 81 | + * |
|
| 82 | + * @param $userTableName The name of the user table |
|
| 83 | + * @param $whereClauseElements Array with fields "ColumnName", "RelationalOperator" and "Value" for filter defintion of the query |
|
| 84 | + * @param $addColumnHeaders Add column headers to result? |
|
| 85 | + * |
|
| 86 | + * @return array The data result as an array |
|
| 87 | + */ |
|
| 88 | + public function userTableQuery($userTableName, $whereClauseElements, $addColumnHeaders) {
|
|
| 89 | + try {
|
|
| 90 | + $parameters = [ |
|
| 91 | + "connectionId" => $this->ConnectionId, |
|
| 92 | + "userTable" => $userTableName, |
|
| 93 | + "whereClauseElements" => $whereClauseElements, |
|
| 94 | + "addColumnHeaders" => $addColumnHeaders |
|
| 95 | + ]; |
|
| 96 | + $result = $this->post("UserTable/UserTableGetRecords", $parameters);
|
|
| 97 | + if (!isset($result->UserTableGetRecordsResult)) throw new \Exception("Unexpected result");
|
|
| 98 | + return $result->UserTableGetRecordsResult; |
|
| 99 | + } catch(\Exception $ex) {
|
|
| 100 | + throw new \Exception("User table query failed: ".$ex->getMessage());
|
|
| 101 | + } |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | - /** |
|
| 105 | - * Uploading a file |
|
| 106 | - * @param string $file Path and file name of file to upload |
|
| 107 | - */ |
|
| 108 | - public function uploadFile($file) {
|
|
| 109 | - $content = file_get_contents($file); |
|
| 110 | - return $this->uploadContent($content); |
|
| 111 | - } |
|
| 104 | + /** |
|
| 105 | + * Uploading a file |
|
| 106 | + * @param string $file Path and file name of file to upload |
|
| 107 | + */ |
|
| 108 | + public function uploadFile($file) {
|
|
| 109 | + $content = file_get_contents($file); |
|
| 110 | + return $this->uploadContent($content); |
|
| 111 | + } |
|
| 112 | 112 | |
| 113 | - /** |
|
| 114 | - * Uploading a stream of data |
|
| 115 | - * @param Stream $stream Stream of content to upload |
|
| 116 | - */ |
|
| 117 | - public function uploadStream($stream) {
|
|
| 118 | - $content = stream_get_contents($stream); |
|
| 119 | - return $this->uploadContent($content); |
|
| 120 | - } |
|
| 113 | + /** |
|
| 114 | + * Uploading a stream of data |
|
| 115 | + * @param Stream $stream Stream of content to upload |
|
| 116 | + */ |
|
| 117 | + public function uploadStream($stream) {
|
|
| 118 | + $content = stream_get_contents($stream); |
|
| 119 | + return $this->uploadContent($content); |
|
| 120 | + } |
|
| 121 | 121 | |
| 122 | - private function uploadContent($content) {
|
|
| 123 | - $base64 = base64_encode($content); |
|
| 124 | - $uploadParameters = [ |
|
| 125 | - "connectionId" => $this->ConnectionId, |
|
| 126 | - "fileContentbase64" => $base64 |
|
| 127 | - ]; |
|
| 128 | - $result = $this->post("File/UploadFileBase64", $uploadParameters);
|
|
| 129 | - return $result->UploadFileBase64Result; |
|
| 130 | - } |
|
| 122 | + private function uploadContent($content) {
|
|
| 123 | + $base64 = base64_encode($content); |
|
| 124 | + $uploadParameters = [ |
|
| 125 | + "connectionId" => $this->ConnectionId, |
|
| 126 | + "fileContentbase64" => $base64 |
|
| 127 | + ]; |
|
| 128 | + $result = $this->post("File/UploadFileBase64", $uploadParameters);
|
|
| 129 | + return $result->UploadFileBase64Result; |
|
| 130 | + } |
|
| 131 | 131 | |
| 132 | - /** |
|
| 133 | - * Performing a post request to service |
|
| 134 | - * |
|
| 135 | - * @param string $path the route to the API endpoint (without service endpoint url) |
|
| 136 | - * @param string Associated array with data to post |
|
| 137 | - * |
|
| 138 | - * @return object Returns object with data. If service returns an error an exception will be thrown with detailed information |
|
| 139 | - */ |
|
| 140 | - private function post($path, $data) |
|
| 141 | - {
|
|
| 142 | - $ch = curl_init(); |
|
| 143 | - //curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); |
|
| 144 | - curl_setopt($ch, CURLOPT_URL, $this->ServiceEndpoint.$path); |
|
| 145 | - curl_setopt($ch, CURLOPT_POST, 1); |
|
| 146 | - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); |
|
| 147 | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
| 148 | - curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']); |
|
| 149 | - $jsonResult = curl_exec($ch); |
|
| 150 | - if (curl_errno($ch)) {
|
|
| 151 | - throw new \Exception("Error on post request: ".curl_errno($ch));
|
|
| 152 | - } |
|
| 153 | - return $this->handleJsonResult($jsonResult); |
|
| 132 | + /** |
|
| 133 | + * Performing a post request to service |
|
| 134 | + * |
|
| 135 | + * @param string $path the route to the API endpoint (without service endpoint url) |
|
| 136 | + * @param string Associated array with data to post |
|
| 137 | + * |
|
| 138 | + * @return object Returns object with data. If service returns an error an exception will be thrown with detailed information |
|
| 139 | + */ |
|
| 140 | + private function post($path, $data) |
|
| 141 | + {
|
|
| 142 | + $ch = curl_init(); |
|
| 143 | + //curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); |
|
| 144 | + curl_setopt($ch, CURLOPT_URL, $this->ServiceEndpoint.$path); |
|
| 145 | + curl_setopt($ch, CURLOPT_POST, 1); |
|
| 146 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); |
|
| 147 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
| 148 | + curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']); |
|
| 149 | + $jsonResult = curl_exec($ch); |
|
| 150 | + if (curl_errno($ch)) {
|
|
| 151 | + throw new \Exception("Error on post request: ".curl_errno($ch));
|
|
| 152 | + } |
|
| 153 | + return $this->handleJsonResult($jsonResult); |
|
| 154 | 154 | |
| 155 | - } |
|
| 155 | + } |
|
| 156 | 156 | |
| 157 | - private function handleJsonResult($json) |
|
| 158 | - {
|
|
| 159 | - if ($json === FALSE) {
|
|
| 160 | - throw new \Exception("No valid JSON has been returned from service.");
|
|
| 161 | - } |
|
| 162 | - $result = json_decode($json); |
|
| 163 | - if (isset($result->ErrorNumber)) {
|
|
| 164 | - throw new \Exception("(".$result->ErrorNumber.") ".$result->Message);
|
|
| 165 | - } |
|
| 166 | - return $result; |
|
| 167 | - } |
|
| 157 | + private function handleJsonResult($json) |
|
| 158 | + {
|
|
| 159 | + if ($json === FALSE) {
|
|
| 160 | + throw new \Exception("No valid JSON has been returned from service.");
|
|
| 161 | + } |
|
| 162 | + $result = json_decode($json); |
|
| 163 | + if (isset($result->ErrorNumber)) {
|
|
| 164 | + throw new \Exception("(".$result->ErrorNumber.") ".$result->Message);
|
|
| 165 | + } |
|
| 166 | + return $result; |
|
| 167 | + } |
|
| 168 | 168 | |
| 169 | - } |
|
| 169 | + } |
|
| 170 | 170 | |
| 171 | 171 | ?> |
| 172 | 172 | \ No newline at end of file |
@@ -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 | } |
@@ -6,170 +6,170 @@ |
||
| 6 | 6 | class TokenGenerator |
| 7 | 7 | {
|
| 8 | 8 | |
| 9 | - /** |
|
| 10 | - * Token version |
|
| 11 | - * @var string |
|
| 12 | - */ |
|
| 13 | - private $TokenVersion = "1"; |
|
| 9 | + /** |
|
| 10 | + * Token version |
|
| 11 | + * @var string |
|
| 12 | + */ |
|
| 13 | + private $TokenVersion = "1"; |
|
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Token lifetime in seconds |
|
| 17 | - * @var int |
|
| 18 | - */ |
|
| 19 | - private $TokenLifeTime = 99000000; |
|
| 15 | + /** |
|
| 16 | + * Token lifetime in seconds |
|
| 17 | + * @var int |
|
| 18 | + */ |
|
| 19 | + private $TokenLifeTime = 99000000; |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * Certificate data (read from PFX-File) |
|
| 23 | - * @var string |
|
| 24 | - */ |
|
| 25 | - private $Certificate = null; |
|
| 21 | + /** |
|
| 22 | + * Certificate data (read from PFX-File) |
|
| 23 | + * @var string |
|
| 24 | + */ |
|
| 25 | + private $Certificate = null; |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * Private key of certificate (read from PFX-file) |
|
| 29 | - * @var string |
|
| 30 | - */ |
|
| 31 | - private $CertPrivateKey = null; |
|
| 27 | + /** |
|
| 28 | + * Private key of certificate (read from PFX-file) |
|
| 29 | + * @var string |
|
| 30 | + */ |
|
| 31 | + private $CertPrivateKey = null; |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * @param string $issuer |
|
| 35 | - * @param string $pfxFile |
|
| 36 | - * @param string $pfxPassword |
|
| 37 | - */ |
|
| 38 | - function __construct(/** |
|
| 39 | - * Issuer host name |
|
| 40 | - */ |
|
| 41 | - private $Issuer, /** |
|
| 42 | - * Full filename of PFX-File (Certificate) |
|
| 43 | - */ |
|
| 44 | - private $PfxFile, /** |
|
| 45 | - * Password for PFX-File (Certificate) |
|
| 46 | - */ |
|
| 47 | - private $PfxPassword) |
|
| 48 | - {
|
|
| 49 | - $this->loadCertificateFromPfx(); |
|
| 50 | - } |
|
| 33 | + /** |
|
| 34 | + * @param string $issuer |
|
| 35 | + * @param string $pfxFile |
|
| 36 | + * @param string $pfxPassword |
|
| 37 | + */ |
|
| 38 | + function __construct(/** |
|
| 39 | + * Issuer host name |
|
| 40 | + */ |
|
| 41 | + private $Issuer, /** |
|
| 42 | + * Full filename of PFX-File (Certificate) |
|
| 43 | + */ |
|
| 44 | + private $PfxFile, /** |
|
| 45 | + * Password for PFX-File (Certificate) |
|
| 46 | + */ |
|
| 47 | + private $PfxPassword) |
|
| 48 | + {
|
|
| 49 | + $this->loadCertificateFromPfx(); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * Token generation |
|
| 54 | - * |
|
| 55 | - * @param string $userEMail The e-mail of the user to generate a token |
|
| 56 | - * |
|
| 57 | - * @return string Token in XML format |
|
| 58 | - */ |
|
| 59 | - public function generateToken($userEMail) |
|
| 60 | - {
|
|
| 61 | - try {
|
|
| 62 | - $now = new \DateTime("now", new \DateTimeZone("utc"));
|
|
| 63 | - $guid = $this->createGUID(); |
|
| 64 | - $writerSignedInfo = xmlwriter_open_memory(); |
|
| 65 | - $this->writeSignedInfo($writerSignedInfo, $userEMail, $now, $guid); |
|
| 66 | - $signedInfo = xmlwriter_output_memory($writerSignedInfo); |
|
| 67 | - $writer = xmlwriter_open_memory(); |
|
| 68 | - xmlwriter_set_indent($writer, false); |
|
| 69 | - xmlwriter_start_element($writer, "InfoShareToken"); |
|
| 70 | - $this->writeSignedInfo($writer, $userEMail, $now, $guid); |
|
| 71 | - xmlwriter_start_element($writer, "SignatureValue"); |
|
| 72 | - xmlwriter_text($writer, $this->signXmlString($signedInfo)); |
|
| 73 | - xmlwriter_end_element($writer); |
|
| 74 | - xmlwriter_end_element($writer); |
|
| 75 | - return xmlwriter_output_memory($writer); |
|
| 76 | - } catch(\Exception $ex) {
|
|
| 77 | - throw new \Exception("Generating token failed: ".$ex->getMessage());
|
|
| 78 | - } |
|
| 79 | - } |
|
| 52 | + /** |
|
| 53 | + * Token generation |
|
| 54 | + * |
|
| 55 | + * @param string $userEMail The e-mail of the user to generate a token |
|
| 56 | + * |
|
| 57 | + * @return string Token in XML format |
|
| 58 | + */ |
|
| 59 | + public function generateToken($userEMail) |
|
| 60 | + {
|
|
| 61 | + try {
|
|
| 62 | + $now = new \DateTime("now", new \DateTimeZone("utc"));
|
|
| 63 | + $guid = $this->createGUID(); |
|
| 64 | + $writerSignedInfo = xmlwriter_open_memory(); |
|
| 65 | + $this->writeSignedInfo($writerSignedInfo, $userEMail, $now, $guid); |
|
| 66 | + $signedInfo = xmlwriter_output_memory($writerSignedInfo); |
|
| 67 | + $writer = xmlwriter_open_memory(); |
|
| 68 | + xmlwriter_set_indent($writer, false); |
|
| 69 | + xmlwriter_start_element($writer, "InfoShareToken"); |
|
| 70 | + $this->writeSignedInfo($writer, $userEMail, $now, $guid); |
|
| 71 | + xmlwriter_start_element($writer, "SignatureValue"); |
|
| 72 | + xmlwriter_text($writer, $this->signXmlString($signedInfo)); |
|
| 73 | + xmlwriter_end_element($writer); |
|
| 74 | + xmlwriter_end_element($writer); |
|
| 75 | + return xmlwriter_output_memory($writer); |
|
| 76 | + } catch(\Exception $ex) {
|
|
| 77 | + throw new \Exception("Generating token failed: ".$ex->getMessage());
|
|
| 78 | + } |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - /** |
|
| 82 | - * Loads the X509-certificate from PFX-File |
|
| 83 | - */ |
|
| 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.");
|
|
| 89 | - $pfxContent = file_get_contents($this->PfxFile); |
|
| 90 | - $results = []; |
|
| 91 | - $read = openssl_pkcs12_read($pfxContent, $results, $this->PfxPassword); |
|
| 92 | - if ($read == false) throw new \Exception("Error on reading PFX-File: ".openssl_error_string());
|
|
| 93 | - $this->Certificate = $results['pkey'].$results['cert']; |
|
| 94 | - $this->CertPrivateKey = $results['pkey']; |
|
| 95 | - } |
|
| 81 | + /** |
|
| 82 | + * Loads the X509-certificate from PFX-File |
|
| 83 | + */ |
|
| 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.");
|
|
| 89 | + $pfxContent = file_get_contents($this->PfxFile); |
|
| 90 | + $results = []; |
|
| 91 | + $read = openssl_pkcs12_read($pfxContent, $results, $this->PfxPassword); |
|
| 92 | + if ($read == false) throw new \Exception("Error on reading PFX-File: ".openssl_error_string());
|
|
| 93 | + $this->Certificate = $results['pkey'].$results['cert']; |
|
| 94 | + $this->CertPrivateKey = $results['pkey']; |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | - private function writeSignedInfo($writer, $userEMail, $time, $uniqueId) |
|
| 98 | - {
|
|
| 99 | - $utcTime = $time->format('Y-m-d H:i:s');
|
|
| 100 | - $utcTime = str_replace(" ", "T", $utcTime)."Z";
|
|
| 101 | - xmlwriter_start_element($writer, "SignedInfo"); |
|
| 102 | - xmlwriter_start_element($writer, "UserPrincipalName"); |
|
| 103 | - xmlwriter_text($writer, $userEMail); |
|
| 104 | - xmlwriter_end_element($writer); |
|
| 105 | - xmlwriter_start_element($writer, "UniqueId"); |
|
| 106 | - xmlwriter_text($writer, $uniqueId); |
|
| 107 | - xmlwriter_end_element($writer); |
|
| 108 | - xmlwriter_start_element($writer, "Version"); |
|
| 109 | - xmlwriter_text($writer, $this->TokenVersion); |
|
| 110 | - xmlwriter_end_element($writer); |
|
| 111 | - xmlwriter_start_element($writer, "TimeStampUTC"); |
|
| 112 | - xmlwriter_text($writer, $utcTime); |
|
| 113 | - xmlwriter_end_element($writer); |
|
| 114 | - xmlwriter_start_element($writer, "LifeTimeSeconds"); |
|
| 115 | - xmlwriter_text($writer, $this->TokenLifeTime); |
|
| 116 | - xmlwriter_end_element($writer); |
|
| 117 | - xmlwriter_start_element($writer, "IssueServer"); |
|
| 118 | - xmlwriter_text($writer, $this->Issuer); |
|
| 119 | - xmlwriter_end_element($writer); |
|
| 120 | - xmlwriter_start_element($writer, "CertificateFingerprint"); |
|
| 121 | - xmlwriter_text($writer, strtoupper(openssl_x509_fingerprint($this->Certificate))); |
|
| 122 | - xmlwriter_end_element($writer); |
|
| 123 | - xmlwriter_start_element($writer, "HashAlgorithm"); |
|
| 124 | - xmlwriter_text($writer, "SHA512"); |
|
| 125 | - xmlwriter_end_element($writer); |
|
| 126 | - xmlwriter_start_element($writer, "Attributes"); |
|
| 127 | - xmlwriter_text($writer, ""); |
|
| 128 | - xmlwriter_end_element($writer); |
|
| 129 | - xmlwriter_end_element($writer); |
|
| 130 | - } |
|
| 97 | + private function writeSignedInfo($writer, $userEMail, $time, $uniqueId) |
|
| 98 | + {
|
|
| 99 | + $utcTime = $time->format('Y-m-d H:i:s');
|
|
| 100 | + $utcTime = str_replace(" ", "T", $utcTime)."Z";
|
|
| 101 | + xmlwriter_start_element($writer, "SignedInfo"); |
|
| 102 | + xmlwriter_start_element($writer, "UserPrincipalName"); |
|
| 103 | + xmlwriter_text($writer, $userEMail); |
|
| 104 | + xmlwriter_end_element($writer); |
|
| 105 | + xmlwriter_start_element($writer, "UniqueId"); |
|
| 106 | + xmlwriter_text($writer, $uniqueId); |
|
| 107 | + xmlwriter_end_element($writer); |
|
| 108 | + xmlwriter_start_element($writer, "Version"); |
|
| 109 | + xmlwriter_text($writer, $this->TokenVersion); |
|
| 110 | + xmlwriter_end_element($writer); |
|
| 111 | + xmlwriter_start_element($writer, "TimeStampUTC"); |
|
| 112 | + xmlwriter_text($writer, $utcTime); |
|
| 113 | + xmlwriter_end_element($writer); |
|
| 114 | + xmlwriter_start_element($writer, "LifeTimeSeconds"); |
|
| 115 | + xmlwriter_text($writer, $this->TokenLifeTime); |
|
| 116 | + xmlwriter_end_element($writer); |
|
| 117 | + xmlwriter_start_element($writer, "IssueServer"); |
|
| 118 | + xmlwriter_text($writer, $this->Issuer); |
|
| 119 | + xmlwriter_end_element($writer); |
|
| 120 | + xmlwriter_start_element($writer, "CertificateFingerprint"); |
|
| 121 | + xmlwriter_text($writer, strtoupper(openssl_x509_fingerprint($this->Certificate))); |
|
| 122 | + xmlwriter_end_element($writer); |
|
| 123 | + xmlwriter_start_element($writer, "HashAlgorithm"); |
|
| 124 | + xmlwriter_text($writer, "SHA512"); |
|
| 125 | + xmlwriter_end_element($writer); |
|
| 126 | + xmlwriter_start_element($writer, "Attributes"); |
|
| 127 | + xmlwriter_text($writer, ""); |
|
| 128 | + xmlwriter_end_element($writer); |
|
| 129 | + xmlwriter_end_element($writer); |
|
| 130 | + } |
|
| 131 | 131 | |
| 132 | - /** |
|
| 133 | - * Signing a XML-String and returns the result |
|
| 134 | - * |
|
| 135 | - * @param string $xml XML-String |
|
| 136 | - * |
|
| 137 | - * @return string |
|
| 138 | - */ |
|
| 139 | - function SignXmlString($signedInfoXml) |
|
| 140 | - {
|
|
| 141 | - try {
|
|
| 142 | - $data = iconv('utf-8', 'utf-16le', $signedInfoXml);
|
|
| 143 | - $privateKey = \phpseclib3\Crypt\RSA::loadFormat('PKCS8', $this->CertPrivateKey)
|
|
| 144 | - ->withPadding(\phpseclib3\Crypt\RSA::SIGNATURE_PKCS1) |
|
| 145 | - ->withHash('sha512');
|
|
| 146 | - $base64 = base64_encode($privateKey->sign($data)); |
|
| 147 | - return $base64; |
|
| 148 | - } catch (\Exception $ex) {
|
|
| 149 | - throw new \Exception("XML signing failed: ".$ex->getMessage());
|
|
| 150 | - } |
|
| 151 | - } |
|
| 132 | + /** |
|
| 133 | + * Signing a XML-String and returns the result |
|
| 134 | + * |
|
| 135 | + * @param string $xml XML-String |
|
| 136 | + * |
|
| 137 | + * @return string |
|
| 138 | + */ |
|
| 139 | + function SignXmlString($signedInfoXml) |
|
| 140 | + {
|
|
| 141 | + try {
|
|
| 142 | + $data = iconv('utf-8', 'utf-16le', $signedInfoXml);
|
|
| 143 | + $privateKey = \phpseclib3\Crypt\RSA::loadFormat('PKCS8', $this->CertPrivateKey)
|
|
| 144 | + ->withPadding(\phpseclib3\Crypt\RSA::SIGNATURE_PKCS1) |
|
| 145 | + ->withHash('sha512');
|
|
| 146 | + $base64 = base64_encode($privateKey->sign($data)); |
|
| 147 | + return $base64; |
|
| 148 | + } catch (\Exception $ex) {
|
|
| 149 | + throw new \Exception("XML signing failed: ".$ex->getMessage());
|
|
| 150 | + } |
|
| 151 | + } |
|
| 152 | 152 | |
| 153 | - /** |
|
| 154 | - * Creates a unique ID |
|
| 155 | - * @return string |
|
| 156 | - */ |
|
| 157 | - private function createGUID(){
|
|
| 158 | - if (function_exists('com_create_guid')){
|
|
| 159 | - return com_create_guid(); |
|
| 160 | - } |
|
| 161 | - else {
|
|
| 162 | - mt_srand((double)microtime()*10000); |
|
| 163 | - $charid = strtoupper(md5(uniqid(random_int(0, mt_getrandmax()), true))); |
|
| 164 | - $hyphen = chr(45);// "-" |
|
| 165 | - $uuid = substr($charid, 0, 8).$hyphen |
|
| 166 | - .substr($charid, 8, 4).$hyphen |
|
| 167 | - .substr($charid,12, 4).$hyphen |
|
| 168 | - .substr($charid,16, 4).$hyphen |
|
| 169 | - .substr($charid,20,12); |
|
| 170 | - return $uuid; |
|
| 171 | - } |
|
| 172 | - } |
|
| 153 | + /** |
|
| 154 | + * Creates a unique ID |
|
| 155 | + * @return string |
|
| 156 | + */ |
|
| 157 | + private function createGUID(){
|
|
| 158 | + if (function_exists('com_create_guid')){
|
|
| 159 | + return com_create_guid(); |
|
| 160 | + } |
|
| 161 | + else {
|
|
| 162 | + mt_srand((double)microtime()*10000); |
|
| 163 | + $charid = strtoupper(md5(uniqid(random_int(0, mt_getrandmax()), true))); |
|
| 164 | + $hyphen = chr(45);// "-" |
|
| 165 | + $uuid = substr($charid, 0, 8).$hyphen |
|
| 166 | + .substr($charid, 8, 4).$hyphen |
|
| 167 | + .substr($charid,12, 4).$hyphen |
|
| 168 | + .substr($charid,16, 4).$hyphen |
|
| 169 | + .substr($charid,20,12); |
|
| 170 | + return $uuid; |
|
| 171 | + } |
|
| 172 | + } |
|
| 173 | 173 | |
| 174 | 174 | } |
| 175 | 175 | |
@@ -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))); |
@@ -386,8 +386,7 @@ discard block |
||
| 386 | 386 | unlink($tmpUserCert); |
| 387 | 387 | } |
| 388 | 388 | |
| 389 | - function join_xph(&$prop, $msg) |
|
| 390 | - { |
|
| 389 | + function join_xph(&$prop, $msg) { |
|
| 391 | 390 | $a = mapi_getprops($msg, [PR_TRANSPORT_MESSAGE_HEADERS]); |
| 392 | 391 | $a = $a === false ? "" : ($a[PR_TRANSPORT_MESSAGE_HEADERS] ?? ""); |
| 393 | 392 | $prop[PR_TRANSPORT_MESSAGE_HEADERS] = |
@@ -988,8 +987,7 @@ discard block |
||
| 988 | 987 | return !empty($rows); |
| 989 | 988 | } |
| 990 | 989 | |
| 991 | - public function clear_openssl_error() |
|
| 992 | - { |
|
| 990 | + public function clear_openssl_error() { |
|
| 993 | 991 | while (@openssl_error_string() !== false) |
| 994 | 992 | /* nothing */; |
| 995 | 993 | } |
@@ -1003,11 +1001,13 @@ discard block |
||
| 1003 | 1001 | */ |
| 1004 | 1002 | public function extract_openssl_error() { |
| 1005 | 1003 | $this->openssl_error = ""; |
| 1006 | - while (($s = @openssl_error_string()) !== false) |
|
| 1007 | - if (strlen($this->openssl_error) == 0) |
|
| 1004 | + while (($s = @openssl_error_string()) !== false) { |
|
| 1005 | + if (strlen($this->openssl_error) == 0) |
|
| 1008 | 1006 | $this->openssl_error = $s; |
| 1009 | - else |
|
| 1010 | - $this->openssl_error .= "\n".$s; |
|
| 1007 | + } |
|
| 1008 | + else { |
|
| 1009 | + $this->openssl_error .= "\n".$s; |
|
| 1010 | + } |
|
| 1011 | 1011 | $openssl_error_code = 0; |
| 1012 | 1012 | if ($this->openssl_error) { |
| 1013 | 1013 | $openssl_error_list = explode(":", $this->openssl_error); |
@@ -17,8 +17,9 @@ discard block |
||
| 17 | 17 | * It also sends the eml file to the client. |
| 18 | 18 | */ |
| 19 | 19 | public function downloadMessageAsFile() { |
| 20 | - if (!$this->message || !$this->store) |
|
| 21 | - return; |
|
| 20 | + if (!$this->message || !$this->store) { |
|
| 21 | + return; |
|
| 22 | + } |
|
| 22 | 23 | // get message properties. |
| 23 | 24 | $messageProps = mapi_getprops($this->message, [PR_SUBJECT, PR_MESSAGE_CLASS]); |
| 24 | 25 | |
@@ -49,8 +50,9 @@ discard block |
||
| 49 | 50 | * Send ZIP to the client if all the requested eml files included successfully into the same. |
| 50 | 51 | */ |
| 51 | 52 | public function downloadMessageAsZipFile() { |
| 52 | - if (!$this->store) |
|
| 53 | - return; |
|
| 53 | + if (!$this->store) { |
|
| 54 | + return; |
|
| 55 | + } |
|
| 54 | 56 | // Generate random ZIP file name at default temporary path of PHP |
| 55 | 57 | $randomZipName = tempnam(sys_get_temp_dir(), 'zip'); |
| 56 | 58 | |