Author: anil.saldhana(a)jboss.com
Date: 2011-01-19 15:47:31 -0500 (Wed, 19 Jan 2011)
New Revision: 639
Added:
federation/trunk/picketlink-web/src/test/java/org/picketlink/test/identity/federation/web/workflow/openid/
federation/trunk/picketlink-web/src/test/java/org/picketlink/test/identity/federation/web/workflow/openid/OpenIDWorkflowTestConsumerServlet.java
federation/trunk/picketlink-web/src/test/java/org/picketlink/test/identity/federation/web/workflow/openid/OpenIDWorkflowUnitTestCase.java
federation/trunk/picketlink-web/src/test/java/org/picketlink/test/identity/federation/web/workflow/openid/PrincipalInducingTestServletFilter.java
federation/trunk/picketlink-web/src/test/resources/endorsed/
federation/trunk/picketlink-web/src/test/resources/endorsed/resolver.jar
federation/trunk/picketlink-web/src/test/resources/endorsed/serializer.jar
federation/trunk/picketlink-web/src/test/resources/endorsed/xalan.jar
federation/trunk/picketlink-web/src/test/resources/endorsed/xercesImpl.jar
federation/trunk/picketlink-web/src/test/resources/endorsed/xml-apis.jar
federation/trunk/picketlink-web/src/test/resources/openid/webapp/
federation/trunk/picketlink-web/src/test/resources/openid/webapp/index.jsp
federation/trunk/picketlink-web/src/test/resources/openid/webapp/securepage.jsp
Modified:
federation/trunk/picketlink-web/pom.xml
federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/servlets/OpenIDProviderServlet.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/openid/InMemoryProtocolAdapter.java
Log:
openid test case related changes
Modified: federation/trunk/picketlink-web/pom.xml
===================================================================
--- federation/trunk/picketlink-web/pom.xml 2011-01-19 20:46:11 UTC (rev 638)
+++ federation/trunk/picketlink-web/pom.xml 2011-01-19 20:47:31 UTC (rev 639)
@@ -84,8 +84,11 @@
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
- <version>2.4.3</version>
+ <version>2.7.1</version>
<configuration>
+ <additionalClasspathElements>
+
<additionalClasspathElement>${basedir}/src/test/resources/endorsed/xercesImpl.jar</additionalClasspathElement>
+ </additionalClasspathElements>
<printSummary>true</printSummary>
<disableXmlReport>false</disableXmlReport>
<testFailureIgnore>false</testFailureIgnore>
@@ -154,6 +157,31 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>jasper</artifactId>
+ <version>6.0.29</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>httpunit</groupId>
+ <artifactId>httpunit</artifactId>
+ <version>1.5.4</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>nekohtml</groupId>
+ <artifactId>nekohtml</artifactId>
+ <version>1.9.12</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ <version>3.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
Modified:
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-01-19
20:46:11 UTC (rev 638)
+++
federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/servlets/OpenIDProviderServlet.java 2011-01-19
20:47:31 UTC (rev 639)
@@ -31,6 +31,7 @@
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
+import org.openid4java.message.Parameter;
import org.picketlink.identity.federation.api.openid.provider.OpenIDParameterList;
import org.picketlink.identity.federation.api.openid.provider.OpenIDProviderManager;
import
org.picketlink.identity.federation.api.openid.provider.OpenIDProviderManager.OpenIDMessage;
@@ -46,10 +47,10 @@
private static final long serialVersionUID = 1L;
private transient ServletContext servletContext = null;
private String securePageName = "securepage.jsp";
-
+
private transient OpenIDProviderManager serverManager = new OpenIDProviderManager();
//private ServerManager serverManager = new ServerManager();
-
+
@Override
public void init(ServletConfig config) throws ServletException
{
@@ -58,10 +59,10 @@
String secpageStr = this.servletContext.getInitParameter("securePage");
if(secpageStr != null && secpageStr.length() > 0)
securePageName = secpageStr;
-
+
serverManager.initialize();
}
-
+
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException
{
@@ -72,99 +73,119 @@
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException
{
HttpSession session = request.getSession();
-
+
if(serverManager.getEndPoint() == null)
+ {
serverManager.setEndPoint(request.getScheme() + "://" +
- request.getServerName() + ":" +
- request.getServerPort() +
- request.getContextPath() +
- "/provider/");
-
+ 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
+ requestp=(OpenIDParameterList) session.getAttribute("parameterlist");
// On a redirect from the OP authn & authz sequence
}
else
{
- requestp = new OpenIDParameterList(request.getParameterMap());
- session.setAttribute("openid.identity",
requestp.getParameter("openid.identity").getValue());
+ 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 " );
+ }
}
String mode = requestp.hasParameter("openid.mode") ?
- requestp.getParameterValue("openid.mode") : null;
+ requestp.getParameterValue("openid.mode") : null;
- OpenIDMessage responsem;
- String responseText;
-
- log("[OpenIDProviderServlet]:mode=" + mode + "::ParameterMap:"
+ requestp);
+ OpenIDMessage responsem = null;
+ String responseText = null;
- if ("associate".equals(mode))
- {
- // --- process an association request ---
- responsem = serverManager.processAssociationRequest(requestp);
- 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;
+ log("mode=" + mode + "::ParameterMap:" + requestp);
- if ((session.getAttribute("authenticatedAndApproved") == null) ||
- (((Boolean)session.getAttribute("authenticatedAndApproved")) ==
Boolean.FALSE) )
- {
- session.setAttribute("parameterlist", requestp);
- response.sendRedirect( request.getContextPath() + "/" +
this.securePageName);
- }
- 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
- }
+ if ("associate".equals(mode))
+ {
+ // --- process an association request ---
+ responsem = serverManager.processAssociationRequest(requestp);
+ 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;
- // --- process an authentication request ---
- responsem = serverManager.processAuthenticationRequest(requestp,
- userSelectedId,
- userSelectedClaimedId,
- authenticatedAndApproved.booleanValue());
+ 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
- // 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))
- {
- // --- processing a verification request ---
- responsem = serverManager.verify(requestp);
- responseText = responsem.getResponseText();
- }
- else
- {
- // --- error response ---
- responsem = serverManager.getDirectError("Unknown request");
- responseText = responsem.getResponseText();
- }
-
- log("[OpenIDProviderServlet]:response="+responseText);
- response.getWriter().write(responseText);
+
+ //Fallback
+ if( authenticatedAndApproved == Boolean.TRUE && userSelectedId
== null )
+ {
+ if( request.getUserPrincipal() != null )
+ userSelectedId = request.getUserPrincipal().getName();
+ }
+ // --- process an authentication request ---
+ responsem = serverManager.processAuthenticationRequest(requestp,
+ userSelectedId,
+ userSelectedClaimedId,
+ authenticatedAndApproved.booleanValue());
+
+ // 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))
+ {
+ // --- processing a verification request ---
+ responsem = serverManager.verify(requestp);
+ responseText = responsem.getResponseText();
+ }
+ else
+ {
+ // --- error response ---
+ responsem = serverManager.getDirectError("Unknown request");
+ responseText = responsem.getResponseText();
+ }
+
+ log( "response="+responseText );
+ response.getWriter().write(responseText);
}
}
\ No newline at end of file
Modified:
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-01-19
20:46:11 UTC (rev 638)
+++
federation/trunk/picketlink-web/src/test/java/org/picketlink/test/identity/federation/web/integration/LocalProviderOpenIDUnitTestCase.java 2011-01-19
20:47:31 UTC (rev 639)
@@ -75,7 +75,8 @@
assertNotNull("List of providers is not null", providers);
OpenIDProviderInformation providerInfo = idm.associate(ad,providers);
- idm.authenticate(ad, providerInfo);
+ boolean auth = idm.authenticate(ad, providerInfo);
+ assertTrue( "OpenID Auth was successful", auth );
}
//A provider servlet that always returns true
@@ -176,7 +177,8 @@
{
resp.setStatus(HttpServletResponse.SC_OK);
return;
- }
+ }
+
//Asking for Yadis discovery
byte[] barr = new byte[1024];
for (int i = 0; i < barr.length; i++)
Modified:
federation/trunk/picketlink-web/src/test/java/org/picketlink/test/identity/federation/web/openid/InMemoryProtocolAdapter.java
===================================================================
---
federation/trunk/picketlink-web/src/test/java/org/picketlink/test/identity/federation/web/openid/InMemoryProtocolAdapter.java 2011-01-19
20:46:11 UTC (rev 638)
+++
federation/trunk/picketlink-web/src/test/java/org/picketlink/test/identity/federation/web/openid/InMemoryProtocolAdapter.java 2011-01-19
20:47:31 UTC (rev 639)
@@ -21,10 +21,7 @@
*/
package org.picketlink.test.identity.federation.web.openid;
-import java.io.IOException;
-import java.net.MalformedURLException;
import java.net.URL;
-import java.net.URLConnection;
import java.util.Map;
import org.picketlink.identity.federation.api.openid.OpenIDAttributeMap;
@@ -34,6 +31,12 @@
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
@@ -61,7 +64,7 @@
public String getReturnURL()
{
- return "http://localhost:11080";
+ return "http://localhost:11080/consumer";
}
public void sendToProvider(int version, String destinationURL, Map<String,
String> paramMap)
@@ -72,38 +75,26 @@
System.out.println("paramMap="+ paramMap);
if(version == 1)
- {
- URL url;
+ {
+ WebConversation wc = new WebConversation();
+ wc.setAuthorization( "anil", "anil" );
+ WebRequest req = new GetMethodWebRequest( destinationURL );
try
{
- url = new URL(destinationURL);
- URLConnection urlConn = url.openConnection();
- for (int i=0; ; i++)
+ WebResponse resp = wc.getResponse( req );
+ URL responseURL = resp.getURL();
+ if( responseURL.toString().contains( "securepage.jsp" ))
{
- String headerName = urlConn.getHeaderFieldKey(i);
- String headerValue = urlConn.getHeaderField(i);
-
- if (headerName == null && headerValue == null)
- {
- // No more headers
- break;
- }
- if (headerName == null)
- {
- // The header value contains the server's HTTP version
- }
- }
-
+ resp = wc.getResponse( responseURL.toString() );
+ WebForm form = resp.getForms()[0];
+ resp = form.submit();
+ }
}
- catch (MalformedURLException e)
- {
- throw new OpenIDProtocolException(e);
- }
- catch (IOException e)
- {
- throw new OpenIDProtocolException(e);
- }
-
+ catch ( Exception e)
+ {
+ e.printStackTrace();
+ throw new OpenIDProtocolException();
+ }
}
else
{
Added:
federation/trunk/picketlink-web/src/test/java/org/picketlink/test/identity/federation/web/workflow/openid/OpenIDWorkflowTestConsumerServlet.java
===================================================================
---
federation/trunk/picketlink-web/src/test/java/org/picketlink/test/identity/federation/web/workflow/openid/OpenIDWorkflowTestConsumerServlet.java
(rev 0)
+++
federation/trunk/picketlink-web/src/test/java/org/picketlink/test/identity/federation/web/workflow/openid/OpenIDWorkflowTestConsumerServlet.java 2011-01-19
20:47:31 UTC (rev 639)
@@ -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.identity.federation.web.workflow.openid;
+
+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:
federation/trunk/picketlink-web/src/test/java/org/picketlink/test/identity/federation/web/workflow/openid/OpenIDWorkflowUnitTestCase.java
===================================================================
---
federation/trunk/picketlink-web/src/test/java/org/picketlink/test/identity/federation/web/workflow/openid/OpenIDWorkflowUnitTestCase.java
(rev 0)
+++
federation/trunk/picketlink-web/src/test/java/org/picketlink/test/identity/federation/web/workflow/openid/OpenIDWorkflowUnitTestCase.java 2011-01-19
20:47:31 UTC (rev 639)
@@ -0,0 +1,85 @@
+/*
+ * 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.workflow.openid;
+
+import java.io.InputStream;
+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.identity.federation.web.servlets.OpenIDProviderServlet;
+import org.picketlink.test.identity.federation.web.openid.InMemoryProtocolAdapter;
+import org.picketlink.test.identity.federation.web.server.EmbeddedWebServerBase;
+
+
+/**
+ * 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();
+ InputStream is = tcl.getResourceAsStream("openid/localhost-yadis.xml");
+
+ assertNotNull("Yadis descriptor not null", is);
+
+ 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:
federation/trunk/picketlink-web/src/test/java/org/picketlink/test/identity/federation/web/workflow/openid/PrincipalInducingTestServletFilter.java
===================================================================
---
federation/trunk/picketlink-web/src/test/java/org/picketlink/test/identity/federation/web/workflow/openid/PrincipalInducingTestServletFilter.java
(rev 0)
+++
federation/trunk/picketlink-web/src/test/java/org/picketlink/test/identity/federation/web/workflow/openid/PrincipalInducingTestServletFilter.java 2011-01-19
20:47:31 UTC (rev 639)
@@ -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.identity.federation.web.workflow.openid;
+
+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: federation/trunk/picketlink-web/src/test/resources/endorsed/resolver.jar
===================================================================
(Binary files differ)
Property changes on:
federation/trunk/picketlink-web/src/test/resources/endorsed/resolver.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: federation/trunk/picketlink-web/src/test/resources/endorsed/serializer.jar
===================================================================
(Binary files differ)
Property changes on:
federation/trunk/picketlink-web/src/test/resources/endorsed/serializer.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: federation/trunk/picketlink-web/src/test/resources/endorsed/xalan.jar
===================================================================
(Binary files differ)
Property changes on:
federation/trunk/picketlink-web/src/test/resources/endorsed/xalan.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: federation/trunk/picketlink-web/src/test/resources/endorsed/xercesImpl.jar
===================================================================
(Binary files differ)
Property changes on:
federation/trunk/picketlink-web/src/test/resources/endorsed/xercesImpl.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: federation/trunk/picketlink-web/src/test/resources/endorsed/xml-apis.jar
===================================================================
(Binary files differ)
Property changes on:
federation/trunk/picketlink-web/src/test/resources/endorsed/xml-apis.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: federation/trunk/picketlink-web/src/test/resources/openid/webapp/index.jsp
===================================================================
--- federation/trunk/picketlink-web/src/test/resources/openid/webapp/index.jsp
(rev 0)
+++ federation/trunk/picketlink-web/src/test/resources/openid/webapp/index.jsp 2011-01-19
20:47:31 UTC (rev 639)
@@ -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: federation/trunk/picketlink-web/src/test/resources/openid/webapp/securepage.jsp
===================================================================
--- federation/trunk/picketlink-web/src/test/resources/openid/webapp/securepage.jsp
(rev 0)
+++
federation/trunk/picketlink-web/src/test/resources/openid/webapp/securepage.jsp 2011-01-19
20:47:31 UTC (rev 639)
@@ -0,0 +1,14 @@
+<%
+ session.setAttribute("authenticatedAndApproved", Boolean.TRUE);
+ if( request.getUserPrincipal() != null )
+ {
+ session.setAttribute( "openid.claimed_id",
request.getUserPrincipal().getName());
+ }
+%>
+
+
+You have logged in.
+
+<form method="POST"
action="<%=request.getContextPath()%>/provider/?_action=complete">
+<input type="submit" value="Continue"/>
+</form>