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