@Test public void authenticateReturnsNullWhenThePasswordIsIncorrect() throws Exception { Optional<String> authenticate = instance.authenticate(KNOWN_USER, "incorrectPassword"); assertThat(authenticate, is(not(present()))); }
@Override public Optional<String> authenticate(String username, String password) throws LocalLoginUnavailableException { try { Optional<Login> first = loginAccess.getLogin(username); if (first.isPresent()) { Login login = first.get(); return isCorrectPassword(password, login) ? Optional.of(login.getUserPid()) : Optional.empty(); } } catch (NoSuchAlgorithmException e) { LOG.error("Encryption algorithm can not be found.", e); throw new LocalLoginUnavailableException(e.getMessage()); } return Optional.empty(); }
JsonBasedAuthenticator implements Authenticator, LoginCreator { @Override public Optional<String> authenticate(String username, String password) throws LocalLoginUnavailableException { try { Optional<Login> first = loginAccess.getLogin(username); if (first.isPresent()) { Login login = first.get(); return isCorrectPassword(password, login) ? Optional.of(login.getUserPid()) : Optional.empty(); } } catch (NoSuchAlgorithmException e) { LOG.error("Encryption algorithm can not be found.", e); throw new LocalLoginUnavailableException(e.getMessage()); } return Optional.empty(); } }
JsonBasedAuthenticator implements Authenticator, LoginCreator { @Override public Optional<String> authenticate(String username, String password) throws LocalLoginUnavailableException { try { Optional<Login> first = loginAccess.getLogin(username); if (first.isPresent()) { Login login = first.get(); return isCorrectPassword(password, login) ? Optional.of(login.getUserPid()) : Optional.empty(); } } catch (NoSuchAlgorithmException e) { LOG.error("Encryption algorithm can not be found.", e); throw new LocalLoginUnavailableException(e.getMessage()); } return Optional.empty(); } JsonBasedAuthenticator(LoginAccess loginAccess, String encryptionAlgorithm); }
JsonBasedAuthenticator implements Authenticator, LoginCreator { @Override public Optional<String> authenticate(String username, String password) throws LocalLoginUnavailableException { try { Optional<Login> first = loginAccess.getLogin(username); if (first.isPresent()) { Login login = first.get(); return isCorrectPassword(password, login) ? Optional.of(login.getUserPid()) : Optional.empty(); } } catch (NoSuchAlgorithmException e) { LOG.error("Encryption algorithm can not be found.", e); throw new LocalLoginUnavailableException(e.getMessage()); } return Optional.empty(); } JsonBasedAuthenticator(LoginAccess loginAccess, String encryptionAlgorithm); @Override Optional<String> authenticate(String username, String password); @Override void createLogin(String userPid, String userName, String password, String givenName, String surname,
                          String email, String organization); Login create(String userPid, String userName, String password, String givenName, String surname, String email,
                      String organization); }
JsonBasedAuthenticator implements Authenticator, LoginCreator { @Override public Optional<String> authenticate(String username, String password) throws LocalLoginUnavailableException { try { Optional<Login> first = loginAccess.getLogin(username); if (first.isPresent()) { Login login = first.get(); return isCorrectPassword(password, login) ? Optional.of(login.getUserPid()) : Optional.empty(); } } catch (NoSuchAlgorithmException e) { LOG.error("Encryption algorithm can not be found.", e); throw new LocalLoginUnavailableException(e.getMessage()); } return Optional.empty(); } JsonBasedAuthenticator(LoginAccess loginAccess, String encryptionAlgorithm); @Override Optional<String> authenticate(String username, String password); @Override void createLogin(String userPid, String userName, String password, String givenName, String surname,
                          String email, String organization); Login create(String userPid, String userName, String password, String givenName, String surname, String email,
                      String organization); static final Logger LOG; }