Sfoglia il codice sorgente

debug authtoken call

andre 5 anni fa
parent
commit
78aab7ec22
1 ha cambiato i file con 32 aggiunte e 26 eliminazioni
  1. 32 26
      zimbraSingle.php

+ 32 - 26
zimbraSingle.php

@@ -194,7 +194,7 @@ function zimbraSingle_ClientArea($params) {
             __FUNCTION__,
             $params,
             'Error: could not gather informations for ' . $params['username'],
-            $accountInfo->getMessage()
+            $accountInfo
         );
         return false;
     }
@@ -243,7 +243,7 @@ function zimbraSingle_UsageUpdate($params) {
                 __FUNCTION__,
                 $params,
                 'Error : could not find quota for ' . $product['username'],
-                $accountQuota->getMessage()
+                $accountQuota
             );
             break;
         }
@@ -254,7 +254,7 @@ function zimbraSingle_UsageUpdate($params) {
                 __FUNCTION__,
                 $params,
                 'Error: could not fetch mailbox info for ' . $product['username'],
-                $mboxObj->getMessage()
+                $mboxObj
             );
             break;
         }
@@ -323,7 +323,7 @@ function zimbraSingle_ChangePassword($params) {
             __FUNCTION__,
             $params,
             'Error: password could not be set for ' . $params['username'],
-            $response->getMessage()
+            $response
         );
         return false;
     }
@@ -368,7 +368,7 @@ function zimbraSingle_CreateAccount($params) {
             __FUNCTION__,
             $params,
             'Error: could not verify ' . $params['username'],
-            $accountExists->getMessage()
+            $accountExists
         );
         return 'Error: could not verify '. $params['username'];
     }
@@ -399,7 +399,7 @@ function zimbraSingle_CreateAccount($params) {
             __FUNCTION__,
             $params,
             'Error: could not find serviceclass ' . $params['configoption1'],
-            $cosID->getMessage()
+            $cosID
         );
         return 'Error: could not find serviceclass ' . $params['configoption1'];
     }
@@ -411,7 +411,7 @@ function zimbraSingle_CreateAccount($params) {
             __FUNCTION__,
             $params,
             'Error: could not create account ' . $params['username'],
-            $zimbraID->getMessage()
+            $zimbraID
         );
         return 'Error: could not create account ' . $params['username'];
     }
@@ -471,7 +471,7 @@ function zimbraSingle_SuspendAccount($params) {
             __FUNCTION__,
             $params,
             'Error: could not lock account ' . $params['username'],
-            $response->getMessage()
+            $response
         );
         return false;
     }
@@ -512,7 +512,7 @@ function zimbraSingle_UnsuspendAccount($params) {
             __FUNCTION__,
             $params,
             'Error: could not unlock account ' . $params['username'],
-            $response->getMessage()
+            $response
             );
         return 'Error: could not unlock account ' . $params['username'];
     }
@@ -552,7 +552,7 @@ function zimbraSingle_TerminateAccount($params) {
             __FUNCTION__,
             $params,
             'Error: could not verify account '. $params['username'],
-            $accountStatus->getMessage()
+            $accountStatus
         );
         return 'Error : account ' . $params['username'] . ' Name could not verified';
     }
@@ -566,7 +566,7 @@ function zimbraSingle_TerminateAccount($params) {
             __FUNCTION__,
             $params,
             'Error: could not remove account '. $params['username'],
-            $response->getMessage()
+            $response
         );
         return 'Error: could not remove account '. $params['username'];
     }
@@ -610,7 +610,7 @@ function zimbraSingle_ChangePackage($params) {
             __FUNCTION__,
             $params,
             'Error: could not set class of service for '. $params['username'],
-            $response->getMessage()
+            $response
         );
         return 'Error: could not set class of service for '. $params['username'];
     }
@@ -621,7 +621,7 @@ function zimbraSingle_ChangePackage($params) {
             __FUNCTION__,
             $params,
             'Error : could not find quota for ' . $params['username'],
-            $accountQuota->getMessage()
+            $accountQuota
         );
     }
     try {
@@ -704,7 +704,7 @@ function zimbraSingle_ConfigOptions($params) {
             __FUNCTION__,
             $params,
             'Error: could not fetch classes of service',
-            $cosIDs->getMessage()
+            $cosIDs
         );
         return false;
     }
@@ -757,18 +757,24 @@ function zimbraSingle_ServiceSingleSignOn($params) {
         );
         return $domainOptions->getMessage();
     }
-    $preAuthKey = $domainOptions['zimbraPreAuthKey'];
-    $userAuth = new Zm_Auth($params['serverhostname'], $params['username'], $preAuthKey, 'user');
-    $authToken = $userAuth->login();
-    logModuleCall(
-        'zimbrasingle',
-        __FUNCTION__,
-        $params,
-        'Debug',
-        $authToken
-    );
+    $preAuthKey = $domainOptions['zimbraPreAuthKey'];    $apiAccountManager = new Zm_Account($api);
+    $accountInfo = $apiAccountManager->getAccountInfo($params['username']);
+    if(is_a($accountInfo, 'Exception')) {
+        logModuleCall(
+            'zimbrasingle',
+            __FUNCTION__,
+            $params,
+            'Error: could not gather informations for ' . $params['username'],
+            $accountInfo
+        );
+        return false;
+    }
+    $webmailUrl = zimbraSingleFindAll($accountInfo, 'PUBLICMAILURL');
+    $timestamp=time()*1000;
+    $preauthToken=hash_hmac("sha1",$username."|name|0|".$timestamp,$preAuthKey);
+    $preauthURL = $webmailUrl[0]['DATA']."?account=".$username."&by=name&timestamp=".$timestamp."&expires=0&preauth=".$preauthToken;
     return array(
         'success' => true,
-        'redirectTo' => 'https://testserver.test.local/' . $authToken,
+        'redirectTo' => $preauthURL,
     );
-}
+}