@Test public void returnsNoTokenIfTheUserIsUnknown() throws Exception { LoggedInUsers instance = userStoreWithUserA; Optional<String> token = instance.userTokenFor("unknownUser", ""); assertThat(token, is(not(present()))); }
public synchronized Optional<String> userTokenFor(String username, String password) throws LocalLoginUnavailableException, AuthenticationUnavailableException { Optional<String> id; Optional<String> token = Optional.empty(); id = authenticator.authenticate(username, password); if (id.isPresent()) { Optional<User> user = userStore.userFor(id.get()); if (user.isPresent()) { String uuid = UUID.randomUUID().toString(); token = Optional.of(uuid); users.put(uuid, user.get()); } } return token; }
LoggedInUsers { public synchronized Optional<String> userTokenFor(String username, String password) throws LocalLoginUnavailableException, AuthenticationUnavailableException { Optional<String> id; Optional<String> token = Optional.empty(); id = authenticator.authenticate(username, password); if (id.isPresent()) { Optional<User> user = userStore.userFor(id.get()); if (user.isPresent()) { String uuid = UUID.randomUUID().toString(); token = Optional.of(uuid); users.put(uuid, user.get()); } } return token; } }
LoggedInUsers { public synchronized Optional<String> userTokenFor(String username, String password) throws LocalLoginUnavailableException, AuthenticationUnavailableException { Optional<String> id; Optional<String> token = Optional.empty(); id = authenticator.authenticate(username, password); if (id.isPresent()) { Optional<User> user = userStore.userFor(id.get()); if (user.isPresent()) { String uuid = UUID.randomUUID().toString(); token = Optional.of(uuid); users.put(uuid, user.get()); } } return token; } LoggedInUsers(Authenticator authenticator, UserStore userStore,
                       Timeout inactivityTimeout, AuthenticationHandler authenticationHandler); }
LoggedInUsers { public synchronized Optional<String> userTokenFor(String username, String password) throws LocalLoginUnavailableException, AuthenticationUnavailableException { Optional<String> id; Optional<String> token = Optional.empty(); id = authenticator.authenticate(username, password); if (id.isPresent()) { Optional<User> user = userStore.userFor(id.get()); if (user.isPresent()) { String uuid = UUID.randomUUID().toString(); token = Optional.of(uuid); users.put(uuid, user.get()); } } return token; } LoggedInUsers(Authenticator authenticator, UserStore userStore,
                       Timeout inactivityTimeout, AuthenticationHandler authenticationHandler); synchronized Optional<User> userFor(String authHeader); synchronized Optional<String> userTokenFor(String username, String password); }
LoggedInUsers { public synchronized Optional<String> userTokenFor(String username, String password) throws LocalLoginUnavailableException, AuthenticationUnavailableException { Optional<String> id; Optional<String> token = Optional.empty(); id = authenticator.authenticate(username, password); if (id.isPresent()) { Optional<User> user = userStore.userFor(id.get()); if (user.isPresent()) { String uuid = UUID.randomUUID().toString(); token = Optional.of(uuid); users.put(uuid, user.get()); } } return token; } LoggedInUsers(Authenticator authenticator, UserStore userStore,
                       Timeout inactivityTimeout, AuthenticationHandler authenticationHandler); synchronized Optional<User> userFor(String authHeader); synchronized Optional<String> userTokenFor(String username, String password); static final Logger LOG; }