title: Adding an authentification system in a deployed Roo/Gwt project
body: <p>I deployed recently a Roo/Gwt project on Google App Engine.</p>
  
  <p>I spent a couple of hours but couldn't find a tutorial that shows, step by step, how can we add n authentification system (withe the Federated Login Api).</p>
  
  <p>I found <a href="http://code.google.com/appengine/articles/openid.html" rel="nofollow noreferrer">this very good article</a> that provides some helpful code :</p>
  
  <pre><code>import java.io.IOException;
  import java.io.PrintWriter;
  import java.util.HashMap;
  import java.util.HashSet;
  import java.util.Map;
  import java.util.Set;
  
  import javax.servlet.http.HttpServlet;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
  import com.google.appengine.api.users.User;
  import com.google.appengine.api.users.UserService;
  import com.google.appengine.api.users.UserServiceFactory;
  
  @SuppressWarnings("serial")
  public class OpenIdDemoServlet extends HttpServlet {
  
      private static final Map&lt;String, String&gt; openIdProviders;
      static {
          openIdProviders = new HashMap&lt;String, String&gt;();
          openIdProviders.put("Google", "google.com/accounts/o8/id");
          openIdProviders.put("Yahoo", "yahoo.com");
          openIdProviders.put("MySpace", "myspace.com");
          openIdProviders.put("AOL", "aol.com");
          openIdProviders.put("MyOpenId.com", "myopenid.com");
      }
  
      @Override
      public void doGet(HttpServletRequest req, HttpServletResponse resp)
              throws IOException {
          UserService userService = UserServiceFactory.getUserService();
          User user = userService.getCurrentUser(); // or req.getUserPrincipal()
          Set&lt;String&gt; attributes = new HashSet();
  
          resp.setContentType("text/html");
          PrintWriter out = resp.getWriter();
  
          if (user != null) {
              out.println("Hello &lt;i&gt;" + user.getNickname() + "&lt;/i&gt;!");
              out.println("[&lt;a href=\""
                      + userService.createLogoutURL(req.getRequestURI())
                      + "\"&gt;sign out&lt;/a&gt;]");
          } else {
              out.println("Hello world! Sign in at: ");
              for (String providerName : openIdProviders.keySet()) {
                  String providerUrl = openIdProviders.get(providerName);
                  String loginUrl = userService.createLoginURL(req
                          .getRequestURI(), null, providerUrl, attributes);
                  out.println("[&lt;a href=\"" + loginUrl + "\"&gt;" + providerName + "&lt;/a&gt;] ");
              }
          }
      }
  }
  </code></pre>
  
  <p>How can I setup this authentification module? Where should I put this code because there is no "main.java" file?</p>
  
  <p>Thank you very much, </p>
  
  <p>Regards</p>