public function testCrypt() { // setup $testOcUser = '******'; $testRcUser = '******'; // reset OCP\Config::$USERVALUES = array(); $result = OC_RoundCube_App::generateKeyPair($testOcUser, 'Passw0rd!'); $privateKey = OC_RoundCube_App::getPrivateKey($testOcUser, 'Passw0rd!'); $this->assertNotNull($privateKey, 'Private key should not be empty.'); $encryptedMailData = OC_RoundCube_App::cryptEmailIdentity($testOcUser, $testRcUser, 'Passw0rd!', false); $mail_user = OC_RoundCube_App::decryptMyEntry($encryptedMailData['mail_user'], $privateKey); $mail_pass = OC_RoundCube_App::decryptMyEntry($encryptedMailData['mail_password'], $privateKey); $this->assertEquals($mail_user, $testRcUser); $this->assertEquals($mail_pass, 'Passw0rd!'); }
echo $cfgClass; ?> " id="roundcube"> <h2> <?php p($l->t('RoundCube Mailaccount')); ?> </h2> <?php $enable_auto_login = OCP\Config::getAppValue('roundcube', 'autoLogin', false); if (!$enable_auto_login) { $username = OCP\User::getUser(); $privKey = OC_RoundCube_App::getPrivateKey($username, false); foreach ($mail_userdata_entries as $mail_userdata) { $mail_username = OC_RoundCube_App::decryptMyEntry($mail_userdata['mail_user'], $privKey); $mail_password = OC_RoundCube_App::decryptMyEntry($mail_userdata['mail_password'], $privKey); // TODO use template and add button for adding entries ?> <input type="text" id="rc_mail_username" name="rc_mail_username" value="<?php echo $mail_username; ?> " placeholder="<?php p($l->t('Email Login Name')); ?> " /> <input type="password" id="rc_mail_password" name="rc_mail_password" placeholder="<?php p($l->t('Email Password')); ?> " data-typetoggle="rc_mail_password_show" />
/** * 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); } }
* 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); } }
$rc_port = OCP\Config::getAppValue('roundcube', 'rcPort', null); OCP\Util::writeLog('roundcube', 'Opening iframe for RC-host ' . $rc_host . ' with port ' . $rc_port, OCP\Util::DEBUG); OCP\Util::writeLog('roundcube', 'Preparing pre-check before rendering mail view ', OCP\Util::INFO); if ($mail_userdata['id'] != '') { if ($mail_userdata['oc_user'] == OCP\User::getUser()) { OCP\Util::writeLog('roundcube', 'Used mail_username: '******'' || $mail_password == '')) { OCP\Util::writeLog('roundcube', 'No valid user login data found.', OCP\Util::ERROR); $html_output = $html_output . $this->inc("part.error.no-settings"); } else { // with autologin oc user = rc user if ($enable_autologin) { $mail_username = $ocUser; } else { $emailUserCrypted = $_SESSION[OC_RoundCube_App::SESSION_ATTR_RCLOGIN]; $mail_username = OC_RoundCube_App::decryptMyEntry($emailUserCrypted, $privKey); } $maildir = OCP\Config::getAppValue('roundcube', 'maildir', ''); if ($maildir != '') { $mailAppReturn = OC_RoundCube_App::showMailFrame($rc_host, $rc_port, $maildir); if ($mailAppReturn->isErrorOccurred()) { OCP\Util::writeLog('roundcube', 'Not rendering roundcube iframe view due to errors', OCP\Util::ERROR); OCP\Util::writeLog('roundcube', 'Got the following error code: ' . $mailAppReturn->getErrorCode(), OCP\Util::ERROR); switch ($mailAppReturn->getErrorCode()) { case OC_Mail_Object::ERROR_CODE_NETWORK: $html_output = $this->inc("part.error.error-settings"); $html_output = $html_output . $mailAppReturn->getErrorDetails(); break; case OC_Mail_Object::ERROR_CODE_LOGIN: $html_output = $this->inc("part.error.wrong-auth"); $html_output = $html_output . $mailAppReturn->getErrorDetails();