I want to implement openId using a popup as the UI. So in my view I create a 
popup that redirect to a servlet using javascript:

   public void onLogin(String provider, String username) {
       String url = "/openid/mylogin?provider=" + provider;
       if (username != null) {
           url = url + "&username=" + username;
       }
       String features = 
"width=450,height=500,location=1,status=1,resizable=yes";
       JavaScriptObject window = WindowUtil.newWindow(url, "login", 
features);
   }

   public static native JavaScriptObject newWindow(String url, String name,
           String features)/*-{
 var window = $wnd.open(url, name, features);
 // Center the window
 var width = @com.google.gwt.user.client.Window::getClientWidth()();
 var height = @com.google.gwt.user.client.Window::getClientHeight()();
 window.moveTo((width - 450) / 2, (height - 500) / 2);
 return window;
   }-*/;

The servlet:

   @Override
   public void doPost(HttpServletRequest request, HttpServletResponse 
response)
           throws IOException, ServletException {

       UserService userService = UserServiceFactory.getUserService();
       User user = userService.getCurrentUser();

       String provider = request.getParameter("provider");
       if (user == null) {
           if (provider != null) {
               // Provider
               Map<String, String> authDomainMap = new HashMap<String, 
String>();
               authDomainMap.put("google", "google.com");
               authDomainMap.put("yahoo", "yahoo.com");
               // URL
               Map<String, String> federatedIdentityMap = new 
HashMap<String, String>();
               federatedIdentityMap.put("google",
                       "https://www.google.com/accounts/o8/id";);
               federatedIdentityMap.put("yahoo",
                       
"http://open.login.yahooapis.com/openid20/www.yahoo.com/xrds";);
               // Attributes
               Set<String> attributesRequest = new HashSet<String>();
               // attributesRequest.add("openid.mode=checkid_immediate");
               // 
attributesRequest.add("openid.ns=http://specs.openid.net/auth/2.0";);
               // 
attributesRequest.add("openid.return_to=http://www.google.com";);

               String loginURL = userService.createLoginURL(
                       request.getRequestURI(), authDomainMap.get(provider),
                       federatedIdentityMap.get(provider), 
attributesRequest);
               System.out.println(loginURL);
               response.sendRedirect(loginURL);
           }
       } else {
           // Associate the session to the current user
           userDao.get().setCurrentUser(user);
       }
   }

During the execution, the dummy form is displayed and then I click on Log 
In. The loginURL is /_ah/login?continue=%2Fopenid%2Fmylogin

After clicking on Log In, the popup is closed and nothing happen, except 
that the user is now logged in. At that point I was expecting that _ah/login 
was called to set the user, and then it would redirect to the 
/openid/mylogin (continue parameter), so I could assign the user to the 
current session.

I know that the user has been logged in because then when I open the popup 
again, the user is not null and I can assign the user to the current 
session. I only tested my code on my dev server and not on app engine.

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-java@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to