@@ -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 |
@@ -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 |
@@ -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 | |
@@ -129,12 +129,12 @@ |
||
| 129 | 129 | if (!$store || !$parententryid || !$entryid) |
| 130 | 130 | break; |
| 131 | 131 | if (!isset($action["message_action"], $action["message_action"]["action_type"]) || |
| 132 | - $action["message_action"]["action_type"] !== "removefavorites") { |
|
| 132 | + $action["message_action"]["action_type"] !== "removefavorites") { |
|
| 133 | 133 | $this->deleteFolder($store, $parententryid, $entryid, $action); |
| 134 | 134 | break; |
| 135 | 135 | } |
| 136 | 136 | if (!isset($action["message_action"]["isSearchFolder"]) || |
| 137 | - !$action["message_action"]["isSearchFolder"]) { |
|
| 137 | + !$action["message_action"]["isSearchFolder"]) { |
|
| 138 | 138 | $this->removeFromFavorite($entryid); |
| 139 | 139 | break; |
| 140 | 140 | } |
@@ -616,8 +616,8 @@ |
||
| 616 | 616 | // may have changed, so it's necessary to check again if they are |
| 617 | 617 | // still in the requested interval. |
| 618 | 618 | if (($start <= $item["props"]["startdate"] && $end > $item['props']['startdate']) || |
| 619 | - ($start < $item["props"]["duedate"] && $end >= $item['props']['duedate']) || |
|
| 620 | - ($start > $item["props"]["startdate"] && $end < $item['props']['duedate'])) { |
|
| 619 | + ($start < $item["props"]["duedate"] && $end >= $item['props']['duedate']) || |
|
| 620 | + ($start > $item["props"]["startdate"] && $end < $item['props']['duedate'])) { |
|
| 621 | 621 | array_push($items, $item); |
| 622 | 622 | } |
| 623 | 623 | } |
@@ -569,7 +569,7 @@ |
||
| 569 | 569 | // for with free/busy permission only opened shared calenders, |
| 570 | 570 | // so do not remove them from the IPM_COMMON_VIEWS |
| 571 | 571 | if ((isset($row[PR_WLINK_SECTION]) && $row[PR_WLINK_SECTION] != wbsidCalendar) || |
| 572 | - !isset($row[PR_WLINK_SECTION])) { |
|
| 572 | + !isset($row[PR_WLINK_SECTION])) { |
|
| 573 | 573 | array_push($faultyLinkMsg, $row[PR_ENTRYID]); |
| 574 | 574 | } |
| 575 | 575 | |