|
QuickStartOpenid
Openid RelyingParty QuickStart GuideLet us learn by example ... this will help you create/deploy asap. For extensions, see OpenIdAttributeExchange and OpenIdSimpleRegistration /WEB-INF/web.xml<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5" metadata-complete="true">
<filter>
<filter-name>openid-filter</filter-name>
<filter-class>com.dyuproject.openid.OpenIdServletFilter</filter-class>
<load-on-startup>1</load-on-startup>
<init-param>
<param-name>forwardUri</param-name>
<param-value>/WEB-INF/views/jsp/login.jsp</param-value> <!-- login page when user is not authenticated-->
</init-param>
</filter>
<filter-mapping>
<filter-name>openid-filter</filter-name>
<url-pattern>/user/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>home-servlet</servlet-name>
<servlet-class>com.example.openid.HomeServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>home-servlet</servlet-name>
<url-pattern>/user/home/</url-pattern>
</servlet-mapping>
</web-app>/WEB-INF/views/jsp/login.jsp<html>
<body>
<div style="color:red;font-size:1.4em">${openid_servlet_filter_msg}</div>
<p>Login with your <span style="color:orange">openid</span></p>
<form method="POST">
<input id="openid_identifier" name="openid_identifier" type="text" size=80/>
<input class="btn" type="submit" value="send"/>
</form>
</body>
</html>HomeServlet.javapublic class HomeServlet extends HttpServlet
{
static
{
RelyingParty.getInstance()
.addListener(new AxSchemaExtension()
.addExchange("email")
.addExchange("country")
.addExchange("language")
);
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
{
OpenIdUser user = (OpenIdUser)request.getAttribute(OpenIdUser.ATTR_NAME);
Map<String,String> axschema = AxSchemaExtension.get(user);
String email = axschema.get("email");
String country = axschema.get("country");
String language = axschema.get("language");
// do something with your user's data
}
}Thats it! |
► Sign in to add a comment
In HomeServlet.java, there's a missing semicolon in the static block.
Thanks. its fixed.
What is the action of the POST form?
Downloaded dyuproject.appspot.com-source-2010-06-22.zip.
How to import this into eclipse?
Download and install maven2. Then execute: $ mvn eclipse:eclipse
Google AppEngine? complains that the openid-filter parameter <load-on-startup>1</load-on-startup> is misplaced in the web.xml file. It wants to see <init-param> instead. Any ideas where this should really go?
my project work on appengine 1.4.2 and 1.5.5, any other version not working. May be your problem in appengine version?