@Test(expected = AcmUserActionFailedException.class) public void changeUserPasswordFailed() throws AcmLdapActionFailedException, AcmUserActionFailedException { String currentPassword = "password"; String newPassword = "newPassword"; LdapTemplate mockTemplate = createMock(LdapTemplate.class); expect(mockLdapDao.buildLdapTemplate(mockLdapAuthenticateConfig, mockUser.getDistinguishedName(), currentPassword)) .andReturn(mockTemplate); expect(mockUserDao.findByUserId("ann-acm")).andReturn(mockUser); mockLdapUserDao.changeUserPassword(mockUser.getDistinguishedName(), currentPassword, newPassword, mockTemplate, mockLdapAuthenticateConfig); expectLastCall().andThrow(new AcmLdapActionFailedException("error")); replayAll(); unit.changeUserPassword("ann-acm", currentPassword, newPassword); verifyAll(); }
public void changeUserPassword(String userName, String currentPassword, String newPassword) throws AcmUserActionFailedException { log.debug("Changing password for user:{}", userName); AcmUser acmUser = userDao.findByUserId(userName); LdapTemplate ldapTemplate = ldapDao.buildLdapTemplate(ldapAuthenticateConfig, acmUser.getDistinguishedName(), currentPassword); try { ldapUserDao.changeUserPassword(acmUser.getDistinguishedName(), currentPassword, newPassword, ldapTemplate, ldapAuthenticateConfig); log.debug("Password changed successfully for User: {}", userName); } catch (AcmLdapActionFailedException e) { throw new AcmUserActionFailedException("change password", "USER", null, "Change password action failed!", null); } try { ldapTemplate = ldapDao.buildLdapTemplate(ldapAuthenticateConfig, acmUser.getDistinguishedName(), newPassword); savePasswordExpirationDate(acmUser, ldapTemplate); } catch (Exception e) { log.warn("Password expiration date was not set for user [{}]", acmUser.getUserId(), e); } }
LdapAuthenticateService { public void changeUserPassword(String userName, String currentPassword, String newPassword) throws AcmUserActionFailedException { log.debug("Changing password for user:{}", userName); AcmUser acmUser = userDao.findByUserId(userName); LdapTemplate ldapTemplate = ldapDao.buildLdapTemplate(ldapAuthenticateConfig, acmUser.getDistinguishedName(), currentPassword); try { ldapUserDao.changeUserPassword(acmUser.getDistinguishedName(), currentPassword, newPassword, ldapTemplate, ldapAuthenticateConfig); log.debug("Password changed successfully for User: {}", userName); } catch (AcmLdapActionFailedException e) { throw new AcmUserActionFailedException("change password", "USER", null, "Change password action failed!", null); } try { ldapTemplate = ldapDao.buildLdapTemplate(ldapAuthenticateConfig, acmUser.getDistinguishedName(), newPassword); savePasswordExpirationDate(acmUser, ldapTemplate); } catch (Exception e) { log.warn("Password expiration date was not set for user [{}]", acmUser.getUserId(), e); } } }
LdapAuthenticateService { public void changeUserPassword(String userName, String currentPassword, String newPassword) throws AcmUserActionFailedException { log.debug("Changing password for user:{}", userName); AcmUser acmUser = userDao.findByUserId(userName); LdapTemplate ldapTemplate = ldapDao.buildLdapTemplate(ldapAuthenticateConfig, acmUser.getDistinguishedName(), currentPassword); try { ldapUserDao.changeUserPassword(acmUser.getDistinguishedName(), currentPassword, newPassword, ldapTemplate, ldapAuthenticateConfig); log.debug("Password changed successfully for User: {}", userName); } catch (AcmLdapActionFailedException e) { throw new AcmUserActionFailedException("change password", "USER", null, "Change password action failed!", null); } try { ldapTemplate = ldapDao.buildLdapTemplate(ldapAuthenticateConfig, acmUser.getDistinguishedName(), newPassword); savePasswordExpirationDate(acmUser, ldapTemplate); } catch (Exception e) { log.warn("Password expiration date was not set for user [{}]", acmUser.getUserId(), e); } }  }
LdapAuthenticateService { public void changeUserPassword(String userName, String currentPassword, String newPassword) throws AcmUserActionFailedException { log.debug("Changing password for user:{}", userName); AcmUser acmUser = userDao.findByUserId(userName); LdapTemplate ldapTemplate = ldapDao.buildLdapTemplate(ldapAuthenticateConfig, acmUser.getDistinguishedName(), currentPassword); try { ldapUserDao.changeUserPassword(acmUser.getDistinguishedName(), currentPassword, newPassword, ldapTemplate, ldapAuthenticateConfig); log.debug("Password changed successfully for User: {}", userName); } catch (AcmLdapActionFailedException e) { throw new AcmUserActionFailedException("change password", "USER", null, "Change password action failed!", null); } try { ldapTemplate = ldapDao.buildLdapTemplate(ldapAuthenticateConfig, acmUser.getDistinguishedName(), newPassword); savePasswordExpirationDate(acmUser, ldapTemplate); } catch (Exception e) { log.warn("Password expiration date was not set for user [{}]", acmUser.getUserId(), e); } }  Boolean authenticate(String userName, String password); void changeUserPassword(String userName, String currentPassword, String newPassword); void resetUserPassword(String token, String password); SpringLdapDao getLdapDao(); void setLdapDao(SpringLdapDao ldapDao); AcmLdapAuthenticateConfig getLdapAuthenticateConfig(); void setLdapAuthenticateConfig(AcmLdapAuthenticateConfig ldapAuthenticateConfig); UserDao getUserDao(); void setUserDao(UserDao userDao); SpringLdapUserDao getLdapUserDao(); void setLdapUserDao(SpringLdapUserDao ldapUserDao); AcmLdapSyncConfig getLdapSyncConfig(); void setLdapSyncConfig(AcmLdapSyncConfig ldapSyncConfig); }
LdapAuthenticateService { public void changeUserPassword(String userName, String currentPassword, String newPassword) throws AcmUserActionFailedException { log.debug("Changing password for user:{}", userName); AcmUser acmUser = userDao.findByUserId(userName); LdapTemplate ldapTemplate = ldapDao.buildLdapTemplate(ldapAuthenticateConfig, acmUser.getDistinguishedName(), currentPassword); try { ldapUserDao.changeUserPassword(acmUser.getDistinguishedName(), currentPassword, newPassword, ldapTemplate, ldapAuthenticateConfig); log.debug("Password changed successfully for User: {}", userName); } catch (AcmLdapActionFailedException e) { throw new AcmUserActionFailedException("change password", "USER", null, "Change password action failed!", null); } try { ldapTemplate = ldapDao.buildLdapTemplate(ldapAuthenticateConfig, acmUser.getDistinguishedName(), newPassword); savePasswordExpirationDate(acmUser, ldapTemplate); } catch (Exception e) { log.warn("Password expiration date was not set for user [{}]", acmUser.getUserId(), e); } }  Boolean authenticate(String userName, String password); void changeUserPassword(String userName, String currentPassword, String newPassword); void resetUserPassword(String token, String password); SpringLdapDao getLdapDao(); void setLdapDao(SpringLdapDao ldapDao); AcmLdapAuthenticateConfig getLdapAuthenticateConfig(); void setLdapAuthenticateConfig(AcmLdapAuthenticateConfig ldapAuthenticateConfig); UserDao getUserDao(); void setUserDao(UserDao userDao); SpringLdapUserDao getLdapUserDao(); void setLdapUserDao(SpringLdapUserDao ldapUserDao); AcmLdapSyncConfig getLdapSyncConfig(); void setLdapSyncConfig(AcmLdapSyncConfig ldapSyncConfig);  }