I have added an Authentication Servlet shown below to my test app already
working on appspot.com. The app is working well on the local app engine
server in Eclipse IDE. But when deployed on appspot, it gives this error
when I try to open the Servlet URL. I have chosen the option "Users with a
valid account in the *indidge.com* Google Apps domain can sign in if the Google
Accounts API <http://code.google.com/appengine/docs/users.html> is used for
authentication".
In the local app server I am able to test it with different emails. However
on AppEngine, I don't even see the Servlet interface. It just fails with
the above message. Other part of the application, which uses a RPC service
and GWT interface works fine, if I point to that URL.
In web.xml, I have added the entry for Servlet
<servlet>
<servlet-name>authServlet</servlet-name>
<servlet-class>com.indidge.hpmmonitor.server.AuthServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>authServlet</servlet-name>
<url-pattern>/authServlet</url-pattern>
</servlet-mapping>
<!-- Default page to serve -->
<welcome-file-list>
<welcome-file>authServlet</welcome-file>
</welcome-file-list>
The Servlet class is very simple
===========================
public class AuthServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throwsIOException {
UserService userService = UserServiceFactory.getUserService();
String param = req.getParameter("cmd");
if (param != null && param.equals("logout")) {
resp.sendRedirect(userService.createLogoutURL(req.getRequestURI()));
}
else {
User user = userService.getCurrentUser();
if (user != null) {
if (user.getEmail().contains("test.com")) {
// Redirect the user to the app screen
resp.sendRedirect("/main.html");
}
else {
// Redirect the user to Not allowed screen
resp.sendRedirect("/NotAllowed.jsp");
}
}
else {
resp.sendRedirect(userService.createLoginURL( req.getRequestURI(),
"google.com"));
}
}
}
}
--
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-appengine-java?hl=en.