/** * @param userId * @return true if successful sets user context, false otherwise */ public boolean setUser(String userId) { if (userId != null && httpRequestChecker != null) { UserInfo userInfo = userMap.get(userId); if (userInfo == null) { String userEmail = getUserProperty(userId, "email"); if (userEmail == null) { log.warn("user " + userId + " email not found in config"); return false; } String password = getUserProperty(userId, "password"); if (password == null) { log.warn("user " + userId + " password not found in config"); return false; } userInfo = new UserInfo(userEmail, password); userMap.put(userId, userInfo); } try { // ? currentUser = null; // null or keep last value ?? httpRequestChecker.setUser(this, userId, userInfo.email, userInfo.password); if (userInfo.email.equals(httpRequestChecker.getCurrentUser(this))) { currentUser = userId; return true; } } catch (IllegalStateException e) { log.warn("failed to set user", e); return false; } catch (IllegalArgumentException e) { log.warn("failed to set user", e); return false; } } return false; }