public IAppUser changePassword(IAppUser user, String newPassword) throws Exception { if(user == null) throw new Exception("Invalid user and/or password."); if(user.useExternalAuthentication()) { throw new ConfigurationException("Change password functionality not supported."); } else { DomainFactory factory = getDomainFactory(); AppUser domUser = (AppUser)factory.getDomainObject(AppUser.class, user.getUserId()); String currentEncodedPassord = domUser.getEncodedPassword(); domUser.setPassword(Configuration.getHash(newPassword)); domUser.setEncodedPassword(Configuration.encryptPasswordWithCloak(newPassword)); java.util.Date date = domUser.getPwdExpDate(); if (date != null) { Calendar cal = Calendar.getInstance(); cal.setTime(new java.util.Date()); cal.add(Calendar.DATE, ConfigFlag.GEN.PASSWD_EXP_INCREMENT.getValue()); domUser.setPwdExpDate(cal.getTime()); } // WDEV-8894 fix - the current encoded password might be null // and in this case we won't store it in the history if(currentEncodedPassord != null && currentEncodedPassord.trim().length() > 0) { List prev = domUser.getPreviousPasswords(); if(prev == null) prev = new ArrayList(); AppUserPasswordVo previousPassword = new AppUserPasswordVo(); previousPassword.setDateTime(new DateTime()); previousPassword.setEncodedPassword(currentEncodedPassord); prev.add(AppUserPasswordVoAssembler.extractAppUserPassword(factory, previousPassword)); domUser.setPreviousPasswords(prev); } factory.save(domUser); AppUserVo fulluser = AppUserVoAssembler.create(domUser); user = fulluser; user.setClearPassword(newPassword); return user; } }
@SuppressWarnings("unchecked") public IAppUser changePassword(IAppUser user, String newPassword) throws Exception { DomainFactory factory = getDomainFactory(); AppUser domUser = (AppUser)factory.getDomainObject(AppUser.class, user.getUserId()); String currentEncodedPassord = domUser.getEncodedPassword(); domUser.setPassword(Configuration.getHash(newPassword)); domUser.setEncodedPassword(Configuration.encryptPasswordWithCloak(newPassword)); java.util.Date date = domUser.getPwdExpDate(); if (date != null) { Calendar cal = Calendar.getInstance(); cal.setTime(new java.util.Date()); cal.add(Calendar.DATE, ConfigFlag.GEN.PASSWD_EXP_INCREMENT.getValue()); domUser.setPwdExpDate(cal.getTime()); } // WDEV-8894 fix - the current encoded password might be null // and in this case we won't store it in the history if(currentEncodedPassord != null && currentEncodedPassord.trim().length() > 0) { List prev = domUser.getPreviousPasswords(); if(prev == null) prev = new ArrayList(); AppUserPasswordVo previousPassword = new AppUserPasswordVo(); previousPassword.setDateTime(new DateTime()); previousPassword.setEncodedPassword(currentEncodedPassord); prev.add(AppUserPasswordVoAssembler.extractAppUserPassword(factory, previousPassword)); domUser.setPreviousPasswords(prev); } factory.save(domUser); AppUserVo fulluser = AppUserVoAssembler.create(domUser); user = fulluser; user.setClearPassword(newPassword); return user; }
@SuppressWarnings("unchecked") public IAppUser changePassword(IAppUser user, String newPassword) throws Exception { DomainFactory factory = getDomainFactory(); AppUser domUser = (AppUser)factory.getDomainObject(AppUser.class, user.getUserId()); java.util.Date date = domUser.getPwdExpDate(); if (date != null) { Calendar cal = Calendar.getInstance(); cal.setTime(new java.util.Date()); cal.add(Calendar.DATE, ConfigFlag.GEN.PASSWD_EXP_INCREMENT.getValue()); domUser.setPwdExpDate(cal.getTime()); } // WDEV-14264 May need to replicate to both HEARTS and MAXIMS if (ConfigFlag.DTO.USER_REPLICATION_SERVICE.getValue().equals("USER")) changeHeartPassword(user, newPassword); else if (ConfigFlag.DTO.USER_REPLICATION_SERVICE.getValue().equals("BOTH")) { changeHeartPassword(user, newPassword); changeMaximsPassword(user, newPassword, domUser.getPwdExpDate()); } else changeMaximsPassword(user, newPassword, domUser.getPwdExpDate()); String currentEncodedPassord = domUser.getEncodedPassword(); domUser.setPassword(Configuration.getHash(newPassword)); domUser.setEncodedPassword(Configuration.encryptPasswordWithCloak(newPassword)); List prev = domUser.getPreviousPasswords(); if(prev == null) prev = new ArrayList(); AppUserPasswordVo previousPassword = new AppUserPasswordVo(); previousPassword.setDateTime(new DateTime()); previousPassword.setEncodedPassword(currentEncodedPassord); //WDEV-9647 If encodedPassword is null, set it to // 'unknown' as not null value in password history if (!previousPassword.getEncodedPasswordIsNotNull()) previousPassword.setEncodedPassword("unknown"); prev.add(AppUserPasswordVoAssembler.extractAppUserPassword(factory, previousPassword)); domUser.setPreviousPasswords(prev); factory.save(domUser); AppUserVo fulluser = AppUserVoAssembler.create(domUser); user = fulluser; user.setClearPassword(newPassword); return user; }