Author: anil.saldhana(a)jboss.com
Date: 2009-11-06 13:12:48 -0500 (Fri, 06 Nov 2009)
New Revision: 913
Added:
identity-federation/trunk/jboss-identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/factories/SAML2HandlerChainFactory.java
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/filters/SPFilter.java
Log:
bring in factory
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-11-06
17:42:49 UTC (rev 912)
+++
identity-federation/trunk/jboss-identity-bindings/src/main/java/org/jboss/identity/federation/bindings/tomcat/idp/IDPWebBrowserSSOValve.java 2009-11-06
18:12:48 UTC (rev 913)
@@ -21,6 +21,8 @@
*/
package org.jboss.identity.federation.bindings.tomcat.idp;
+import static org.jboss.identity.federation.core.util.StringUtil.isNotNull;
+
import java.io.IOException;
import java.io.InputStream;
import java.security.GeneralSecurityException;
@@ -52,6 +54,7 @@
import org.jboss.identity.federation.core.config.KeyProviderType;
import org.jboss.identity.federation.core.exceptions.ConfigurationException;
import org.jboss.identity.federation.core.exceptions.ParsingException;
+import org.jboss.identity.federation.core.exceptions.ProcessingException;
import org.jboss.identity.federation.core.handler.config.Handlers;
import org.jboss.identity.federation.core.impl.DelegatedAttributeManager;
import org.jboss.identity.federation.core.interfaces.AttributeManager;
@@ -64,8 +67,8 @@
import org.jboss.identity.federation.core.saml.v2.constants.JBossSAMLURIConstants;
import
org.jboss.identity.federation.core.saml.v2.exceptions.IssueInstantMissingException;
import org.jboss.identity.federation.core.saml.v2.exceptions.IssuerNotTrustedException;
+import org.jboss.identity.federation.core.saml.v2.factories.SAML2HandlerChainFactory;
import org.jboss.identity.federation.core.saml.v2.holders.IssuerInfoHolder;
-import org.jboss.identity.federation.core.saml.v2.impl.DefaultSAML2HandlerChain;
import org.jboss.identity.federation.core.saml.v2.impl.DefaultSAML2HandlerChainConfig;
import org.jboss.identity.federation.core.saml.v2.impl.DefaultSAML2HandlerRequest;
import org.jboss.identity.federation.core.saml.v2.impl.DefaultSAML2HandlerResponse;
@@ -76,6 +79,7 @@
import org.jboss.identity.federation.core.saml.v2.interfaces.SAML2HandlerResponse;
import org.jboss.identity.federation.core.saml.v2.interfaces.SAML2Handler.HANDLER_TYPE;
import org.jboss.identity.federation.core.saml.v2.util.HandlerUtil;
+import org.jboss.identity.federation.core.util.StringUtil;
import org.jboss.identity.federation.saml.v2.SAML2Object;
import org.jboss.identity.federation.saml.v2.protocol.RequestAbstractType;
import org.jboss.identity.federation.saml.v2.protocol.StatusResponseType;
@@ -88,9 +92,7 @@
import org.jboss.identity.federation.web.util.RedirectBindingUtil;
import org.w3c.dom.Document;
-import static org.jboss.identity.federation.core.util.StringUtil.isNotNull;
-
/**
* Generic Web Browser SSO valve for the IDP
*
@@ -126,6 +128,8 @@
private Context context = null;
+ private transient String samlHandlerChainClass = null;
+
//Set a list of attributes we are interested in separated by comma
public void setAttributeList(String attribList)
{
@@ -171,8 +175,13 @@
{
throw new RuntimeException(e);
}
+ }
+
+ public void setSamlHandlerChainClass(String samlHandlerChainClass)
+ {
+ this.samlHandlerChainClass = samlHandlerChainClass;
}
-
+
@Override
public void invoke(Request request, Response response) throws IOException,
ServletException
{
@@ -774,7 +783,17 @@
started = true;
//Get the chain from config
- chain = new DefaultSAML2HandlerChain();
+ if(StringUtil.isNullOrEmpty(samlHandlerChainClass))
+ chain = SAML2HandlerChainFactory.createChain();
+ else
+ try
+ {
+ chain = SAML2HandlerChainFactory.createChain(this.samlHandlerChainClass);
+ }
+ catch (ProcessingException e1)
+ {
+ throw new LifecycleException(e1);
+ }
String configFile = GeneralConstants.CONFIG_FILE_LOCATION;
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-11-06
17:42:49 UTC (rev 912)
+++
identity-federation/trunk/jboss-identity-bindings/src/main/java/org/jboss/identity/federation/bindings/tomcat/sp/BaseFormAuthenticator.java 2009-11-06
18:12:48 UTC (rev 913)
@@ -35,13 +35,15 @@
import org.apache.catalina.connector.Request;
import org.apache.log4j.Logger;
import org.jboss.identity.federation.core.config.SPType;
+import org.jboss.identity.federation.core.exceptions.ProcessingException;
import org.jboss.identity.federation.core.handler.config.Handlers;
-import org.jboss.identity.federation.core.saml.v2.impl.DefaultSAML2HandlerChain;
+import org.jboss.identity.federation.core.saml.v2.factories.SAML2HandlerChainFactory;
import org.jboss.identity.federation.core.saml.v2.impl.DefaultSAML2HandlerChainConfig;
import org.jboss.identity.federation.core.saml.v2.interfaces.SAML2Handler;
import org.jboss.identity.federation.core.saml.v2.interfaces.SAML2HandlerChain;
import org.jboss.identity.federation.core.saml.v2.interfaces.SAML2HandlerChainConfig;
import org.jboss.identity.federation.core.saml.v2.util.HandlerUtil;
+import org.jboss.identity.federation.core.util.StringUtil;
import org.jboss.identity.federation.web.constants.GeneralConstants;
import org.jboss.identity.federation.web.util.ConfigurationUtil;
@@ -63,6 +65,8 @@
protected String configFile = GeneralConstants.CONFIG_FILE_LOCATION;
protected transient SAML2HandlerChain chain = null;
+
+ protected transient String samlHandlerChainClass = null;
public BaseFormAuthenticator()
{
@@ -79,6 +83,12 @@
this.configFile = configFile;
}
+
+ public void setSamlHandlerChainClass(String samlHandlerChainClass)
+ {
+ this.samlHandlerChainClass = samlHandlerChainClass;
+ }
+
/**
* Perform validation os the request object
* @param request
@@ -113,8 +123,19 @@
if(is == null)
throw new RuntimeException(configFile + " missing");
- //Get the chain from config
- chain = new DefaultSAML2HandlerChain();
+ //Get the chain from config
+ if(StringUtil.isNullOrEmpty(samlHandlerChainClass))
+ chain = SAML2HandlerChainFactory.createChain();
+ else
+ try
+ {
+ chain = SAML2HandlerChainFactory.createChain(this.samlHandlerChainClass);
+ }
+ catch (ProcessingException e1)
+ {
+ throw new LifecycleException(e1);
+ }
+
try
{
spConfiguration = ConfigurationUtil.getSPConfiguration(is);
@@ -126,9 +147,7 @@
{
throw new RuntimeException(e);
}
-
- //Get the chain from config
- chain = new DefaultSAML2HandlerChain();
+
try
{
//Get the handlers
Added:
identity-federation/trunk/jboss-identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/factories/SAML2HandlerChainFactory.java
===================================================================
---
identity-federation/trunk/jboss-identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/factories/SAML2HandlerChainFactory.java
(rev 0)
+++
identity-federation/trunk/jboss-identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/factories/SAML2HandlerChainFactory.java 2009-11-06
18:12:48 UTC (rev 913)
@@ -0,0 +1,55 @@
+/*
+ * 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.identity.federation.core.saml.v2.factories;
+
+import org.jboss.identity.federation.core.exceptions.ProcessingException;
+import org.jboss.identity.federation.core.saml.v2.impl.DefaultSAML2HandlerChain;
+import org.jboss.identity.federation.core.saml.v2.interfaces.SAML2HandlerChain;
+
+/**
+ * Creates {@code SAML2HandlerChain}
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Nov 6, 2009
+ */
+public class SAML2HandlerChainFactory
+{
+ public static SAML2HandlerChain createChain()
+ {
+ return new DefaultSAML2HandlerChain();
+ }
+
+ public static SAML2HandlerChain createChain(String fqn) throws ProcessingException
+ {
+ if(fqn == null)
+ throw new IllegalArgumentException("fqn is null");
+ ClassLoader tcl = SecurityActions.getContextClassLoader();
+
+ try
+ {
+ return (SAML2HandlerChain) tcl.loadClass(fqn).newInstance();
+ }
+ catch (Exception e)
+ {
+ throw new ProcessingException("Cannot create chain:",e);
+ }
+ }
+}
\ No newline at end of file
Modified:
identity-federation/trunk/jboss-identity-web/src/main/java/org/jboss/identity/federation/web/filters/SPFilter.java
===================================================================
---
identity-federation/trunk/jboss-identity-web/src/main/java/org/jboss/identity/federation/web/filters/SPFilter.java 2009-11-06
17:42:49 UTC (rev 912)
+++
identity-federation/trunk/jboss-identity-web/src/main/java/org/jboss/identity/federation/web/filters/SPFilter.java 2009-11-06
18:12:48 UTC (rev 913)
@@ -72,9 +72,9 @@
import org.jboss.identity.federation.core.saml.v2.constants.JBossSAMLURIConstants;
import org.jboss.identity.federation.core.saml.v2.exceptions.AssertionExpiredException;
import org.jboss.identity.federation.core.saml.v2.exceptions.IssuerNotTrustedException;
+import org.jboss.identity.federation.core.saml.v2.factories.SAML2HandlerChainFactory;
import org.jboss.identity.federation.core.saml.v2.holders.DestinationInfoHolder;
import org.jboss.identity.federation.core.saml.v2.holders.IssuerInfoHolder;
-import org.jboss.identity.federation.core.saml.v2.impl.DefaultSAML2HandlerChain;
import org.jboss.identity.federation.core.saml.v2.impl.DefaultSAML2HandlerChainConfig;
import org.jboss.identity.federation.core.saml.v2.impl.DefaultSAML2HandlerRequest;
import org.jboss.identity.federation.core.saml.v2.impl.DefaultSAML2HandlerResponse;
@@ -88,6 +88,7 @@
import org.jboss.identity.federation.core.saml.v2.util.AssertionUtil;
import org.jboss.identity.federation.core.saml.v2.util.DocumentUtil;
import org.jboss.identity.federation.core.saml.v2.util.HandlerUtil;
+import org.jboss.identity.federation.core.util.StringUtil;
import org.jboss.identity.federation.core.util.XMLSignatureUtil;
import org.jboss.identity.federation.saml.v2.SAML2Object;
import org.jboss.identity.federation.saml.v2.assertion.AssertionType;
@@ -134,7 +135,7 @@
private IRoleValidator roleValidator = new DefaultRoleValidator();
- private String logOutPage = GeneralConstants.LOGOUT_PAGE_NAME;
+ private String logOutPage = GeneralConstants.LOGOUT_PAGE_NAME;
public void destroy()
{
@@ -464,9 +465,21 @@
options.put("ROLES", roles);
}
this.roleValidator.intialize(options);
+
+ String samlHandlerChainClass =
filterConfig.getInitParameter("SAML_HANDLER_CHAIN_CLASS");
- //Get the chain from config
- chain = new DefaultSAML2HandlerChain();
+ //Get the chain from config
+ if(StringUtil.isNullOrEmpty(samlHandlerChainClass))
+ chain = SAML2HandlerChainFactory.createChain();
+ else
+ try
+ {
+ chain = SAML2HandlerChainFactory.createChain(samlHandlerChainClass);
+ }
+ catch (ProcessingException e1)
+ {
+ throw new ServletException(e1);
+ }
try
{
//Get the handlers