/**
   * Method that performs introspection on an AUTH string, and returns data as a String->String
   * hashmap.
   *
   * @param auth the authstring to query, as built by an auth impl.
   * @return the data from the introspect, in a map.
   * @throws IOException if anything goes wrong.
   */
  private Map<String, String> introspectAuth(String accesstoken) throws IOException {
    Map<String, String> results = new HashMap<String, String>();

    // create a fb client using the supplied access token
    FacebookClient client = new DefaultFacebookClient(accesstoken, Version.VERSION_2_5);

    try {
      // get back just the email, and name for the user, we'll get the id
      // for free.
      // fb only allows us to retrieve the things we asked for back in
      // FacebookAuth when creating the token.
      User userWithMetadata =
          client.fetchObject("me", User.class, Parameter.with("fields", "email,name"));

      results.put("valid", "true");
      results.put("email", userWithMetadata.getEmail());
      results.put("name", userWithMetadata.getName());
      results.put("id", "facebook:" + userWithMetadata.getId());

    } catch (FacebookOAuthException e) {
      results.clear();
      results.put("valid", "false");
    }

    return results;
  }
 public static void fbLogin() {
   String token = params.get("token");
   if (null != token && !token.isEmpty()) {
     FacebookClient fb = new DefaultFacebookClient(token);
     User fbUser = fb.fetchObject("me", User.class);
     Logger.info("Facebook User:"******"Such a user does not exists. Create/Register one...");
       // Register a new...
       // Email uniqueness is controlled by Facebook I suppose, so no need to check on our side...
       sesUser = new SUser(fbUser.getName(), fbUser.getEmail());
       sesUser.fbId = fbUser.getId();
       sesUser.save();
     }
     Auth.fbLogin(token, sesUser);
   } else {
     redirect("/");
   }
 }