/**
  * get anonymous registry
  * 
  * @return array
  */
 protected function _getAnonymousRegistryData()
 {
     $locale = Tinebase_Core::get('locale');
     $tbFrontendHttp = new Tinebase_Frontend_Http();
     // default credentials
     if (isset(Tinebase_Core::getConfig()->login)) {
         $loginConfig = Tinebase_Core::getConfig()->login;
         $defaultUsername = isset($loginConfig->username) ? $loginConfig->username : '';
         $defaultPassword = isset($loginConfig->password) ? $loginConfig->password : '';
     } else {
         $defaultUsername = '';
         $defaultPassword = '';
     }
     $symbols = Zend_Locale::getTranslationList('symbols', $locale);
     $registryData = array('modSsl' => Tinebase_Auth::getConfiguredBackend() == Tinebase_Auth::MODSSL, 'serviceMap' => $tbFrontendHttp->getServiceMap(), 'locale' => array('locale' => $locale->toString(), 'language' => Zend_Locale::getTranslation($locale->getLanguage(), 'language', $locale), 'region' => Zend_Locale::getTranslation($locale->getRegion(), 'country', $locale)), 'version' => array('buildType' => TINE20_BUILDTYPE, 'codeName' => TINE20_CODENAME, 'packageString' => TINE20_PACKAGESTRING, 'releaseTime' => TINE20_RELEASETIME, 'filesHash' => TINE20_BUILDTYPE != 'DEVELOPMENT' ? $tbFrontendHttp->getJsCssHash() : null), 'defaultUsername' => $defaultUsername, 'defaultPassword' => $defaultPassword, 'denySurveys' => Tinebase_Core::getConfig()->denySurveys, 'titlePostfix' => Tinebase_Config::getInstance()->get(Tinebase_Config::PAGETITLEPOSTFIX), 'redirectUrl' => Tinebase_Config::getInstance()->get(Tinebase_Config::REDIRECTURL), 'helpUrl' => Tinebase_Core::getConfig()->helpUrl, 'maxFileUploadSize' => Tinebase_Helper::convertToBytes(ini_get('upload_max_filesize')), 'maxPostSize' => Tinebase_Helper::convertToBytes(ini_get('post_max_size')), 'thousandSeparator' => $symbols['group'], 'decimalSeparator' => $symbols['decimal'], 'filesystemAvailable' => Tinebase_Core::isFilesystemAvailable());
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' Anonymous registry: ' . print_r($registryData, TRUE));
     }
     return $registryData;
 }
 /**
  * test imap authentication
  */
 public function testImapAuth()
 {
     // use imap config for the auth config
     $imapConfig = Tinebase_Config::getInstance()->get(Tinebase_Config::IMAP, new Tinebase_Config_Struct())->toArray();
     if (empty($imapConfig)) {
         $this->markTestSkipped('No IMAP config found.');
     }
     $authConfig = array('host' => $imapConfig['host'], 'port' => $imapConfig['port'], 'ssl' => $imapConfig['ssl'], 'domain' => $imapConfig['domain']);
     Tinebase_Auth::setBackendType(Tinebase_Auth::IMAP);
     Tinebase_Auth::setBackendConfiguration($authConfig);
     Tinebase_Auth::saveBackendConfiguration();
     Tinebase_Auth::getInstance()->setBackend();
     $this->assertEquals(Tinebase_Auth::IMAP, Tinebase_Auth::getConfiguredBackend());
     $testCredentials = TestServer::getInstance()->getTestCredentials();
     // valid authentication
     $authResult = Tinebase_Auth::getInstance()->authenticate($testCredentials['username'], $testCredentials['password']);
     $this->assertTrue($authResult->isValid());
     // invalid authentication
     $authResult = Tinebase_Auth::getInstance()->authenticate($testCredentials['username'], 'some pw');
     $this->assertFalse($authResult->isValid());
     $this->assertEquals(Tinebase_Auth::FAILURE_CREDENTIAL_INVALID, $authResult->getCode());
     $this->assertEquals(array('Invalid credentials for user ' . $this->_getEmailAddress(), ''), $authResult->getMessages());
 }
 /**
  * returns TRUE if user has to change his/her password (compare sambaSAM->pwdMustChange with Tinebase_DateTime::now())
  *
  * TODO switch check AUTH backend?
  *
  * @return boolean
  */
 public function mustChangePassword()
 {
     switch (Tinebase_User::getConfiguredBackend()) {
         case Tinebase_User::ACTIVEDIRECTORY:
             return $this->_sambaSamPasswordChangeNeeded();
             break;
         case Tinebase_User::LDAP:
             return $this->_sambaSamPasswordChangeNeeded();
             break;
         default:
             if (Tinebase_Auth::getConfiguredBackend() === Tinebase_Auth::SQL) {
                 return $this->_sqlPasswordChangeNeeded();
             } else {
                 // no pw change needed for non-sql auth backends
                 return false;
             }
             break;
     }
 }
 /**
  *
  * get auth provider data
  *
  * @return array
  *
  * @todo get this from config table instead of file!
  */
 protected function _getAuthProviderData()
 {
     $result = Tinebase_Auth::getBackendConfigurationWithDefaults(Setup_Core::get(Setup_Core::CHECKDB));
     $result['backend'] = Setup_Core::get(Setup_Core::CHECKDB) ? Tinebase_Auth::getConfiguredBackend() : Tinebase_Auth::SQL;
     return $result;
 }
예제 #5
0
 /**
  * test imap authentication
  */
 public function testImapAuth()
 {
     // use imap config for the auth config
     $imapConfig = Tinebase_Config::getInstance()->getConfigAsArray(Tinebase_Config::IMAP);
     if (empty($imapConfig)) {
         $this->markTestSkipped('No IMAP config found.');
     }
     $authConfig = array('host' => $imapConfig['host'], 'port' => $imapConfig['port'], 'ssl' => $imapConfig['ssl'], 'domain' => $imapConfig['domain']);
     Tinebase_Auth::setBackendType(Tinebase_Auth::IMAP);
     Tinebase_Auth::setBackendConfiguration($authConfig);
     Tinebase_Auth::saveBackendConfiguration();
     Tinebase_Auth::getInstance()->setBackend();
     $this->assertEquals(Tinebase_Auth::IMAP, Tinebase_Auth::getConfiguredBackend());
     $testConfig = Zend_Registry::get('testConfig');
     // valid authentication
     $authResult = Tinebase_Auth::getInstance()->authenticate($testConfig->username, $testConfig->password);
     $this->assertTrue($authResult->isValid());
     // invalid authentication
     $authResult = Tinebase_Auth::getInstance()->authenticate($testConfig->username, 'some pw');
     $this->assertFalse($authResult->isValid());
     $this->assertEquals(Tinebase_Auth::FAILURE_CREDENTIAL_INVALID, $authResult->getCode());
     if ($testConfig->email) {
         $this->assertEquals(array('Invalid credentials for user ' . $testConfig->email, ''), $authResult->getMessages());
     }
 }