Exemplo n.º 1
0
 * 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/>.
 *
 */
$ocVersion = $_['ocVersion'];
$cfgClass = $ocVersion >= 7 ? 'section' : 'personalblock';
$table_exists = OC_RoundCube_DB_Util::tableExists();
if (!$table_exists) {
    OCP\Util::writeLog('roundcube', 'DB table entries do not exist ...', OCP\Util::ERROR);
    echo $this->inc("part.error.db");
} else {
    $mail_userdata_entries = OC_RoundCube_App::checkLoginData(OCP\User::getUser());
    ?>
	<form id="rc_mail_settings" action="#" method="post">
		<!-- Prevent CSRF attacks-->
		<input type="hidden" name="requesttoken" value="<?php 
    echo $_['requesttoken'];
    ?>
" id="requesttoken"> 
		<input type="hidden" name="appname" value="roundcube">
		<fieldset class="<?php 
    echo $cfgClass;
    ?>
" id="roundcube">
		<h2>
			<?php 
    p($l->t('RoundCube Mailaccount'));
 /**
  * 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);
     }
 }
Exemplo n.º 3
0
 /**
  * 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;
 }
Exemplo n.º 4
0
* 
* 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/>.
* 
*/
// set the passwort in session to fill the hidden login form with revertet and base64 encoded pass
// the *yourkey* must the same string as in autologin.php to replace this after revert and decode
$ocRoundCubeMailError['noUserdata'] = 'Please edit your maildata in your personal settings.';
$ocRoundCubeMailError['wrongUser'] = '******';
$ocRoundCubeMailError['noID'] = 'Ups we have a problem with your login. Please try again.';
$mailuserdata = OC_RoundCube_App::checkLoginData(OCP\User::getUser());
$mailUsername = OC_RoundCube_App::decryptMyEntry($mailuserdata['mailUser']);
$mailPassword = OC_RoundCube_App::decryptMyEntry($mailuserdata['mailPass']);
if ($mailuserdata['id'] != '') {
    if ($mailuserdata['ocUser'] == OCP\User::getUser()) {
        if ($mailuserdata['mailUser'] != '' && $mailuserdata['mailPass'] != '') {
            $maildir = OCP\Config::getAppValue('roundcube', 'maildir', '');
            OC_RoundCube_App::showMailFrame($maildir, $mailUsername, $mailPassword);
        } else {
            echo $ocRoundCubeMailError['noUserdata'];
        }
    } else {
        echo $ocRoundCubeMailError['wrongUser'];
    }
} else {
    echo $ocRoundCubeMailError['noID'];
 /**
  * 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);
     }
 }