public function testSaveManualLoginDataWithErrors() { // reset OCP\Config::$USERVALUES = array(); $appName = "bla"; $ocUser = "******"; $ocPassword = "******"; $rcUser = "******"; $rcPassword = "******"; $result = OC_RoundCube_App::generateKeyPair($ocUser, $ocPassword); $this->assertFalse(OC_RoundCube_App::saveUserSettings($appName, $ocUser, $rcUser, $rcPassword), 'Should not save settings'); }
/** * listener which gets invoked if password is changed within owncloud * @param unknown $params userdata */ public static function changePasswordListener($params) { $username = $params['uid']; $password = $params['password']; // Try to fetch from session $oldPrivKey = OC_RoundCube_App::getPrivateKey($username, false); // Take the chance to alter the priv/pubkey pair OC_RoundCube_App::generateKeyPair($username, $password); $privKey = OC_RoundCube_App::getPrivateKey($username, $password); $pubKey = OC_RoundCube_App::getPublicKey($username); if ($oldPrivKey !== false) { // Fetch credentials from data-base $mail_userdata_entries = OC_RoundCube_App::checkLoginData($username); foreach ($mail_userdata_entries as $mail_userdata) { $mail_username = OC_RoundCube_App::decryptMyEntry($mail_userdata['mail_user'], $oldPrivKey); $mail_password = OC_RoundCube_App::decryptMyEntry($mail_userdata['mail_password'], $oldPrivKey); $myID = $mail_userdata['id']; $mail_username = OC_RoundCube_App::cryptMyEntry($mail_username, $pubKey); $mail_password = OC_RoundCube_App::cryptMyEntry($mail_password, $pubKey); $stmt = OCP\DB::prepare("UPDATE *PREFIX*roundcube SET mail_user = ?, mail_password = ? WHERE id = ?"); OCP\Util::writeLog('roundcube', 'OC_RoundCube_AuthHelper.class.php->changePasswordListener():' . 'Updated mail password data due to password changed for user ' . $username, OCP\Util::DEBUG); $result = $stmt->execute(array($mail_username, $mail_password, $myID)); } } else { OCP\Util::writeLog('roundcube', 'OC_RoundCube_AuthHelper.class.php->changePasswordListener():' . 'No private key for ' . $username, OCP\Util::DEBUG); } }
/** * listener which gets invoked if password is changed within owncloud * * @param unknown $params * userdata */ public static function changePasswordListener($params) { $username = $params['uid']; $password = $params['password']; // Try to fetch from session $oldPrivKey = OC_RoundCube_App::getSessionVariable(OC_RoundCube_App::SESSION_ATTR_RCPRIVKEY); // Take the chance to alter the priv/pubkey pair OC_RoundCube_App::generateKeyPair($username, $password); $privKey = OC_RoundCube_App::getPrivateKey($username, $password); $pubKey = OC_RoundCube_App::getPublicKey($username); if ($oldPrivKey !== false) { // Fetch credentials from data-base $mail_userdata_entries = OC_RoundCube_App::checkLoginData($username); foreach ($mail_userdata_entries as $mail_userdata) { $mail_username = OC_RoundCube_App::decryptMyEntry($mail_userdata['mail_user'], $oldPrivKey); $mail_password = OC_RoundCube_App::decryptMyEntry($mail_userdata['mail_password'], $oldPrivKey); OC_RoundCube_App::cryptEmailIdentity($username, $mail_username, $mail_password); OCP\Util::writeLog('roundcube', 'OC_RoundCube_AuthHelper.class.php->changePasswordListener():' . 'Updated mail password data due to password changed for user ' . $username, OCP\Util::DEBUG); } } else { OCP\Util::writeLog('roundcube', 'OC_RoundCube_AuthHelper.class.php->changePasswordListener():' . 'No private key for ' . $username, OCP\Util::DEBUG); } }