@Test public void authenticate() { String userName = "userName"; String password = "password"; String searchBase = "searchBase"; String userIdAttributeName = "userIdAttributeName"; String filter = "(" + userIdAttributeName + "=" + userName + ")"; AcmLdapAuthenticateConfig config = new AcmLdapAuthenticateConfig(); config.setSearchBase(searchBase); config.setUserIdAttributeName(userIdAttributeName); unit.setLdapAuthenticateConfig(config); expect(mockLdapDao.buildLdapTemplate(config)).andReturn(mockLdapTemplate); expect(mockLdapTemplate.authenticate(searchBase, filter, password)).andReturn(true); replayAll(); Boolean isAuthenticated = unit.authenticate(userName, password); verifyAll(); assertTrue(isAuthenticated); }
public Boolean authenticate(String userName, String password) { LdapTemplate template = getLdapDao().buildLdapTemplate(getLdapAuthenticateConfig()); String userIdAttributeName = getLdapAuthenticateConfig().getUserIdAttributeName(); String searchBase = getLdapAuthenticateConfig().getSearchBase(); userName = StringUtils.substringBeforeLast(userName, "@"); String filter = "(" + userIdAttributeName + "=" + userName + ")"; boolean authenticated = template.authenticate(searchBase, filter, password); log.debug("searchBase[{}], filter[{}], authenticated[{}]", searchBase, filter, authenticated); return authenticated; }
LdapAuthenticateService { public Boolean authenticate(String userName, String password) { LdapTemplate template = getLdapDao().buildLdapTemplate(getLdapAuthenticateConfig()); String userIdAttributeName = getLdapAuthenticateConfig().getUserIdAttributeName(); String searchBase = getLdapAuthenticateConfig().getSearchBase(); userName = StringUtils.substringBeforeLast(userName, "@"); String filter = "(" + userIdAttributeName + "=" + userName + ")"; boolean authenticated = template.authenticate(searchBase, filter, password); log.debug("searchBase[{}], filter[{}], authenticated[{}]", searchBase, filter, authenticated); return authenticated; } }
LdapAuthenticateService { public Boolean authenticate(String userName, String password) { LdapTemplate template = getLdapDao().buildLdapTemplate(getLdapAuthenticateConfig()); String userIdAttributeName = getLdapAuthenticateConfig().getUserIdAttributeName(); String searchBase = getLdapAuthenticateConfig().getSearchBase(); userName = StringUtils.substringBeforeLast(userName, "@"); String filter = "(" + userIdAttributeName + "=" + userName + ")"; boolean authenticated = template.authenticate(searchBase, filter, password); log.debug("searchBase[{}], filter[{}], authenticated[{}]", searchBase, filter, authenticated); return authenticated; }  }
LdapAuthenticateService { public Boolean authenticate(String userName, String password) { LdapTemplate template = getLdapDao().buildLdapTemplate(getLdapAuthenticateConfig()); String userIdAttributeName = getLdapAuthenticateConfig().getUserIdAttributeName(); String searchBase = getLdapAuthenticateConfig().getSearchBase(); userName = StringUtils.substringBeforeLast(userName, "@"); String filter = "(" + userIdAttributeName + "=" + userName + ")"; boolean authenticated = template.authenticate(searchBase, filter, password); log.debug("searchBase[{}], filter[{}], authenticated[{}]", searchBase, filter, authenticated); return authenticated; }  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 Boolean authenticate(String userName, String password) { LdapTemplate template = getLdapDao().buildLdapTemplate(getLdapAuthenticateConfig()); String userIdAttributeName = getLdapAuthenticateConfig().getUserIdAttributeName(); String searchBase = getLdapAuthenticateConfig().getSearchBase(); userName = StringUtils.substringBeforeLast(userName, "@"); String filter = "(" + userIdAttributeName + "=" + userName + ")"; boolean authenticated = template.authenticate(searchBase, filter, password); log.debug("searchBase[{}], filter[{}], authenticated[{}]", searchBase, filter, authenticated); return authenticated; }  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);  }