public void updatePassword(String userName, Database db) throws ConstraintException, SystemException { SystemUser systemUser = getSystemUserWithName(userName, db); String newPassword = PasswordGenerator.generate(); String password = newPassword; if (CmsPropertyHandler.getUsePasswordEncryption()) { try { byte[] encryptedPassRaw = DigestUtils.sha(password); String encryptedPass = new String(new Base64().encode(encryptedPassRaw), "ASCII"); password = encryptedPass; } catch (Exception e) { System.out.println("Error generating password:"******"<div><h2>Password changed</h2></div>"); sb.append( "<div>CMS notification: You or an administrator have requested a new password for your account (" + userName + "). <br/>"); sb.append("<br/>"); sb.append("The new password is '" + newPassword + "'.<br/>"); sb.append("<br/>"); sb.append("Please notify the administrator if this does not work. <br/>"); sb.append("<br/>"); sb.append("-----------------------------------------------------------------------<br/>"); sb.append("This email was automatically generated and the sender is the CMS-system. <br/>"); sb.append("Do not reply to this email. </div>"); String systemEmailSender = CmsPropertyHandler.getSystemEmailSender(); if (systemEmailSender == null || systemEmailSender.equalsIgnoreCase("")) systemEmailSender = "InfoGlueCMS@" + CmsPropertyHandler.getMailSmtpHost(); try { MailServiceFactory.getService() .send( systemEmailSender, systemUser.getEmail(), null, "InfoGlue Information - Password changed!!", sb.toString()); } catch (Exception e) { logger.error( "The notification was not sent to [" + systemEmailSender + ", " + systemUser.getEmail() + "]. Reason:" + e.getMessage(), e); } }