/**
  * @preserveGlobalState disabled
  */
 public function testConnectionError()
 {
     try {
         $rcLogin = new OC_RoundCube_Login('127.0.0.1', '49080', 'roundcube/', true, true, true);
         $rcLogin->login("*****@*****.**", "42");
     } catch (Exception $e) {
         print $e;
     }
 }
Exemplo n.º 2
0
 public function testConnectionError()
 {
     $rcLogin = new OC_RoundCube_Login('localhost', '443', 'mail');
     try {
         $rcLogin->login("user", "password");
     } catch (OC_Mail_NetworkingException $expected) {
         return;
     }
     $this->fail('An expected exception has not been raised.');
 }
 public function testConnectionError()
 {
     $rcLogin = new OC_RoundCube_Login('localhost', '4443', 'mail');
     try {
         $rcLogin->login("user", "password");
         $this->assertFalse($rcLogin->isLoggedIn(), 'Should not be logged in', true, true, true);
     } catch (OC_Mail_NetworkingException $expected) {
         return;
     }
     $this->fail('An expected exception has not been raised.');
 }
Exemplo n.º 4
0
 /**
  * Try to refresh roundcube session
  *
  * @param
  *            roundcube host to use $rcHost
  * @param
  *            port of the roundcube server $rcPort
  * @param
  *            context path of roundcube $maildir
  * @return true if session refresh was successfull, otherwise false
  */
 public static function refresh($rcHost, $rcPort, $maildir)
 {
     $ocUser = OCP\User::getUser();
     // Create RC login object.
     $enableDebug = OCP\Config::getAppValue('roundcube', 'enableDebug', 'false');
     $disableSSLverify = OCP\Config::getAppValue('roundcube', 'noSSLverify', 'false');
     $rcl = new OC_RoundCube_Login($rcHost, $rcPort, $maildir, $disableSSLverify, $enableDebug, false);
     // reuse session ID
     $sessId = self::getSessionVariable(self::SESSION_ATTR_RCSESSID);
     if ($sessId !== false) {
         $rcl->setSessionID($sessId);
     }
     $sessAuth = self::getSessionVariable(self::SESSION_ATTR_RCSESSAUTH);
     if ($sessAuth !== false) {
         $rcl->setSessionAuth($sessAuth);
     }
     // Try to refresh
     OCP\Util::writeLog('roundcube', 'OC_RoundCube_App.class.php->refresh(): Trying to refresh RoundCube session under ' . $maildir, OCP\Util::DEBUG);
     if ($rcl->isLoggedIn()) {
         OCP\Util::writeLog('roundcube', 'OC_RoundCube_App.class.php->refresh(): Successfully refreshed the RC session.', OCP\Util::INFO);
         self::setSessionVariable(self::SESSION_ATTR_RCSESSAUTH, $rcl->getSessionAuth());
         return true;
     } else {
         // login errors, let's try once again
         if ($rcl->isLoggedIn()) {
             OCP\Util::writeLog('roundcube', 'OC_RoundCube_App.class.php->refresh(): Trying again to refresh RoundCube session under ' . $maildir, OCP\Util::DEBUG);
             self::setSessionVariable(self::SESSION_ATTR_RCSESSAUTH, $rcl->getSessionAuth());
             return true;
         } else {
             // TODO add new exception here for relogin
             OCP\Util::writeLog('roundcube', 'OC_RoundCube_App.class.php->refresh(): Failed to refresh the RC session.', OCP\Util::INFO);
             return false;
         }
     }
 }
Exemplo n.º 5
0
 /**
  *
  * @brief showing up roundcube iFrame
  * @param roundcube host $rcHost
  * @param roundcube port $rcPort
  * @param path to roundcube installation, Note: The first parameter is the URL-path of the RC inst
  * NOT the file-system path http://host.com/path/to/roundcube/ --> "/path/to/roundcube" $maildir
  *
  */
 public static function showMailFrame($rcHost, $rcPort, $maildir)
 {
     $returnObject = new OC_Mail_Object();
     $enableDebug = OCP\Config::getAppValue('roundcube', 'enableDebug', true);
     $enableAutologin = OCP\Config::getAppValue('roundcube', 'autoLogin', false);
     // Create RC login object.
     $rcl = new OC_RoundCube_Login($rcHost, $rcPort, $maildir, $enableDebug);
     try {
         if (!$rcl->isLoggedIn()) {
             // If the login fails, display an error message in the loggs
             OCP\Util::writeLog('roundcube', 'OC_RoundCube_App.class.php->showMailFrame(): Not logged in.', OCP\Util::ERROR);
             OCP\Util::writeLog('roundcube', 'OC_RoundCube_App.class.php->showMailFrame(): Trying to refresh session.', OCP\Util::INFO);
             if (!OC_RoundCube_App::refresh($rcHost, $rcPort, $maildir)) {
                 throw new OC_Mail_LoginException("Unable to login to roundcube");
             }
         }
         OCP\Util::writeLog('roundcube', 'OC_RoundCube_App.class.php->showMailFrame(): Preparing iFrame for roundcube:' . $rcl->getRedirectPath(), OCP\Util::DEBUG);
         // loader image
         $loader_image = OCP\Util::imagePath('roundcube', 'loader.gif');
         $disable_header_nav = OCP\Config::getAppValue('roundcube', 'removeHeaderNav', 'false');
         $disable_control_nav = OCP\Config::getAppValue('roundcube', 'removeControlNav', 'false');
         // create iFrame begin
         $returnObject->appendHtmlOutput('<img src="' . $loader_image . '" id="roundcubeLoader">');
         $returnObject->appendHtmlOutput('<iframe src="' . $rcl->getRedirectPath() . '" id="roundcubeFrame"  name="roundcube" width="100%" style="display:none;">  </iframe>');
         $returnObject->appendHtmlOutput('<input type="hidden" id="disable_header_nav" value="' . $disable_header_nav . '"/>');
         $returnObject->appendHtmlOutput('<input type="hidden" id="disable_control_nav" value="' . $disable_control_nav . '"/>');
         // create iFrame end
     } catch (OC_Mail_NetworkingException $ex_net) {
         $returnObject->setErrorOccurred(true);
         $returnObject->setErrorCode(OC_Mail_Object::ERROR_CODE_NETWORK);
         $returnObject->setHtmlOutput('');
         $returnObject->setErrorDetails("ERROR: Technical problem during trying to connect to roundcube server, " . $ex_net->getMessage());
         OCP\Util::writeLog('roundcube', 'OC_RoundCube_App.class.php->showMailFrame(): RoundCube can\'t login to roundcube due to a network connection exception to roundcube', OCP\Util::ERROR);
     } catch (OC_Mail_LoginException $ex_login) {
         $returnObject->setErrorOccurred(true);
         if ($enableAutologin) {
             OCP\Util::writeLog('roundcube', 'OC_RoundCube_App.class.php->showMailFrame(): Autologin is enabled. Seems that the owncloud and roundcube login details do not match', OCP\Util::ERROR);
             $returnObject->setErrorCode(OC_Mail_Object::ERROR_CODE_AUTOLOGIN);
         } else {
             $returnObject->setErrorCode(OC_Mail_Object::ERROR_CODE_LOGIN);
         }
         $returnObject->setHtmlOutput('');
         $returnObject->setErrorDetails("ERROR: Technical problem, " . $ex_login->getMessage());
         OCP\Util::writeLog('roundcube', 'OC_RoundCube_App.class.php->showMailFrame(): RoundCube can\'t login to roundcube due to a login exception to roundcube', OCP\Util::ERROR);
     } catch (OC_Mail_RC_InstallNotFoundException $ex_login) {
         $returnObject->setErrorOccurred(true);
         $returnObject->setErrorCode(OC_Mail_Object::ERROR_CODE_RC_NOT_FOUND);
         $returnObject->setHtmlOutput('');
         $returnObject->setErrorDetails("ERROR: Technical problem, " . $ex_login->getMessage());
         OCP\Util::writeLog('roundcube', 'OC_RoundCube_App.class.php->showMailFrame(): RoundCube can\'t be found on the given path.', OCP\Util::ERROR);
     } catch (Exception $ex_login) {
         $returnObject->setErrorOccurred(true);
         $returnObject->setErrorCode(OC_Mail_Object::ERROR_CODE_GENERAL);
         $returnObject->setHtmlOutput('');
         $returnObject->setErrorDetails("ERROR: Technical problem, " . $ex_login->getMessage());
         OCP\Util::writeLog('roundcube', 'OC_RoundCube_App.class.php->showMailFrame(): RoundCube can\'t login to roundcube due to a unkown exception to roundcube', OCP\Util::ERROR);
     }
     return $returnObject;
 }
	/**
	 * Try to refresh roundcube session
	 * @param roundcube host to use $rcHost
	 * @param port of the roundcube server $rcPort
	 * @param context path of roundcube $maildir
	 * @return true if session refresh was successfull, otherwise false
	 */
	public static function refresh($rcHost, $rcPort, $maildir){
		$ocUser = OCP\User::getUser();
		// Create RC login object.
		$enableDebug = OCP\Config::getAppValue('roundcube', 'enableDebug', 'true');
		$rcl = new OC_RoundCube_Login($rcHost, $rcPort, $maildir, $enableDebug);
		// Try to refresh
		OCP\Util::writeLog('roundcube', 'OC_RoundCube_App.class.php->refresh(): Trying to refresh RoundCube session under ' . $maildir, OCP\Util::DEBUG);
		if ($rcl -> isLoggedIn()) {
			OCP\Util::writeLog('roundcube', 'OC_RoundCube_App.class.php->refresh(): Successfully refreshed the RC session.', OCP\Util::INFO);
			return true;
		} else {
			// login expired, we are
			// TODO add new exception here for relogin
			OCP\Util::writeLog('roundcube', 'OC_RoundCube_App.class.php->refresh(): Failed to refresh the RC session.', OCP\Util::ERROR);
			return false;
		}
	}