Picketlink SVN: r995 - in federation/trunk/picketlink-webapps: assembly and 1 other directory.
by picketlink-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2011-06-13 16:34:59 -0400 (Mon, 13 Jun 2011)
New Revision: 995
Removed:
federation/trunk/picketlink-webapps/openid-consumer/
federation/trunk/picketlink-webapps/openid-provider/
Modified:
federation/trunk/picketlink-webapps/assembly/bin.xml
federation/trunk/picketlink-webapps/pom.xml
Log:
openid webapp migration to social
Modified: federation/trunk/picketlink-webapps/assembly/bin.xml
===================================================================
--- federation/trunk/picketlink-webapps/assembly/bin.xml 2011-06-13 20:33:33 UTC (rev 994)
+++ federation/trunk/picketlink-webapps/assembly/bin.xml 2011-06-13 20:34:59 UTC (rev 995)
@@ -50,16 +50,6 @@
<fileMode>0444</fileMode>
</file>
<file>
- <source>${basedir}/../openid-consumer/target/openid-consumer.war</source>
- <outputDirectory>picketlink</outputDirectory>
- <fileMode>0444</fileMode>
- </file>
- <file>
- <source>${basedir}/../openid-provider/target/openid-provider.war</source>
- <outputDirectory>picketlink</outputDirectory>
- <fileMode>0444</fileMode>
- </file>
- <file>
<source>${basedir}/../pdp/target/pdp.war</source>
<outputDirectory>picketlink</outputDirectory>
<fileMode>0444</fileMode>
Modified: federation/trunk/picketlink-webapps/pom.xml
===================================================================
--- federation/trunk/picketlink-webapps/pom.xml 2011-06-13 20:33:33 UTC (rev 994)
+++ federation/trunk/picketlink-webapps/pom.xml 2011-06-13 20:34:59 UTC (rev 995)
@@ -39,8 +39,6 @@
<module>idp-sig-no-val</module>
<module>idp-standalone</module>
<module>metadata</module>
- <module>openid-provider</module>
- <module>openid-consumer</module>
<module>picketlink-sts</module>
<module>pdp</module>
<!--
13 years, 6 months
Picketlink SVN: r994 - in social/trunk: webapps and 6 other directories.
by picketlink-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2011-06-13 16:33:33 -0400 (Mon, 13 Jun 2011)
New Revision: 994
Added:
social/trunk/webapps/
social/trunk/webapps/openid-consumer/
social/trunk/webapps/openid-consumer/pom.xml
social/trunk/webapps/openid-consumer/resources/
social/trunk/webapps/openid-consumer/resources/META-INF/
social/trunk/webapps/openid-consumer/resources/WEB-INF/
social/trunk/webapps/openid-consumer/resources/WEB-INF/web.xml
social/trunk/webapps/openid-consumer/resources/consumer_return.jsp
social/trunk/webapps/openid-consumer/resources/formredirection.jsp
social/trunk/webapps/openid-consumer/resources/index.jsp
social/trunk/webapps/openid-provider/
social/trunk/webapps/openid-provider/pom.xml
social/trunk/webapps/openid-provider/resources/
social/trunk/webapps/openid-provider/resources/META-INF/
social/trunk/webapps/openid-provider/resources/WEB-INF/
social/trunk/webapps/openid-provider/resources/WEB-INF/web.xml
social/trunk/webapps/openid-provider/resources/index.jsp
social/trunk/webapps/openid-provider/resources/login-error.jsp
social/trunk/webapps/openid-provider/resources/login.jsp
social/trunk/webapps/openid-provider/resources/securepage.jsp
social/trunk/webapps/pom.xml
Log:
openid webapps
Added: social/trunk/webapps/openid-consumer/pom.xml
===================================================================
--- social/trunk/webapps/openid-consumer/pom.xml (rev 0)
+++ social/trunk/webapps/openid-consumer/pom.xml 2011-06-13 20:33:33 UTC (rev 994)
@@ -0,0 +1,39 @@
+<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">
+ <parent>
+ <groupId>org.picketlink</groupId>
+ <artifactId>picketlink-social-webapps</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ <relativePath>../</relativePath>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>openid-consumer</artifactId>
+ <packaging>war</packaging>
+ <name>PicketLink Federation OpenID Consumer</name>
+ <url>http://labs.jboss.org/portal/picketlink/</url>
+ <description>PicketLink Samples contains the samples for Federated Identity Needs.</description>
+ <licenses>
+ <license>
+ <name>lgpl</name>
+ <url>http://repository.jboss.com/licenses/lgpl.txt</url>
+ </license>
+ </licenses>
+ <organization>
+ <name>JBoss Inc.</name>
+ <url>http://www.jboss.org</url>
+ </organization>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-war-plugin</artifactId>
+ <version>2.0.2</version>
+ <configuration>
+ <warName>openid-consumer</warName>
+ <webappDirectory>${basedir}/resources/</webappDirectory>
+ <warSourceExcludes>WEB-INF/lib/*.jar</warSourceExcludes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Property changes on: social/trunk/webapps/openid-consumer/pom.xml
___________________________________________________________________
Added: svn:executable
+ *
Added: social/trunk/webapps/openid-consumer/resources/WEB-INF/web.xml
===================================================================
--- social/trunk/webapps/openid-consumer/resources/WEB-INF/web.xml (rev 0)
+++ social/trunk/webapps/openid-consumer/resources/WEB-INF/web.xml 2011-06-13 20:33:33 UTC (rev 994)
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<web-app xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:c="http://java.sun.com/jsp/jstl/core"
+ xmlns:fmt="http://java.sun.com/jsp/jstl/fmt"
+ 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">
+
+ <display-name>OpenID Consumer Application</display-name>
+ <description>
+ This is the consumer application for OpenID.
+ </description>
+ <servlet>
+ <servlet-name>ConsumerServlet</servlet-name>
+ <servlet-class>org.picketlink.social.servlets.OpenIDConsumerServlet</servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>ConsumerServlet</servlet-name>
+ <url-pattern>/consumer/*</url-pattern>
+ </servlet-mapping>
+</web-app>
Property changes on: social/trunk/webapps/openid-consumer/resources/WEB-INF/web.xml
___________________________________________________________________
Added: svn:executable
+ *
Added: social/trunk/webapps/openid-consumer/resources/consumer_return.jsp
===================================================================
--- social/trunk/webapps/openid-consumer/resources/consumer_return.jsp (rev 0)
+++ social/trunk/webapps/openid-consumer/resources/consumer_return.jsp 2011-06-13 20:33:33 UTC (rev 994)
@@ -0,0 +1,32 @@
+<%@ page session="true" %>
+<%@ page import="org.picketlink.social.openid.api.*, org.picketlink.social.openid.web.*" %>
+
+<html>
+<body>
+
+
+<%
+ // extract the receiving URL from the HTTP request
+ StringBuffer receivingURL = request.getRequestURL();
+ String queryString = request.getQueryString();
+ if (queryString != null && queryString.length() > 0)
+ receivingURL.append("?").append(request.getQueryString());
+
+ OpenIDManager manager = (OpenIDManager)session.getAttribute("openid_manager");
+
+ HTTPProtocolAdaptor adapter = new HTTPProtocolAdaptor(new HTTPOpenIDContext(request,response,application));
+ boolean auth = manager.verify(adapter, request.getParameterMap(), receivingURL.toString());
+%>
+
+<%
+ if(auth)
+ {
+ out.println("Should have redirected to index page as we are authenticated successfully");
+ }
+ else
+ {
+%>
+ Not Logged In!!!
+<%}%>
+</body>
+</html>
Property changes on: social/trunk/webapps/openid-consumer/resources/consumer_return.jsp
___________________________________________________________________
Added: svn:executable
+ *
Added: social/trunk/webapps/openid-consumer/resources/formredirection.jsp
===================================================================
--- social/trunk/webapps/openid-consumer/resources/formredirection.jsp (rev 0)
+++ social/trunk/webapps/openid-consumer/resources/formredirection.jsp 2011-06-13 20:33:33 UTC (rev 994)
@@ -0,0 +1,16 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <title>OpenID HTML FORM Redirection</title>
+</head>
+<body onload="document.forms['openid-form-redirection'].submit();">
+ <form name="openid-form-redirection" action="${destinationUrl}" method="post" accept-charset="utf-8">
+ <c:forEach var="parameter" items="${parameterMap}">
+ <input type="hidden" name="${parameter.key}" value="${parameter.value}"/>
+ </c:forEach>
+ <button type="submit">Continue...</button>
+ </form>
+</body>
+</html>
Property changes on: social/trunk/webapps/openid-consumer/resources/formredirection.jsp
___________________________________________________________________
Added: svn:executable
+ *
Added: social/trunk/webapps/openid-consumer/resources/index.jsp
===================================================================
--- social/trunk/webapps/openid-consumer/resources/index.jsp (rev 0)
+++ social/trunk/webapps/openid-consumer/resources/index.jsp 2011-06-13 20:33:33 UTC (rev 994)
@@ -0,0 +1,42 @@
+<%@ page session="true" %>
+
+<%@ page import="org.picketlink.social.openid.api.OpenIDManager,org.picketlink.social.openid.web.HTTPProtocolAdaptor, org.picketlink.identity.social.openid.web.HTTPOpenIDContext" %>
+<html>
+<body>
+
+<%
+ String baseURL = "http://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath();
+ //Correct the return url if needed
+ String returnURL = baseURL + "/consumer_return.jsp";
+%>
+
+<%
+ OpenIDManager manager = (OpenIDManager)session.getAttribute("openid_manager");
+
+ if (request.getParameter("logout")!=null)
+ {
+ HTTPProtocolAdaptor adapter = new HTTPProtocolAdaptor(new HTTPOpenIDContext(request,response, application));
+ manager.logout(adapter);
+%>
+ Logged out!<p>
+ <%
+ }
+
+ if (session.getAttribute("openid")==null) {
+ %>
+ <form method="POST" action="<%=baseURL%>/consumer/">
+ <strong>OpenID:</strong>
+ <input type="text" name="openid" size="60"/><br>
+ <input type="submit"/>
+ </form>
+ <%
+ } else {
+
+ %>
+
+ Logged in as <%= session.getAttribute("openid") %><p>
+ <a href="?logout=true">Log out</a>
+
+ <% } %>
+</body>
+</html>
Property changes on: social/trunk/webapps/openid-consumer/resources/index.jsp
___________________________________________________________________
Added: svn:executable
+ *
Added: social/trunk/webapps/openid-provider/pom.xml
===================================================================
--- social/trunk/webapps/openid-provider/pom.xml (rev 0)
+++ social/trunk/webapps/openid-provider/pom.xml 2011-06-13 20:33:33 UTC (rev 994)
@@ -0,0 +1,39 @@
+<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">
+ <parent>
+ <groupId>org.picketlink</groupId>
+ <artifactId>picketlink-social-webapps</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ <relativePath>../</relativePath>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>openid-provider</artifactId>
+ <packaging>war</packaging>
+ <name>PicketLink Federation OpenID Provider</name>
+ <url>http://labs.jboss.org/portal/picketlink/</url>
+ <description>PicketLink Samples contains the samples for Federated Identity Needs.</description>
+ <licenses>
+ <license>
+ <name>lgpl</name>
+ <url>http://repository.jboss.com/licenses/lgpl.txt</url>
+ </license>
+ </licenses>
+ <organization>
+ <name>JBoss Inc.</name>
+ <url>http://www.jboss.org</url>
+ </organization>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-war-plugin</artifactId>
+ <version>2.0.2</version>
+ <configuration>
+ <warName>openid-provider</warName>
+ <webappDirectory>${basedir}/resources/</webappDirectory>
+ <warSourceExcludes>WEB-INF/lib/*.jar</warSourceExcludes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Property changes on: social/trunk/webapps/openid-provider/pom.xml
___________________________________________________________________
Added: svn:executable
+ *
Added: social/trunk/webapps/openid-provider/resources/WEB-INF/web.xml
===================================================================
--- social/trunk/webapps/openid-provider/resources/WEB-INF/web.xml (rev 0)
+++ social/trunk/webapps/openid-provider/resources/WEB-INF/web.xml 2011-06-13 20:33:33 UTC (rev 994)
@@ -0,0 +1,51 @@
+<?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">
+
+ <display-name>OpenID Provider Application</display-name>
+ <description>
+ This is the provider application for OpenID.
+ </description>
+
+ <servlet>
+ <servlet-name>ProviderServlet</servlet-name>
+ <servlet-class>org.picketlink.social.servlets.OpenIDProviderServlet</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>ProviderServlet</servlet-name>
+ <url-pattern>/provider/*</url-pattern>
+ </servlet-mapping>
+
+ <security-constraint>
+ <display-name>Secure Page</display-name>
+ <web-resource-collection>
+ <web-resource-name>SecurePage</web-resource-name>
+ <url-pattern>/securepage.jsp</url-pattern>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>user</role-name>
+ </auth-constraint>
+ <user-data-constraint>
+ <transport-guarantee>NONE</transport-guarantee>
+ </user-data-constraint>
+ </security-constraint>
+
+ <!-- Define the Login Configuration for this Application -->
+ <login-config>
+ <auth-method>FORM</auth-method>
+ <realm-name>OpenID Provider</realm-name>
+ <form-login-config>
+ <form-login-page>/login.jsp</form-login-page>
+ <form-error-page>/loginerror.jsp</form-error-page>
+ </form-login-config>
+ </login-config>
+
+
+ <security-role>
+ <role-name>user</role-name>
+ </security-role>
+
+</web-app>
Property changes on: social/trunk/webapps/openid-provider/resources/WEB-INF/web.xml
___________________________________________________________________
Added: svn:executable
+ *
Added: social/trunk/webapps/openid-provider/resources/index.jsp
===================================================================
--- social/trunk/webapps/openid-provider/resources/index.jsp (rev 0)
+++ social/trunk/webapps/openid-provider/resources/index.jsp 2011-06-13 20:33:33 UTC (rev 994)
@@ -0,0 +1,18 @@
+<%@ page contentType="application/xrds+xml"%><?xml version="1.0" encoding="UTF-8"?>
+<xrds:XRDS
+ xmlns:xrds="xri://$xrds"
+ xmlns:openid="http://openid.net/xmlns/1.0"
+ xmlns="xri://$xrd*($v*2.0)">
+ <XRD>
+ <!-- Change the URI for OpenID2 pointing to where the provider is located -->
+ <Service priority="0">
+ <Type>http://specs.openid.net/auth/2.0</Type>
+ <URI>http://localhost:8080/openid-provider/provider/</URI>
+ </Service>
+ <!-- Change the URI for OpenID1 pointing to where the provider is located -->
+ <Service priority="1">
+ <Type>http://openid.net/signon/1.0</Type>
+ <URI>http://localhost:8080/openid-provider/provider/</URI>
+ </Service>
+ </XRD>
+</xrds:XRDS>
Property changes on: social/trunk/webapps/openid-provider/resources/index.jsp
___________________________________________________________________
Added: svn:executable
+ *
Added: social/trunk/webapps/openid-provider/resources/login-error.jsp
===================================================================
--- social/trunk/webapps/openid-provider/resources/login-error.jsp (rev 0)
+++ social/trunk/webapps/openid-provider/resources/login-error.jsp 2011-06-13 20:33:33 UTC (rev 994)
@@ -0,0 +1,6 @@
+<html><head><title>Login Page</title></head>
+<body>
+<font size='5' color='blue'>Login Error</font><hr>
+
+</body>
+ </html>
Property changes on: social/trunk/webapps/openid-provider/resources/login-error.jsp
___________________________________________________________________
Added: svn:executable
+ *
Added: social/trunk/webapps/openid-provider/resources/login.jsp
===================================================================
--- social/trunk/webapps/openid-provider/resources/login.jsp (rev 0)
+++ social/trunk/webapps/openid-provider/resources/login.jsp 2011-06-13 20:33:33 UTC (rev 994)
@@ -0,0 +1,16 @@
+<html><head><title>Login Page</title></head>
+<body>
+<font size='5' color='blue'>Please Login</font><hr>
+
+<form action='j_security_check' method='post'>
+<table>
+ <tr><td>Name:</td>
+ <td><input type='text' name='j_username'></td></tr>
+ <tr><td>Password:</td>
+ <td><input type='password' name='j_password' size='8'></td>
+ </tr>
+</table>
+<br>
+ <input type='submit' value='login'>
+</form></body>
+ </html>
Property changes on: social/trunk/webapps/openid-provider/resources/login.jsp
___________________________________________________________________
Added: svn:executable
+ *
Added: social/trunk/webapps/openid-provider/resources/securepage.jsp
===================================================================
--- social/trunk/webapps/openid-provider/resources/securepage.jsp (rev 0)
+++ social/trunk/webapps/openid-provider/resources/securepage.jsp 2011-06-13 20:33:33 UTC (rev 994)
@@ -0,0 +1,10 @@
+<%
+ session.setAttribute("authenticatedAndApproved", Boolean.TRUE);
+%>
+
+
+You have logged in.
+
+<form method="POST" action="<%=request.getContextPath()%>/provider/?_action=complete">
+<input type="submit" value="Continue"/>
+</form>
Property changes on: social/trunk/webapps/openid-provider/resources/securepage.jsp
___________________________________________________________________
Added: svn:executable
+ *
Added: social/trunk/webapps/pom.xml
===================================================================
--- social/trunk/webapps/pom.xml (rev 0)
+++ social/trunk/webapps/pom.xml 2011-06-13 20:33:33 UTC (rev 994)
@@ -0,0 +1,29 @@
+<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">
+ <parent>
+ <groupId>org.picketlink</groupId>
+ <artifactId>picketlink-social-parent</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ <relativePath>../parent</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>picketlink-social-webapps</artifactId>
+ <packaging>pom</packaging>
+ <name>PicketLink Social Web Applications</name>
+ <url>http://labs.jboss.org/portal/jbosssecurity/</url>
+ <description>PicketLink Web Applications contains the web
+ applications for Federated Identity Needs.</description>
+ <licenses>
+ <license>
+ <name>lgpl</name>
+ <url>http://repository.jboss.com/licenses/lgpl.txt</url>
+ </license>
+ </licenses>
+ <organization>
+ <name>JBoss Inc.</name>
+ <url>http://www.jboss.org</url>
+ </organization>
+ <modules>
+ <module>openid-provider</module>
+ <module>openid-consumer</module>
+ </modules>
+</project>
Property changes on: social/trunk/webapps/pom.xml
___________________________________________________________________
Added: svn:executable
+ *
13 years, 6 months
Picketlink SVN: r993 - in social/trunk: facebook and 12 other directories.
by picketlink-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2011-06-13 16:23:03 -0400 (Mon, 13 Jun 2011)
New Revision: 993
Modified:
social/trunk/
social/trunk/facebook/
social/trunk/facebook/src/
social/trunk/facebook/src/main/
social/trunk/facebook/src/main/java/
social/trunk/facebook/src/main/java/org/
social/trunk/facebook/src/main/java/org/picketlink/
social/trunk/facebook/src/main/java/org/picketlink/social/
social/trunk/facebook/src/main/java/org/picketlink/social/facebook/
social/trunk/facebook/src/main/resources/
social/trunk/facebook/src/test/
social/trunk/facebook/src/test/java/
social/trunk/facebook/src/test/resources/
social/trunk/parent/
Log:
set svn ig
Property changes on: social/trunk
___________________________________________________________________
Added: svn:ignore
+ .settings
target
target-eclipse
eclipse-target
.project
.classpath
.settings
.metadata
Property changes on: social/trunk/facebook
___________________________________________________________________
Added: svn:ignore
+ .settings
target
target-eclipse
eclipse-target
.project
.classpath
.settings
.metadata
Property changes on: social/trunk/facebook/src
___________________________________________________________________
Added: svn:ignore
+ .settings
target
target-eclipse
eclipse-target
.project
.classpath
.settings
.metadata
Property changes on: social/trunk/facebook/src/main
___________________________________________________________________
Added: svn:ignore
+ .settings
target
target-eclipse
eclipse-target
.project
.classpath
.settings
.metadata
Property changes on: social/trunk/facebook/src/main/java
___________________________________________________________________
Added: svn:ignore
+ .settings
target
target-eclipse
eclipse-target
.project
.classpath
.settings
.metadata
Property changes on: social/trunk/facebook/src/main/java/org
___________________________________________________________________
Added: svn:ignore
+ .settings
target
target-eclipse
eclipse-target
.project
.classpath
.settings
.metadata
Property changes on: social/trunk/facebook/src/main/java/org/picketlink
___________________________________________________________________
Added: svn:ignore
+ .settings
target
target-eclipse
eclipse-target
.project
.classpath
.settings
.metadata
Property changes on: social/trunk/facebook/src/main/java/org/picketlink/social
___________________________________________________________________
Added: svn:ignore
+ .settings
target
target-eclipse
eclipse-target
.project
.classpath
.settings
.metadata
Property changes on: social/trunk/facebook/src/main/java/org/picketlink/social/facebook
___________________________________________________________________
Added: svn:ignore
+ .settings
target
target-eclipse
eclipse-target
.project
.classpath
.settings
.metadata
Property changes on: social/trunk/facebook/src/main/resources
___________________________________________________________________
Added: svn:ignore
+ .settings
target
target-eclipse
eclipse-target
.project
.classpath
.settings
.metadata
Property changes on: social/trunk/facebook/src/test
___________________________________________________________________
Added: svn:ignore
+ .settings
target
target-eclipse
eclipse-target
.project
.classpath
.settings
.metadata
Property changes on: social/trunk/facebook/src/test/java
___________________________________________________________________
Added: svn:ignore
+ .settings
target
target-eclipse
eclipse-target
.project
.classpath
.settings
.metadata
Property changes on: social/trunk/facebook/src/test/resources
___________________________________________________________________
Added: svn:ignore
+ .settings
target
target-eclipse
eclipse-target
.project
.classpath
.settings
.metadata
Property changes on: social/trunk/parent
___________________________________________________________________
Added: svn:ignore
+ .settings
target
target-eclipse
eclipse-target
.project
.classpath
.settings
.metadata
13 years, 6 months
Picketlink SVN: r992 - in social/trunk/openid: src and 26 other directories.
by picketlink-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2011-06-13 16:15:18 -0400 (Mon, 13 Jun 2011)
New Revision: 992
Modified:
social/trunk/openid/
social/trunk/openid/src/
social/trunk/openid/src/main/
social/trunk/openid/src/main/java/
social/trunk/openid/src/main/java/org/
social/trunk/openid/src/main/java/org/picketlink/
social/trunk/openid/src/main/java/org/picketlink/social/
social/trunk/openid/src/main/java/org/picketlink/social/openid/
social/trunk/openid/src/main/java/org/picketlink/social/openid/api/
social/trunk/openid/src/main/java/org/picketlink/social/openid/api/exceptions/
social/trunk/openid/src/main/java/org/picketlink/social/openid/providers/
social/trunk/openid/src/main/java/org/picketlink/social/openid/providers/helpers/
social/trunk/openid/src/main/java/org/picketlink/social/openid/servlets/
social/trunk/openid/src/main/java/org/picketlink/social/openid/web/
social/trunk/openid/src/main/resources/
social/trunk/openid/src/test/
social/trunk/openid/src/test/java/
social/trunk/openid/src/test/java/org/
social/trunk/openid/src/test/java/org/picketlink/
social/trunk/openid/src/test/java/org/picketlink/test/
social/trunk/openid/src/test/java/org/picketlink/test/social/
social/trunk/openid/src/test/java/org/picketlink/test/social/openid/
social/trunk/openid/src/test/java/org/picketlink/test/social/openid/integration/
social/trunk/openid/src/test/java/org/picketlink/test/social/openid/workflow/
social/trunk/openid/src/test/resources/
social/trunk/openid/src/test/resources/endorsed/
social/trunk/openid/src/test/resources/openid/
social/trunk/openid/src/test/resources/openid/webapp/
Log:
set svn ig
Property changes on: social/trunk/openid
___________________________________________________________________
Added: svn:ignore
+ .settings
target
target-eclipse
eclipse-target
.project
.classpath
.settings
.metadata
Property changes on: social/trunk/openid/src
___________________________________________________________________
Added: svn:ignore
+ .settings
target
target-eclipse
eclipse-target
.project
.classpath
.settings
.metadata
Property changes on: social/trunk/openid/src/main
___________________________________________________________________
Added: svn:ignore
+ .settings
target
target-eclipse
eclipse-target
.project
.classpath
.settings
.metadata
Property changes on: social/trunk/openid/src/main/java
___________________________________________________________________
Added: svn:ignore
+ .settings
target
target-eclipse
eclipse-target
.project
.classpath
.settings
.metadata
Property changes on: social/trunk/openid/src/main/java/org
___________________________________________________________________
Added: svn:ignore
+ .settings
target
target-eclipse
eclipse-target
.project
.classpath
.settings
.metadata
Property changes on: social/trunk/openid/src/main/java/org/picketlink
___________________________________________________________________
Added: svn:ignore
+ .settings
target
target-eclipse
eclipse-target
.project
.classpath
.settings
.metadata
Property changes on: social/trunk/openid/src/main/java/org/picketlink/social
___________________________________________________________________
Added: svn:ignore
+ .settings
target
target-eclipse
eclipse-target
.project
.classpath
.settings
.metadata
Property changes on: social/trunk/openid/src/main/java/org/picketlink/social/openid
___________________________________________________________________
Added: svn:ignore
+ .settings
target
target-eclipse
eclipse-target
.project
.classpath
.settings
.metadata
Property changes on: social/trunk/openid/src/main/java/org/picketlink/social/openid/api
___________________________________________________________________
Added: svn:ignore
+ .settings
target
target-eclipse
eclipse-target
.project
.classpath
.settings
.metadata
Property changes on: social/trunk/openid/src/main/java/org/picketlink/social/openid/api/exceptions
___________________________________________________________________
Added: svn:ignore
+ .settings
target
target-eclipse
eclipse-target
.project
.classpath
.settings
.metadata
Property changes on: social/trunk/openid/src/main/java/org/picketlink/social/openid/providers
___________________________________________________________________
Added: svn:ignore
+ .settings
target
target-eclipse
eclipse-target
.project
.classpath
.settings
.metadata
Property changes on: social/trunk/openid/src/main/java/org/picketlink/social/openid/providers/helpers
___________________________________________________________________
Added: svn:ignore
+ .settings
target
target-eclipse
eclipse-target
.project
.classpath
.settings
.metadata
Property changes on: social/trunk/openid/src/main/java/org/picketlink/social/openid/servlets
___________________________________________________________________
Added: svn:ignore
+ .settings
target
target-eclipse
eclipse-target
.project
.classpath
.settings
.metadata
Property changes on: social/trunk/openid/src/main/java/org/picketlink/social/openid/web
___________________________________________________________________
Added: svn:ignore
+ .settings
target
target-eclipse
eclipse-target
.project
.classpath
.settings
.metadata
Property changes on: social/trunk/openid/src/main/resources
___________________________________________________________________
Added: svn:ignore
+ .settings
target
target-eclipse
eclipse-target
.project
.classpath
.settings
.metadata
Property changes on: social/trunk/openid/src/test
___________________________________________________________________
Added: svn:ignore
+ .settings
target
target-eclipse
eclipse-target
.project
.classpath
.settings
.metadata
Property changes on: social/trunk/openid/src/test/java
___________________________________________________________________
Added: svn:ignore
+ .settings
target
target-eclipse
eclipse-target
.project
.classpath
.settings
.metadata
Property changes on: social/trunk/openid/src/test/java/org
___________________________________________________________________
Added: svn:ignore
+ .settings
target
target-eclipse
eclipse-target
.project
.classpath
.settings
.metadata
Property changes on: social/trunk/openid/src/test/java/org/picketlink
___________________________________________________________________
Added: svn:ignore
+ .settings
target
target-eclipse
eclipse-target
.project
.classpath
.settings
.metadata
Property changes on: social/trunk/openid/src/test/java/org/picketlink/test
___________________________________________________________________
Added: svn:ignore
+ .settings
target
target-eclipse
eclipse-target
.project
.classpath
.settings
.metadata
Property changes on: social/trunk/openid/src/test/java/org/picketlink/test/social
___________________________________________________________________
Added: svn:ignore
+ .settings
target
target-eclipse
eclipse-target
.project
.classpath
.settings
.metadata
Property changes on: social/trunk/openid/src/test/java/org/picketlink/test/social/openid
___________________________________________________________________
Added: svn:ignore
+ .settings
target
target-eclipse
eclipse-target
.project
.classpath
.settings
.metadata
Property changes on: social/trunk/openid/src/test/java/org/picketlink/test/social/openid/integration
___________________________________________________________________
Added: svn:ignore
+ .settings
target
target-eclipse
eclipse-target
.project
.classpath
.settings
.metadata
Property changes on: social/trunk/openid/src/test/java/org/picketlink/test/social/openid/workflow
___________________________________________________________________
Added: svn:ignore
+ .settings
target
target-eclipse
eclipse-target
.project
.classpath
.settings
.metadata
Property changes on: social/trunk/openid/src/test/resources
___________________________________________________________________
Added: svn:ignore
+ .settings
target
target-eclipse
eclipse-target
.project
.classpath
.settings
.metadata
Property changes on: social/trunk/openid/src/test/resources/endorsed
___________________________________________________________________
Added: svn:ignore
+ .settings
target
target-eclipse
eclipse-target
.project
.classpath
.settings
.metadata
Property changes on: social/trunk/openid/src/test/resources/openid
___________________________________________________________________
Added: svn:ignore
+ .settings
target
target-eclipse
eclipse-target
.project
.classpath
.settings
.metadata
Property changes on: social/trunk/openid/src/test/resources/openid/webapp
___________________________________________________________________
Added: svn:ignore
+ .settings
target
target-eclipse
eclipse-target
.project
.classpath
.settings
.metadata
13 years, 6 months
Picketlink SVN: r991 - in federation/trunk: picketlink-fed-api/src/main/java/org/picketlink/identity/federation/api and 8 other directories.
by picketlink-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2011-06-13 16:07:13 -0400 (Mon, 13 Jun 2011)
New Revision: 991
Removed:
federation/trunk/picketlink-fed-api/src/main/java/org/picketlink/identity/federation/api/openid/
federation/trunk/picketlink-fed-api/src/main/java/org/picketlink/identity/federation/core/
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/openid/
federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/openid/
federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/servlets/OpenIDConsumerServlet.java
federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/servlets/OpenIDProviderServlet.java
federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/servlets/OpenIDYadisServlet.java
federation/trunk/picketlink-web/src/test/java/org/picketlink/test/identity/federation/web/integration/LocalProviderOpenIDUnitTestCase.java
federation/trunk/picketlink-web/src/test/java/org/picketlink/test/identity/federation/web/integration/YadisMetadataUnitTestCase.java
federation/trunk/picketlink-web/src/test/java/org/picketlink/test/identity/federation/web/openid/
federation/trunk/picketlink-web/src/test/java/org/picketlink/test/identity/federation/web/workflow/openid/
federation/trunk/picketlink-web/src/test/resources/openid/
Modified:
federation/trunk/picketlink-fed-core/src/main/resources/core-sts.xml
Log:
openid code migration to PicketLink social project
Modified: federation/trunk/picketlink-fed-core/src/main/resources/core-sts.xml
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/resources/core-sts.xml 2011-06-13 20:06:16 UTC (rev 990)
+++ federation/trunk/picketlink-fed-core/src/main/resources/core-sts.xml 2011-06-13 20:07:13 UTC (rev 991)
@@ -5,8 +5,8 @@
TokenType="urn:oasis:names:tc:SAML:2.0:assertion"
TokenElement="Assertion"
TokenElementNS="urn:oasis:names:tc:SAML:2.0:assertion"/>
- <TokenProvider ProviderClass="org.picketlink.identity.federation.core.openid.providers.OpenIDTokenProvider"
+ <!--<TokenProvider ProviderClass="org.picketlink.identity.federation.core.openid.providers.OpenIDTokenProvider"
TokenType="urn:openid:1:0"
TokenElementNS="urn:openid:1:0"/>
- </TokenProviders>
+ --></TokenProviders>
</PicketLinkSTS>
\ No newline at end of file
Deleted: federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/servlets/OpenIDConsumerServlet.java
===================================================================
--- federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/servlets/OpenIDConsumerServlet.java 2011-06-13 20:06:16 UTC (rev 990)
+++ federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/servlets/OpenIDConsumerServlet.java 2011-06-13 20:07:13 UTC (rev 991)
@@ -1,100 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.picketlink.identity.federation.web.servlets;
-
-import java.io.IOException;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
-
-import org.picketlink.identity.federation.api.openid.OpenIDManager;
-import org.picketlink.identity.federation.api.openid.OpenIDRequest;
-import org.picketlink.identity.federation.api.openid.OpenIDManager.OpenIDProviderInformation;
-import org.picketlink.identity.federation.api.openid.OpenIDManager.OpenIDProviderList;
-import org.picketlink.identity.federation.api.openid.exceptions.OpenIDGeneralException;
-import org.picketlink.identity.federation.web.openid.HTTPOpenIDContext;
-import org.picketlink.identity.federation.web.openid.HTTPProtocolAdaptor;
-
-/**
- * OpenID Consumer Servlet that gets a post
- * request from the main JSP page of the consumer
- * web application.
- * @author Anil.Saldhana(a)redhat.com
- * @since Jul 10, 2009
- */
-public class OpenIDConsumerServlet extends HttpServlet
-{
- private static final long serialVersionUID = 1L;
-
- private transient ServletContext servletContext;
- private String returnURL;
-
- @Override
- public void init(ServletConfig config) throws ServletException
- {
- super.init(config);
- this.servletContext = config.getServletContext();
- returnURL = this.servletContext.getInitParameter("returnURL");
- }
-
- @Override
- protected void doPost(HttpServletRequest req, HttpServletResponse resp)
- throws ServletException, IOException
- {
- if(returnURL == null)
- returnURL = "http://" + req.getServerName() + ":" + req.getServerPort() +
- req.getContextPath() + "/consumer_return.jsp";
-
- String userEntry = req.getParameter("openid");
- OpenIDRequest openIDReq = new OpenIDRequest(userEntry);
-
- HttpSession session = req.getSession();
- OpenIDManager manager = (OpenIDManager) session.getAttribute("openid_manager");
- if(manager == null)
- {
- manager = new OpenIDManager(openIDReq);
- session.setAttribute("openid_manager", manager);
- }
- manager.setUserString( userEntry );
-
- try
- {
- OpenIDProviderList listOfProviders = manager.discoverProviders();
- HTTPOpenIDContext httpOpenIDCtx = new HTTPOpenIDContext(req,resp, this.servletContext);
- httpOpenIDCtx.setReturnURL(returnURL);
-
- HTTPProtocolAdaptor adapter = new HTTPProtocolAdaptor(httpOpenIDCtx);
- OpenIDProviderInformation providerInfo = manager.associate(adapter, listOfProviders);
- manager.authenticate(adapter, providerInfo);
- }
- catch (OpenIDGeneralException e)
- {
- log("[OpenIDConsumerServlet]Exception in dealing with the provider:",e);
- resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
- }
- }
-}
\ No newline at end of file
Deleted: federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/servlets/OpenIDProviderServlet.java
===================================================================
--- federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/servlets/OpenIDProviderServlet.java 2011-06-13 20:06:16 UTC (rev 990)
+++ federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/servlets/OpenIDProviderServlet.java 2011-06-13 20:07:13 UTC (rev 991)
@@ -1,240 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.picketlink.identity.federation.web.servlets;
-
-import java.io.IOException;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
-
-import org.openid4java.message.Parameter;
-import org.picketlink.identity.federation.core.exceptions.ProcessingException;
-import org.picketlink.identity.federation.core.openid.providers.helpers.OpenIDParameterList;
-import org.picketlink.identity.federation.core.openid.providers.helpers.OpenIDProtocolContext;
-import org.picketlink.identity.federation.core.openid.providers.helpers.OpenIDProtocolContext.AUTH_HOLDER;
-import org.picketlink.identity.federation.core.openid.providers.helpers.OpenIDProtocolContext.MODE;
-import org.picketlink.identity.federation.core.openid.providers.helpers.OpenIDProviderManager.OpenIDMessage;
-import org.picketlink.identity.federation.core.sts.PicketLinkCoreSTS;
-
-/**
- * Servlet that provides the Provider functionality
- * for OpenID
- * @author Anil.Saldhana(a)redhat.com
- * @since Jul 15, 2009
- */
-public class OpenIDProviderServlet extends HttpServlet
-{
- private static final long serialVersionUID = 1L;
- private transient ServletContext servletContext = null;
- private String securePageName = "securepage.jsp";
-
- private transient PicketLinkCoreSTS sts = PicketLinkCoreSTS.instance();
-
- @Override
- public void init(ServletConfig config) throws ServletException
- {
- super.init(config);
- this.servletContext = config.getServletContext();
- String secpageStr = this.servletContext.getInitParameter("securePage");
- if(secpageStr != null && secpageStr.length() > 0)
- securePageName = secpageStr;
-
- sts.installDefaultConfiguration( ( String[] )null );
- }
-
- @Override
- protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
- {
- doPost(request, response);
- }
-
- @Override
- protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
- {
- HttpSession session = request.getSession();
-
- OpenIDProtocolContext protoCtx = new OpenIDProtocolContext();
-
- protoCtx.setEndpoint(request.getScheme() + "://" +
- request.getServerName() + ":" +
- request.getServerPort() +
- request.getContextPath() +
- "/provider/");
-
- OpenIDParameterList requestp;
-
- if ("complete".equals(request.getParameter("_action"))) // Completing the authz and authn process by redirecting here
- {
- requestp=(OpenIDParameterList) session.getAttribute("parameterlist"); // On a redirect from the OP authn & authz sequence
- }
- else
- {
- requestp = new OpenIDParameterList(request.getParameterMap());
- Parameter openidIdentity = requestp.getParameter("openid.identity");
- if( openidIdentity != null )
- {
- session.setAttribute("openid.identity", openidIdentity.getValue());
- }
- else
- {
- log( "The Parameter openid.identity is null " );
- }
- }
-
- protoCtx.setRequestParameterList( requestp );
-
-
- String mode = requestp.hasParameter("openid.mode") ?
- requestp.getParameterValue("openid.mode") : null;
-
- OpenIDMessage responsem = null;
- String responseText = null;
-
- log("mode=" + mode + "::ParameterMap:" + requestp);
-
- if ("associate".equals(mode))
- {
- protoCtx.setMode( MODE.ASSOCIATE );
- try
- {
- sts.issueToken( protoCtx );
- }
- catch (ProcessingException e)
- {
- throw new ServletException( e );
- }
-
- responsem = protoCtx.getResponseMessage();
-
- // --- process an association request ---
- responseText = responsem.getResponseText();
- }
- else if ("checkid_setup".equals(mode)
- || "checkid_immediate".equals(mode))
- {
- // interact with the user and obtain data needed to continue
- //List userData = userInteraction(requestp);
- String userSelectedId = null;
- String userSelectedClaimedId = null;
- Boolean authenticatedAndApproved = Boolean.FALSE;
-
- if ((session.getAttribute("authenticatedAndApproved") == null) ||
- (((Boolean)session.getAttribute("authenticatedAndApproved")) == Boolean.FALSE) )
- {
- session.setAttribute("parameterlist", requestp);
- response.setContentType("text/html" );
- response.sendRedirect( request.getContextPath() + "/" + this.securePageName);
- return;
- }
- else
- {
- userSelectedId = (String) session.getAttribute("openid.claimed_id");
- userSelectedClaimedId = (String) session.getAttribute("openid.identity");
- authenticatedAndApproved = (Boolean) session.getAttribute("authenticatedAndApproved");
- // Remove the parameterlist so this provider can accept requests from elsewhere
- session.removeAttribute("parameterlist");
- session.setAttribute("authenticatedAndApproved", Boolean.FALSE); // Makes you authorize each and every time
-
-
- //Fallback
- if( authenticatedAndApproved == Boolean.TRUE && userSelectedId == null )
- {
- userSelectedId = userSelectedClaimedId;
- }
- if( "checkid_setup".equals(mode) )
- protoCtx.setMode( MODE.CHECK_ID_SETUP );
- else
- protoCtx.setMode( MODE.CHECK_ID_IMMEDIATE );
-
- protoCtx.setAuthenticationHolder( new AUTH_HOLDER(userSelectedId,
- userSelectedClaimedId, authenticatedAndApproved));
-
- try
- {
- // --- process an authentication request ---
- sts.issueToken(protoCtx);
- }
- catch (ProcessingException e)
- {
- throw new ServletException( e );
- }
-
- responsem = protoCtx.getResponseMessage();
-
- // caller will need to decide which of the following to use:
- // - GET HTTP-redirect to the return_to URL
- // - HTML FORM Redirection
- //responseText = response.wwwFormEncoding();
- if (responsem.isSuccessful())
- {
- response.sendRedirect( responsem.getDestinationURL(true));
- return;
- }
- else
- {
- responseText="<pre>"+ responsem.getResponseText() +"</pre>";
- }
-
- }
- }
- else if ("check_authentication".equals(mode))
- {
- try
- {
- // --- processing a verification request ---
- sts.validateToken( protoCtx );
- }
- catch (ProcessingException e)
- {
- throw new ServletException( e );
- }
- responsem = protoCtx.getResponseMessage();
-
- responseText = responsem.getResponseText();
- }
- else
- {
- protoCtx.setIssueError( Boolean.TRUE );
- protoCtx.setErrorText( "Unknown request" );
- try
- {
- // --- error response ---
- sts.issueToken(protoCtx);
- }
- catch (ProcessingException e)
- {
- throw new ServletException( e );
- }
- responsem = protoCtx.getResponseMessage();
-
- responseText = responsem.getResponseText();
- }
-
- log( "response="+responseText );
- response.getWriter().write(responseText);
- }
-}
\ No newline at end of file
Deleted: federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/servlets/OpenIDYadisServlet.java
===================================================================
--- federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/servlets/OpenIDYadisServlet.java 2011-06-13 20:06:16 UTC (rev 990)
+++ federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/servlets/OpenIDYadisServlet.java 2011-06-13 20:07:13 UTC (rev 991)
@@ -1,122 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.picketlink.identity.federation.web.servlets;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-/**
- * Servlet used for Yadis Discovery in OpenID
- * @author Anil.Saldhana(a)redhat.com
- * @since Jul 7, 2009
- */
-public class OpenIDYadisServlet extends HttpServlet
-{
- private static final long serialVersionUID = 1L;
-
- private String yadisResourceFile = "/WEB-INF/openid-yadis.xml";
- private String yadisURL = null;
-
- private boolean supportHTTP_HEAD = false; //By default, we support GET
-
- private transient InputStream yadisResourceInputStream = null;
-
- @Override
- public void init(ServletConfig config) throws ServletException
- {
- super.init(config);
- ServletContext context = config.getServletContext();
-
- String yadisResourceFileStr = config.getInitParameter("yadisResourceFile");
- if(yadisResourceFileStr != null && yadisResourceFileStr.length() > 0)
- yadisResourceFile = yadisResourceFileStr;
- log("yadisResourceFile Location="+ yadisResourceFile);
-
- yadisURL = config.getInitParameter("yadisResourceURL");
-
- if(yadisURL == null || yadisURL.length() == 0)
- {
- yadisResourceInputStream = context.getResourceAsStream(yadisResourceFile);
- if(yadisResourceInputStream == null)
- throw new RuntimeException("yadisResourceFile is missing");
- }
-
- String supportHead = config.getInitParameter("support_HTTP_HEAD");
- if(supportHead != null && supportHead.length() > 0)
- supportHTTP_HEAD = Boolean.parseBoolean(supportHead);
- }
-
-
- @Override
- protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
- {
- if(this.supportHTTP_HEAD)
- {
- log("GET not supported as HTTP HEAD has been configured");
- resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
- return;
- }
- else
- {
- if(yadisResourceInputStream == null)
- {
- log("ERROR::yadisResourceInputStream is null");
- resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
- return;
- }
-
- byte[] barr = new byte[1024];
- for (int i = 0; i < barr.length; i++)
- {
- int b = yadisResourceInputStream.read( );
- if (b == -1) break;
- barr[i] = (byte) b;
- }
-
- resp.setContentType("application/xrds+xml");
- resp.setStatus(HttpServletResponse.SC_OK);
- OutputStream os = resp.getOutputStream();
- os.write(barr);
- os.flush();
- os.close();
- }
- }
-
- @Override
- protected void doHead(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
- {
- if(this.supportHTTP_HEAD)
- {
- resp.addHeader("X-XRDS-Location", yadisURL);
- }
- resp.setStatus(HttpServletResponse.SC_OK);
- return;
- }
-}
\ No newline at end of file
Deleted: federation/trunk/picketlink-web/src/test/java/org/picketlink/test/identity/federation/web/integration/LocalProviderOpenIDUnitTestCase.java
===================================================================
--- federation/trunk/picketlink-web/src/test/java/org/picketlink/test/identity/federation/web/integration/LocalProviderOpenIDUnitTestCase.java 2011-06-13 20:06:16 UTC (rev 990)
+++ federation/trunk/picketlink-web/src/test/java/org/picketlink/test/identity/federation/web/integration/LocalProviderOpenIDUnitTestCase.java 2011-06-13 20:07:13 UTC (rev 991)
@@ -1,198 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.picketlink.test.identity.federation.web.integration;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.picketlink.identity.federation.api.openid.OpenIDManager;
-import org.picketlink.identity.federation.api.openid.OpenIDRequest;
-import org.picketlink.identity.federation.api.openid.OpenIDManager.OpenIDProviderInformation;
-import org.picketlink.identity.federation.api.openid.OpenIDManager.OpenIDProviderList;
-import org.picketlink.test.identity.federation.web.openid.InMemoryProtocolAdapter;
-import org.picketlink.test.identity.federation.web.server.EmbeddedWebServerBase;
-import org.mortbay.jetty.servlet.Context;
-import org.mortbay.jetty.servlet.ServletHolder;
-import org.openid4java.message.AuthSuccess;
-import org.openid4java.message.DirectError;
-import org.openid4java.message.Message;
-import org.openid4java.message.ParameterList;
-import org.openid4java.server.InMemoryServerAssociationStore;
-import org.openid4java.server.ServerManager;
-
-/**
- * Test the OpenID functionality within the VM
- * @author Anil.Saldhana(a)redhat.com
- * @since Jul 7, 2009
- */
-public class LocalProviderOpenIDUnitTestCase extends EmbeddedWebServerBase
-{
- protected void establishUserApps()
- {
- ClassLoader tcl = Thread.currentThread().getContextClassLoader();
- InputStream is = tcl.getResourceAsStream("openid/localhost-yadis.xml");
-
- assertNotNull("Yadis descriptor not null", is);
-
- Context context = new Context(server,"/",Context.SESSIONS);
- context.addServlet(new ServletHolder(new YadisServlet(is)), "/*");
-
- context.addServlet(new ServletHolder(new ProviderServlet()), "/provider/");
- }
-
- public void testOpenIDAuth() throws Exception
- {
- //String username = "http://jbosstest.myopenid.com";
- String username = "http://localhost:11080";
- InMemoryProtocolAdapter ad = new InMemoryProtocolAdapter();
- OpenIDRequest openIDRequest = new OpenIDRequest(username);
- OpenIDManager idm = new OpenIDManager(openIDRequest);
- OpenIDProviderList providers = idm.discoverProviders();
- assertNotNull("List of providers is not null", providers);
-
- OpenIDProviderInformation providerInfo = idm.associate(ad,providers);
- boolean auth = idm.authenticate(ad, providerInfo);
- assertTrue( "OpenID Auth was successful", auth );
- }
-
- //A provider servlet that always returns true
- private static class ProviderServlet extends HttpServlet
- {
- private static final long serialVersionUID = 1L;
-
- @Override
- protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
- {
- doGet(req, resp);
- }
-
- @Override
- protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
- {
- System.out.println("Inside ProviderServlet::doGet");
-
- ParameterList requestP = new ParameterList(req.getParameterMap());
-
- ServerManager manager = new ServerManager();
- manager.setSharedAssociations(new InMemoryServerAssociationStore());
- manager.setPrivateAssociations(new InMemoryServerAssociationStore());
- manager.setOPEndpointUrl("http://localhost:11080/provider/");
-
- String userSelectedId = "http://test.localhost:11080";
- String userSelectedClaimedId = userSelectedId;
- boolean authenticatedAndApproved = true;
-
- String responseText = "";
-
- String mode = requestP.hasParameter("openid.mode") ?
- requestP.getParameterValue("openid.mode") : null;
-
- System.out.println("ProviderServlet::mode="+mode);
- Message responsem ;
- if ("associate".equals(mode))
- {
- // --- process an association request ---
- responsem = manager.associationResponse(requestP);
- responseText = responsem.keyValueFormEncoding().trim();
- }
- else if ("checkid_setup".equals(mode)
- || "checkid_immediate".equals(mode))
- {
- responsem = manager.authResponse(requestP,
- userSelectedId,
- userSelectedClaimedId,
- authenticatedAndApproved );
-
- if (responsem instanceof AuthSuccess)
- {
- resp.sendRedirect(((AuthSuccess) responsem).getDestinationUrl(true));
- return;
- }
- else
- {
- responseText="<pre>"+responsem.keyValueFormEncoding().trim()+"</pre>";
- }
- }
- else if ("check_authentication".equals(mode))
- {
- // --- processing a verification request ---
- responsem = manager.verify(requestP);
- responseText = responsem.keyValueFormEncoding().trim();
- }
- else
- {
- // --- error response ---
- responsem = DirectError.createDirectError("Unknown request");
- responseText = responsem.keyValueFormEncoding().trim();
- }
-
- resp.setStatus(HttpServletResponse.SC_OK);
- resp.getWriter().print(responseText);
- }
- }
-
- //A Yadis servlet that just reads the XML from the Inputstream and passes it back
- private class YadisServlet extends HttpServlet
- {
- private static final long serialVersionUID = 1L;
-
- private InputStream yadisDescriptor;
-
- public YadisServlet(InputStream yadisDescriptor)
- {
- if(yadisDescriptor == null)
- throw new RuntimeException("input stream null");
- this.yadisDescriptor = yadisDescriptor;
- }
-
- protected void doGet(HttpServletRequest request, HttpServletResponse resp)
- throws ServletException, IOException
- {
- System.out.println("Inside Yadis Servlet");
- if("HEAD".equals(request.getMethod()))
- {
- resp.setStatus(HttpServletResponse.SC_OK);
- return;
- }
-
- //Asking for Yadis discovery
- byte[] barr = new byte[1024];
- for (int i = 0; i < barr.length; i++)
- {
- int b = yadisDescriptor.read();
- if (b == -1) break;
- barr[i] = (byte) b;
- }
- resp.setContentType("application/xrds+xml");
- resp.setStatus(HttpServletResponse.SC_OK);
-
- String ycontent = new String(barr);
- ycontent = ycontent.replace("\n"," ").trim();
- resp.getWriter().print(ycontent);
- }
- }
-}
\ No newline at end of file
Deleted: federation/trunk/picketlink-web/src/test/java/org/picketlink/test/identity/federation/web/integration/YadisMetadataUnitTestCase.java
===================================================================
--- federation/trunk/picketlink-web/src/test/java/org/picketlink/test/identity/federation/web/integration/YadisMetadataUnitTestCase.java 2011-06-13 20:06:16 UTC (rev 990)
+++ federation/trunk/picketlink-web/src/test/java/org/picketlink/test/identity/federation/web/integration/YadisMetadataUnitTestCase.java 2011-06-13 20:07:13 UTC (rev 991)
@@ -1,97 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.picketlink.test.identity.federation.web.integration;
-
-import java.io.IOException;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.picketlink.identity.federation.api.openid.OpenIDManager;
-import org.picketlink.identity.federation.api.openid.OpenIDRequest;
-import org.picketlink.identity.federation.api.openid.OpenIDManager.OpenIDProviderList;
-import org.picketlink.identity.federation.web.servlets.OpenIDYadisServlet;
-import org.picketlink.test.identity.federation.web.server.EmbeddedWebServerBase;
-import org.mortbay.jetty.servlet.Context;
-import org.mortbay.jetty.servlet.ServletHolder;
-
-/**
- * Unit test the OpenID Yadis Servlet
- * @author Anil.Saldhana(a)redhat.com
- * @since Jul 7, 2009
- */
-public class YadisMetadataUnitTestCase extends EmbeddedWebServerBase
-{
- protected void establishUserApps()
- {
- Context context = new Context(server,"/",Context.SESSIONS);
- ServletHolder servletHolder = new ServletHolder(new OpenIDYadisServlet());
- servletHolder.setInitParameter("support_HTTP_HEAD", "true");
- servletHolder.setInitParameter("yadisResourceURL", "http://localhost:11080/yadis");
-
- context.addServlet(servletHolder, "/*");
-
- context.addServlet(new ServletHolder( new TestYadisResourceServlet()), "/yadis");
- }
-
- public void testYadisDiscovery() throws Exception
- {
- //String username = "http://jbosstest.myopenid.com";
- String username = "http://localhost:11080";
-
- OpenIDRequest openIDRequest = new OpenIDRequest(username);
- OpenIDManager idm = new OpenIDManager(openIDRequest);
-
- OpenIDProviderList providers = idm.discoverProviders();
- assertNotNull("Providers list is not null", providers);
- assertEquals("1 provider", 1, providers.size());
- }
-
- /**
- * Servlet that just outputs an Yadis resource
- */
- private class TestYadisResourceServlet extends HttpServlet
- {
- private static final long serialVersionUID = 1L;
-
- String yadis = "<xrds:XRDS "+
- " xmlns:xrds=\'xri://$xrds\' " +
- " xmlns:openid=\'http://openid.net/xmlns/1.0\'" +
- " xmlns=\'xri://$xrd*($v*2.0)\'>" +
- "<XRD>" +
- " <Service priority=\'0\'>" +
- " <Type>http://openid.net/signon/1.0</Type>" +
- " <URI>http://localhost/provider.jsp</URI>" +
- " </Service>"+
- "</XRD>" +
- "</xrds:XRDS>";
- @Override
- protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
- {
- resp.setContentType("application/xrds+xml");
- resp.setStatus(HttpServletResponse.SC_OK);
- resp.getWriter().print(yadis);
- }
- }
-}
\ No newline at end of file
13 years, 6 months
Picketlink SVN: r990 - federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/sts.
by picketlink-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2011-06-13 16:06:16 -0400 (Mon, 13 Jun 2011)
New Revision: 990
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/sts/PicketLinkCoreSTS.java
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/sts/SecurityActions.java
Log:
beef up config file processing
Modified: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/sts/PicketLinkCoreSTS.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/sts/PicketLinkCoreSTS.java 2011-06-13 20:01:45 UTC (rev 989)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/sts/PicketLinkCoreSTS.java 2011-06-13 20:06:16 UTC (rev 990)
@@ -308,16 +308,42 @@
if (configurationFile.exists())
configurationFileURL = configurationFile.toURI().toURL();
else
+ {
// if not configuration file was found in the user home, check the context classloader.
- configurationFileURL = SecurityActions.getContextClassLoader().getResource(fileName);
+ ClassLoader tccl = SecurityActions.getContextClassLoader();
+ configurationFileURL = tccl.getResource(fileName);
+ }
// if no configuration file was found, log a warn message and use default configuration values.
if (configurationFileURL == null)
{
- logger.warn(fileName + " configuration file not found. Using default configuration values");
- return new PicketLinkSTSConfiguration();
+ logger.warn(fileName + " configuration file not found using TCCL");
+ ClassLoader clazzLoader = SecurityActions.getClassLoader(getClass());
+ configurationFileURL = clazzLoader.getResource(fileName);
}
+ // if no configuration file was found, log a warn message and use default configuration values.
+ if (configurationFileURL == null)
+ {
+ logger.warn(fileName + " configuration file not found using classloader");
+ try
+ {
+ configurationFileURL = new URL(fileName);
+ }
+ catch (Exception e)
+ {
+ return new PicketLinkSTSConfiguration();
+ }
+ finally
+ {
+ if (configurationFileURL == null)
+ {
+ logger.warn(fileName + " configuration file not found using URL. Using default configuration values");
+ return new PicketLinkSTSConfiguration();
+ }
+ }
+ }
+
InputStream stream = configurationFileURL.openStream();
STSType stsConfig = (STSType) new STSConfigParser().parse(stream);
STSConfiguration configuration = new PicketLinkSTSConfiguration(stsConfig);
Modified: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/sts/SecurityActions.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/sts/SecurityActions.java 2011-06-13 20:01:45 UTC (rev 989)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/sts/SecurityActions.java 2011-06-13 20:06:16 UTC (rev 990)
@@ -54,6 +54,17 @@
});
}
+ static ClassLoader getClassLoader(final Class<?> clazz)
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
+ {
+ public ClassLoader run()
+ {
+ return clazz.getClassLoader();
+ }
+ });
+ }
+
/**
* <p>
* Loads a class using the thread context class loader in a privileged block.
13 years, 6 months
Picketlink SVN: r989 - in social/trunk/openid/src: main/java/org/picketlink/social/openid/web and 4 other directories.
by picketlink-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2011-06-13 16:01:45 -0400 (Mon, 13 Jun 2011)
New Revision: 989
Added:
social/trunk/openid/src/test/resources/openid/webapp/test-sts.xml
Modified:
social/trunk/openid/src/main/java/org/picketlink/social/openid/servlets/OpenIDConsumerServlet.java
social/trunk/openid/src/main/java/org/picketlink/social/openid/servlets/OpenIDProviderServlet.java
social/trunk/openid/src/main/java/org/picketlink/social/openid/web/HTTPProtocolAdaptor.java
social/trunk/openid/src/test/java/org/picketlink/test/social/openid/InMemoryProtocolAdapter.java
social/trunk/openid/src/test/java/org/picketlink/test/social/openid/integration/LocalProviderOpenIDUnitTestCase.java
social/trunk/openid/src/test/java/org/picketlink/test/social/openid/integration/YadisMetadataUnitTestCase.java
social/trunk/openid/src/test/java/org/picketlink/test/social/openid/workflow/OpenIDWorkflowTestConsumerServlet.java
social/trunk/openid/src/test/java/org/picketlink/test/social/openid/workflow/OpenIDWorkflowUnitTestCase.java
Log:
openid code migration
Modified: social/trunk/openid/src/main/java/org/picketlink/social/openid/servlets/OpenIDConsumerServlet.java
===================================================================
--- social/trunk/openid/src/main/java/org/picketlink/social/openid/servlets/OpenIDConsumerServlet.java 2011-06-13 19:09:04 UTC (rev 988)
+++ social/trunk/openid/src/main/java/org/picketlink/social/openid/servlets/OpenIDConsumerServlet.java 2011-06-13 20:01:45 UTC (rev 989)
@@ -31,14 +31,15 @@
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
-import org.picketlink.identity.federation.api.openid.OpenIDManager;
-import org.picketlink.identity.federation.api.openid.OpenIDRequest;
-import org.picketlink.identity.federation.api.openid.OpenIDManager.OpenIDProviderInformation;
-import org.picketlink.identity.federation.api.openid.OpenIDManager.OpenIDProviderList;
-import org.picketlink.identity.federation.api.openid.exceptions.OpenIDGeneralException;
-import org.picketlink.identity.federation.web.openid.HTTPOpenIDContext;
-import org.picketlink.identity.federation.web.openid.HTTPProtocolAdaptor;
+import org.picketlink.social.openid.api.OpenIDManager;
+import org.picketlink.social.openid.api.OpenIDManager.OpenIDProviderInformation;
+import org.picketlink.social.openid.api.OpenIDManager.OpenIDProviderList;
+import org.picketlink.social.openid.api.OpenIDRequest;
+import org.picketlink.social.openid.api.exceptions.OpenIDGeneralException;
+import org.picketlink.social.openid.web.HTTPOpenIDContext;
+import org.picketlink.social.openid.web.HTTPProtocolAdaptor;
+
/**
* OpenID Consumer Servlet that gets a post
* request from the main JSP page of the consumer
Modified: social/trunk/openid/src/main/java/org/picketlink/social/openid/servlets/OpenIDProviderServlet.java
===================================================================
--- social/trunk/openid/src/main/java/org/picketlink/social/openid/servlets/OpenIDProviderServlet.java 2011-06-13 19:09:04 UTC (rev 988)
+++ social/trunk/openid/src/main/java/org/picketlink/social/openid/servlets/OpenIDProviderServlet.java 2011-06-13 20:01:45 UTC (rev 989)
@@ -22,6 +22,7 @@
package org.picketlink.social.openid.servlets;
import java.io.IOException;
+import java.net.MalformedURLException;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
@@ -62,8 +63,24 @@
String secpageStr = this.servletContext.getInitParameter("securePage");
if(secpageStr != null && secpageStr.length() > 0)
securePageName = secpageStr;
+
+ String configFile = null;
+ String configFileStr = this.servletContext.getInitParameter("configFile");
+ if(configFileStr != null && configFileStr.length() > 0)
+ {
+ try
+ {
+ configFile = servletContext.getResource(configFileStr).toExternalForm();
+ }
+ catch (MalformedURLException e)
+ {
+ throw new ServletException(e);
+ }
+ }
+
+ log("configFile="+configFile);
- sts.installDefaultConfiguration( ( String[] )null );
+ sts.installDefaultConfiguration( new String[] {configFile} );
}
@Override
Modified: social/trunk/openid/src/main/java/org/picketlink/social/openid/web/HTTPProtocolAdaptor.java
===================================================================
--- social/trunk/openid/src/main/java/org/picketlink/social/openid/web/HTTPProtocolAdaptor.java 2011-06-13 19:09:04 UTC (rev 988)
+++ social/trunk/openid/src/main/java/org/picketlink/social/openid/web/HTTPProtocolAdaptor.java 2011-06-13 20:01:45 UTC (rev 989)
@@ -30,15 +30,15 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.apache.log4j.Logger;
-import org.picketlink.identity.federation.api.openid.OpenIDAttributeMap;
-import org.picketlink.identity.federation.api.openid.OpenIDLifecycle;
-import org.picketlink.identity.federation.api.openid.OpenIDLifecycleEvent;
-import org.picketlink.identity.federation.api.openid.OpenIDProtocolAdapter;
-import org.picketlink.identity.federation.api.openid.OpenIDLifecycleEvent.OP;
-import org.picketlink.identity.federation.api.openid.OpenIDLifecycleEvent.TYPE;
-import org.picketlink.identity.federation.api.openid.exceptions.OpenIDLifeCycleException;
-import org.picketlink.identity.federation.api.openid.exceptions.OpenIDProtocolException;
+import org.apache.log4j.Logger;
+import org.picketlink.social.openid.api.OpenIDAttributeMap;
+import org.picketlink.social.openid.api.OpenIDLifecycle;
+import org.picketlink.social.openid.api.OpenIDLifecycleEvent;
+import org.picketlink.social.openid.api.OpenIDLifecycleEvent.OP;
+import org.picketlink.social.openid.api.OpenIDLifecycleEvent.TYPE;
+import org.picketlink.social.openid.api.OpenIDProtocolAdapter;
+import org.picketlink.social.openid.api.exceptions.OpenIDLifeCycleException;
+import org.picketlink.social.openid.api.exceptions.OpenIDProtocolException;
/**
* Protocol adapter for HTTP
Modified: social/trunk/openid/src/test/java/org/picketlink/test/social/openid/InMemoryProtocolAdapter.java
===================================================================
--- social/trunk/openid/src/test/java/org/picketlink/test/social/openid/InMemoryProtocolAdapter.java 2011-06-13 19:09:04 UTC (rev 988)
+++ social/trunk/openid/src/test/java/org/picketlink/test/social/openid/InMemoryProtocolAdapter.java 2011-06-13 20:01:45 UTC (rev 989)
@@ -24,12 +24,12 @@
import java.net.URL;
import java.util.Map;
-import org.picketlink.identity.federation.api.openid.OpenIDAttributeMap;
-import org.picketlink.identity.federation.api.openid.OpenIDLifecycle;
-import org.picketlink.identity.federation.api.openid.OpenIDLifecycleEvent;
-import org.picketlink.identity.federation.api.openid.OpenIDProtocolAdapter;
-import org.picketlink.identity.federation.api.openid.exceptions.OpenIDLifeCycleException;
-import org.picketlink.identity.federation.api.openid.exceptions.OpenIDProtocolException;
+import org.picketlink.social.openid.api.OpenIDAttributeMap;
+import org.picketlink.social.openid.api.OpenIDLifecycle;
+import org.picketlink.social.openid.api.OpenIDLifecycleEvent;
+import org.picketlink.social.openid.api.OpenIDProtocolAdapter;
+import org.picketlink.social.openid.api.exceptions.OpenIDLifeCycleException;
+import org.picketlink.social.openid.api.exceptions.OpenIDProtocolException;
import com.meterware.httpunit.GetMethodWebRequest;
import com.meterware.httpunit.WebConversation;
Modified: social/trunk/openid/src/test/java/org/picketlink/test/social/openid/integration/LocalProviderOpenIDUnitTestCase.java
===================================================================
--- social/trunk/openid/src/test/java/org/picketlink/test/social/openid/integration/LocalProviderOpenIDUnitTestCase.java 2011-06-13 19:09:04 UTC (rev 988)
+++ social/trunk/openid/src/test/java/org/picketlink/test/social/openid/integration/LocalProviderOpenIDUnitTestCase.java 2011-06-13 20:01:45 UTC (rev 989)
@@ -28,11 +28,11 @@
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-
-import org.picketlink.identity.federation.api.openid.OpenIDManager;
-import org.picketlink.identity.federation.api.openid.OpenIDRequest;
-import org.picketlink.identity.federation.api.openid.OpenIDManager.OpenIDProviderInformation;
-import org.picketlink.identity.federation.api.openid.OpenIDManager.OpenIDProviderList;
+
+import org.picketlink.social.openid.api.OpenIDManager;
+import org.picketlink.social.openid.api.OpenIDManager.OpenIDProviderInformation;
+import org.picketlink.social.openid.api.OpenIDManager.OpenIDProviderList;
+import org.picketlink.social.openid.api.OpenIDRequest;
import org.picketlink.test.social.openid.EmbeddedWebServerBase;
import org.picketlink.test.social.openid.InMemoryProtocolAdapter;
import org.mortbay.jetty.servlet.Context;
Modified: social/trunk/openid/src/test/java/org/picketlink/test/social/openid/integration/YadisMetadataUnitTestCase.java
===================================================================
--- social/trunk/openid/src/test/java/org/picketlink/test/social/openid/integration/YadisMetadataUnitTestCase.java 2011-06-13 19:09:04 UTC (rev 988)
+++ social/trunk/openid/src/test/java/org/picketlink/test/social/openid/integration/YadisMetadataUnitTestCase.java 2011-06-13 20:01:45 UTC (rev 989)
@@ -27,10 +27,10 @@
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-
-import org.picketlink.identity.federation.api.openid.OpenIDManager;
-import org.picketlink.identity.federation.api.openid.OpenIDRequest;
-import org.picketlink.identity.federation.api.openid.OpenIDManager.OpenIDProviderList;
+
+import org.picketlink.social.openid.api.OpenIDManager;
+import org.picketlink.social.openid.api.OpenIDManager.OpenIDProviderList;
+import org.picketlink.social.openid.api.OpenIDRequest;
import org.picketlink.social.openid.servlets.OpenIDYadisServlet;
import org.picketlink.test.social.openid.EmbeddedWebServerBase;
import org.mortbay.jetty.servlet.Context;
Modified: social/trunk/openid/src/test/java/org/picketlink/test/social/openid/workflow/OpenIDWorkflowTestConsumerServlet.java
===================================================================
--- social/trunk/openid/src/test/java/org/picketlink/test/social/openid/workflow/OpenIDWorkflowTestConsumerServlet.java 2011-06-13 19:09:04 UTC (rev 988)
+++ social/trunk/openid/src/test/java/org/picketlink/test/social/openid/workflow/OpenIDWorkflowTestConsumerServlet.java 2011-06-13 20:01:45 UTC (rev 989)
@@ -28,9 +28,10 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.picketlink.identity.federation.api.openid.OpenIDManager;
-import org.picketlink.identity.federation.web.openid.HTTPOpenIDContext;
-import org.picketlink.identity.federation.web.openid.HTTPProtocolAdaptor;
+import org.picketlink.social.openid.api.OpenIDManager;
+import org.picketlink.social.openid.web.HTTPOpenIDContext;
+import org.picketlink.social.openid.web.HTTPProtocolAdaptor;
+
/**
* Test Consumer Servlet
Modified: social/trunk/openid/src/test/java/org/picketlink/test/social/openid/workflow/OpenIDWorkflowUnitTestCase.java
===================================================================
--- social/trunk/openid/src/test/java/org/picketlink/test/social/openid/workflow/OpenIDWorkflowUnitTestCase.java 2011-06-13 19:09:04 UTC (rev 988)
+++ social/trunk/openid/src/test/java/org/picketlink/test/social/openid/workflow/OpenIDWorkflowUnitTestCase.java 2011-06-13 20:01:45 UTC (rev 989)
@@ -22,14 +22,16 @@
package org.picketlink.test.social.openid.workflow;
import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
import org.mortbay.jetty.servlet.Context;
import org.mortbay.jetty.servlet.ServletHolder;
-import org.mortbay.jetty.webapp.WebAppContext;
-import org.picketlink.identity.federation.api.openid.OpenIDManager;
-import org.picketlink.identity.federation.api.openid.OpenIDManager.OpenIDProviderInformation;
-import org.picketlink.identity.federation.api.openid.OpenIDManager.OpenIDProviderList;
-import org.picketlink.identity.federation.api.openid.OpenIDRequest;
+import org.mortbay.jetty.webapp.WebAppContext;
+import org.picketlink.social.openid.api.OpenIDManager;
+import org.picketlink.social.openid.api.OpenIDManager.OpenIDProviderInformation;
+import org.picketlink.social.openid.api.OpenIDManager.OpenIDProviderList;
+import org.picketlink.social.openid.api.OpenIDRequest;
import org.picketlink.social.openid.servlets.OpenIDProviderServlet;
import org.picketlink.test.social.openid.EmbeddedWebServerBase;
import org.picketlink.test.social.openid.InMemoryProtocolAdapter;
@@ -46,6 +48,7 @@
private OpenIDRequest openIDRequest = new OpenIDRequest( username );
private OpenIDManager manager = new OpenIDManager( openIDRequest );
+ @SuppressWarnings({"unchecked", "rawtypes"})
protected void establishUserApps()
{
ClassLoader tcl = Thread.currentThread().getContextClassLoader();
@@ -60,6 +63,12 @@
Context context = new WebAppContext( warUrlString, CONTEXTPATH );
server.setHandler( context );
+
+ Map initParams = new HashMap();
+ initParams.put("configFile", "/test-sts.xml");
+ context.setInitParams(initParams);
+
+ Thread.currentThread().setContextClassLoader(context.getClassLoader());
context.addServlet(new ServletHolder(new OpenIDProviderServlet()), "/provider/");
Added: social/trunk/openid/src/test/resources/openid/webapp/test-sts.xml
===================================================================
--- social/trunk/openid/src/test/resources/openid/webapp/test-sts.xml (rev 0)
+++ social/trunk/openid/src/test/resources/openid/webapp/test-sts.xml 2011-06-13 20:01:45 UTC (rev 989)
@@ -0,0 +1,12 @@
+<PicketLinkSTS xmlns="urn:picketlink:identity-federation:config:1.0"
+ STSName="PicketLinkCoreSTS" TokenTimeout="7200" EncryptToken="false">
+ <TokenProviders>
+ <TokenProvider ProviderClass="org.picketlink.identity.federation.core.saml.v2.providers.SAML20AssertionTokenProvider"
+ TokenType="urn:oasis:names:tc:SAML:2.0:assertion"
+ TokenElement="Assertion"
+ TokenElementNS="urn:oasis:names:tc:SAML:2.0:assertion"/>
+ <TokenProvider ProviderClass="org.picketlink.social.openid.providers.OpenIDTokenProvider"
+ TokenType="urn:openid:1:0"
+ TokenElementNS="urn:openid:1:0"/>
+ </TokenProviders>
+</PicketLinkSTS>
\ No newline at end of file
13 years, 6 months
Picketlink SVN: r988 - in social/trunk/openid/src/main/java/org/picketlink/social/openid: api and 1 other directories.
by picketlink-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2011-06-13 15:09:04 -0400 (Mon, 13 Jun 2011)
New Revision: 988
Added:
social/trunk/openid/src/main/java/org/picketlink/social/openid/api/
social/trunk/openid/src/main/java/org/picketlink/social/openid/api/OpenIDAttributeMap.java
social/trunk/openid/src/main/java/org/picketlink/social/openid/api/OpenIDConstants.java
social/trunk/openid/src/main/java/org/picketlink/social/openid/api/OpenIDLifecycle.java
social/trunk/openid/src/main/java/org/picketlink/social/openid/api/OpenIDLifecycleEvent.java
social/trunk/openid/src/main/java/org/picketlink/social/openid/api/OpenIDManager.java
social/trunk/openid/src/main/java/org/picketlink/social/openid/api/OpenIDProtocolAdapter.java
social/trunk/openid/src/main/java/org/picketlink/social/openid/api/OpenIDRequest.java
social/trunk/openid/src/main/java/org/picketlink/social/openid/api/exceptions/
social/trunk/openid/src/main/java/org/picketlink/social/openid/api/exceptions/OpenIDAssociationException.java
social/trunk/openid/src/main/java/org/picketlink/social/openid/api/exceptions/OpenIDConsumerException.java
social/trunk/openid/src/main/java/org/picketlink/social/openid/api/exceptions/OpenIDDiscoveryException.java
social/trunk/openid/src/main/java/org/picketlink/social/openid/api/exceptions/OpenIDGeneralException.java
social/trunk/openid/src/main/java/org/picketlink/social/openid/api/exceptions/OpenIDLifeCycleException.java
social/trunk/openid/src/main/java/org/picketlink/social/openid/api/exceptions/OpenIDMessageException.java
social/trunk/openid/src/main/java/org/picketlink/social/openid/api/exceptions/OpenIDProtocolException.java
Log:
openid migration
Added: social/trunk/openid/src/main/java/org/picketlink/social/openid/api/OpenIDAttributeMap.java
===================================================================
--- social/trunk/openid/src/main/java/org/picketlink/social/openid/api/OpenIDAttributeMap.java (rev 0)
+++ social/trunk/openid/src/main/java/org/picketlink/social/openid/api/OpenIDAttributeMap.java 2011-06-13 19:09:04 UTC (rev 988)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.picketlink.social.openid.api;
+
+import java.util.HashMap;
+
+/**
+ * Attribute Map to be retrieved from the OpenID Provider
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Jul 6, 2009
+ */
+public class OpenIDAttributeMap extends HashMap<String, String>
+{
+ private static final long serialVersionUID = 1L;
+}
\ No newline at end of file
Added: social/trunk/openid/src/main/java/org/picketlink/social/openid/api/OpenIDConstants.java
===================================================================
--- social/trunk/openid/src/main/java/org/picketlink/social/openid/api/OpenIDConstants.java (rev 0)
+++ social/trunk/openid/src/main/java/org/picketlink/social/openid/api/OpenIDConstants.java 2011-06-13 19:09:04 UTC (rev 988)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.picketlink.social.openid.api;
+
+/**
+ * OpenID URL based Constants
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Jul 7, 2009
+ */
+public enum OpenIDConstants
+{
+ EMAIL("http://schema.openid.net/contact/email"),
+ FULLNAME("http://schema.openid.net/contact/fullname"),
+ DOB("http://schema.openid.net/contact/dob"),
+ GENDER("http://schema.openid.net/contact/gender"),
+ POSTCODE("http://schema.openid.net/contact/postcode"),
+ COUNTRY("http://schema.openid.net/contact/country"),
+ LANGUAGE("http://schema.openid.net/contact/language"),
+ TIMEZONE("http://schema.openid.net/contact/timezone");
+
+ private String constantURL;
+
+ private OpenIDConstants(String url)
+ {
+ this.constantURL = url;
+ }
+
+ public String url()
+ {
+ return this.constantURL;
+ }
+}
Added: social/trunk/openid/src/main/java/org/picketlink/social/openid/api/OpenIDLifecycle.java
===================================================================
--- social/trunk/openid/src/main/java/org/picketlink/social/openid/api/OpenIDLifecycle.java (rev 0)
+++ social/trunk/openid/src/main/java/org/picketlink/social/openid/api/OpenIDLifecycle.java 2011-06-13 19:09:04 UTC (rev 988)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.picketlink.social.openid.api;
+
+import org.picketlink.social.openid.api.exceptions.OpenIDLifeCycleException;
+
+
+/**
+ * Denotes the lifecycle methods the OpenIDManager
+ * calls back - Consumer Side
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Jul 10, 2009
+ */
+public interface OpenIDLifecycle
+{
+ /**
+ * Handle an openid lifecycle event from
+ * the openid manager
+ * @param event
+ */
+ void handle(OpenIDLifecycleEvent event) throws OpenIDLifeCycleException;
+
+ /**
+ * Handle an array of lifecycle events from the OpenID Manager
+ * @param eventArr
+ * @throws OpenIDLifeCycleException
+ */
+ void handle(OpenIDLifecycleEvent[] eventArr) throws OpenIDLifeCycleException;
+
+ /**
+ * Provide the value for an attribute to
+ * the openid manager
+ * @param name
+ * @return
+ */
+ Object getAttributeValue(String name);
+}
\ No newline at end of file
Added: social/trunk/openid/src/main/java/org/picketlink/social/openid/api/OpenIDLifecycleEvent.java
===================================================================
--- social/trunk/openid/src/main/java/org/picketlink/social/openid/api/OpenIDLifecycleEvent.java (rev 0)
+++ social/trunk/openid/src/main/java/org/picketlink/social/openid/api/OpenIDLifecycleEvent.java 2011-06-13 19:09:04 UTC (rev 988)
@@ -0,0 +1,102 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.picketlink.social.openid.api;
+
+/**
+ * Events in the lifecycle
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Jul 10, 2009
+ */
+public class OpenIDLifecycleEvent
+{
+ public enum TYPE
+ {
+ SUCCESS("lifecycle"),
+ SESSION("session");
+ private String type;
+
+ TYPE(String type)
+ {
+ this.type = type;
+ }
+
+ public String type()
+ {
+ return type;
+ }
+ }
+
+ public enum OP
+ {
+ ADD,REMOVE;
+ }
+
+ private TYPE eventType;
+ private OP operation;
+ private String attributeName;
+ private Object attributeValue;
+
+ public OpenIDLifecycleEvent(TYPE type, OP operation, String attr, Object val)
+ {
+ this.eventType = type;
+ this.operation = operation;
+ this.attributeName = attr;
+ this.attributeValue = val;
+ }
+
+ /**
+ * Get the type of the event (session, lifecycle etc)
+ * @return
+ */
+ public TYPE getEventType()
+ {
+ return eventType;
+ }
+
+ /**
+ * Get the operation we are dealing with (add,remove)
+ * @return
+ */
+ public OP getOperation()
+ {
+ return this.operation;
+ }
+
+ /**
+ * Return the attribute name that needs
+ * to be dealt at the session level
+ * @return
+ */
+ public String getAttributeName()
+ {
+ return attributeName;
+ }
+
+ /**
+ * Get the attribute value
+ * @return
+ */
+ public Object getAttributeValue()
+ {
+ return attributeValue;
+ }
+}
\ No newline at end of file
Added: social/trunk/openid/src/main/java/org/picketlink/social/openid/api/OpenIDManager.java
===================================================================
--- social/trunk/openid/src/main/java/org/picketlink/social/openid/api/OpenIDManager.java (rev 0)
+++ social/trunk/openid/src/main/java/org/picketlink/social/openid/api/OpenIDManager.java 2011-06-13 19:09:04 UTC (rev 988)
@@ -0,0 +1,433 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.picketlink.social.openid.api;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import org.openid4java.association.AssociationException;
+import org.openid4java.consumer.ConsumerException;
+import org.openid4java.consumer.ConsumerManager;
+import org.openid4java.consumer.InMemoryConsumerAssociationStore;
+import org.openid4java.consumer.InMemoryNonceVerifier;
+import org.openid4java.consumer.VerificationResult;
+import org.openid4java.discovery.DiscoveryException;
+import org.openid4java.discovery.DiscoveryInformation;
+import org.openid4java.discovery.Identifier;
+import org.openid4java.message.AuthRequest;
+import org.openid4java.message.AuthSuccess;
+import org.openid4java.message.MessageException;
+import org.openid4java.message.ParameterList;
+import org.openid4java.message.ax.FetchRequest;
+import org.openid4java.message.sreg.SRegRequest;
+import org.picketlink.social.openid.api.OpenIDLifecycleEvent.OP;
+import org.picketlink.social.openid.api.OpenIDLifecycleEvent.TYPE;
+import org.picketlink.social.openid.api.exceptions.OpenIDAssociationException;
+import org.picketlink.social.openid.api.exceptions.OpenIDConsumerException;
+import org.picketlink.social.openid.api.exceptions.OpenIDDiscoveryException;
+import org.picketlink.social.openid.api.exceptions.OpenIDLifeCycleException;
+import org.picketlink.social.openid.api.exceptions.OpenIDMessageException;
+import org.picketlink.social.openid.api.exceptions.OpenIDProtocolException;
+
+/**
+ * OpenID Manager for consumers
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Jul 6, 2009
+ */
+public class OpenIDManager
+{
+ public enum CONST
+ {
+ OPENID("openid"),
+ OPENID_CLAIMED("openid-claimed"),
+ OPENID_DISC("openid-discovered");
+
+ private String val;
+ CONST(String val)
+ {
+ this.val = val;
+ }
+ public String get()
+ {
+ return this.val;
+ }
+ }
+
+ private OpenIDRequest request = null;
+
+ private ConsumerManager consumerManager = null;
+
+ private String userString = null;
+
+ public OpenIDManager(OpenIDRequest theReq)
+ {
+ this.request = theReq;
+ try
+ {
+ consumerManager = new ConsumerManager();
+ consumerManager.setAssociations(new InMemoryConsumerAssociationStore());
+ consumerManager.setNonceVerifier(new InMemoryNonceVerifier(5000));
+
+ userString = request.getURL();
+ }
+ catch(ConsumerException ce)
+ {
+ throw new RuntimeException(ce);
+ }
+ }
+
+ /**
+ * Set the user string
+ * @param userString
+ */
+ public void setUserString(String userString)
+ {
+ this.userString = userString;
+ }
+
+ /**
+ * Get the OpenID Request
+ * @return
+ */
+ public OpenIDRequest getOpenIDRequest()
+ {
+ return this.request;
+ }
+
+ @SuppressWarnings("unchecked")
+ public OpenIDProviderList discoverProviders() throws OpenIDDiscoveryException, OpenIDConsumerException
+ {
+ // perform discovery on the user-supplied identifier
+ List<DiscoveryInformation> discoveries;
+ try
+ {
+ discoveries = consumerManager.discover(userString);
+ }
+ catch (DiscoveryException e1)
+ {
+ throw new OpenIDDiscoveryException(e1);
+ }
+
+ return new OpenIDProviderList(discoveries);
+ }
+
+ /**
+ * Associate with a list of open id providers
+ * @param adapter Protocol adapter (such as http)
+ * @param listOfProviders (a list of providers from discovery)
+ * @return
+ * @throws OpenIDConsumerException
+ * @throws OpenIDLifeCycleException
+ */
+ public OpenIDProviderInformation associate(OpenIDProtocolAdapter adapter,
+ OpenIDProviderList listOfProviders)
+ throws OpenIDConsumerException, OpenIDLifeCycleException
+ {
+ OpenIDLifecycle lifeCycle = null;
+
+ if(adapter instanceof OpenIDLifecycle)
+ {
+ lifeCycle = (OpenIDLifecycle) adapter;
+ }
+ List<DiscoveryInformation> discoveries = listOfProviders.get();
+
+ if(discoveries.size() == 0)
+ throw new OpenIDConsumerException("No open id endpoints discovered");
+
+ // attempt to associate with the OpenID provider
+ // and retrieve one service endpoint for authentication
+ DiscoveryInformation discovered = consumerManager.associate(discoveries);
+
+ // store the discovery information in the user's session for later use
+ // leave out for stateless operation / if there is no session
+ if(lifeCycle != null)
+ {
+ OpenIDLifecycleEvent ev =new OpenIDLifecycleEvent(TYPE.SESSION,
+ OP.ADD, CONST.OPENID_DISC.get(), discovered);
+ lifeCycle.handle(ev);
+ }
+ return new OpenIDProviderInformation(discovered);
+ }
+
+ /**
+ * Authenticate an user with the provider
+ * @param adapter protocol adapter
+ * @param providerInfo Information about a provider derived from discovery process
+ * @return
+ * @throws OpenIDDiscoveryException
+ * @throws OpenIDConsumerException
+ * @throws OpenIDMessageException
+ * @throws OpenIDProtocolException
+ */
+ @SuppressWarnings("unchecked")
+ public boolean authenticate(OpenIDProtocolAdapter adapter, OpenIDProviderInformation providerInfo)
+ throws OpenIDDiscoveryException,
+ OpenIDConsumerException, OpenIDMessageException, OpenIDProtocolException
+ {
+ DiscoveryInformation discovered = providerInfo.get();
+
+ // obtain a AuthRequest message to be sent to the OpenID provider
+ try
+ {
+ AuthRequest authReq = consumerManager.authenticate(discovered,
+ adapter.getReturnURL());
+
+ // Attribute Exchange example: fetching the 'email' attribute
+ FetchRequest fetch = FetchRequest.createFetchRequest();
+ SRegRequest sregReq = SRegRequest.createFetchRequest();
+
+ OpenIDAttributeMap amap = adapter.getAttributeMap();
+
+ if ("1".equals(amap.get("nickname")))
+ {
+ // fetch.addAttribute("nickname",
+ // "http://schema.openid.net/contact/nickname", false);
+ sregReq.addAttribute("nickname", false);
+ }
+
+ if ("1".equals(amap.get("email")))
+ {
+ fetch.addAttribute("email",OpenIDConstants.EMAIL.url(), false);
+ sregReq.addAttribute("email", false);
+ }
+
+ if ("1".equals(amap.get("fullname")))
+ {
+ fetch.addAttribute("fullname",OpenIDConstants.FULLNAME.url(), false);
+ sregReq.addAttribute("fullname", false);
+ }
+ if ("1".equals(amap.get("dob")))
+ {
+ fetch.addAttribute("dob",OpenIDConstants.DOB.url(), true);
+ sregReq.addAttribute("dob", false);
+ }
+
+ if ("1".equals(amap.get("gender")))
+ {
+ fetch.addAttribute("gender",OpenIDConstants.GENDER.url(), false);
+ sregReq.addAttribute("gender", false);
+ }
+
+ if ("1".equals(amap.get("postcode")))
+ {
+ fetch.addAttribute("postcode",OpenIDConstants.POSTCODE.url(), false);
+ sregReq.addAttribute("postcode", false);
+ }
+
+ if ("1".equals(amap.get("country")))
+ {
+ fetch.addAttribute("country",OpenIDConstants.COUNTRY.url(), false);
+ sregReq.addAttribute("country", false);
+ }
+
+ if ("1".equals(amap.get("language")))
+ {
+ fetch.addAttribute("language", OpenIDConstants.LANGUAGE.url(),false);
+ sregReq.addAttribute("language", false);
+ }
+
+ if ("1".equals(amap.get("timezone")))
+ {
+ fetch.addAttribute("timezone", OpenIDConstants.TIMEZONE.url(), false);
+ sregReq.addAttribute("timezone", false);
+ }
+
+
+ // attach the extension to the authentication request
+ if (!sregReq.getAttributes().isEmpty())
+ {
+ authReq.addExtension(sregReq);
+ }
+
+ if (!discovered.isVersion2())
+ {
+ // Option 1: GET HTTP-redirect to the OpenID Provider endpoint
+ // The only method supported in OpenID 1.x
+ // redirect-URL usually limited ~2048 bytes
+ adapter.sendToProvider(1, authReq.getDestinationUrl(true), null);
+ return true;
+ }
+ else
+ {
+ // Option 2: HTML FORM Redirection (Allows payloads >2048 bytes)
+ adapter.sendToProvider(2, authReq.getDestinationUrl(false),
+ authReq.getParameterMap());
+ }
+ }
+ catch (MessageException e)
+ {
+ throw new OpenIDMessageException(e);
+ }
+ catch (ConsumerException e)
+ {
+ throw new OpenIDConsumerException(e);
+ }
+ return false;
+ }
+
+ /**
+ * Verify a previously authenticated user with the provider
+ * @param adapter protocol adapter
+ * @param parameterMap request parameters
+ * @param receivedURL url where the response will be received
+ * @return
+ * @throws OpenIDMessageException
+ * @throws OpenIDDiscoveryException
+ * @throws OpenIDAssociationException
+ * @throws OpenIDLifeCycleException
+ */
+ public boolean verify(OpenIDProtocolAdapter adapter, Map<String,String> parameterMap,
+ String receivedURL) throws OpenIDMessageException,
+ OpenIDDiscoveryException, OpenIDAssociationException, OpenIDLifeCycleException
+ {
+ OpenIDLifecycle lifeCycle = null;
+
+ if(adapter instanceof OpenIDLifecycle)
+ {
+ lifeCycle = (OpenIDLifecycle) adapter;
+ }
+ ParameterList responselist = new ParameterList(parameterMap);
+
+ if(lifeCycle == null)
+ throw new IllegalStateException("Lifecycle not found");
+
+ DiscoveryInformation discovered =
+ (DiscoveryInformation) lifeCycle.getAttributeValue(CONST.OPENID_DISC.get());
+
+ // verify the response; ConsumerManager needs to be the same
+ // (static) instance used to place the authentication request
+ try
+ {
+ VerificationResult verification = this.consumerManager.verify(
+ receivedURL,
+ responselist, discovered);
+
+ // examine the verification result and extract the verified identifier
+ Identifier verified = verification.getVerifiedId();
+ if (verified != null)
+ {
+ AuthSuccess authSuccess =
+ (AuthSuccess) verification.getAuthResponse();
+
+ //Create an lifecycle event array
+ OpenIDLifecycleEvent[] eventArr = new OpenIDLifecycleEvent[]
+ {
+ /**Store the id**/
+ new OpenIDLifecycleEvent(TYPE.SESSION,
+ OP.ADD, CONST.OPENID.get(), authSuccess.getIdentity()),
+
+ /** Store the claimed **/
+ new OpenIDLifecycleEvent(TYPE.SESSION,
+ OP.ADD, CONST.OPENID_CLAIMED.get(), authSuccess.getClaimed()),
+
+ /** Indicate success **/
+ new OpenIDLifecycleEvent(TYPE.SUCCESS,
+ null, null, null)
+ };
+ lifeCycle.handle(eventArr);
+ return true;
+ }
+ }
+ catch (MessageException e)
+ {
+ throw new OpenIDMessageException(e);
+ }
+ catch (DiscoveryException e)
+ {
+ throw new OpenIDDiscoveryException(e);
+ }
+ catch (AssociationException e)
+ {
+ throw new OpenIDAssociationException(e);
+ }
+
+ return false;
+ }
+
+ /**
+ * Log an user out from an openid provider
+ * @param adapter protocol adapter
+ * @throws OpenIDLifeCycleException
+ */
+ public void logout(OpenIDProtocolAdapter adapter) throws OpenIDLifeCycleException
+ {
+ OpenIDLifecycle lifeCycle = null;
+
+ if(adapter instanceof OpenIDLifecycle)
+ {
+ lifeCycle = (OpenIDLifecycle) adapter;
+ }
+ if(lifeCycle != null)
+ {
+ lifeCycle.handle(new OpenIDLifecycleEvent(TYPE.SESSION, OP.REMOVE, CONST.OPENID.get(), null));
+ lifeCycle.handle(new OpenIDLifecycleEvent(TYPE.SESSION, OP.REMOVE, CONST.OPENID_CLAIMED.get(), null));
+ }
+ }
+
+ /**
+ * Information about a provider from the
+ * discovery process
+ */
+ public static class OpenIDProviderInformation
+ {
+ private DiscoveryInformation discovered;
+
+ OpenIDProviderInformation(DiscoveryInformation di)
+ {
+ this.discovered = di;
+ }
+
+ DiscoveryInformation get()
+ {
+ return this.discovered;
+ }
+ }
+
+ /**
+ * List of OpenID providers
+ */
+ public static class OpenIDProviderList
+ {
+ private List<DiscoveryInformation> providers = null;
+
+ OpenIDProviderList(List<DiscoveryInformation> providers)
+ {
+ this.providers = providers;
+ }
+
+ void addProvider( DiscoveryInformation provider )
+ {
+ this.providers.add( provider );
+ }
+
+ List<DiscoveryInformation> get()
+ {
+ return Collections.unmodifiableList(providers);
+ }
+
+ public int size()
+ {
+ return this.providers != null ? providers.size() : 0;
+ }
+ }
+}
\ No newline at end of file
Added: social/trunk/openid/src/main/java/org/picketlink/social/openid/api/OpenIDProtocolAdapter.java
===================================================================
--- social/trunk/openid/src/main/java/org/picketlink/social/openid/api/OpenIDProtocolAdapter.java (rev 0)
+++ social/trunk/openid/src/main/java/org/picketlink/social/openid/api/OpenIDProtocolAdapter.java 2011-06-13 19:09:04 UTC (rev 988)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.picketlink.social.openid.api;
+
+import java.util.Map;
+
+import org.picketlink.social.openid.api.exceptions.OpenIDProtocolException;
+
+
+/**
+ * Callback adapter sent to the OpenIDManager
+ * that implements the protocol behavior
+ * such as HTTP
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Jul 6, 2009
+ */
+public interface OpenIDProtocolAdapter
+{
+ /**
+ * Map of attributes to be retrieved from the provider
+ * @return
+ */
+ OpenIDAttributeMap getAttributeMap();
+
+ /**
+ * Provide the return url for the OpenIDManager where the
+ * Relying Party can handle responses from the OpenID Provider
+ * @return
+ */
+ String getReturnURL();
+
+ /**
+ * Send the request to the OpenID Provider
+ * @param version OpenID version 1 is via HTTP Redirect
+ * and by HTTP Post for version 2
+ * @param destinationURL Final Destination URL
+ * @param paramMap Map of parameters
+ */
+ void sendToProvider(int version, String destinationURL,
+ Map<String,String> paramMap) throws OpenIDProtocolException;
+}
\ No newline at end of file
Added: social/trunk/openid/src/main/java/org/picketlink/social/openid/api/OpenIDRequest.java
===================================================================
--- social/trunk/openid/src/main/java/org/picketlink/social/openid/api/OpenIDRequest.java (rev 0)
+++ social/trunk/openid/src/main/java/org/picketlink/social/openid/api/OpenIDRequest.java 2011-06-13 19:09:04 UTC (rev 988)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.picketlink.social.openid.api;
+
+/**
+ * Represents an OpenID request
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Jul 6, 2009
+ */
+public class OpenIDRequest
+{
+ private String url;
+
+ public OpenIDRequest()
+ {
+ }
+
+ public OpenIDRequest(String url)
+ {
+ this.url = url;
+ }
+
+ /**
+ * Get the username (openid url)
+ * @return
+ */
+ public String getURL()
+ {
+ return this.url;
+ }
+
+ /**
+ * Set the username in the form of url
+ * @param url
+ * @return
+ */
+ public OpenIDRequest setURL(String url)
+ {
+ this.url = url;
+ return this;
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder();
+ builder.append("[OpenIDRequest:").append(this.url).append("]");
+ return builder.toString();
+ }
+}
\ No newline at end of file
Added: social/trunk/openid/src/main/java/org/picketlink/social/openid/api/exceptions/OpenIDAssociationException.java
===================================================================
--- social/trunk/openid/src/main/java/org/picketlink/social/openid/api/exceptions/OpenIDAssociationException.java (rev 0)
+++ social/trunk/openid/src/main/java/org/picketlink/social/openid/api/exceptions/OpenIDAssociationException.java 2011-06-13 19:09:04 UTC (rev 988)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.picketlink.social.openid.api.exceptions;
+
+/**
+ * Exception indicating openid association problems
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Jul 10, 2009
+ */
+public class OpenIDAssociationException extends OpenIDGeneralException
+{
+ private static final long serialVersionUID = 1L;
+
+ public OpenIDAssociationException()
+ {
+ super();
+ }
+
+ public OpenIDAssociationException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ public OpenIDAssociationException(String msg)
+ {
+ super(msg);
+ }
+
+ public OpenIDAssociationException(Throwable cause)
+ {
+ super(cause);
+ }
+}
\ No newline at end of file
Added: social/trunk/openid/src/main/java/org/picketlink/social/openid/api/exceptions/OpenIDConsumerException.java
===================================================================
--- social/trunk/openid/src/main/java/org/picketlink/social/openid/api/exceptions/OpenIDConsumerException.java (rev 0)
+++ social/trunk/openid/src/main/java/org/picketlink/social/openid/api/exceptions/OpenIDConsumerException.java 2011-06-13 19:09:04 UTC (rev 988)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.picketlink.social.openid.api.exceptions;
+
+
+/**
+ * OpenID Exception at the consumer
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Jul 6, 2009
+ */
+public class OpenIDConsumerException extends OpenIDGeneralException
+{
+ private static final long serialVersionUID = 1L;
+
+ public OpenIDConsumerException()
+ {
+ super();
+ }
+
+ public OpenIDConsumerException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ public OpenIDConsumerException(String msg)
+ {
+ super(msg);
+ }
+
+ public OpenIDConsumerException(Throwable cause)
+ {
+ super(cause);
+ }
+}
\ No newline at end of file
Added: social/trunk/openid/src/main/java/org/picketlink/social/openid/api/exceptions/OpenIDDiscoveryException.java
===================================================================
--- social/trunk/openid/src/main/java/org/picketlink/social/openid/api/exceptions/OpenIDDiscoveryException.java (rev 0)
+++ social/trunk/openid/src/main/java/org/picketlink/social/openid/api/exceptions/OpenIDDiscoveryException.java 2011-06-13 19:09:04 UTC (rev 988)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.picketlink.social.openid.api.exceptions;
+
+
+/**
+ * Discovery of OpenID Provider Exception
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Jul 6, 2009
+ */
+public class OpenIDDiscoveryException extends OpenIDGeneralException
+{
+ private static final long serialVersionUID = 1L;
+
+ public OpenIDDiscoveryException()
+ {
+ super();
+ }
+
+ public OpenIDDiscoveryException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ public OpenIDDiscoveryException(String msg)
+ {
+ super(msg);
+ }
+
+ public OpenIDDiscoveryException(Throwable cause)
+ {
+ super(cause);
+ }
+}
\ No newline at end of file
Added: social/trunk/openid/src/main/java/org/picketlink/social/openid/api/exceptions/OpenIDGeneralException.java
===================================================================
--- social/trunk/openid/src/main/java/org/picketlink/social/openid/api/exceptions/OpenIDGeneralException.java (rev 0)
+++ social/trunk/openid/src/main/java/org/picketlink/social/openid/api/exceptions/OpenIDGeneralException.java 2011-06-13 19:09:04 UTC (rev 988)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.picketlink.social.openid.api.exceptions;
+
+import java.security.GeneralSecurityException;
+
+/**
+ * Base class for all OpenID exceptions
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Jul 10, 2009
+ */
+public class OpenIDGeneralException extends GeneralSecurityException
+{
+ private static final long serialVersionUID = 1L;
+
+ public OpenIDGeneralException()
+ {
+ super();
+ }
+
+ public OpenIDGeneralException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ public OpenIDGeneralException(String msg)
+ {
+ super(msg);
+ }
+
+ public OpenIDGeneralException(Throwable cause)
+ {
+ super(cause);
+ }
+}
\ No newline at end of file
Added: social/trunk/openid/src/main/java/org/picketlink/social/openid/api/exceptions/OpenIDLifeCycleException.java
===================================================================
--- social/trunk/openid/src/main/java/org/picketlink/social/openid/api/exceptions/OpenIDLifeCycleException.java (rev 0)
+++ social/trunk/openid/src/main/java/org/picketlink/social/openid/api/exceptions/OpenIDLifeCycleException.java 2011-06-13 19:09:04 UTC (rev 988)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.picketlink.social.openid.api.exceptions;
+
+/**
+ * Exception indicating issues during lifecycle handling
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Jul 10, 2009
+ */
+public class OpenIDLifeCycleException extends OpenIDGeneralException
+{
+ private static final long serialVersionUID = 1L;
+
+ public OpenIDLifeCycleException()
+ {
+ super();
+ }
+
+ public OpenIDLifeCycleException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ public OpenIDLifeCycleException(String msg)
+ {
+ super(msg);
+ }
+
+ public OpenIDLifeCycleException(Throwable cause)
+ {
+ super(cause);
+ }
+}
\ No newline at end of file
Added: social/trunk/openid/src/main/java/org/picketlink/social/openid/api/exceptions/OpenIDMessageException.java
===================================================================
--- social/trunk/openid/src/main/java/org/picketlink/social/openid/api/exceptions/OpenIDMessageException.java (rev 0)
+++ social/trunk/openid/src/main/java/org/picketlink/social/openid/api/exceptions/OpenIDMessageException.java 2011-06-13 19:09:04 UTC (rev 988)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.picketlink.social.openid.api.exceptions;
+
+
+/**
+ * OpenID exception for message transit
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Jul 6, 2009
+ */
+public class OpenIDMessageException extends OpenIDGeneralException
+{
+ private static final long serialVersionUID = 1L;
+
+ public OpenIDMessageException()
+ {
+ super();
+ }
+
+ public OpenIDMessageException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ public OpenIDMessageException(String msg)
+ {
+ super(msg);
+ }
+
+ public OpenIDMessageException(Throwable cause)
+ {
+ super(cause);
+ }
+}
\ No newline at end of file
Added: social/trunk/openid/src/main/java/org/picketlink/social/openid/api/exceptions/OpenIDProtocolException.java
===================================================================
--- social/trunk/openid/src/main/java/org/picketlink/social/openid/api/exceptions/OpenIDProtocolException.java (rev 0)
+++ social/trunk/openid/src/main/java/org/picketlink/social/openid/api/exceptions/OpenIDProtocolException.java 2011-06-13 19:09:04 UTC (rev 988)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.picketlink.social.openid.api.exceptions;
+
+
+/**
+ * Exception indicating a protocol exception
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Jul 6, 2009
+ */
+public class OpenIDProtocolException extends OpenIDGeneralException
+{
+ private static final long serialVersionUID = 1L;
+
+ public OpenIDProtocolException()
+ {
+ super();
+ }
+
+ public OpenIDProtocolException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ public OpenIDProtocolException(String msg)
+ {
+ super(msg);
+ }
+
+ public OpenIDProtocolException(Throwable cause)
+ {
+ super(cause);
+ }
+}
13 years, 6 months
Picketlink SVN: r987 - in social/trunk/openid/src/test: java/org/picketlink/test/social/openid/integration and 5 other directories.
by picketlink-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2011-06-13 15:00:59 -0400 (Mon, 13 Jun 2011)
New Revision: 987
Added:
social/trunk/openid/src/test/java/org/picketlink/test/social/openid/EmbeddedWebServerBase.java
social/trunk/openid/src/test/java/org/picketlink/test/social/openid/InMemoryProtocolAdapter.java
social/trunk/openid/src/test/java/org/picketlink/test/social/openid/integration/
social/trunk/openid/src/test/java/org/picketlink/test/social/openid/integration/LocalProviderOpenIDUnitTestCase.java
social/trunk/openid/src/test/java/org/picketlink/test/social/openid/integration/YadisMetadataUnitTestCase.java
social/trunk/openid/src/test/java/org/picketlink/test/social/openid/workflow/
social/trunk/openid/src/test/java/org/picketlink/test/social/openid/workflow/OpenIDWorkflowTestConsumerServlet.java
social/trunk/openid/src/test/java/org/picketlink/test/social/openid/workflow/OpenIDWorkflowUnitTestCase.java
social/trunk/openid/src/test/java/org/picketlink/test/social/openid/workflow/PrincipalInducingTestServletFilter.java
social/trunk/openid/src/test/resources/endorsed/
social/trunk/openid/src/test/resources/endorsed/resolver.jar
social/trunk/openid/src/test/resources/endorsed/serializer.jar
social/trunk/openid/src/test/resources/endorsed/xalan.jar
social/trunk/openid/src/test/resources/endorsed/xercesImpl.jar
social/trunk/openid/src/test/resources/endorsed/xml-apis.jar
social/trunk/openid/src/test/resources/openid/
social/trunk/openid/src/test/resources/openid/localhost-yadis.xml
social/trunk/openid/src/test/resources/openid/webapp/
social/trunk/openid/src/test/resources/openid/webapp/index.jsp
social/trunk/openid/src/test/resources/openid/webapp/securepage.jsp
Log:
openid code migration
Added: social/trunk/openid/src/test/java/org/picketlink/test/social/openid/EmbeddedWebServerBase.java
===================================================================
--- social/trunk/openid/src/test/java/org/picketlink/test/social/openid/EmbeddedWebServerBase.java (rev 0)
+++ social/trunk/openid/src/test/java/org/picketlink/test/social/openid/EmbeddedWebServerBase.java 2011-06-13 19:00:59 UTC (rev 987)
@@ -0,0 +1,81 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.picketlink.test.social.openid;
+
+import junit.framework.TestCase;
+
+import org.mortbay.jetty.Connector;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.bio.SocketConnector;
+
+/**
+ * Base class for embedded web server based tests
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Jul 8, 2009
+ */
+public abstract class EmbeddedWebServerBase extends TestCase
+{
+ protected Server server = null;
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+
+ //Start the Jetty embedded container
+ server = new Server();
+
+ server.setConnectors(getConnectors());
+
+ this.establishUserApps();
+
+ server.start();
+ }
+
+ public void tearDown() throws Exception
+ {
+ if(server != null)
+ {
+ server.stop();
+ server.destroy();
+ server = null;
+ }
+ super.tearDown();
+ }
+
+ /**
+ * Return the connectors that need to be configured
+ * on the server. Subclasses can create as many connectors
+ * as they want
+ * @return
+ */
+ protected Connector[] getConnectors()
+ {
+ Connector connector=new SocketConnector();
+ connector.setPort(11080);
+ return new Connector[]{connector};
+ }
+
+ /**
+ * Establish the user applications - context, servlets etc
+ */
+ protected abstract void establishUserApps();
+}
\ No newline at end of file
Added: social/trunk/openid/src/test/java/org/picketlink/test/social/openid/InMemoryProtocolAdapter.java
===================================================================
--- social/trunk/openid/src/test/java/org/picketlink/test/social/openid/InMemoryProtocolAdapter.java (rev 0)
+++ social/trunk/openid/src/test/java/org/picketlink/test/social/openid/InMemoryProtocolAdapter.java 2011-06-13 19:00:59 UTC (rev 987)
@@ -0,0 +1,104 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.picketlink.test.social.openid;
+
+import java.net.URL;
+import java.util.Map;
+
+import org.picketlink.identity.federation.api.openid.OpenIDAttributeMap;
+import org.picketlink.identity.federation.api.openid.OpenIDLifecycle;
+import org.picketlink.identity.federation.api.openid.OpenIDLifecycleEvent;
+import org.picketlink.identity.federation.api.openid.OpenIDProtocolAdapter;
+import org.picketlink.identity.federation.api.openid.exceptions.OpenIDLifeCycleException;
+import org.picketlink.identity.federation.api.openid.exceptions.OpenIDProtocolException;
+
+import com.meterware.httpunit.GetMethodWebRequest;
+import com.meterware.httpunit.WebConversation;
+import com.meterware.httpunit.WebForm;
+import com.meterware.httpunit.WebRequest;
+import com.meterware.httpunit.WebResponse;
+
+/**
+ * Adapter that is in memory or the same VM
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Jul 7, 2009
+ */
+public class InMemoryProtocolAdapter implements OpenIDProtocolAdapter, OpenIDLifecycle
+{
+ public OpenIDAttributeMap getAttributeMap()
+ {
+ return new OpenIDAttributeMap();
+ }
+
+ public void handle(OpenIDLifecycleEvent event)
+ {
+ }
+
+ public Object getAttributeValue(String name)
+ {
+ return null;
+ }
+
+ public void handle(OpenIDLifecycleEvent[] eventArr) throws OpenIDLifeCycleException
+ {
+ }
+
+ public String getReturnURL()
+ {
+ return "http://localhost:11080/consumer";
+ }
+
+ public void sendToProvider(int version, String destinationURL, Map<String, String> paramMap)
+ throws OpenIDProtocolException
+ {
+ System.out.println("Version="+ version);
+ System.out.println("destinationURL="+ destinationURL);
+ System.out.println("paramMap="+ paramMap);
+
+ if(version == 1)
+ {
+ WebConversation wc = new WebConversation();
+ wc.setAuthorization( "anil", "anil" );
+ WebRequest req = new GetMethodWebRequest( destinationURL );
+ try
+ {
+ WebResponse resp = wc.getResponse( req );
+ URL responseURL = resp.getURL();
+ if( responseURL.toString().contains( "securepage.jsp" ))
+ {
+ resp = wc.getResponse( responseURL.toString() );
+ WebForm form = resp.getForms()[0];
+ resp = form.submit();
+ }
+ }
+ catch ( Exception e)
+ {
+ e.printStackTrace();
+ throw new OpenIDProtocolException();
+ }
+ }
+ else
+ {
+ throw new RuntimeException("Not implemented");
+ }
+ }
+}
\ No newline at end of file
Added: social/trunk/openid/src/test/java/org/picketlink/test/social/openid/integration/LocalProviderOpenIDUnitTestCase.java
===================================================================
--- social/trunk/openid/src/test/java/org/picketlink/test/social/openid/integration/LocalProviderOpenIDUnitTestCase.java (rev 0)
+++ social/trunk/openid/src/test/java/org/picketlink/test/social/openid/integration/LocalProviderOpenIDUnitTestCase.java 2011-06-13 19:00:59 UTC (rev 987)
@@ -0,0 +1,198 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.picketlink.test.social.openid.integration;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.picketlink.identity.federation.api.openid.OpenIDManager;
+import org.picketlink.identity.federation.api.openid.OpenIDRequest;
+import org.picketlink.identity.federation.api.openid.OpenIDManager.OpenIDProviderInformation;
+import org.picketlink.identity.federation.api.openid.OpenIDManager.OpenIDProviderList;
+import org.picketlink.test.social.openid.EmbeddedWebServerBase;
+import org.picketlink.test.social.openid.InMemoryProtocolAdapter;
+import org.mortbay.jetty.servlet.Context;
+import org.mortbay.jetty.servlet.ServletHolder;
+import org.openid4java.message.AuthSuccess;
+import org.openid4java.message.DirectError;
+import org.openid4java.message.Message;
+import org.openid4java.message.ParameterList;
+import org.openid4java.server.InMemoryServerAssociationStore;
+import org.openid4java.server.ServerManager;
+
+/**
+ * Test the OpenID functionality within the VM
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Jul 7, 2009
+ */
+public class LocalProviderOpenIDUnitTestCase extends EmbeddedWebServerBase
+{
+ protected void establishUserApps()
+ {
+ ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+ InputStream is = tcl.getResourceAsStream("openid/localhost-yadis.xml");
+
+ assertNotNull("Yadis descriptor not null", is);
+
+ Context context = new Context(server,"/",Context.SESSIONS);
+ context.addServlet(new ServletHolder(new YadisServlet(is)), "/*");
+
+ context.addServlet(new ServletHolder(new ProviderServlet()), "/provider/");
+ }
+
+ public void testOpenIDAuth() throws Exception
+ {
+ //String username = "http://jbosstest.myopenid.com";
+ String username = "http://localhost:11080";
+ InMemoryProtocolAdapter ad = new InMemoryProtocolAdapter();
+ OpenIDRequest openIDRequest = new OpenIDRequest(username);
+ OpenIDManager idm = new OpenIDManager(openIDRequest);
+ OpenIDProviderList providers = idm.discoverProviders();
+ assertNotNull("List of providers is not null", providers);
+
+ OpenIDProviderInformation providerInfo = idm.associate(ad,providers);
+ boolean auth = idm.authenticate(ad, providerInfo);
+ assertTrue( "OpenID Auth was successful", auth );
+ }
+
+ //A provider servlet that always returns true
+ private static class ProviderServlet extends HttpServlet
+ {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
+ {
+ doGet(req, resp);
+ }
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
+ {
+ System.out.println("Inside ProviderServlet::doGet");
+
+ ParameterList requestP = new ParameterList(req.getParameterMap());
+
+ ServerManager manager = new ServerManager();
+ manager.setSharedAssociations(new InMemoryServerAssociationStore());
+ manager.setPrivateAssociations(new InMemoryServerAssociationStore());
+ manager.setOPEndpointUrl("http://localhost:11080/provider/");
+
+ String userSelectedId = "http://test.localhost:11080";
+ String userSelectedClaimedId = userSelectedId;
+ boolean authenticatedAndApproved = true;
+
+ String responseText = "";
+
+ String mode = requestP.hasParameter("openid.mode") ?
+ requestP.getParameterValue("openid.mode") : null;
+
+ System.out.println("ProviderServlet::mode="+mode);
+ Message responsem ;
+ if ("associate".equals(mode))
+ {
+ // --- process an association request ---
+ responsem = manager.associationResponse(requestP);
+ responseText = responsem.keyValueFormEncoding().trim();
+ }
+ else if ("checkid_setup".equals(mode)
+ || "checkid_immediate".equals(mode))
+ {
+ responsem = manager.authResponse(requestP,
+ userSelectedId,
+ userSelectedClaimedId,
+ authenticatedAndApproved );
+
+ if (responsem instanceof AuthSuccess)
+ {
+ resp.sendRedirect(((AuthSuccess) responsem).getDestinationUrl(true));
+ return;
+ }
+ else
+ {
+ responseText="<pre>"+responsem.keyValueFormEncoding().trim()+"</pre>";
+ }
+ }
+ else if ("check_authentication".equals(mode))
+ {
+ // --- processing a verification request ---
+ responsem = manager.verify(requestP);
+ responseText = responsem.keyValueFormEncoding().trim();
+ }
+ else
+ {
+ // --- error response ---
+ responsem = DirectError.createDirectError("Unknown request");
+ responseText = responsem.keyValueFormEncoding().trim();
+ }
+
+ resp.setStatus(HttpServletResponse.SC_OK);
+ resp.getWriter().print(responseText);
+ }
+ }
+
+ //A Yadis servlet that just reads the XML from the Inputstream and passes it back
+ private class YadisServlet extends HttpServlet
+ {
+ private static final long serialVersionUID = 1L;
+
+ private InputStream yadisDescriptor;
+
+ public YadisServlet(InputStream yadisDescriptor)
+ {
+ if(yadisDescriptor == null)
+ throw new RuntimeException("input stream null");
+ this.yadisDescriptor = yadisDescriptor;
+ }
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse resp)
+ throws ServletException, IOException
+ {
+ System.out.println("Inside Yadis Servlet");
+ if("HEAD".equals(request.getMethod()))
+ {
+ resp.setStatus(HttpServletResponse.SC_OK);
+ return;
+ }
+
+ //Asking for Yadis discovery
+ byte[] barr = new byte[1024];
+ for (int i = 0; i < barr.length; i++)
+ {
+ int b = yadisDescriptor.read();
+ if (b == -1) break;
+ barr[i] = (byte) b;
+ }
+ resp.setContentType("application/xrds+xml");
+ resp.setStatus(HttpServletResponse.SC_OK);
+
+ String ycontent = new String(barr);
+ ycontent = ycontent.replace("\n"," ").trim();
+ resp.getWriter().print(ycontent);
+ }
+ }
+}
\ No newline at end of file
Added: social/trunk/openid/src/test/java/org/picketlink/test/social/openid/integration/YadisMetadataUnitTestCase.java
===================================================================
--- social/trunk/openid/src/test/java/org/picketlink/test/social/openid/integration/YadisMetadataUnitTestCase.java (rev 0)
+++ social/trunk/openid/src/test/java/org/picketlink/test/social/openid/integration/YadisMetadataUnitTestCase.java 2011-06-13 19:00:59 UTC (rev 987)
@@ -0,0 +1,97 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.picketlink.test.social.openid.integration;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.picketlink.identity.federation.api.openid.OpenIDManager;
+import org.picketlink.identity.federation.api.openid.OpenIDRequest;
+import org.picketlink.identity.federation.api.openid.OpenIDManager.OpenIDProviderList;
+import org.picketlink.social.openid.servlets.OpenIDYadisServlet;
+import org.picketlink.test.social.openid.EmbeddedWebServerBase;
+import org.mortbay.jetty.servlet.Context;
+import org.mortbay.jetty.servlet.ServletHolder;
+
+/**
+ * Unit test the OpenID Yadis Servlet
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Jul 7, 2009
+ */
+public class YadisMetadataUnitTestCase extends EmbeddedWebServerBase
+{
+ protected void establishUserApps()
+ {
+ Context context = new Context(server,"/",Context.SESSIONS);
+ ServletHolder servletHolder = new ServletHolder(new OpenIDYadisServlet());
+ servletHolder.setInitParameter("support_HTTP_HEAD", "true");
+ servletHolder.setInitParameter("yadisResourceURL", "http://localhost:11080/yadis");
+
+ context.addServlet(servletHolder, "/*");
+
+ context.addServlet(new ServletHolder( new TestYadisResourceServlet()), "/yadis");
+ }
+
+ public void testYadisDiscovery() throws Exception
+ {
+ //String username = "http://jbosstest.myopenid.com";
+ String username = "http://localhost:11080";
+
+ OpenIDRequest openIDRequest = new OpenIDRequest(username);
+ OpenIDManager idm = new OpenIDManager(openIDRequest);
+
+ OpenIDProviderList providers = idm.discoverProviders();
+ assertNotNull("Providers list is not null", providers);
+ assertEquals("1 provider", 1, providers.size());
+ }
+
+ /**
+ * Servlet that just outputs an Yadis resource
+ */
+ private class TestYadisResourceServlet extends HttpServlet
+ {
+ private static final long serialVersionUID = 1L;
+
+ String yadis = "<xrds:XRDS "+
+ " xmlns:xrds=\'xri://$xrds\' " +
+ " xmlns:openid=\'http://openid.net/xmlns/1.0\'" +
+ " xmlns=\'xri://$xrd*($v*2.0)\'>" +
+ "<XRD>" +
+ " <Service priority=\'0\'>" +
+ " <Type>http://openid.net/signon/1.0</Type>" +
+ " <URI>http://localhost/provider.jsp</URI>" +
+ " </Service>"+
+ "</XRD>" +
+ "</xrds:XRDS>";
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
+ {
+ resp.setContentType("application/xrds+xml");
+ resp.setStatus(HttpServletResponse.SC_OK);
+ resp.getWriter().print(yadis);
+ }
+ }
+}
\ No newline at end of file
Added: social/trunk/openid/src/test/java/org/picketlink/test/social/openid/workflow/OpenIDWorkflowTestConsumerServlet.java
===================================================================
--- social/trunk/openid/src/test/java/org/picketlink/test/social/openid/workflow/OpenIDWorkflowTestConsumerServlet.java (rev 0)
+++ social/trunk/openid/src/test/java/org/picketlink/test/social/openid/workflow/OpenIDWorkflowTestConsumerServlet.java 2011-06-13 19:00:59 UTC (rev 987)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.picketlink.test.social.openid.workflow;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.picketlink.identity.federation.api.openid.OpenIDManager;
+import org.picketlink.identity.federation.web.openid.HTTPOpenIDContext;
+import org.picketlink.identity.federation.web.openid.HTTPProtocolAdaptor;
+
+/**
+ * Test Consumer Servlet
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Jan 19, 2011
+ */
+public class OpenIDWorkflowTestConsumerServlet extends HttpServlet
+{
+ private static final long serialVersionUID = 1L;
+
+ private OpenIDManager manager = null;
+
+ public OpenIDWorkflowTestConsumerServlet( OpenIDManager mgr )
+ {
+ this.manager = mgr;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
+ {
+ log( "Provider response:" + request.getQueryString() );
+ log( "UserID Chosen=" + request.getParameter( "openid.identity" ));
+
+ // extract the receiving URL from the HTTP request
+ StringBuffer receivingURL = request.getRequestURL();
+ String queryString = request.getQueryString();
+ if (queryString != null && queryString.length() > 0)
+ receivingURL.append("?").append(request.getQueryString());
+
+ HTTPProtocolAdaptor adapter = new HTTPProtocolAdaptor(new HTTPOpenIDContext( request,response, getServletContext() ));
+ try
+ {
+ boolean auth = manager.verify(adapter, request.getParameterMap(), receivingURL.toString() );
+ if( !auth )
+ throw new ServletException( "OpenID information from provider not successfully verified" );
+ }
+ catch ( Exception e)
+ {
+ e.printStackTrace();
+ throw new IOException();
+ }
+ }
+}
\ No newline at end of file
Added: social/trunk/openid/src/test/java/org/picketlink/test/social/openid/workflow/OpenIDWorkflowUnitTestCase.java
===================================================================
--- social/trunk/openid/src/test/java/org/picketlink/test/social/openid/workflow/OpenIDWorkflowUnitTestCase.java (rev 0)
+++ social/trunk/openid/src/test/java/org/picketlink/test/social/openid/workflow/OpenIDWorkflowUnitTestCase.java 2011-06-13 19:00:59 UTC (rev 987)
@@ -0,0 +1,81 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.picketlink.test.social.openid.workflow;
+
+import java.net.URL;
+
+import org.mortbay.jetty.servlet.Context;
+import org.mortbay.jetty.servlet.ServletHolder;
+import org.mortbay.jetty.webapp.WebAppContext;
+import org.picketlink.identity.federation.api.openid.OpenIDManager;
+import org.picketlink.identity.federation.api.openid.OpenIDManager.OpenIDProviderInformation;
+import org.picketlink.identity.federation.api.openid.OpenIDManager.OpenIDProviderList;
+import org.picketlink.identity.federation.api.openid.OpenIDRequest;
+import org.picketlink.social.openid.servlets.OpenIDProviderServlet;
+import org.picketlink.test.social.openid.EmbeddedWebServerBase;
+import org.picketlink.test.social.openid.InMemoryProtocolAdapter;
+
+
+/**
+ * Test the workflow of an OpenID Consumer with a provider
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Jan 18, 2011
+ */
+public class OpenIDWorkflowUnitTestCase extends EmbeddedWebServerBase
+{
+ private String username = "http://localhost:11080";
+ private OpenIDRequest openIDRequest = new OpenIDRequest( username );
+ private OpenIDManager manager = new OpenIDManager( openIDRequest );
+
+ protected void establishUserApps()
+ {
+ ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+
+ final String WEBAPPDIR = "openid/webapp";
+
+ final String CONTEXTPATH = "/";
+
+ // for localhost:port/admin/index.html and whatever else is in the webapp directory
+ final URL warUrl = tcl.getResource(WEBAPPDIR);
+ final String warUrlString = warUrl.toExternalForm();
+
+ Context context = new WebAppContext( warUrlString, CONTEXTPATH );
+ server.setHandler( context );
+
+ context.addServlet(new ServletHolder(new OpenIDProviderServlet()), "/provider/");
+
+ context.addServlet( new ServletHolder( new OpenIDWorkflowTestConsumerServlet( manager)), "/consumer" );
+
+ context.addFilter(PrincipalInducingTestServletFilter.class, "/securepage.jsp", 1 );
+ }
+
+ public void testOpenIDAuth() throws Exception
+ {
+ InMemoryProtocolAdapter ad = new InMemoryProtocolAdapter();
+ OpenIDProviderList providers = manager.discoverProviders();
+ assertNotNull("List of providers is not null", providers);
+
+ OpenIDProviderInformation providerInfo = manager.associate( ad,providers );
+ boolean isValid = manager.authenticate( ad, providerInfo );
+ assertTrue( "Authentication is valid" , isValid );
+ }
+}
\ No newline at end of file
Added: social/trunk/openid/src/test/java/org/picketlink/test/social/openid/workflow/PrincipalInducingTestServletFilter.java
===================================================================
--- social/trunk/openid/src/test/java/org/picketlink/test/social/openid/workflow/PrincipalInducingTestServletFilter.java (rev 0)
+++ social/trunk/openid/src/test/java/org/picketlink/test/social/openid/workflow/PrincipalInducingTestServletFilter.java 2011-06-13 19:00:59 UTC (rev 987)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.picketlink.test.social.openid.workflow;
+
+import java.io.IOException;
+import java.security.Principal;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+import org.mortbay.jetty.Request;
+
+/**
+ * A servlet filter for testing that adds a principal with name "anil"
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Jan 19, 2011
+ */
+public class PrincipalInducingTestServletFilter implements Filter
+{
+ public void init(FilterConfig filterConfig) throws ServletException
+ {
+ }
+
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,
+ ServletException
+ {
+ Request jettyRequest = (Request) request;
+ if( jettyRequest.getUserPrincipal() == null )
+ {
+ jettyRequest.setUserPrincipal( new Principal() {
+
+ public String getName()
+ {
+ return "http://localhost:11080/";
+ }} );
+ }
+ chain.doFilter(request, response);
+ }
+
+ public void destroy()
+ {
+ }
+}
\ No newline at end of file
Added: social/trunk/openid/src/test/resources/endorsed/resolver.jar
===================================================================
(Binary files differ)
Property changes on: social/trunk/openid/src/test/resources/endorsed/resolver.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: social/trunk/openid/src/test/resources/endorsed/serializer.jar
===================================================================
(Binary files differ)
Property changes on: social/trunk/openid/src/test/resources/endorsed/serializer.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: social/trunk/openid/src/test/resources/endorsed/xalan.jar
===================================================================
(Binary files differ)
Property changes on: social/trunk/openid/src/test/resources/endorsed/xalan.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: social/trunk/openid/src/test/resources/endorsed/xercesImpl.jar
===================================================================
(Binary files differ)
Property changes on: social/trunk/openid/src/test/resources/endorsed/xercesImpl.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: social/trunk/openid/src/test/resources/endorsed/xml-apis.jar
===================================================================
(Binary files differ)
Property changes on: social/trunk/openid/src/test/resources/endorsed/xml-apis.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: social/trunk/openid/src/test/resources/openid/localhost-yadis.xml
===================================================================
--- social/trunk/openid/src/test/resources/openid/localhost-yadis.xml (rev 0)
+++ social/trunk/openid/src/test/resources/openid/localhost-yadis.xml 2011-06-13 19:00:59 UTC (rev 987)
@@ -0,0 +1,10 @@
+<xrds:XRDS xmlns:xrds="xri://$xrds"
+ xmlns:openid="http://openid.net/xmlns/1.0"
+ xmlns="xri://$xrd*($v*2.0)">
+ <XRD>
+ <Service priority="0">
+ <Type>http://openid.net/signon/1.0</Type>
+ <URI>http://localhost:11080/provider/</URI>
+ </Service>
+ </XRD>
+</xrds:XRDS>
\ No newline at end of file
Added: social/trunk/openid/src/test/resources/openid/webapp/index.jsp
===================================================================
--- social/trunk/openid/src/test/resources/openid/webapp/index.jsp (rev 0)
+++ social/trunk/openid/src/test/resources/openid/webapp/index.jsp 2011-06-13 19:00:59 UTC (rev 987)
@@ -0,0 +1,18 @@
+<%@ page contentType="application/xrds+xml"%><?xml version="1.0" encoding="UTF-8"?>
+<xrds:XRDS
+ xmlns:xrds="xri://$xrds"
+ xmlns:openid="http://openid.net/xmlns/1.0"
+ xmlns="xri://$xrd*($v*2.0)">
+ <XRD>
+ <!-- Change the URI for OpenID2 pointing to where the provider is located -->
+ <Service priority="0">
+ <Type>http://specs.openid.net/auth/2.0</Type>
+ <URI>http://localhost:11080/provider/</URI>
+ </Service>
+ <!-- Change the URI for OpenID1 pointing to where the provider is located -->
+ <Service priority="1">
+ <Type>http://openid.net/signon/1.0</Type>
+ <URI>http://localhost:11080/provider/</URI>
+ </Service>
+ </XRD>
+</xrds:XRDS>
Added: social/trunk/openid/src/test/resources/openid/webapp/securepage.jsp
===================================================================
--- social/trunk/openid/src/test/resources/openid/webapp/securepage.jsp (rev 0)
+++ social/trunk/openid/src/test/resources/openid/webapp/securepage.jsp 2011-06-13 19:00:59 UTC (rev 987)
@@ -0,0 +1,10 @@
+<%
+ session.setAttribute("authenticatedAndApproved", Boolean.TRUE);
+%>
+
+
+You have logged in.
+
+<form method="POST" action="<%=request.getContextPath()%>/provider/?_action=complete">
+<input type="submit" value="Continue"/>
+</form>
13 years, 6 months
Picketlink SVN: r986 - in social/trunk/openid/src/main/java/org/picketlink/social/openid: providers and 2 other directories.
by picketlink-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2011-06-13 14:36:40 -0400 (Mon, 13 Jun 2011)
New Revision: 986
Added:
social/trunk/openid/src/main/java/org/picketlink/social/openid/servlets/
social/trunk/openid/src/main/java/org/picketlink/social/openid/servlets/OpenIDConsumerServlet.java
social/trunk/openid/src/main/java/org/picketlink/social/openid/servlets/OpenIDProviderServlet.java
social/trunk/openid/src/main/java/org/picketlink/social/openid/servlets/OpenIDYadisServlet.java
social/trunk/openid/src/main/java/org/picketlink/social/openid/servlets/SecurityActions.java
Modified:
social/trunk/openid/src/main/java/org/picketlink/social/openid/providers/OpenIDTokenProvider.java
social/trunk/openid/src/main/java/org/picketlink/social/openid/providers/helpers/OpenIDProtocolContext.java
Log:
migrate openid servlets from fed trunk
Modified: social/trunk/openid/src/main/java/org/picketlink/social/openid/providers/OpenIDTokenProvider.java
===================================================================
--- social/trunk/openid/src/main/java/org/picketlink/social/openid/providers/OpenIDTokenProvider.java 2011-06-13 18:25:32 UTC (rev 985)
+++ social/trunk/openid/src/main/java/org/picketlink/social/openid/providers/OpenIDTokenProvider.java 2011-06-13 18:36:40 UTC (rev 986)
@@ -22,19 +22,19 @@
package org.picketlink.social.openid.providers;
import javax.xml.namespace.QName;
-
-import org.picketlink.identity.federation.core.exceptions.ProcessingException;
+
+import org.jboss.security.xacml.sunxacml.ProcessingException;
import org.picketlink.identity.federation.core.interfaces.ProtocolContext;
import org.picketlink.identity.federation.core.interfaces.SecurityTokenProvider;
-import org.picketlink.identity.federation.core.openid.providers.helpers.OpenIDParameterList;
-import org.picketlink.identity.federation.core.openid.providers.helpers.OpenIDProtocolContext;
-import org.picketlink.identity.federation.core.openid.providers.helpers.OpenIDProtocolContext.AUTH_HOLDER;
-import org.picketlink.identity.federation.core.openid.providers.helpers.OpenIDProtocolContext.MODE;
-import org.picketlink.identity.federation.core.openid.providers.helpers.OpenIDProviderManager;
-import org.picketlink.identity.federation.core.openid.providers.helpers.OpenIDTokenRegistryStore;
-import org.picketlink.identity.federation.core.openid.providers.helpers.OpenIDProviderManager.OpenIDMessage;
import org.picketlink.identity.federation.core.sts.AbstractSecurityTokenProvider;
import org.picketlink.identity.federation.core.sts.PicketLinkCoreSTS;
+import org.picketlink.social.openid.providers.helpers.OpenIDParameterList;
+import org.picketlink.social.openid.providers.helpers.OpenIDProtocolContext;
+import org.picketlink.social.openid.providers.helpers.OpenIDProtocolContext.AUTH_HOLDER;
+import org.picketlink.social.openid.providers.helpers.OpenIDProtocolContext.MODE;
+import org.picketlink.social.openid.providers.helpers.OpenIDProviderManager;
+import org.picketlink.social.openid.providers.helpers.OpenIDTokenRegistryStore;
+import org.picketlink.social.openid.providers.helpers.OpenIDProviderManager.OpenIDMessage;
/**
* @author Anil.Saldhana(a)redhat.com
@@ -49,7 +49,7 @@
protected static OpenIDProviderManager serverManager = null; //Will be initialized the first time of access
/**
- * @see org.picketlink.identity.federation.core.interfaces.SecurityTokenProvider#supports(java.lang.String)
+ * @see org.picketlink.social.interfaces.SecurityTokenProvider#supports(java.lang.String)
*/
public boolean supports(String namespace)
{
@@ -57,7 +57,7 @@
}
/**
- * @see org.picketlink.identity.federation.core.interfaces.SecurityTokenProvider#tokenType()
+ * @see org.picketlink.social.interfaces.SecurityTokenProvider#tokenType()
*/
public String tokenType()
{
@@ -65,7 +65,7 @@
}
/**
- * @see org.picketlink.identity.federation.core.interfaces.SecurityTokenProvider#getSupportedQName()
+ * @see org.picketlink.social.interfaces.SecurityTokenProvider#getSupportedQName()
*/
public QName getSupportedQName()
{
@@ -73,7 +73,7 @@
}
/**
- * @see org.picketlink.identity.federation.core.interfaces.SecurityTokenProvider#family()
+ * @see org.picketlink.social.interfaces.SecurityTokenProvider#family()
*/
public String family()
{
@@ -81,7 +81,7 @@
}
/**
- * @see org.picketlink.identity.federation.core.interfaces.SecurityTokenProvider#issueToken(org.picketlink.identity.federation.core.interfaces.ProtocolContext)
+ * @see org.picketlink.social.interfaces.SecurityTokenProvider#issueToken(org.picketlink.social.interfaces.ProtocolContext)
*/
public void issueToken(ProtocolContext context) throws ProcessingException
{
@@ -137,7 +137,7 @@
}
/**
- * @see org.picketlink.identity.federation.core.interfaces.SecurityTokenProvider#renewToken(org.picketlink.identity.federation.core.interfaces.ProtocolContext)
+ * @see org.picketlink.social.interfaces.SecurityTokenProvider#renewToken(org.picketlink.social.interfaces.ProtocolContext)
*/
public void renewToken(ProtocolContext context) throws ProcessingException
{
@@ -148,7 +148,7 @@
}
/*
- * @see org.picketlink.identity.federation.core.interfaces.SecurityTokenProvider#cancelToken(org.picketlink.identity.federation.core.interfaces.ProtocolContext)
+ * @see org.picketlink.social.interfaces.SecurityTokenProvider#cancelToken(org.picketlink.social.interfaces.ProtocolContext)
*/
public void cancelToken(ProtocolContext context) throws ProcessingException
{
@@ -159,7 +159,7 @@
}
/**
- * @see org.picketlink.identity.federation.core.interfaces.SecurityTokenProvider#validateToken(org.picketlink.identity.federation.core.interfaces.ProtocolContext)
+ * @see org.picketlink.social.interfaces.SecurityTokenProvider#validateToken(org.picketlink.social.interfaces.ProtocolContext)
*/
public void validateToken(ProtocolContext context) throws ProcessingException
{
Modified: social/trunk/openid/src/main/java/org/picketlink/social/openid/providers/helpers/OpenIDProtocolContext.java
===================================================================
--- social/trunk/openid/src/main/java/org/picketlink/social/openid/providers/helpers/OpenIDProtocolContext.java 2011-06-13 18:25:32 UTC (rev 985)
+++ social/trunk/openid/src/main/java/org/picketlink/social/openid/providers/helpers/OpenIDProtocolContext.java 2011-06-13 18:36:40 UTC (rev 986)
@@ -25,8 +25,8 @@
import org.picketlink.identity.federation.core.interfaces.ProtocolContext;
import org.picketlink.identity.federation.core.interfaces.SecurityTokenProvider;
-import org.picketlink.identity.federation.core.openid.providers.OpenIDTokenProvider;
-import org.picketlink.identity.federation.core.openid.providers.helpers.OpenIDProviderManager.OpenIDMessage;
+import org.picketlink.social.openid.providers.OpenIDTokenProvider;
+import org.picketlink.social.openid.providers.helpers.OpenIDProviderManager.OpenIDMessage;
/**
* {@code ProtocolContext} for the OpenID Layer
Added: social/trunk/openid/src/main/java/org/picketlink/social/openid/servlets/OpenIDConsumerServlet.java
===================================================================
--- social/trunk/openid/src/main/java/org/picketlink/social/openid/servlets/OpenIDConsumerServlet.java (rev 0)
+++ social/trunk/openid/src/main/java/org/picketlink/social/openid/servlets/OpenIDConsumerServlet.java 2011-06-13 18:36:40 UTC (rev 986)
@@ -0,0 +1,100 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.picketlink.social.openid.servlets;
+
+import java.io.IOException;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.picketlink.identity.federation.api.openid.OpenIDManager;
+import org.picketlink.identity.federation.api.openid.OpenIDRequest;
+import org.picketlink.identity.federation.api.openid.OpenIDManager.OpenIDProviderInformation;
+import org.picketlink.identity.federation.api.openid.OpenIDManager.OpenIDProviderList;
+import org.picketlink.identity.federation.api.openid.exceptions.OpenIDGeneralException;
+import org.picketlink.identity.federation.web.openid.HTTPOpenIDContext;
+import org.picketlink.identity.federation.web.openid.HTTPProtocolAdaptor;
+
+/**
+ * OpenID Consumer Servlet that gets a post
+ * request from the main JSP page of the consumer
+ * web application.
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Jul 10, 2009
+ */
+public class OpenIDConsumerServlet extends HttpServlet
+{
+ private static final long serialVersionUID = 1L;
+
+ private transient ServletContext servletContext;
+ private String returnURL;
+
+ @Override
+ public void init(ServletConfig config) throws ServletException
+ {
+ super.init(config);
+ this.servletContext = config.getServletContext();
+ returnURL = this.servletContext.getInitParameter("returnURL");
+ }
+
+ @Override
+ protected void doPost(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, IOException
+ {
+ if(returnURL == null)
+ returnURL = "http://" + req.getServerName() + ":" + req.getServerPort() +
+ req.getContextPath() + "/consumer_return.jsp";
+
+ String userEntry = req.getParameter("openid");
+ OpenIDRequest openIDReq = new OpenIDRequest(userEntry);
+
+ HttpSession session = req.getSession();
+ OpenIDManager manager = (OpenIDManager) session.getAttribute("openid_manager");
+ if(manager == null)
+ {
+ manager = new OpenIDManager(openIDReq);
+ session.setAttribute("openid_manager", manager);
+ }
+ manager.setUserString( userEntry );
+
+ try
+ {
+ OpenIDProviderList listOfProviders = manager.discoverProviders();
+ HTTPOpenIDContext httpOpenIDCtx = new HTTPOpenIDContext(req,resp, this.servletContext);
+ httpOpenIDCtx.setReturnURL(returnURL);
+
+ HTTPProtocolAdaptor adapter = new HTTPProtocolAdaptor(httpOpenIDCtx);
+ OpenIDProviderInformation providerInfo = manager.associate(adapter, listOfProviders);
+ manager.authenticate(adapter, providerInfo);
+ }
+ catch (OpenIDGeneralException e)
+ {
+ log("[OpenIDConsumerServlet]Exception in dealing with the provider:",e);
+ resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+ }
+ }
+}
\ No newline at end of file
Added: social/trunk/openid/src/main/java/org/picketlink/social/openid/servlets/OpenIDProviderServlet.java
===================================================================
--- social/trunk/openid/src/main/java/org/picketlink/social/openid/servlets/OpenIDProviderServlet.java (rev 0)
+++ social/trunk/openid/src/main/java/org/picketlink/social/openid/servlets/OpenIDProviderServlet.java 2011-06-13 18:36:40 UTC (rev 986)
@@ -0,0 +1,240 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.picketlink.social.openid.servlets;
+
+import java.io.IOException;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.openid4java.message.Parameter;
+import org.picketlink.identity.federation.core.exceptions.ProcessingException;
+import org.picketlink.identity.federation.core.sts.PicketLinkCoreSTS;
+import org.picketlink.social.openid.providers.helpers.OpenIDParameterList;
+import org.picketlink.social.openid.providers.helpers.OpenIDProtocolContext;
+import org.picketlink.social.openid.providers.helpers.OpenIDProtocolContext.AUTH_HOLDER;
+import org.picketlink.social.openid.providers.helpers.OpenIDProtocolContext.MODE;
+import org.picketlink.social.openid.providers.helpers.OpenIDProviderManager.OpenIDMessage;
+
+/**
+ * Servlet that provides the Provider functionality
+ * for OpenID
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Jul 15, 2009
+ */
+public class OpenIDProviderServlet extends HttpServlet
+{
+ private static final long serialVersionUID = 1L;
+ private transient ServletContext servletContext = null;
+ private String securePageName = "securepage.jsp";
+
+ private transient PicketLinkCoreSTS sts = PicketLinkCoreSTS.instance();
+
+ @Override
+ public void init(ServletConfig config) throws ServletException
+ {
+ super.init(config);
+ this.servletContext = config.getServletContext();
+ String secpageStr = this.servletContext.getInitParameter("securePage");
+ if(secpageStr != null && secpageStr.length() > 0)
+ securePageName = secpageStr;
+
+ sts.installDefaultConfiguration( ( String[] )null );
+ }
+
+ @Override
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
+ {
+ doPost(request, response);
+ }
+
+ @Override
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
+ {
+ HttpSession session = request.getSession();
+
+ OpenIDProtocolContext protoCtx = new OpenIDProtocolContext();
+
+ protoCtx.setEndpoint(request.getScheme() + "://" +
+ request.getServerName() + ":" +
+ request.getServerPort() +
+ request.getContextPath() +
+ "/provider/");
+
+ OpenIDParameterList requestp;
+
+ if ("complete".equals(request.getParameter("_action"))) // Completing the authz and authn process by redirecting here
+ {
+ requestp=(OpenIDParameterList) session.getAttribute("parameterlist"); // On a redirect from the OP authn & authz sequence
+ }
+ else
+ {
+ requestp = new OpenIDParameterList(request.getParameterMap());
+ Parameter openidIdentity = requestp.getParameter("openid.identity");
+ if( openidIdentity != null )
+ {
+ session.setAttribute("openid.identity", openidIdentity.getValue());
+ }
+ else
+ {
+ log( "The Parameter openid.identity is null " );
+ }
+ }
+
+ protoCtx.setRequestParameterList( requestp );
+
+
+ String mode = requestp.hasParameter("openid.mode") ?
+ requestp.getParameterValue("openid.mode") : null;
+
+ OpenIDMessage responsem = null;
+ String responseText = null;
+
+ log("mode=" + mode + "::ParameterMap:" + requestp);
+
+ if ("associate".equals(mode))
+ {
+ protoCtx.setMode( MODE.ASSOCIATE );
+ try
+ {
+ sts.issueToken( protoCtx );
+ }
+ catch (ProcessingException e)
+ {
+ throw new ServletException( e );
+ }
+
+ responsem = protoCtx.getResponseMessage();
+
+ // --- process an association request ---
+ responseText = responsem.getResponseText();
+ }
+ else if ("checkid_setup".equals(mode)
+ || "checkid_immediate".equals(mode))
+ {
+ // interact with the user and obtain data needed to continue
+ //List userData = userInteraction(requestp);
+ String userSelectedId = null;
+ String userSelectedClaimedId = null;
+ Boolean authenticatedAndApproved = Boolean.FALSE;
+
+ if ((session.getAttribute("authenticatedAndApproved") == null) ||
+ (((Boolean)session.getAttribute("authenticatedAndApproved")) == Boolean.FALSE) )
+ {
+ session.setAttribute("parameterlist", requestp);
+ response.setContentType("text/html" );
+ response.sendRedirect( request.getContextPath() + "/" + this.securePageName);
+ return;
+ }
+ else
+ {
+ userSelectedId = (String) session.getAttribute("openid.claimed_id");
+ userSelectedClaimedId = (String) session.getAttribute("openid.identity");
+ authenticatedAndApproved = (Boolean) session.getAttribute("authenticatedAndApproved");
+ // Remove the parameterlist so this provider can accept requests from elsewhere
+ session.removeAttribute("parameterlist");
+ session.setAttribute("authenticatedAndApproved", Boolean.FALSE); // Makes you authorize each and every time
+
+
+ //Fallback
+ if( authenticatedAndApproved == Boolean.TRUE && userSelectedId == null )
+ {
+ userSelectedId = userSelectedClaimedId;
+ }
+ if( "checkid_setup".equals(mode) )
+ protoCtx.setMode( MODE.CHECK_ID_SETUP );
+ else
+ protoCtx.setMode( MODE.CHECK_ID_IMMEDIATE );
+
+ protoCtx.setAuthenticationHolder( new AUTH_HOLDER(userSelectedId,
+ userSelectedClaimedId, authenticatedAndApproved));
+
+ try
+ {
+ // --- process an authentication request ---
+ sts.issueToken(protoCtx);
+ }
+ catch (ProcessingException e)
+ {
+ throw new ServletException( e );
+ }
+
+ responsem = protoCtx.getResponseMessage();
+
+ // caller will need to decide which of the following to use:
+ // - GET HTTP-redirect to the return_to URL
+ // - HTML FORM Redirection
+ //responseText = response.wwwFormEncoding();
+ if (responsem.isSuccessful())
+ {
+ response.sendRedirect( responsem.getDestinationURL(true));
+ return;
+ }
+ else
+ {
+ responseText="<pre>"+ responsem.getResponseText() +"</pre>";
+ }
+
+ }
+ }
+ else if ("check_authentication".equals(mode))
+ {
+ try
+ {
+ // --- processing a verification request ---
+ sts.validateToken( protoCtx );
+ }
+ catch (ProcessingException e)
+ {
+ throw new ServletException( e );
+ }
+ responsem = protoCtx.getResponseMessage();
+
+ responseText = responsem.getResponseText();
+ }
+ else
+ {
+ protoCtx.setIssueError( Boolean.TRUE );
+ protoCtx.setErrorText( "Unknown request" );
+ try
+ {
+ // --- error response ---
+ sts.issueToken(protoCtx);
+ }
+ catch (ProcessingException e)
+ {
+ throw new ServletException( e );
+ }
+ responsem = protoCtx.getResponseMessage();
+
+ responseText = responsem.getResponseText();
+ }
+
+ log( "response="+responseText );
+ response.getWriter().write(responseText);
+ }
+}
\ No newline at end of file
Added: social/trunk/openid/src/main/java/org/picketlink/social/openid/servlets/OpenIDYadisServlet.java
===================================================================
--- social/trunk/openid/src/main/java/org/picketlink/social/openid/servlets/OpenIDYadisServlet.java (rev 0)
+++ social/trunk/openid/src/main/java/org/picketlink/social/openid/servlets/OpenIDYadisServlet.java 2011-06-13 18:36:40 UTC (rev 986)
@@ -0,0 +1,122 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.picketlink.social.openid.servlets;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * Servlet used for Yadis Discovery in OpenID
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Jul 7, 2009
+ */
+public class OpenIDYadisServlet extends HttpServlet
+{
+ private static final long serialVersionUID = 1L;
+
+ private String yadisResourceFile = "/WEB-INF/openid-yadis.xml";
+ private String yadisURL = null;
+
+ private boolean supportHTTP_HEAD = false; //By default, we support GET
+
+ private transient InputStream yadisResourceInputStream = null;
+
+ @Override
+ public void init(ServletConfig config) throws ServletException
+ {
+ super.init(config);
+ ServletContext context = config.getServletContext();
+
+ String yadisResourceFileStr = config.getInitParameter("yadisResourceFile");
+ if(yadisResourceFileStr != null && yadisResourceFileStr.length() > 0)
+ yadisResourceFile = yadisResourceFileStr;
+ log("yadisResourceFile Location="+ yadisResourceFile);
+
+ yadisURL = config.getInitParameter("yadisResourceURL");
+
+ if(yadisURL == null || yadisURL.length() == 0)
+ {
+ yadisResourceInputStream = context.getResourceAsStream(yadisResourceFile);
+ if(yadisResourceInputStream == null)
+ throw new RuntimeException("yadisResourceFile is missing");
+ }
+
+ String supportHead = config.getInitParameter("support_HTTP_HEAD");
+ if(supportHead != null && supportHead.length() > 0)
+ supportHTTP_HEAD = Boolean.parseBoolean(supportHead);
+ }
+
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
+ {
+ if(this.supportHTTP_HEAD)
+ {
+ log("GET not supported as HTTP HEAD has been configured");
+ resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
+ return;
+ }
+ else
+ {
+ if(yadisResourceInputStream == null)
+ {
+ log("ERROR::yadisResourceInputStream is null");
+ resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+ return;
+ }
+
+ byte[] barr = new byte[1024];
+ for (int i = 0; i < barr.length; i++)
+ {
+ int b = yadisResourceInputStream.read( );
+ if (b == -1) break;
+ barr[i] = (byte) b;
+ }
+
+ resp.setContentType("application/xrds+xml");
+ resp.setStatus(HttpServletResponse.SC_OK);
+ OutputStream os = resp.getOutputStream();
+ os.write(barr);
+ os.flush();
+ os.close();
+ }
+ }
+
+ @Override
+ protected void doHead(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
+ {
+ if(this.supportHTTP_HEAD)
+ {
+ resp.addHeader("X-XRDS-Location", yadisURL);
+ }
+ resp.setStatus(HttpServletResponse.SC_OK);
+ return;
+ }
+}
\ No newline at end of file
Added: social/trunk/openid/src/main/java/org/picketlink/social/openid/servlets/SecurityActions.java
===================================================================
--- social/trunk/openid/src/main/java/org/picketlink/social/openid/servlets/SecurityActions.java (rev 0)
+++ social/trunk/openid/src/main/java/org/picketlink/social/openid/servlets/SecurityActions.java 2011-06-13 18:36:40 UTC (rev 986)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.picketlink.social.openid.servlets;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+/**
+ * Privileged Blocks
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Dec 9, 2008
+ */
+class SecurityActions
+{
+ /**
+ * Get the Thread Context ClassLoader
+ * @return
+ */
+ static ClassLoader getContextClassLoader()
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
+ {
+ public ClassLoader run()
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ });
+ }
+}
13 years, 6 months