Author: anil.saldhana(a)jboss.com
Date: 2009-10-11 00:52:57 -0400 (Sun, 11 Oct 2009)
New Revision: 838
Added:
identity-federation/trunk/jboss-identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/impl/DefaultSAML2HandlerConfig.java
identity-federation/trunk/jboss-identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/interfaces/SAML2HandlerChainConfig.java
Modified:
identity-federation/trunk/jboss-identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/interfaces/SAML2Handler.java
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/handlers/saml2/BaseSAML2Handler.java
identity-federation/trunk/jboss-identity-web/src/main/java/org/jboss/identity/federation/web/handlers/saml2/RolesGenerationHandler.java
identity-federation/trunk/jboss-identity-web/src/main/java/org/jboss/identity/federation/web/handlers/saml2/SAML2AuthenticationHandler.java
identity-federation/trunk/jboss-identity-web/src/main/java/org/jboss/identity/federation/web/handlers/saml2/SAML2IssuerTrustHandler.java
identity-federation/trunk/jboss-identity-web/src/main/java/org/jboss/identity/federation/web/handlers/saml2/SAML2LogOutHandler.java
identity-federation/trunk/jboss-identity-web/src/main/java/org/jboss/identity/federation/web/servlets/IDPServlet.java
Log:
JBID-198: saml2 handler arch
Added:
identity-federation/trunk/jboss-identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/impl/DefaultSAML2HandlerConfig.java
===================================================================
---
identity-federation/trunk/jboss-identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/impl/DefaultSAML2HandlerConfig.java
(rev 0)
+++
identity-federation/trunk/jboss-identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/impl/DefaultSAML2HandlerConfig.java 2009-10-11
04:52:57 UTC (rev 838)
@@ -0,0 +1,50 @@
+/*
+ * 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.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.identity.federation.core.saml.v2.interfaces.SAML2HandlerChainConfig;
+
+/**
+ * Default implementation of the handler config
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Oct 10, 2009
+ */
+public class DefaultSAML2HandlerConfig implements SAML2HandlerChainConfig
+{
+ private Map<String, Object> params = new HashMap<String, Object>();
+
+ public DefaultSAML2HandlerConfig(Map<String,Object> map)
+ {
+ this.params = map;
+ }
+
+ /**
+ * @see SAML2HandlerChainConfig#getParameter(String)
+ */
+ public Object getParameter(String parameterName)
+ {
+ return params.get(parameterName);
+ }
+}
\ No newline at end of file
Modified:
identity-federation/trunk/jboss-identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/interfaces/SAML2Handler.java
===================================================================
---
identity-federation/trunk/jboss-identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/interfaces/SAML2Handler.java 2009-10-10
20:59:55 UTC (rev 837)
+++
identity-federation/trunk/jboss-identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/interfaces/SAML2Handler.java 2009-10-11
04:52:57 UTC (rev 838)
@@ -34,6 +34,12 @@
{
/**
* Initialize the handler
+ * @param handlerConfig Handler Config
+ */
+ void init(SAML2HandlerChainConfig handlerConfig);
+
+ /**
+ * Initialize the handler from configuration
* @param options
*/
void init(Map<String,Object> options);
Added:
identity-federation/trunk/jboss-identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/interfaces/SAML2HandlerChainConfig.java
===================================================================
---
identity-federation/trunk/jboss-identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/interfaces/SAML2HandlerChainConfig.java
(rev 0)
+++
identity-federation/trunk/jboss-identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/interfaces/SAML2HandlerChainConfig.java 2009-10-11
04:52:57 UTC (rev 838)
@@ -0,0 +1,37 @@
+/*
+ * 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.interfaces;
+
+/**
+ * Configuration passed to the handler chain
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Oct 10, 2009
+ */
+public interface SAML2HandlerChainConfig
+{
+ /**
+ * Get a parameter from the chain config
+ * @param parameterName
+ * @return
+ */
+ public Object getParameter(String parameterName);
+}
\ 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-10-10
20:59:55 UTC (rev 837)
+++
identity-federation/trunk/jboss-identity-web/src/main/java/org/jboss/identity/federation/web/filters/SPFilter.java 2009-10-11
04:52:57 UTC (rev 838)
@@ -74,10 +74,12 @@
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.DefaultSAML2HandlerConfig;
import org.jboss.identity.federation.core.saml.v2.impl.DefaultSAML2HandlerRequest;
import org.jboss.identity.federation.core.saml.v2.impl.DefaultSAML2HandlerResponse;
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.interfaces.SAML2HandlerRequest;
import org.jboss.identity.federation.core.saml.v2.interfaces.SAML2HandlerResponse;
import
org.jboss.identity.federation.core.saml.v2.interfaces.SAML2HandlerRequest.GENERATE_REQUEST_TYPE;
@@ -278,10 +280,6 @@
holder.getIssuer(), samlObject,
HANDLER_TYPE.SP);
- Map<String,Object> requestOptions = new
HashMap<String,Object>();
- requestOptions.put(GeneralConstants.CONFIGURATION, this.spConfiguration);
- saml2HandlerRequest.setOptions(requestOptions);
-
SAML2HandlerResponse saml2HandlerResponse = new
DefaultSAML2HandlerResponse();
//Deal with handler chains
@@ -390,6 +388,17 @@
//Get the handlers
Handlers handlers =
ConfigurationUtil.getHandlers(context.getResourceAsStream("/WEB-INF/jbid-handlers.xml"));
chain.addAll(HandlerUtil.getHandlers(handlers));
+
+ Map<String, Object> configOptions = new HashMap<String, Object>();
+ configOptions.put(GeneralConstants.CONFIGURATION, spConfiguration);
+
+ SAML2HandlerChainConfig handlerConfig = new
DefaultSAML2HandlerConfig(configOptions);
+ Set<SAML2Handler> samlHandlers = chain.handlers();
+
+ for(SAML2Handler handler: samlHandlers)
+ {
+ handler.init(handlerConfig);
+ }
}
catch(Exception e)
{
Modified:
identity-federation/trunk/jboss-identity-web/src/main/java/org/jboss/identity/federation/web/handlers/saml2/BaseSAML2Handler.java
===================================================================
---
identity-federation/trunk/jboss-identity-web/src/main/java/org/jboss/identity/federation/web/handlers/saml2/BaseSAML2Handler.java 2009-10-10
20:59:55 UTC (rev 837)
+++
identity-federation/trunk/jboss-identity-web/src/main/java/org/jboss/identity/federation/web/handlers/saml2/BaseSAML2Handler.java 2009-10-11
04:52:57 UTC (rev 838)
@@ -26,7 +26,9 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
+import org.jboss.identity.federation.core.exceptions.ProcessingException;
import org.jboss.identity.federation.core.saml.v2.interfaces.SAML2Handler;
+import org.jboss.identity.federation.core.saml.v2.interfaces.SAML2HandlerChainConfig;
import org.jboss.identity.federation.core.saml.v2.interfaces.SAML2HandlerRequest;
import org.jboss.identity.federation.web.core.HTTPContext;
@@ -48,7 +50,14 @@
this.options = options;
}
-
+ public void init(SAML2HandlerChainConfig handlerConfig)
+ {
+ }
+
+ public void reset() throws ProcessingException
+ {
+ }
+
public static HttpServletRequest getHttpRequest(SAML2HandlerRequest request)
{
HTTPContext context = (HTTPContext) request.getContext();
Modified:
identity-federation/trunk/jboss-identity-web/src/main/java/org/jboss/identity/federation/web/handlers/saml2/RolesGenerationHandler.java
===================================================================
---
identity-federation/trunk/jboss-identity-web/src/main/java/org/jboss/identity/federation/web/handlers/saml2/RolesGenerationHandler.java 2009-10-10
20:59:55 UTC (rev 837)
+++
identity-federation/trunk/jboss-identity-web/src/main/java/org/jboss/identity/federation/web/handlers/saml2/RolesGenerationHandler.java 2009-10-11
04:52:57 UTC (rev 838)
@@ -28,13 +28,13 @@
import javax.servlet.http.HttpSession;
import org.jboss.identity.federation.core.exceptions.ProcessingException;
+import org.jboss.identity.federation.core.saml.v2.interfaces.SAML2HandlerChainConfig;
import org.jboss.identity.federation.core.saml.v2.interfaces.SAML2HandlerRequest;
import org.jboss.identity.federation.core.saml.v2.interfaces.SAML2HandlerResponse;
import org.jboss.identity.federation.saml.v2.protocol.LogoutRequestType;
import org.jboss.identity.federation.web.constants.GeneralConstants;
import org.jboss.identity.federation.web.core.HTTPContext;
import org.jboss.identity.federation.web.interfaces.RoleGenerator;
-import org.jboss.identity.federation.web.roles.DefaultRoleGenerator;
/**
* Handles the generation of roles
@@ -43,13 +43,19 @@
*/
public class RolesGenerationHandler extends BaseSAML2Handler
{
- private transient RoleGenerator rg = new DefaultRoleGenerator();
+ @SuppressWarnings("unused")
+ private transient RoleGenerator rg = null;
+
+ public void init(SAML2HandlerChainConfig handlerConfig)
+ {
+ rg = (RoleGenerator) handlerConfig.getParameter(GeneralConstants.ROLE_GENERATOR);
+ }
@Override
public void init(Map<String, Object> options)
{
super.init(options);
- if(options.containsKey("ROLE_GENERATOR"))
+ if(options.containsKey(GeneralConstants.ROLE_GENERATOR))
{
String clazzName = (String) options.get(GeneralConstants.ROLE_GENERATOR);
ClassLoader tcl = SecurityActions.getContextClassLoader();
@@ -99,13 +105,6 @@
public void generateSAMLRequest(SAML2HandlerRequest request, SAML2HandlerResponse
response)
throws ProcessingException
- {
- return;
+ {
}
-
- public void reset() throws ProcessingException
- {
- // TODO Auto-generated method stub
-
- }
}
Modified:
identity-federation/trunk/jboss-identity-web/src/main/java/org/jboss/identity/federation/web/handlers/saml2/SAML2AuthenticationHandler.java
===================================================================
---
identity-federation/trunk/jboss-identity-web/src/main/java/org/jboss/identity/federation/web/handlers/saml2/SAML2AuthenticationHandler.java 2009-10-10
20:59:55 UTC (rev 837)
+++
identity-federation/trunk/jboss-identity-web/src/main/java/org/jboss/identity/federation/web/handlers/saml2/SAML2AuthenticationHandler.java 2009-10-11
04:52:57 UTC (rev 838)
@@ -372,10 +372,4 @@
return principal;
}
}
-
- public void reset() throws ProcessingException
- {
- // TODO Auto-generated method stub
-
- }
}
\ No newline at end of file
Modified:
identity-federation/trunk/jboss-identity-web/src/main/java/org/jboss/identity/federation/web/handlers/saml2/SAML2IssuerTrustHandler.java
===================================================================
---
identity-federation/trunk/jboss-identity-web/src/main/java/org/jboss/identity/federation/web/handlers/saml2/SAML2IssuerTrustHandler.java 2009-10-10
20:59:55 UTC (rev 837)
+++
identity-federation/trunk/jboss-identity-web/src/main/java/org/jboss/identity/federation/web/handlers/saml2/SAML2IssuerTrustHandler.java 2009-10-11
04:52:57 UTC (rev 838)
@@ -78,11 +78,7 @@
{
sp.handleStatusResponseType(request, response);
}
- }
-
- public void reset() throws ProcessingException
- {
- }
+ }
private class IDPTrustHandler
{
Modified:
identity-federation/trunk/jboss-identity-web/src/main/java/org/jboss/identity/federation/web/handlers/saml2/SAML2LogOutHandler.java
===================================================================
---
identity-federation/trunk/jboss-identity-web/src/main/java/org/jboss/identity/federation/web/handlers/saml2/SAML2LogOutHandler.java 2009-10-10
20:59:55 UTC (rev 837)
+++
identity-federation/trunk/jboss-identity-web/src/main/java/org/jboss/identity/federation/web/handlers/saml2/SAML2LogOutHandler.java 2009-10-11
04:52:57 UTC (rev 838)
@@ -451,11 +451,5 @@
response.setRelayState(relayState);
response.setDestination(logOutRequest.getIssuer().getValue());
}
- }
-
- public void reset() throws ProcessingException
- {
- // TODO Auto-generated method stub
-
- }
+ }
}
\ No newline at end of file
Modified:
identity-federation/trunk/jboss-identity-web/src/main/java/org/jboss/identity/federation/web/servlets/IDPServlet.java
===================================================================
---
identity-federation/trunk/jboss-identity-web/src/main/java/org/jboss/identity/federation/web/servlets/IDPServlet.java 2009-10-10
20:59:55 UTC (rev 837)
+++
identity-federation/trunk/jboss-identity-web/src/main/java/org/jboss/identity/federation/web/servlets/IDPServlet.java 2009-10-11
04:52:57 UTC (rev 838)
@@ -58,10 +58,12 @@
import org.jboss.identity.federation.core.saml.v2.exceptions.IssuerNotTrustedException;
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.DefaultSAML2HandlerConfig;
import org.jboss.identity.federation.core.saml.v2.impl.DefaultSAML2HandlerRequest;
import org.jboss.identity.federation.core.saml.v2.impl.DefaultSAML2HandlerResponse;
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.interfaces.SAML2HandlerRequest;
import org.jboss.identity.federation.core.saml.v2.interfaces.SAML2HandlerResponse;
import
org.jboss.identity.federation.core.saml.v2.interfaces.SAML2HandlerRequest.HANDLER_TYPE;
@@ -149,6 +151,18 @@
//Get the handlers
handlers =
ConfigurationUtil.getHandlers(context.getResourceAsStream("/WEB-INF/jbid-handlers.xml"));
chain.addAll(HandlerUtil.getHandlers(handlers));
+
+ Map<String, Object> configOptions = new HashMap<String, Object>();
+ configOptions.put(GeneralConstants.ROLE_GENERATOR, rg);
+
+ SAML2HandlerChainConfig handlerConfig = new
DefaultSAML2HandlerConfig(configOptions);
+ Set<SAML2Handler> samlHandlers = chain.handlers();
+
+ for(SAML2Handler handler: samlHandlers)
+ {
+ handler.init(handlerConfig);
+ }
+
}
catch (Exception e)
{
@@ -278,10 +292,6 @@
HANDLER_TYPE.IDP);
saml2HandlerRequest.setRelayState(relayState);
- Map<String, Object> requestOptions = new HashMap<String,
Object>();
- requestOptions.put("ROLE_GENERATOR", rg);
- saml2HandlerRequest.setOptions(requestOptions);
-
SAML2HandlerResponse saml2HandlerResponse = new
DefaultSAML2HandlerResponse();
Set<SAML2Handler> handlers = chain.handlers();
@@ -296,6 +306,7 @@
{
for(SAML2Handler handler: handlers)
{
+ handler.reset();
handler.handleStatusResponseType(saml2HandlerRequest,
saml2HandlerResponse);
}
}