Package org.olat.registration

Examples of org.olat.registration.TemporaryKey


    mailMap.put("changedEMail", changedEmail);
   
    XStream xml = new XStream();
    String serMailMap = xml.toXML(mailMap);
   
    TemporaryKey tk = loadCleanTemporaryKey(serMailMap);       
    if (tk == null) {
      tk = rm.createTemporaryKeyByEmail(serMailMap, ip, RegistrationManager.EMAIL_CHANGE);
    } else {
      rm.deleteTemporaryKeyWithId(tk.getRegistrationKey());
      tk = rm.createTemporaryKeyByEmail(serMailMap, ip, RegistrationManager.EMAIL_CHANGE);
    }
   
    // create date, time string
    Calendar cal = Calendar.getInstance();
    cal.setTime(tk.getCreationDate());
    cal.add(Calendar.DAY_OF_WEEK, ChangeEMailController.TIME_OUT);
    String time = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, ureq.getLocale()).format(cal.getTime());
    // create body and subject for email
    body = this.translator.translate("email.change.body", new String[] { serverpath + "/dmz/emchange/index.html?key=" + tk.getRegistrationKey() + "&lang=" + ureq.getLocale().getLanguage(), time })
        + SEPARATOR + this.translator.translate("email.change.wherefrom", new String[] { serverpath, today, ip });
    subject = translate("email.change.subject");
    // send email
    try {
      boolean isMailSent = mailer.sendEmail(changedEmail, subject, body);
      if (isMailSent) {
        tk.setMailSent(true);
        // set key
        User user = this.identityToModify.getUser();
        user.setProperty("emchangeKey", tk.getRegistrationKey());
        UserManager.getInstance().updateUser(user);
        getWindowControl().setInfo(this.translator.translate("email.sent"));
      } else {
        tk.setMailSent(false);
        rm.deleteTemporaryKeyWithId(tk.getRegistrationKey());
        getWindowControl().setError(this.translator.translate("email.notsent"));
      }
    } catch (AddressException e) {
      rm.deleteTemporaryKeyWithId(tk.getRegistrationKey());
      getWindowControl().setError(this.translator.translate("email.notsent"));
    } catch (SendFailedException e) {
      rm.deleteTemporaryKeyWithId(tk.getRegistrationKey());
      getWindowControl().setError(this.translator.translate("email.notsent"));
    } catch (MessagingException e) {
      rm.deleteTemporaryKeyWithId(tk.getRegistrationKey());
      getWindowControl().setError(this.translator.translate("email.notsent"));
    }
  }
View Full Code Here


   * Load and clean temporary keys with action "EMAIL_CHANGE".
   * @param serMailMap
   * @return
   */
  private TemporaryKey loadCleanTemporaryKey(String serMailMap) {
    TemporaryKey tk = rm.loadTemporaryKeyByEmail(serMailMap);
    if (tk == null) {
      XStream xml = new XStream();
      HashMap<String, String> mails = (HashMap<String, String>) xml.fromXML(serMailMap);
      String currentEMail = mails.get("currentEMail");
      List<TemporaryKey> tks = rm.loadTemporaryKeyByAction(RegistrationManager.EMAIL_CHANGE);
View Full Code Here

TOP

Related Classes of org.olat.registration.TemporaryKey

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.