private void createUserSessionDetails(HttpServletRequest request, AuthToken token) {
   // create client and get facebook user
   log.debug("Creating new Facebook client for token: " + token);
   FacebookClient client = new DefaultFacebookClient(token.getToken());
   FacebookUser fbuser = client.fetchObject("me", FacebookUser.class);
   // get current session and fetch user
   Session session = sessionManager.getSessionByExternalId(fbuser.getId(), operatorId);
   log.debug("Found session for client: " + session);
   User user = userManager.getUser(session.getUserId());
   // update display name
   userManager.setDisplayName(user.getId(), fbuser.getName());
   // fire event
   fbuser.updateKalahDetails(user);
   eventSink.userLoggedIn(user, fbuser);
   // store objects in session
   setSessionAttribute(request, SESSION_ATTR, session);
   setSessionAttribute(request, CLIENT_ATTR, client);
   setSessionAttribute(request, USER_ATTR, user);
 }
 private boolean checkLocalSignIn(HttpServletRequest request) {
   if ("true".equals(request.getParameter("local"))) {
     String u = request.getParameter("u");
     String p = request.getParameter("p");
     log.debug("Local sign-in for user " + u);
     User user = userManager.authLocalUser(u, p);
     if (user != null) {
       Session session = sessionManager.getSessionByUserId(user.getId());
       log.debug("Found session for client: " + session);
       setSessionAttribute(request, SESSION_ATTR, session);
       setSessionAttribute(request, USER_ATTR, user);
       return true;
     } else {
       log.debug("Login for user " + u + " failed");
       return false;
     }
   } else {
     return false;
   }
 }
 public long createLocalUser(String name, String pass) {
   return manager.createLocalUser(name, pass).getId();
 }