Note that there are some explanatory texts on larger screens.

plurals
  1. POFacebook Connect example in JSP (tomcat)
    text
    copied!<p>I'm building a JSP application and I would like to use Facebook Connect as one path for user registration and authentication, but I'm not finding much information about how to fetch and parse the FB cookie or even the right flow. I'm trying to merge the information found in the official <a href="http://developers.facebook.com/docs/authentication/">documentation</a> with a step by step guide like <a href="http://www.barattalo.it/facebook-connect-tutorial/">this one</a> but for Java. I am not opposed to relying on libraries like <a href="http://www.socialjava.com/">Social Java</a> but understanding the steps would be helpful. Here are the 3 use cases I'm trying to satisfy.</p> <ol> <li>Unauthenticated/unregistered user on my site clicks on "Facebook Connect" button to sign up (capturing email, name and profile ID) and and sign in.</li> <li>Unauthenticated user clicks on ""Facebook Connect" button to create a valid session on my domain.</li> <li>Authenticated and registered user without a connected Facebook profile clicks on "Facebook Connect" and associates a Facebook profile ID (and the option to update their email and name) with their existing profile.</li> </ol> <p>For this project I have a Profile class that looks like this (I'm using the excellent <a href="http://projectlombok.org/">Project Lombok</a> with Hibernate)</p> <pre><code>@Entity @Data public class Profile implements java.io.Serializable { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private long id; private String username; private String password; private String displayName; private String email; private String zipCode; private String mobileNumber; private String facebookId; @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime") private DateTime dateCreated; private int status; private int level; } </code></pre> <p>Status and Level really should be enums, but I'm trying to keep the code tiny for this question.</p> <p><sub><b>Disclaimer:</b>I've been reading a lot of blogs about how to setup Facebook Connect for user registration and authentication, but they are for the most part based on PHP and older versions of the Facebook API (even some SO questions point to the old wiki in their accepted answers). This seems like a perfect application of the SO community.</sub></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload