/**
  * Use the pulic key of the respective user to encrypt the given
  * email identity and store it in the data-base.
  * @param The OwnCloud user id $ocUser
  * @param The IMAP account Id $emailUser
  * @param unknown $emailPassword
  * @return The IMAP credentials.|unknown
  */
 public static function cryptEmailIdentity($ocUser, $emailUser, $emailPassword)
 {
     $mail_userdata_entries = OC_RoundCube_App::checkLoginData($ocUser);
     if ($mail_userdata_entries === false) {
         return false;
     }
     $mail_userdata = $mail_userdata_entries[0];
     $myID = $mail_userdata['id'];
     $pubKey = self::getPublicKey($ocUser);
     if ($pubKey === false) {
         return false;
     }
     $emailUser = OC_RoundCube_App::cryptMyEntry($emailUser, $pubKey);
     $emailPassword = OC_RoundCube_App::cryptMyEntry($emailPassword, $pubKey);
     if ($emailUser === false || $emailPassword === false) {
         return false;
     }
     $stmt = OCP\DB::prepare("UPDATE *PREFIX*roundcube SET mail_user = ?, mail_password = ? WHERE id = ?");
     $result = $stmt->execute(array($emailUser, $emailPassword, $myID));
     return $result;
 }
 /**
  * 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);
     }
 }
Exemple #3
0
* @author Martin Reinhardt and David Jaedke
* @copyright 2012 Martin Reinhardt contact@martinreinhardt-online.de
* 
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either 
* version 3 of the License, or any later version.
* 
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*  
* You should have received a copy of the GNU Lesser General Public 
* License along with this library.  If not, see <http://www.gnu.org/licenses/>.
* 
*/
if ($_POST) {
    $myID = OC_RoundCube_App::existLoginData(OCP\User::getUser());
    $mailuser = OC_RoundCube_App::cryptMyEntry($_POST['mailUsername']);
    $mailpass = OC_RoundCube_App::cryptMyEntry($_POST['mailPassword']);
    $stmt = OCP\DB::prepare("UPDATE *PREFIX*roundcube SET mailUser = '******', mailPass = '******' WHERE id = {$myID}");
    $result = $stmt->execute();
}
// fill template
$tmpl = new OCP\Template('roundcube', 'userSettings');
foreach ($params as $param) {
    $value = OCP\Config::getAppValue('roundcube', $param, '');
    $tmpl->assign($param, $value);
}
return $tmpl->fetchPage();