Merge branch '2013.10' into 2014.11
[tine20] / tine20 / Tinebase / Auth.php
index 323ed1b..42439eb 100755 (executable)
@@ -80,7 +80,7 @@ class Tinebase_Auth
     const FAILURE_PASSWORD_EXPIRED      = -101;
     
     /**
-     * Failure due the account is temporarly blocked
+     * Failure due the account is temporarily blocked
      */
     const FAILURE_BLOCKED               = -102;
         
@@ -135,6 +135,7 @@ class Tinebase_Auth
             'accountCanonicalForm' => '2',
             'accountDomainName' => '',
             'accountDomainNameShort' => '',
+            'tryUsernameSplit' => '0'
          ),
          self::IMAP => array(
             'host'      => '',
@@ -206,10 +207,19 @@ class Tinebase_Auth
         if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(
             __METHOD__ . '::' . __LINE__ . ' Trying to authenticate '. $_username);
         
-        $this->_backend->setIdentity($_username);
+        try {
+            $this->_backend->setIdentity($_username);
+        } catch (Zend_Auth_Adapter_Exception $zaae) {
+            return new Zend_Auth_Result(
+                Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID,
+                $_username,
+                array($zaae->getMessage())
+            );
+        }
+        
         $this->_backend->setCredential($_password);
         
-        if (Zend_Session::isStarted()) {
+        if (Tinebase_Session::isStarted()) {
             Zend_Auth::getInstance()->setStorage(new Zend_Auth_Storage_Session());
         } else {
             Zend_Auth::getInstance()->setStorage(new Zend_Auth_Storage_NonPersistent());
@@ -362,8 +372,12 @@ class Tinebase_Auth
                 $rawBackendConfiguration = array();
             }
             self::$_backendConfiguration = is_array($rawBackendConfiguration) ? $rawBackendConfiguration : Zend_Json::decode($rawBackendConfiguration);
+            
+            if (!empty(self::$_backendConfiguration['password'])) {
+                Tinebase_Core::getLogger()->getFormatter()->addReplacement(self::$_backendConfiguration['password']);
+            }
         }
-
+        
         if (isset($_key)) {
             return (isset(self::$_backendConfiguration[$_key]) || array_key_exists($_key, self::$_backendConfiguration)) ? self::$_backendConfiguration[$_key] : $_default;
         } else {