}
public void updatePassword(String userName, String oldPassword, String newPassword, Database db) throws ConstraintException, SystemException, Exception
{
if(newPassword == null)
throw new ConstraintException("SystemUser.newPassword", "301");
if(CmsPropertyHandler.getUsePasswordEncryption())
{
try
{
byte[] encryptedPassRaw = DigestUtils.sha(newPassword);
String encryptedPass = new String(Base64.encodeBase64(encryptedPassRaw), "ASCII");
newPassword = encryptedPass;
byte[] encryptedOldPasswordRaw = DigestUtils.sha(oldPassword);
String encryptedOldPass = new String(Base64.encodeBase64(encryptedOldPasswordRaw), "ASCII");
oldPassword = encryptedOldPass;
}
catch (Exception e)
{
logger.error("Error generating password:" + e.getMessage());
}
}
SystemUser systemUser = getSystemUser(db, userName, oldPassword);
if(systemUser == null)
throw new ConstraintException("SystemUser.oldPassword", "310");
systemUser.setPassword(newPassword);
}