Author: anil.saldhana(a)jboss.com
Date: 2009-10-21 12:54:23 -0400 (Wed, 21 Oct 2009)
New Revision: 863
Added:
identity-federation/trunk/jboss-identity-bindings/src/test/java/org/jboss/test/identity/federation/bindings/mock/
identity-federation/trunk/jboss-identity-bindings/src/test/java/org/jboss/test/identity/federation/bindings/mock/MockCatalinaContext.java
identity-federation/trunk/jboss-identity-bindings/src/test/java/org/jboss/test/identity/federation/bindings/mock/MockCatalinaLoginConfig.java
identity-federation/trunk/jboss-identity-bindings/src/test/java/org/jboss/test/identity/federation/bindings/mock/MockCatalinaRealm.java
identity-federation/trunk/jboss-identity-bindings/src/test/java/org/jboss/test/identity/federation/bindings/mock/MockCatalinaRequest.java
identity-federation/trunk/jboss-identity-bindings/src/test/java/org/jboss/test/identity/federation/bindings/mock/MockCatalinaResponse.java
identity-federation/trunk/jboss-identity-bindings/src/test/java/org/jboss/test/identity/federation/bindings/mock/MockCatalinaSession.java
identity-federation/trunk/jboss-identity-bindings/src/test/java/org/jboss/test/identity/federation/bindings/workflow/
identity-federation/trunk/jboss-identity-bindings/src/test/java/org/jboss/test/identity/federation/bindings/workflow/SAML2RedirectWorkflowUnitTestCase.java
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/logout/
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/logout/idp/
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/logout/idp/WEB-INF/
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/logout/idp/WEB-INF/jbid-handlers.xml
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/logout/idp/WEB-INF/jboss-idfed.xml
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/logout/idp/roles.properties
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/logout/sp/
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/logout/sp/employee/
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/logout/sp/employee/WEB-INF/
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/logout/sp/employee/WEB-INF/jbid-handlers.xml
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/logout/sp/employee/WEB-INF/jboss-idfed.xml
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/logout/sp/employee/roles.properties
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/logout/sp/sales/
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/logout/sp/sales/WEB-INF/
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/logout/sp/sales/WEB-INF/jbid-handlers.xml
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/logout/sp/sales/WEB-INF/jboss-idfed.xml
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/logout/sp/sales/roles.properties
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/post/
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/post/idp/
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/post/idp/WEB-INF/
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/post/idp/WEB-INF/jbid-handlers.xml
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/post/idp/WEB-INF/jboss-idfed.xml
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/post/idp/roles.properties
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/post/idp/users.properties
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/post/sp/
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/post/sp/employee/
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/post/sp/employee/WEB-INF/
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/post/sp/employee/WEB-INF/jbid-handlers.xml
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/post/sp/employee/WEB-INF/jboss-idfed.xml
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/post/sp/employee/roles.properties
Modified:
identity-federation/trunk/jboss-identity-bindings/src/main/java/org/jboss/identity/federation/bindings/tomcat/idp/IDPWebBrowserSSOValve.java
identity-federation/trunk/jboss-identity-bindings/src/main/java/org/jboss/identity/federation/bindings/tomcat/sp/BaseFormAuthenticator.java
identity-federation/trunk/jboss-identity-web/src/main/java/org/jboss/identity/federation/web/util/IDPWebRequestUtil.java
identity-federation/trunk/jboss-identity-web/src/test/java/org/jboss/test/identity/federation/web/mock/MockHttpSession.java
Log:
JBID-40: workflow test
Modified:
identity-federation/trunk/jboss-identity-bindings/src/main/java/org/jboss/identity/federation/bindings/tomcat/idp/IDPWebBrowserSSOValve.java
===================================================================
---
identity-federation/trunk/jboss-identity-bindings/src/main/java/org/jboss/identity/federation/bindings/tomcat/idp/IDPWebBrowserSSOValve.java 2009-10-20
18:45:58 UTC (rev 862)
+++
identity-federation/trunk/jboss-identity-bindings/src/main/java/org/jboss/identity/federation/bindings/tomcat/idp/IDPWebBrowserSSOValve.java 2009-10-21
16:54:23 UTC (rev 863)
@@ -278,7 +278,7 @@
}
catch (IssuerNotTrustedException e)
{
- if(trace) log.trace(e);
+ if(trace) log.trace("Exception in processing request:",e);
samlResponse =
webRequestUtil.getErrorResponse(referer,
@@ -287,7 +287,7 @@
}
catch (ParsingException e)
{
- if(trace) log.trace(e);
+ if(trace) log.trace("Exception in processing request:",e);
samlResponse =
webRequestUtil.getErrorResponse(referer,
@@ -296,7 +296,7 @@
}
catch (ConfigurationException e)
{
- if(trace) log.trace(e);
+ if(trace) log.trace("Exception in processing request:",e);
samlResponse =
webRequestUtil.getErrorResponse(referer,
@@ -305,7 +305,7 @@
}
catch (IssueInstantMissingException e)
{
- if(trace) log.trace(e);
+ if(trace) log.trace("Exception in processing request:",e);
samlResponse =
webRequestUtil.getErrorResponse(referer,
@@ -314,13 +314,22 @@
}
catch(GeneralSecurityException e)
{
- if(trace) log.trace(e);
+ if(trace) log.trace("Exception in processing request:", e);
samlResponse =
webRequestUtil.getErrorResponse(referer,
JBossSAMLURIConstants.STATUS_AUTHNFAILED.get(),
this.identityURL, this.signOutgoingMessages);
}
+ catch(Exception e)
+ {
+ if(trace) log.trace("Exception in processing request:",e);
+
+ samlResponse =
+ webRequestUtil.getErrorResponse(referer,
+ JBossSAMLURIConstants.STATUS_AUTHNFAILED.get(),
+ this.identityURL, this.signOutgoingMessages);
+ }
finally
{
try
Modified:
identity-federation/trunk/jboss-identity-bindings/src/main/java/org/jboss/identity/federation/bindings/tomcat/sp/BaseFormAuthenticator.java
===================================================================
---
identity-federation/trunk/jboss-identity-bindings/src/main/java/org/jboss/identity/federation/bindings/tomcat/sp/BaseFormAuthenticator.java 2009-10-20
18:45:58 UTC (rev 862)
+++
identity-federation/trunk/jboss-identity-bindings/src/main/java/org/jboss/identity/federation/bindings/tomcat/sp/BaseFormAuthenticator.java 2009-10-21
16:54:23 UTC (rev 863)
@@ -96,4 +96,22 @@
throw new RuntimeException(e);
}
}
+
+ public void testStart() throws LifecycleException
+ {
+ InputStream is = context.getServletContext().getResourceAsStream(configFile);
+ if(is == null)
+ throw new RuntimeException(configFile + " missing");
+ try
+ {
+ spConfiguration = ConfigurationUtil.getSPConfiguration(is);
+ this.identityURL = spConfiguration.getIdentityURL();
+ this.serviceURL = spConfiguration.getServiceURL();
+ if(trace) log.trace("Identity Provider URL=" + this.identityURL);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
}
\ No newline at end of file
Added:
identity-federation/trunk/jboss-identity-bindings/src/test/java/org/jboss/test/identity/federation/bindings/mock/MockCatalinaContext.java
===================================================================
---
identity-federation/trunk/jboss-identity-bindings/src/test/java/org/jboss/test/identity/federation/bindings/mock/MockCatalinaContext.java
(rev 0)
+++
identity-federation/trunk/jboss-identity-bindings/src/test/java/org/jboss/test/identity/federation/bindings/mock/MockCatalinaContext.java 2009-10-21
16:54:23 UTC (rev 863)
@@ -0,0 +1,957 @@
+/*
+ * 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.jboss.test.identity.federation.bindings.mock;
+
+import java.beans.PropertyChangeListener;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+
+import javax.naming.directory.DirContext;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.Servlet;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+import org.apache.catalina.Cluster;
+import org.apache.catalina.Context;
+
+import org.apache.catalina.Container;
+import org.apache.catalina.ContainerListener;
+import org.apache.catalina.Loader;
+import org.apache.catalina.Manager;
+import org.apache.catalina.Pipeline;
+import org.apache.catalina.Realm;
+import org.apache.catalina.Wrapper;
+import org.apache.catalina.connector.Request;
+import org.apache.catalina.connector.Response;
+import org.apache.catalina.deploy.ApplicationParameter;
+import org.apache.catalina.deploy.ErrorPage;
+import org.apache.catalina.deploy.FilterDef;
+import org.apache.catalina.deploy.FilterMap;
+import org.apache.catalina.deploy.LoginConfig;
+import org.apache.catalina.deploy.NamingResources;
+import org.apache.catalina.deploy.SecurityConstraint;
+import org.apache.catalina.util.CharsetMapper;
+import org.apache.juli.logging.Log;
+import org.apache.tomcat.util.http.mapper.Mapper;
+
+/**
+ * Mock Catalina Context
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Oct 20, 2009
+ */
+@SuppressWarnings("unchecked")
+public class MockCatalinaContext
+implements Context, Container, ServletContext
+{
+ private Realm realm;
+ public void addChild(Container arg0)
+ {
+ }
+
+ public void addContainerListener(ContainerListener arg0)
+ {
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener arg0)
+ {
+ }
+
+ public void backgroundProcess()
+ {
+ }
+
+ public Container findChild(String arg0)
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public Container[] findChildren()
+ {
+
+ throw new RuntimeException("NYI");
+ }
+
+ public ContainerListener[] findContainerListeners()
+ {
+
+ throw new RuntimeException("NYI");
+ }
+
+ public int getBackgroundProcessorDelay()
+ {
+
+ return 0;
+ }
+
+ public Cluster getCluster()
+ {
+
+ throw new RuntimeException("NYI");
+ }
+
+ public String getInfo()
+ {
+
+ throw new RuntimeException("NYI");
+ }
+
+ public Loader getLoader()
+ {
+
+ throw new RuntimeException("NYI");
+ }
+
+ public Log getLogger()
+ {
+
+ throw new RuntimeException("NYI");
+ }
+
+ public Manager getManager()
+ {
+
+ throw new RuntimeException("NYI");
+ }
+
+ public Object getMappingObject()
+ {
+
+ throw new RuntimeException("NYI");
+ }
+
+ public String getName()
+ {
+
+ throw new RuntimeException("NYI");
+ }
+
+ public String getObjectName()
+ {
+
+ throw new RuntimeException("NYI");
+ }
+
+ public Container getParent()
+ {
+ return this;
+ }
+
+ public ClassLoader getParentClassLoader()
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public Pipeline getPipeline()
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public DirContext getResources()
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public void invoke(Request arg0, Response arg1) throws IOException, ServletException
+ {
+ }
+
+ public void removeChild(Container arg0)
+ {
+ }
+
+ public void removeContainerListener(ContainerListener arg0)
+ {
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener arg0)
+ {
+ }
+
+ public void setBackgroundProcessorDelay(int arg0)
+ {
+ }
+
+ public void setCluster(Cluster arg0)
+ {
+ }
+
+ public void setLoader(Loader arg0)
+ {
+ }
+
+ public void setManager(Manager arg0)
+ {
+ }
+
+ public void setName(String arg0)
+ {
+ }
+
+ public void setParent(Container arg0)
+ {
+ }
+
+ public void setParentClassLoader(ClassLoader arg0)
+ {
+ }
+
+ public void setRealm(Realm arg0)
+ {
+ this.realm = arg0;
+ }
+
+ public void setResources(DirContext arg0)
+ {
+ }
+
+ public void addApplicationListener(String arg0)
+ {
+ }
+
+ public void addApplicationParameter(ApplicationParameter arg0)
+ {
+ }
+
+ public void addConstraint(SecurityConstraint arg0)
+ {
+ }
+
+ public void addErrorPage(ErrorPage arg0)
+ {
+ }
+
+ public void addFilterDef(FilterDef arg0)
+ {
+ }
+
+ public void addFilterMap(FilterMap arg0)
+ {
+ }
+
+ public void addInstanceListener(String arg0)
+ {
+ }
+
+ public void addJspMapping(String arg0)
+ {
+ }
+
+ public void addLocaleEncodingMappingParameter(String arg0, String arg1)
+ {
+ }
+
+ public void addMimeMapping(String arg0, String arg1)
+ {
+ }
+
+ public void addParameter(String arg0, String arg1)
+ {
+ }
+
+ public void addRoleMapping(String arg0, String arg1)
+ {
+ }
+
+ public void addSecurityRole(String arg0)
+ {
+ }
+
+ public void addServletMapping(String arg0, String arg1)
+ {
+ }
+
+ public void addTaglib(String arg0, String arg1)
+ {
+ }
+
+ public void addWatchedResource(String arg0)
+ {
+ }
+
+ public void addWelcomeFile(String arg0)
+ {
+ }
+
+ public void addWrapperLifecycle(String arg0)
+ {
+ }
+
+ public void addWrapperListener(String arg0)
+ {
+ }
+
+ public Wrapper createWrapper()
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public String[] findApplicationListeners()
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public ApplicationParameter[] findApplicationParameters()
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public SecurityConstraint[] findConstraints()
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public ErrorPage findErrorPage(int arg0)
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public ErrorPage findErrorPage(String arg0)
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public ErrorPage[] findErrorPages()
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public FilterDef findFilterDef(String arg0)
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public FilterDef[] findFilterDefs()
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public FilterMap[] findFilterMaps()
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public String[] findInstanceListeners()
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public String findMimeMapping(String arg0)
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public String[] findMimeMappings()
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public String findParameter(String arg0)
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public String[] findParameters()
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public String findRoleMapping(String arg0)
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public boolean findSecurityRole(String arg0)
+ {
+ return false;
+ }
+
+ public String[] findSecurityRoles()
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public String findServletMapping(String arg0)
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public String[] findServletMappings()
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public String findStatusPage(int arg0)
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public int[] findStatusPages()
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public String findTaglib(String arg0)
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public String[] findTaglibs()
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public String[] findWatchedResources()
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public boolean findWelcomeFile(String arg0)
+ {
+ return false;
+ }
+
+ public String[] findWelcomeFiles()
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public String[] findWrapperLifecycles()
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public String[] findWrapperListeners()
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public String getAltDDName()
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public Object[] getApplicationEventListeners()
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public Object[] getApplicationLifecycleListeners()
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public boolean getAvailable()
+ {
+ return false;
+ }
+
+ public CharsetMapper getCharsetMapper()
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public String getConfigFile()
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public boolean getConfigured()
+ {
+ return false;
+ }
+
+ public boolean getCookies()
+ {
+ return false;
+ }
+
+ public boolean getCrossContext()
+ {
+ return false;
+ }
+
+ public String getDisplayName()
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public boolean getDistributable()
+ {
+ return false;
+ }
+
+ public String getDocBase()
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public String getEncodedPath()
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public boolean getIgnoreAnnotations()
+ {
+ return false;
+ }
+
+ public LoginConfig getLoginConfig()
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public Mapper getMapper()
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public NamingResources getNamingResources()
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public boolean getOverride()
+ {
+ return false;
+ }
+
+ public String getPath()
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public boolean getPrivileged()
+ {
+ return false;
+ }
+
+ public String getPublicId()
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public boolean getReloadable()
+ {
+ return false;
+ }
+
+ public ServletContext getServletContext()
+ {
+ return this;
+ }
+
+ public int getSessionTimeout()
+ {
+ return 0;
+ }
+
+ public boolean getSwallowOutput()
+ {
+ return false;
+ }
+
+ public boolean getTldNamespaceAware()
+ {
+ return false;
+ }
+
+ public boolean getTldValidation()
+ {
+ return false;
+ }
+
+ public String getWrapperClass()
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public boolean getXmlNamespaceAware()
+ {
+ return false;
+ }
+
+ public boolean getXmlValidation()
+ {
+ return false;
+ }
+
+ public void reload()
+ {
+ }
+
+ public void removeApplicationListener(String arg0)
+ {
+ }
+
+ public void removeApplicationParameter(String arg0)
+ {
+ }
+
+ public void removeConstraint(SecurityConstraint arg0)
+ {
+ }
+
+ public void removeErrorPage(ErrorPage arg0)
+ {
+ }
+
+ public void removeFilterDef(FilterDef arg0)
+ {
+ }
+
+ public void removeFilterMap(FilterMap arg0)
+ {
+ }
+
+ public void removeInstanceListener(String arg0)
+ {
+ }
+
+ public void removeMimeMapping(String arg0)
+ {
+ }
+
+ public void removeParameter(String arg0)
+ {
+ }
+
+ public void removeRoleMapping(String arg0)
+ {
+ }
+
+ public void removeSecurityRole(String arg0)
+ {
+ }
+
+ public void removeServletMapping(String arg0)
+ {
+ }
+
+ public void removeTaglib(String arg0)
+ {
+ }
+
+ public void removeWatchedResource(String arg0)
+ {
+ }
+
+ public void removeWelcomeFile(String arg0)
+ {
+ }
+
+ public void removeWrapperLifecycle(String arg0)
+ {
+ }
+
+ public void removeWrapperListener(String arg0)
+ {
+ }
+
+ public void setAltDDName(String arg0)
+ {
+ }
+
+ public void setApplicationEventListeners(Object[] arg0)
+ {
+ }
+
+ public void setApplicationLifecycleListeners(Object[] arg0)
+ {
+ }
+
+ public void setAvailable(boolean arg0)
+ {
+ }
+
+ public void setCharsetMapper(CharsetMapper arg0)
+ {
+ }
+
+ public void setConfigFile(String arg0)
+ {
+ }
+
+ public void setConfigured(boolean arg0)
+ {
+ }
+
+ public void setCookies(boolean arg0)
+ {
+ }
+
+ public void setCrossContext(boolean arg0)
+ {
+ }
+
+ public void setDisplayName(String arg0)
+ {
+ }
+
+ public void setDistributable(boolean arg0)
+ {
+ }
+
+ public void setDocBase(String arg0)
+ {
+ }
+
+ public void setIgnoreAnnotations(boolean arg0)
+ {
+ }
+
+ public void setLoginConfig(LoginConfig arg0)
+ {
+ }
+
+ public void setNamingResources(NamingResources arg0)
+ {
+ }
+
+ public void setOverride(boolean arg0)
+ {
+ }
+
+ public void setPath(String arg0)
+ {
+ }
+
+ public void setPrivileged(boolean arg0)
+ {
+ }
+
+ public void setPublicId(String arg0)
+ {
+ }
+
+ public void setReloadable(boolean arg0)
+ {
+ }
+
+ public void setSessionTimeout(int arg0)
+ {
+ }
+
+ public void setSwallowOutput(boolean arg0)
+ {
+ }
+
+ public void setTldNamespaceAware(boolean arg0)
+ {
+ }
+
+ public void setTldValidation(boolean arg0)
+ {
+ }
+
+ public void setWrapperClass(String arg0)
+ {
+ }
+
+ public void setXmlNamespaceAware(boolean arg0)
+ {
+ }
+
+ public void setXmlValidation(boolean arg0)
+ {
+ }
+
+ public Realm getRealm()
+ {
+ return realm;
+ }
+
+
+ //Copied from MockServletContext
+ private Map params = new HashMap();
+ private Map attribs = new HashMap();
+
+ public Object getAttribute(String arg0)
+ {
+ return attribs.get(arg0);
+ }
+
+ public Enumeration getAttributeNames()
+ {
+ return new Enumeration()
+ {
+ private Iterator iter = attribs.entrySet().iterator();
+
+ public boolean hasMoreElements()
+ {
+ return iter.hasNext();
+ }
+
+ public Object nextElement()
+ {
+ Entry<String,Object> entry = (Entry<String, Object>)
iter.next();
+ return entry.getValue();
+ }
+ };
+ }
+
+ public ServletContext getContext(String arg0)
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public String getContextPath()
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public String getInitParameter(String arg0)
+ {
+ return (String) params.get(arg0);
+ }
+
+ public Enumeration getInitParameterNames()
+ {
+ return new Enumeration()
+ {
+ private Iterator iter = params.entrySet().iterator();
+
+ public boolean hasMoreElements()
+ {
+ return iter.hasNext();
+ }
+
+ public Object nextElement()
+ {
+ Entry<String,Object> entry = (Entry<String, Object>)
iter.next();
+ return entry.getKey();
+ }
+ };
+ }
+
+ public int getMajorVersion()
+ {
+ return 0;
+ }
+
+ public String getMimeType(String arg0)
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public int getMinorVersion()
+ {
+ return 0;
+ }
+
+ public RequestDispatcher getNamedDispatcher(String arg0)
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public String getRealPath(String arg0)
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public RequestDispatcher getRequestDispatcher(String arg0)
+ {
+ return new RequestDispatcher()
+ {
+
+ public void include(ServletRequest arg0, ServletResponse arg1) throws
ServletException, IOException
+ {
+ }
+
+ public void forward(ServletRequest arg0, ServletResponse arg1) throws
ServletException, IOException
+ {
+ }
+ };
+ }
+
+ public URL getResource(String arg0) throws MalformedURLException
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public InputStream getResourceAsStream(String arg0)
+ {
+ return Thread.currentThread().getContextClassLoader().getResourceAsStream(arg0);
+ }
+
+ public Set getResourcePaths(String arg0)
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public String getServerInfo()
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public Servlet getServlet(String arg0) throws ServletException
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public String getServletContextName()
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public Enumeration getServletNames()
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public Enumeration getServlets()
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public void log(String arg0)
+ {
+ }
+
+ public void log(Exception arg0, String arg1)
+ {
+ }
+
+ public void log(String arg0, Throwable arg1)
+ {
+ }
+
+ public void removeAttribute(String arg0)
+ {
+ this.attribs.remove(arg0);
+ }
+
+ public void setAttribute(String arg0, Object arg1)
+ {
+ this.attribs.put(arg0, arg1);
+ }
+}
\ No newline at end of file
Added:
identity-federation/trunk/jboss-identity-bindings/src/test/java/org/jboss/test/identity/federation/bindings/mock/MockCatalinaLoginConfig.java
===================================================================
---
identity-federation/trunk/jboss-identity-bindings/src/test/java/org/jboss/test/identity/federation/bindings/mock/MockCatalinaLoginConfig.java
(rev 0)
+++
identity-federation/trunk/jboss-identity-bindings/src/test/java/org/jboss/test/identity/federation/bindings/mock/MockCatalinaLoginConfig.java 2009-10-21
16:54:23 UTC (rev 863)
@@ -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.jboss.test.identity.federation.bindings.mock;
+
+import org.apache.catalina.deploy.LoginConfig;
+
+/**
+ * Mock LoginConfig
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Oct 20, 2009
+ */
+public class MockCatalinaLoginConfig extends LoginConfig
+{
+ private static final long serialVersionUID = 1L;
+}
Added:
identity-federation/trunk/jboss-identity-bindings/src/test/java/org/jboss/test/identity/federation/bindings/mock/MockCatalinaRealm.java
===================================================================
---
identity-federation/trunk/jboss-identity-bindings/src/test/java/org/jboss/test/identity/federation/bindings/mock/MockCatalinaRealm.java
(rev 0)
+++
identity-federation/trunk/jboss-identity-bindings/src/test/java/org/jboss/test/identity/federation/bindings/mock/MockCatalinaRealm.java 2009-10-21
16:54:23 UTC (rev 863)
@@ -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.jboss.test.identity.federation.bindings.mock;
+
+import java.security.Principal;
+
+import org.apache.catalina.realm.RealmBase;
+
+/**
+ * Mock Tomcat Realm
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Oct 21, 2009
+ */
+public class MockCatalinaRealm extends RealmBase
+{
+ private String name;
+ private String pass;
+ private Principal principal;
+
+ public MockCatalinaRealm(String name, String pass, Principal p)
+ {
+ this.name = name;
+ this.pass = pass;
+ this.principal = p;
+ }
+
+ @Override
+ protected String getName()
+ {
+ return name;
+ }
+
+ @Override
+ protected String getPassword(String arg0)
+ {
+ return pass;
+ }
+
+ @Override
+ protected Principal getPrincipal(String arg0)
+ {
+ return principal;
+ }
+
+ @Override
+ public Principal authenticate(String arg0, String arg1)
+ {
+ return principal;
+ }
+}
\ No newline at end of file
Added:
identity-federation/trunk/jboss-identity-bindings/src/test/java/org/jboss/test/identity/federation/bindings/mock/MockCatalinaRequest.java
===================================================================
---
identity-federation/trunk/jboss-identity-bindings/src/test/java/org/jboss/test/identity/federation/bindings/mock/MockCatalinaRequest.java
(rev 0)
+++
identity-federation/trunk/jboss-identity-bindings/src/test/java/org/jboss/test/identity/federation/bindings/mock/MockCatalinaRequest.java 2009-10-21
16:54:23 UTC (rev 863)
@@ -0,0 +1,134 @@
+/*
+ * 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.jboss.test.identity.federation.bindings.mock;
+
+import java.security.Principal;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.catalina.Session;
+import org.apache.catalina.connector.Request;
+
+/**
+ * Request for catalina container
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Oct 20, 2009
+ */
+public class MockCatalinaRequest extends Request
+{
+ private Map<String,String> params = new HashMap<String, String>();
+ private Map<String,String> headers = new HashMap<String, String>();
+ private Session session;
+ private Principal principal;
+ private String method;
+ private String remotee;
+ private String queryString;
+
+
+ @Override
+ public void addHeader(String name, String value)
+ {
+ this.headers.put(name, value);
+ }
+
+ @Override
+ public String getHeader(String name)
+ {
+ return headers.get(name);
+ }
+
+ @Override
+ public Principal getPrincipal()
+ {
+ return principal;
+ }
+
+ @Override
+ public void setUserPrincipal(Principal arg0)
+ {
+ this.principal = arg0;
+ }
+
+ @Override
+ public String getParameter(String name)
+ {
+ return this.params.get(name);
+ }
+
+ public void setParameter(String key, String value)
+ {
+ params.put(key, value);
+ }
+
+ @Override
+ public String getQueryString()
+ {
+ return this.queryString;
+ }
+
+ @Override
+ public void setQueryString(String query)
+ {
+ this.queryString = query;
+ }
+
+ @Override
+ public String getRemoteAddr()
+ {
+ return this.remotee;
+ }
+
+ @Override
+ public void setRemoteAddr(String remoteAddr)
+ {
+ this.remotee = remoteAddr;
+ }
+
+ @Override
+ public String getMethod()
+ {
+ return this.method;
+ }
+
+ @Override
+ public void setMethod(String method)
+ {
+ this.method = method;
+ }
+
+ @Override
+ public Session getSessionInternal()
+ {
+ return session;
+ }
+
+ @Override
+ public Session getSessionInternal(boolean b)
+ {
+ return session;
+ }
+
+ public void setSession(Session s)
+ {
+ this.session = s;
+ }
+}
\ No newline at end of file
Added:
identity-federation/trunk/jboss-identity-bindings/src/test/java/org/jboss/test/identity/federation/bindings/mock/MockCatalinaResponse.java
===================================================================
---
identity-federation/trunk/jboss-identity-bindings/src/test/java/org/jboss/test/identity/federation/bindings/mock/MockCatalinaResponse.java
(rev 0)
+++
identity-federation/trunk/jboss-identity-bindings/src/test/java/org/jboss/test/identity/federation/bindings/mock/MockCatalinaResponse.java 2009-10-21
16:54:23 UTC (rev 863)
@@ -0,0 +1,76 @@
+/*
+ * 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.jboss.test.identity.federation.bindings.mock;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.catalina.connector.Response;
+
+/**
+ * Mock catalina response
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Oct 20, 2009
+ */
+public class MockCatalinaResponse extends Response
+{
+ private Map<String, String> headers = new HashMap<String, String>();
+ private int status;
+ public String redirectString;
+
+ @Override
+ public void setCharacterEncoding(String charset)
+ {
+ }
+
+ @Override
+ public void setHeader(String name, String value)
+ {
+ this.headers.put(name, value);
+ }
+
+ @Override
+ public int getStatus()
+ {
+ return this.status;
+ }
+
+ @Override
+ public void setStatus(int status)
+ {
+ this.status = status;
+ }
+
+ @Override
+ public void sendRedirect(String arg0) throws IOException
+ {
+ this.redirectString = arg0;
+ }
+
+ @Override
+ public boolean isCommitted()
+ {
+ return false;
+ }
+
+}
\ No newline at end of file
Added:
identity-federation/trunk/jboss-identity-bindings/src/test/java/org/jboss/test/identity/federation/bindings/mock/MockCatalinaSession.java
===================================================================
---
identity-federation/trunk/jboss-identity-bindings/src/test/java/org/jboss/test/identity/federation/bindings/mock/MockCatalinaSession.java
(rev 0)
+++
identity-federation/trunk/jboss-identity-bindings/src/test/java/org/jboss/test/identity/federation/bindings/mock/MockCatalinaSession.java 2009-10-21
16:54:23 UTC (rev 863)
@@ -0,0 +1,289 @@
+/*
+ * 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.jboss.test.identity.federation.bindings.mock;
+
+import java.security.Principal;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.UUID;
+import java.util.Map.Entry;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpSession;
+import javax.servlet.http.HttpSessionContext;
+
+import org.apache.catalina.Manager;
+import org.apache.catalina.Session;
+import org.apache.catalina.SessionListener;
+
+/**
+ * Mock session for the catalina infrastructure
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Oct 20, 2009
+ */
+@SuppressWarnings({"deprecation", "unchecked"})
+public class MockCatalinaSession implements Session, HttpSession
+{
+ private Map<String, Object> notes = new HashMap<String,Object>();
+
+ public void setMaxInactiveInterval(int arg0)
+ {
+ }
+
+ public void access()
+ {
+ }
+
+ public void addSessionListener(SessionListener arg0)
+ {
+ }
+
+ public void endAccess()
+ {
+ }
+
+ public void expire()
+ {
+ }
+
+ public String getAuthType()
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public String getIdInternal()
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public String getInfo()
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public long getLastAccessedTimeInternal()
+ {
+ return 0;
+ }
+
+ public Manager getManager()
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public Object getNote(String arg0)
+ {
+ return notes.get(arg0);
+ }
+
+ public Iterator getNoteNames()
+ {
+ return notes.keySet().iterator();
+ }
+
+ public Principal getPrincipal()
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public HttpSession getSession()
+ {
+ return this;
+ }
+
+ public boolean isValid()
+ {
+ return false;
+ }
+
+ public void recycle()
+ {
+ }
+
+ public void removeNote(String arg0)
+ {
+ }
+
+ public void removeSessionListener(SessionListener arg0)
+ {
+ }
+
+ public void setAuthType(String arg0)
+ {
+ }
+
+ public void setCreationTime(long arg0)
+ {
+ }
+
+ public void setId(String arg0)
+ {
+ }
+
+ public void setManager(Manager arg0)
+ {
+ }
+
+ public void setNew(boolean arg0)
+ {
+ }
+
+ public void setNote(String arg0, Object arg1)
+ {
+ this.notes.put(arg0, arg1);
+ }
+
+ public void setPrincipal(Principal arg0)
+ {
+ }
+
+ public void setValid(boolean arg0)
+ {
+ }
+
+ //Copied from MockHttpSession
+ private boolean valid = true;
+
+ private Map<String,Object> attribs = new HashMap<String,Object>();
+
+ private String id = UUID.randomUUID().toString();
+
+ private ServletContext context;
+
+ public boolean isInvalidated()
+ {
+ return valid == false;
+ }
+
+ public Object getAttribute(String arg0)
+ {
+ return attribs.get(arg0);
+ }
+
+ public Enumeration getAttributeNames()
+ {
+ return new Enumeration()
+ {
+ private Iterator iter = attribs.entrySet().iterator();
+
+ public boolean hasMoreElements()
+ {
+ return iter.hasNext();
+ }
+
+ public Object nextElement()
+ {
+ Entry<String,Object> entry = (Entry<String, Object>)
iter.next();
+ return entry.getValue();
+ }
+ };
+ }
+
+ public long getCreationTime()
+ {
+ return 0;
+ }
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public long getLastAccessedTime()
+ {
+ return 0;
+ }
+
+ public int getMaxInactiveInterval()
+ {
+ return 0;
+ }
+
+ public void setServletContext(ServletContext servletContext)
+ {
+ this.context = servletContext;
+ }
+
+ public ServletContext getServletContext()
+ {
+ return this.context;
+ }
+
+ public HttpSessionContext getSessionContext()
+ {
+
+ throw new RuntimeException("NYI");
+ }
+
+ public Object getValue(String arg0)
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public String[] getValueNames()
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public void invalidate()
+ {
+ this.valid = false;
+ }
+
+ public boolean isNew()
+ {
+ if(this.valid == false)
+ throw new IllegalStateException("Session already invalidated");
+
+ return false;
+ }
+
+ public void putValue(String arg0, Object arg1)
+ {
+ if(this.valid == false)
+ throw new IllegalStateException("Session already invalidated");
+ }
+
+ public void removeAttribute(String arg0)
+ {
+ if(this.valid == false)
+ throw new IllegalStateException("Session already invalidated");
+
+ this.attribs.remove(arg0);
+ }
+
+ public void removeValue(String arg0)
+ {
+ if(this.valid == false)
+ throw new IllegalStateException("Session already invalidated");
+ }
+
+ public void setAttribute(String arg0, Object arg1)
+ {
+ if(this.valid == false)
+ throw new IllegalStateException("Session already invalidated");
+
+ this.attribs.put(arg0, arg1);
+ }
+}
\ No newline at end of file
Added:
identity-federation/trunk/jboss-identity-bindings/src/test/java/org/jboss/test/identity/federation/bindings/workflow/SAML2RedirectWorkflowUnitTestCase.java
===================================================================
---
identity-federation/trunk/jboss-identity-bindings/src/test/java/org/jboss/test/identity/federation/bindings/workflow/SAML2RedirectWorkflowUnitTestCase.java
(rev 0)
+++
identity-federation/trunk/jboss-identity-bindings/src/test/java/org/jboss/test/identity/federation/bindings/workflow/SAML2RedirectWorkflowUnitTestCase.java 2009-10-21
16:54:23 UTC (rev 863)
@@ -0,0 +1,149 @@
+/*
+ * 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.jboss.test.identity.federation.bindings.workflow;
+
+import java.net.URL;
+import java.security.Principal;
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.apache.catalina.realm.GenericPrincipal;
+import org.jboss.identity.federation.bindings.tomcat.idp.IDPWebBrowserSSOValve;
+import org.jboss.identity.federation.bindings.tomcat.sp.SPRedirectFormAuthenticator;
+import org.jboss.identity.federation.web.util.RedirectBindingUtil;
+import org.jboss.test.identity.federation.bindings.mock.*;
+
+/**
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Oct 20, 2009
+ */
+public class SAML2RedirectWorkflowUnitTestCase extends TestCase
+{
+ private String profile = "saml2/logout";
+ private ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+ private String employee = "http://localhost:8080/employee/";
+
+ private String SAML_REQUEST_KEY = "SAMLRequest=";
+
+ private String SAML_RESPONSE_KEY = "SAMLResponse=";
+
+ public void testSAML2Redirect() throws Exception
+ {
+ MockContextClassLoader mclSPEmp = setupTCL(profile + "/sp/employee");
+ Thread.currentThread().setContextClassLoader(mclSPEmp);
+
+ SPRedirectFormAuthenticator sp = new SPRedirectFormAuthenticator();
+
+ MockCatalinaContext context = new MockCatalinaContext();
+ MockCatalinaRequest request = new MockCatalinaRequest();
+
+ request.setParameter("RelayState", null);
+
+ MockCatalinaResponse response = new MockCatalinaResponse();
+ MockCatalinaLoginConfig loginConfig = new MockCatalinaLoginConfig();
+
+ sp.setContainer(context);
+ sp.testStart();
+
+ sp.authenticate(request, response, loginConfig);
+
+ String redirectStr = response.redirectString;
+ assertNotNull("Redirect String is null?", redirectStr);
+ String saml =
RedirectBindingUtil.urlDecode(redirectStr.substring(redirectStr.indexOf(SAML_REQUEST_KEY)
+
+ SAML_REQUEST_KEY.length()) );
+
+ MockCatalinaSession session = new MockCatalinaSession();
+
+ //Now send it to IDP
+ MockCatalinaRealm realm = new MockCatalinaRealm("anil", "test",
new Principal()
+ {
+ public String getName()
+ {
+ return "anil";
+ }
+ });
+
+ List<String> roles = new ArrayList<String>();
+ roles.add("manager");
+ roles.add("employee");
+
+ MockContextClassLoader mclIDP = setupTCL(profile + "/idp/");
+ Thread.currentThread().setContextClassLoader(mclIDP);
+
+ request = new MockCatalinaRequest();
+ request.setRemoteAddr(employee);
+ request.setSession(session);
+ request.setParameter("SAMLRequest", saml);
+ request.setUserPrincipal(new GenericPrincipal(realm, "anil",
"test", roles) );
+ request.setMethod("GET");
+
+ response = new MockCatalinaResponse();
+
+ IDPWebBrowserSSOValve idp = new IDPWebBrowserSSOValve();
+
+ idp.setSignOutgoingMessages(false);
+
+ idp.setContainer(context);
+ idp.start();
+ idp.invoke(request, response);
+
+ redirectStr = response.redirectString;
+ String samlResponse =
RedirectBindingUtil.urlDecode(redirectStr.substring(redirectStr.indexOf(SAML_RESPONSE_KEY)
+
+ SAML_RESPONSE_KEY.length()));
+
+ mclSPEmp = setupTCL(profile + "/sp/employee");
+ Thread.currentThread().setContextClassLoader(mclSPEmp);
+
+
+ sp = new SPRedirectFormAuthenticator();
+
+ context = new MockCatalinaContext();
+
+ context.setRealm(realm);
+ request = new MockCatalinaRequest();
+ request.setContext(context);
+
+ request.setParameter("SAMLResponse", samlResponse);
+ request.setParameter("RelayState", null);
+ request.setSession(session);
+
+ response = new MockCatalinaResponse();
+ loginConfig = new MockCatalinaLoginConfig();
+
+ sp.setContainer(context);
+ sp.testStart();
+
+ assertTrue("Employee app auth success", sp.authenticate(request,
response, loginConfig) );
+ }
+
+ private MockContextClassLoader setupTCL(String resource)
+ {
+ URL[] urls = new URL[] {tcl.getResource(resource)};
+
+ MockContextClassLoader mcl = new MockContextClassLoader(urls);
+ mcl.setDelegate(tcl);
+ mcl.setProfile(resource);
+ return mcl;
+ }
+}
\ No newline at end of file
Added:
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/logout/idp/WEB-INF/jbid-handlers.xml
===================================================================
---
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/logout/idp/WEB-INF/jbid-handlers.xml
(rev 0)
+++
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/logout/idp/WEB-INF/jbid-handlers.xml 2009-10-21
16:54:23 UTC (rev 863)
@@ -0,0 +1,5 @@
+<Handlers xmlns="urn:jboss:identity-federation:handler:config:1.0">
+ <Handler
class="org.jboss.identity.federation.web.handlers.saml2.SAML2IssuerTrustHandler"/>
+ <Handler
class="org.jboss.identity.federation.web.handlers.saml2.SAML2LogOutHandler"/>
+ <Handler
class="org.jboss.identity.federation.web.handlers.saml2.RolesGenerationHandler"/>
+</Handlers>
\ No newline at end of file
Added:
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/logout/idp/WEB-INF/jboss-idfed.xml
===================================================================
---
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/logout/idp/WEB-INF/jboss-idfed.xml
(rev 0)
+++
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/logout/idp/WEB-INF/jboss-idfed.xml 2009-10-21
16:54:23 UTC (rev 863)
@@ -0,0 +1,9 @@
+<JBossIDP xmlns="urn:jboss:identity-federation:config:1.0"
+ AttributeManager=""
+
RoleGenerator="org.jboss.identity.federation.core.impl.EmptyRoleGenerator">
+<IdentityURL>http://localhost:8080/idp/</IdentityURL>
+<Trust>
+ <Domains>localhost,jboss.com,jboss.org</Domains>
+</Trust>
+
+</JBossIDP>
Added:
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/logout/idp/roles.properties
===================================================================
---
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/logout/idp/roles.properties
(rev 0)
+++
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/logout/idp/roles.properties 2009-10-21
16:54:23 UTC (rev 863)
@@ -0,0 +1 @@
+manager=manager
\ No newline at end of file
Added:
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/logout/sp/employee/WEB-INF/jbid-handlers.xml
===================================================================
---
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/logout/sp/employee/WEB-INF/jbid-handlers.xml
(rev 0)
+++
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/logout/sp/employee/WEB-INF/jbid-handlers.xml 2009-10-21
16:54:23 UTC (rev 863)
@@ -0,0 +1,3 @@
+<Handlers xmlns="urn:jboss:identity-federation:handler:config:1.0">
+ <Handler
class="org.jboss.identity.federation.web.handlers.saml2.SAML2LogOutHandler"/>
+</Handlers>
\ No newline at end of file
Added:
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/logout/sp/employee/WEB-INF/jboss-idfed.xml
===================================================================
---
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/logout/sp/employee/WEB-INF/jboss-idfed.xml
(rev 0)
+++
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/logout/sp/employee/WEB-INF/jboss-idfed.xml 2009-10-21
16:54:23 UTC (rev 863)
@@ -0,0 +1,6 @@
+<JBossSP xmlns="urn:jboss:identity-federation:config:1.0"
+ AttributeManager="">
+<IdentityURL>http://localhost:8080/idp/</IdentityURL>
+<ServiceURL>http://localhost:8080/employee/</ServiceURL>
+
+</JBossSP>
\ No newline at end of file
Added:
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/logout/sp/employee/roles.properties
===================================================================
---
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/logout/sp/employee/roles.properties
(rev 0)
+++
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/logout/sp/employee/roles.properties 2009-10-21
16:54:23 UTC (rev 863)
@@ -0,0 +1 @@
+manager=manager
\ No newline at end of file
Added:
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/logout/sp/sales/WEB-INF/jbid-handlers.xml
===================================================================
---
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/logout/sp/sales/WEB-INF/jbid-handlers.xml
(rev 0)
+++
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/logout/sp/sales/WEB-INF/jbid-handlers.xml 2009-10-21
16:54:23 UTC (rev 863)
@@ -0,0 +1,3 @@
+<Handlers xmlns="urn:jboss:identity-federation:handler:config:1.0">
+ <Handler
class="org.jboss.identity.federation.web.handlers.saml2.SAML2LogOutHandler"/>
+</Handlers>
\ No newline at end of file
Added:
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/logout/sp/sales/WEB-INF/jboss-idfed.xml
===================================================================
---
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/logout/sp/sales/WEB-INF/jboss-idfed.xml
(rev 0)
+++
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/logout/sp/sales/WEB-INF/jboss-idfed.xml 2009-10-21
16:54:23 UTC (rev 863)
@@ -0,0 +1,6 @@
+<JBossSP xmlns="urn:jboss:identity-federation:config:1.0"
+ AttributeManager="">
+<IdentityURL>http://localhost:8080/idp/</IdentityURL>
+<ServiceURL>http://localhost:8080/sales/</ServiceURL>
+
+</JBossSP>
\ No newline at end of file
Added:
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/logout/sp/sales/roles.properties
===================================================================
---
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/logout/sp/sales/roles.properties
(rev 0)
+++
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/logout/sp/sales/roles.properties 2009-10-21
16:54:23 UTC (rev 863)
@@ -0,0 +1 @@
+manager=manager
\ No newline at end of file
Added:
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/post/idp/WEB-INF/jbid-handlers.xml
===================================================================
---
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/post/idp/WEB-INF/jbid-handlers.xml
(rev 0)
+++
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/post/idp/WEB-INF/jbid-handlers.xml 2009-10-21
16:54:23 UTC (rev 863)
@@ -0,0 +1,5 @@
+<Handlers xmlns="urn:jboss:identity-federation:handler:config:1.0">
+ <Handler
class="org.jboss.identity.federation.web.handlers.saml2.SAML2IssuerTrustHandler"/>
+ <Handler
class="org.jboss.identity.federation.web.handlers.saml2.SAML2LogOutHandler"/>
+ <Handler
class="org.jboss.identity.federation.web.handlers.saml2.SAML2AuthenticationHandler"/>
+</Handlers>
\ No newline at end of file
Added:
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/post/idp/WEB-INF/jboss-idfed.xml
===================================================================
---
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/post/idp/WEB-INF/jboss-idfed.xml
(rev 0)
+++
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/post/idp/WEB-INF/jboss-idfed.xml 2009-10-21
16:54:23 UTC (rev 863)
@@ -0,0 +1,8 @@
+<JBossIDP xmlns="urn:jboss:identity-federation:config:1.0"
+ AttributeManager="">
+<IdentityURL>http://localhost:8080/idp/</IdentityURL>
+<Trust>
+ <Domains>localhost,jboss.com,jboss.org</Domains>
+</Trust>
+
+</JBossIDP>
Added:
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/post/idp/roles.properties
===================================================================
---
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/post/idp/roles.properties
(rev 0)
+++
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/post/idp/roles.properties 2009-10-21
16:54:23 UTC (rev 863)
@@ -0,0 +1,2 @@
+manager=manager
+anil=manager,sales,employee
\ No newline at end of file
Added:
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/post/idp/users.properties
===================================================================
---
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/post/idp/users.properties
(rev 0)
+++
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/post/idp/users.properties 2009-10-21
16:54:23 UTC (rev 863)
@@ -0,0 +1 @@
+anil=anil
\ No newline at end of file
Added:
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/post/sp/employee/WEB-INF/jbid-handlers.xml
===================================================================
---
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/post/sp/employee/WEB-INF/jbid-handlers.xml
(rev 0)
+++
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/post/sp/employee/WEB-INF/jbid-handlers.xml 2009-10-21
16:54:23 UTC (rev 863)
@@ -0,0 +1,5 @@
+<Handlers xmlns="urn:jboss:identity-federation:handler:config:1.0">
+ <Handler
class="org.jboss.identity.federation.web.handlers.saml2.SAML2IssuerTrustHandler"/>
+ <Handler
class="org.jboss.identity.federation.web.handlers.saml2.SAML2LogOutHandler"/>
+ <Handler
class="org.jboss.identity.federation.web.handlers.saml2.SAML2AuthenticationHandler"/>
+</Handlers>
\ No newline at end of file
Added:
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/post/sp/employee/WEB-INF/jboss-idfed.xml
===================================================================
---
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/post/sp/employee/WEB-INF/jboss-idfed.xml
(rev 0)
+++
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/post/sp/employee/WEB-INF/jboss-idfed.xml 2009-10-21
16:54:23 UTC (rev 863)
@@ -0,0 +1,6 @@
+<JBossSP xmlns="urn:jboss:identity-federation:config:1.0"
+ AttributeManager="">
+<IdentityURL>http://localhost:8080/idp/</IdentityURL>
+<ServiceURL>http://localhost:8080/employee/</ServiceURL>
+
+</JBossSP>
\ No newline at end of file
Added:
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/post/sp/employee/roles.properties
===================================================================
---
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/post/sp/employee/roles.properties
(rev 0)
+++
identity-federation/trunk/jboss-identity-bindings/src/test/resources/saml2/post/sp/employee/roles.properties 2009-10-21
16:54:23 UTC (rev 863)
@@ -0,0 +1 @@
+manager=manager
\ No newline at end of file
Modified:
identity-federation/trunk/jboss-identity-web/src/main/java/org/jboss/identity/federation/web/util/IDPWebRequestUtil.java
===================================================================
---
identity-federation/trunk/jboss-identity-web/src/main/java/org/jboss/identity/federation/web/util/IDPWebRequestUtil.java 2009-10-20
18:45:58 UTC (rev 862)
+++
identity-federation/trunk/jboss-identity-web/src/main/java/org/jboss/identity/federation/web/util/IDPWebRequestUtil.java 2009-10-21
16:54:23 UTC (rev 863)
@@ -149,7 +149,15 @@
SAML2Request saml2Request = new SAML2Request();
if(redirectProfile)
{
- is = RedirectBindingUtil.base64DeflateDecode(samlMessage);
+ try
+ {
+ is = RedirectBindingUtil.base64DeflateDecode(samlMessage);
+ }
+ catch(Exception e)
+ {
+ log.error("Exception in parsing saml message:", e);
+ throw new ParsingException();
+ }
}
else
{
Modified:
identity-federation/trunk/jboss-identity-web/src/test/java/org/jboss/test/identity/federation/web/mock/MockHttpSession.java
===================================================================
---
identity-federation/trunk/jboss-identity-web/src/test/java/org/jboss/test/identity/federation/web/mock/MockHttpSession.java 2009-10-20
18:45:58 UTC (rev 862)
+++
identity-federation/trunk/jboss-identity-web/src/test/java/org/jboss/test/identity/federation/web/mock/MockHttpSession.java 2009-10-21
16:54:23 UTC (rev 863)
@@ -36,7 +36,8 @@
* Mock HttpSession
* @author Anil.Saldhana(a)redhat.com
* @since Oct 7, 2009
- */
+ */
+@SuppressWarnings({"deprecation", "unchecked"})
public class MockHttpSession implements HttpSession
{
private boolean valid = true;