1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/webidor/pom.xml Sat May 30 08:10:23 2009 +0200
1.3 @@ -0,0 +1,112 @@
1.4 +<?xml version="1.0" encoding="UTF-8"?>
1.5 +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
1.6 + <modelVersion>4.0.0</modelVersion>
1.7 + <parent>
1.8 + <artifactId>all-quoridor</artifactId>
1.9 + <groupId>org.apidesign</groupId>
1.10 + <version>1.0</version>
1.11 + </parent>
1.12 + <groupId>org.apidesign</groupId>
1.13 + <artifactId>webidor</artifactId>
1.14 + <packaging>war</packaging>
1.15 + <version>1.0</version>
1.16 + <name>webidor JEE5 Webapp</name>
1.17 + <url>http://maven.apache.org</url>
1.18 + <dependencies>
1.19 +
1.20 + <dependency>
1.21 + <groupId>javax.servlet</groupId>
1.22 + <artifactId>servlet-api</artifactId>
1.23 + <version>2.5</version>
1.24 + <scope>provided</scope>
1.25 + </dependency>
1.26 +
1.27 + <dependency>
1.28 + <groupId>javax.servlet.jsp</groupId>
1.29 + <artifactId>jsp-api</artifactId>
1.30 + <version>2.1</version>
1.31 + <scope>provided</scope>
1.32 + </dependency>
1.33 +
1.34 + <dependency>
1.35 + <groupId>junit</groupId>
1.36 + <artifactId>junit</artifactId>
1.37 + <version>3.8.1</version>
1.38 + <scope>test</scope>
1.39 + </dependency>
1.40 + <dependency>
1.41 + <groupId>org.openid4java</groupId>
1.42 + <artifactId>openid4java</artifactId>
1.43 + <version>0.9.3</version>
1.44 + </dependency>
1.45 + <dependency>
1.46 + <groupId>org.springframework</groupId>
1.47 + <artifactId>spring-webmvc</artifactId>
1.48 + <version>2.5</version>
1.49 + </dependency>
1.50 + <dependency>
1.51 + <groupId>org.springframework</groupId>
1.52 + <artifactId>spring</artifactId>
1.53 + <version>2.5</version>
1.54 + </dependency>
1.55 + <dependency>
1.56 + <groupId>org.apache.struts</groupId>
1.57 + <artifactId>struts-core</artifactId>
1.58 + <version>1.3.8</version>
1.59 + </dependency>
1.60 + <dependency>
1.61 + <groupId>org.apache.struts</groupId>
1.62 + <artifactId>struts-el</artifactId>
1.63 + <version>1.3.8</version>
1.64 + </dependency>
1.65 + <dependency>
1.66 + <groupId>org.apache.struts</groupId>
1.67 + <artifactId>struts-extras</artifactId>
1.68 + <version>1.3.8</version>
1.69 + </dependency>
1.70 + <dependency>
1.71 + <groupId>org.apache.struts</groupId>
1.72 + <artifactId>struts-faces</artifactId>
1.73 + <version>1.3.8</version>
1.74 + </dependency>
1.75 + <dependency>
1.76 + <groupId>org.apache.struts</groupId>
1.77 + <artifactId>struts-mailreader-dao</artifactId>
1.78 + <version>1.3.8</version>
1.79 + </dependency>
1.80 + <dependency>
1.81 + <groupId>org.apache.struts</groupId>
1.82 + <artifactId>struts-scripting</artifactId>
1.83 + <version>1.3.8</version>
1.84 + </dependency>
1.85 + <dependency>
1.86 + <groupId>org.apache.struts</groupId>
1.87 + <artifactId>struts-taglib</artifactId>
1.88 + <version>1.3.8</version>
1.89 + </dependency>
1.90 + <dependency>
1.91 + <groupId>org.apache.struts</groupId>
1.92 + <artifactId>struts-tiles</artifactId>
1.93 + <version>1.3.8</version>
1.94 + </dependency>
1.95 + </dependencies>
1.96 + <build>
1.97 + <plugins>
1.98 + <plugin>
1.99 + <groupId>org.apache.maven.plugins</groupId>
1.100 + <artifactId>maven-compiler-plugin</artifactId>
1.101 + <version>2.0.2</version>
1.102 + <configuration>
1.103 + <source>1.5</source>
1.104 + <target>1.5</target>
1.105 + </configuration>
1.106 + </plugin>
1.107 + </plugins>
1.108 + <finalName>webidor</finalName>
1.109 + </build>
1.110 + <properties>
1.111 + <netbeans.hint.deploy.server>gfv3</netbeans.hint.deploy.server>
1.112 + </properties>
1.113 +</project>
1.114 +
1.115 +
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/webidor/src/main/java/cz/xelfi/quoridor/webidor/LoginController.java Sat May 30 08:10:23 2009 +0200
2.3 @@ -0,0 +1,141 @@
2.4 +/*
2.5 + * To change this template, choose Tools | Templates
2.6 + * and open the template in the editor.
2.7 + */
2.8 +
2.9 +package cz.xelfi.quoridor.webidor;
2.10 +
2.11 +import java.util.HashMap;
2.12 +import java.util.List;
2.13 +import javax.servlet.http.HttpServletRequest;
2.14 +import javax.servlet.http.HttpServletResponse;
2.15 +import javax.servlet.http.HttpSession;
2.16 +import org.openid4java.consumer.ConsumerManager;
2.17 +import org.openid4java.consumer.VerificationResult;
2.18 +import org.openid4java.discovery.Discovery;
2.19 +import org.openid4java.discovery.DiscoveryInformation;
2.20 +import org.openid4java.discovery.Identifier;
2.21 +import org.openid4java.message.AuthRequest;
2.22 +import org.openid4java.message.AuthSuccess;
2.23 +import org.openid4java.message.MessageExtension;
2.24 +import org.openid4java.message.ParameterList;
2.25 +import org.openid4java.message.ax.AxMessage;
2.26 +import org.openid4java.message.ax.FetchRequest;
2.27 +import org.openid4java.message.ax.FetchResponse;
2.28 +import org.springframework.web.servlet.ModelAndView;
2.29 +import org.springframework.web.servlet.mvc.AbstractController;
2.30 +
2.31 +/**
2.32 + *
2.33 + * @author Jaroslav Tulach <jtulach@netbeans.org>
2.34 + */
2.35 +public class LoginController extends AbstractController {
2.36 +
2.37 + public LoginController() {
2.38 + }
2.39 +
2.40 + protected ModelAndView handleRequestInternal(
2.41 + HttpServletRequest request,
2.42 + HttpServletResponse response
2.43 + ) throws Exception {
2.44 + String openid = request.getParameter("openid"); // NOI18N
2.45 + if (openid != null) {
2.46 + StringBuffer ret = request.getRequestURL();
2.47 + return discover(openid, ret.toString(), request.getSession());
2.48 + }
2.49 + String openret = request.getParameter("openid.claimed_id");
2.50 + if (openret != null) {
2.51 + return login(request, response);
2.52 + }
2.53 + return new ModelAndView("login");
2.54 + }
2.55 +
2.56 + // instantiate a ConsumerManager object
2.57 + private static ConsumerManager manager;
2.58 + private ModelAndView discover(String openid, String returnToUrl, HttpSession session) throws Exception {
2.59 + if (manager == null) {
2.60 + manager = new ConsumerManager();
2.61 + }
2.62 +
2.63 + // build an Identifier instance from the user-supplied identifier
2.64 + Identifier identifier = Discovery.parseIdentifier(openid);
2.65 +
2.66 + // perform discovery on the user-supplied identifier
2.67 + List discoveries = manager.getDiscovery().discover(identifier);
2.68 +
2.69 + // attempt to associate with an OpenID provider
2.70 + // and retrieve one service endpoint for authentication
2.71 + DiscoveryInformation discovered = manager.associate(discoveries);
2.72 +
2.73 + // store the discovery information in the user's session
2.74 + session.setAttribute("openid-disco", discovered);
2.75 +
2.76 + // Attribute Exchange example: fetching the 'email' attribute
2.77 + FetchRequest fetch = FetchRequest.createFetchRequest();
2.78 + fetch.addAttribute("email", // attribute alias
2.79 + "http://schema.openid.net/contact/email", // type URI
2.80 + true); // required
2.81 +
2.82 + // obtain a AuthRequest message to be sent to the OpenID provider
2.83 + AuthRequest authReq = manager.authenticate(discovered, returnToUrl);
2.84 +
2.85 + // attach the extension to the authentication request
2.86 + //authReq.addExtensionParams(fetch);
2.87 +
2.88 + // Option 2: HTML FORM Redirection
2.89 + // Allows payloads > 255 bytes
2.90 +
2.91 + // <FORM action="OpenID Provider's service endpoint">
2.92 + // see samples/formredirection.jsp for a JSP example
2.93 + HashMap<String,Object> map = new HashMap<String, Object>();
2.94 + map.put("OPEndpoint", authReq.getOPEndpoint()); // NOI18N
2.95 + map.put("message", authReq.getParameterMap()); // NOI18N
2.96 +
2.97 + // build a HTML FORM with the message parameters
2.98 + return new ModelAndView("loginredirection", map);
2.99 + }
2.100 +
2.101 + private ModelAndView login(HttpServletRequest request, HttpServletResponse res)
2.102 + throws Exception {
2.103 + // extract the parameters from the authentication response
2.104 + // (which comes in as a HTTP request from the OpenID provider)
2.105 + ParameterList response = new ParameterList(request.getParameterMap());
2.106 +
2.107 + // retrieve the previously stored discovery information
2.108 + DiscoveryInformation discovered
2.109 + = (DiscoveryInformation) request.getSession().getAttribute("openid-disco");
2.110 +
2.111 + // extract the receiving URL from the HTTP request
2.112 + StringBuffer receivingURL = request.getRequestURL();
2.113 + String queryString = request.getQueryString();
2.114 + if (queryString != null && queryString.length() > 0)
2.115 + receivingURL.append("?").append(request.getQueryString());
2.116 +
2.117 + // verify the response; ConsumerManager needs to be the same
2.118 + // (static) instance used to place the authentication request
2.119 + VerificationResult verification = manager.verify(
2.120 + receivingURL.toString(),
2.121 + response, discovered);
2.122 +
2.123 + HashMap<String,Object> map = new HashMap<String, Object>();
2.124 + // examine the verification result and extract the verified identifier
2.125 + Identifier verified = verification.getVerifiedId();
2.126 + if (verified != null)
2.127 + {
2.128 + /*
2.129 + // Attribute Exchange: retrieving the fetched "email" attribute
2.130 + AuthSuccess authSuccess = AuthSuccess.createAuthSuccess(response);
2.131 + MessageExtension ext =
2.132 + authSuccess.getExtension(AxMessage.OPENID_NS_AX);
2.133 + if (ext != null)
2.134 + {
2.135 + FetchResponse fetchResp =FetchResponse.createFetchResponse(ext.getParameters());
2.136 + String email = fetchResp.getParameterValue("email");
2.137 + }
2.138 + */
2.139 + map.put("id", verified.getIdentifier()); // NOI18N
2.140 + }
2.141 +
2.142 + return new ModelAndView("index", map);
2.143 + }
2.144 +}
2.145 \ No newline at end of file
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/webidor/src/main/webapp/WEB-INF/applicationContext.xml Sat May 30 08:10:23 2009 +0200
3.3 @@ -0,0 +1,24 @@
3.4 +<?xml version="1.0" encoding="UTF-8"?>
3.5 +<beans xmlns="http://www.springframework.org/schema/beans"
3.6 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3.7 + xmlns:p="http://www.springframework.org/schema/p"
3.8 + xmlns:aop="http://www.springframework.org/schema/aop"
3.9 + xmlns:tx="http://www.springframework.org/schema/tx"
3.10 + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
3.11 + http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
3.12 + http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
3.13 +
3.14 + <!--bean id="propertyConfigurer"
3.15 + class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
3.16 + p:location="/WEB-INF/jdbc.properties" />
3.17 +
3.18 + <bean id="dataSource"
3.19 + class="org.springframework.jdbc.datasource.DriverManagerDataSource"
3.20 + p:driverClassName="${jdbc.driverClassName}"
3.21 + p:url="${jdbc.url}"
3.22 + p:username="${jdbc.username}"
3.23 + p:password="${jdbc.password}" /-->
3.24 +
3.25 + <!-- ADD PERSISTENCE SUPPORT HERE (jpa, hibernate, etc) -->
3.26 +
3.27 +</beans>
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/webidor/src/main/webapp/WEB-INF/dispatcher-servlet.xml Sat May 30 08:10:23 2009 +0200
4.3 @@ -0,0 +1,43 @@
4.4 +<?xml version="1.0" encoding="UTF-8"?>
4.5 +<beans xmlns="http://www.springframework.org/schema/beans"
4.6 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4.7 + xmlns:p="http://www.springframework.org/schema/p"
4.8 + xmlns:aop="http://www.springframework.org/schema/aop"
4.9 + xmlns:tx="http://www.springframework.org/schema/tx"
4.10 + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
4.11 + http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
4.12 +http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
4.13 +
4.14 + <bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"/>
4.15 +
4.16 + <!--
4.17 + Most controllers will use the ControllerClassNameHandlerMapping above, but
4.18 + for the index controller we are using ParameterizableViewController, so we must
4.19 + define an explicit mapping for it.
4.20 + -->
4.21 + <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
4.22 + <property name="mappings">
4.23 + <props>
4.24 + <prop key="index.html">indexController</prop>
4.25 + </props>
4.26 + </property>
4.27 + </bean>
4.28 +
4.29 + <bean id="viewResolver"
4.30 + class="org.springframework.web.servlet.view.InternalResourceViewResolver"
4.31 + p:prefix="/WEB-INF/jsp/"
4.32 + p:suffix=".jsp" />
4.33 +
4.34 + <!--
4.35 + The index controller.
4.36 + -->
4.37 + <bean name="indexController"
4.38 + class="org.springframework.web.servlet.mvc.ParameterizableViewController"
4.39 + p:viewName="index" />
4.40 +
4.41 +
4.42 + <bean name="/login.html" class="cz.xelfi.quoridor.webidor.LoginController"/>
4.43 +
4.44 +
4.45 +
4.46 +</beans>
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/webidor/src/main/webapp/WEB-INF/jsp/index.jsp Sat May 30 08:10:23 2009 +0200
5.3 @@ -0,0 +1,19 @@
5.4 +<%@page contentType="text/html" pageEncoding="UTF-8"%>
5.5 +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
5.6 + "http://www.w3.org/TR/html4/loose.dtd">
5.7 +
5.8 +<html>
5.9 + <head>
5.10 + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5.11 + <title>Welcome to Spring Web MVC project</title>
5.12 + </head>
5.13 +
5.14 + <body>
5.15 + <p>Hello ${id}! This is the default welcome page for a Spring Web MVC project.</p>
5.16 + <p><i>To display a different welcome page for this project, modify</i>
5.17 + <tt>index.jsp</tt> <i>, or create your own welcome page then change
5.18 + the redirection in</i> <tt>redirect.jsp</tt> <i>to point to the new
5.19 + welcome page and also update the welcome-file setting in</i>
5.20 + <tt>web.xml</tt>.</p>
5.21 + </body>
5.22 +</html>
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
6.2 +++ b/webidor/src/main/webapp/WEB-INF/jsp/login.jsp Sat May 30 08:10:23 2009 +0200
6.3 @@ -0,0 +1,18 @@
6.4 +<%@page contentType="text/html" pageEncoding="UTF-8"%>
6.5 +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
6.6 + "http://www.w3.org/TR/html4/loose.dtd">
6.7 +
6.8 +<html>
6.9 + <head>
6.10 + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
6.11 + <title>Login</title>
6.12 + </head>
6.13 + <body>
6.14 + <h1>Login</h1>
6.15 +
6.16 + <form action="login.html" method="post">
6.17 + <a href="http://en.wikipedia.org/wiki/Openid">Open ID</a>:
6.18 + <input type="text" name="openid" value="http://"/>
6.19 + </form>
6.20 + </body>
6.21 +</html>
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
7.2 +++ b/webidor/src/main/webapp/WEB-INF/jsp/loginredirection.jsp Sat May 30 08:10:23 2009 +0200
7.3 @@ -0,0 +1,20 @@
7.4 +<%--
7.5 + ~ Copyright 2006-2008 Sxip Identity Corporation
7.6 + --%>
7.7 +
7.8 +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
7.9 +"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
7.10 +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
7.11 +<html xmlns="http://www.w3.org/1999/xhtml">
7.12 +<head>
7.13 + <title>OpenID HTML FORM Redirection</title>
7.14 +</head>
7.15 +<body onload="document.forms['openid-form-redirection'].submit();">
7.16 + <form name="openid-form-redirection" action="${OPEndpoint}" method="post" accept-charset="utf-8">
7.17 + <c:forEach var="parameter" items="${message}">
7.18 + <input type="hidden" name="${parameter.key}" value="${parameter.value}"/>
7.19 + </c:forEach>
7.20 + <button type="submit">Continue...</button>
7.21 + </form>
7.22 +</body>
7.23 +</html>
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
8.2 +++ b/webidor/src/main/webapp/WEB-INF/sun-web.xml Sat May 30 08:10:23 2009 +0200
8.3 @@ -0,0 +1,11 @@
8.4 +<?xml version="1.0" encoding="UTF-8"?>
8.5 +<!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 Servlet 2.5//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_2_5-0.dtd">
8.6 +<sun-web-app error-url="">
8.7 + <class-loader delegate="true"/>
8.8 + <jsp-config>
8.9 + <property name="keepgenerated" value="true">
8.10 + <description>Keep a copy of the generated servlet class' java code.</description>
8.11 + </property>
8.12 + </jsp-config>
8.13 +</sun-web-app>
8.14 +
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
9.2 +++ b/webidor/src/main/webapp/WEB-INF/web.xml Sat May 30 08:10:23 2009 +0200
9.3 @@ -0,0 +1,28 @@
9.4 +<?xml version="1.0" encoding="UTF-8"?>
9.5 +<web-app version="2.5" 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">
9.6 + <display-name>webidor</display-name>
9.7 + <context-param>
9.8 + <param-name>contextConfigLocation</param-name>
9.9 + <param-value>/WEB-INF/applicationContext.xml</param-value>
9.10 + </context-param>
9.11 + <listener>
9.12 + <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
9.13 + </listener>
9.14 + <servlet>
9.15 + <servlet-name>dispatcher</servlet-name>
9.16 + <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
9.17 + <load-on-startup>2</load-on-startup>
9.18 + </servlet>
9.19 + <servlet-mapping>
9.20 + <servlet-name>dispatcher</servlet-name>
9.21 + <url-pattern>*.html</url-pattern>
9.22 + </servlet-mapping>
9.23 + <session-config>
9.24 + <session-timeout>
9.25 + 30
9.26 + </session-timeout>
9.27 + </session-config>
9.28 + <welcome-file-list>
9.29 + <welcome-file>index.jsp</welcome-file>
9.30 + </welcome-file-list>
9.31 + </web-app>
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
10.2 +++ b/webidor/src/main/webapp/index.jsp Sat May 30 08:10:23 2009 +0200
10.3 @@ -0,0 +1,13 @@
10.4 +<%@page contentType="text/html" pageEncoding="UTF-8"%>
10.5 +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
10.6 + "http://www.w3.org/TR/html4/loose.dtd">
10.7 +
10.8 +<html>
10.9 + <head>
10.10 + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
10.11 + <title>JSP Page</title>
10.12 + </head>
10.13 + <body>
10.14 + <h1>Hello World!</h1>
10.15 + </body>
10.16 +</html>
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
11.2 +++ b/webidor/src/main/webapp/redirect.jsp Sat May 30 08:10:23 2009 +0200
11.3 @@ -0,0 +1,9 @@
11.4 +<%--
11.5 +Views should be stored under the WEB-INF folder so that
11.6 +they are not accessible except through controller process.
11.7 +
11.8 +This JSP is here to provide a redirect to the dispatcher
11.9 +servlet but should be the only JSP outside of WEB-INF.
11.10 +--%>
11.11 +<%@page contentType="text/html" pageEncoding="UTF-8"%>
11.12 +<% response.sendRedirect("index.html"); %>