[picketlink-commits] Picketlink SVN: r986 - in social/trunk/openid/src/main/java/org/picketlink/social/openid: providers and 2 other directories.
picketlink-commits at lists.jboss.org
picketlink-commits at lists.jboss.org
Mon Jun 13 14:36:41 EDT 2011
Author: anil.saldhana at 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 at 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 at 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 at 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 at 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 at 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();
+ }
+ });
+ }
+}
More information about the picketlink-commits
mailing list