First pass to clean up config and fix multi serivce instance bug
authorlajoie <lajoie@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Sun, 17 Feb 2008 09:45:42 +0000 (09:45 +0000)
committerlajoie <lajoie@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Sun, 17 Feb 2008 09:45:42 +0000 (09:45 +0000)
Support for exporting all services directly to the ServletContext

git-svn-id: https://subversion.switch.ch/svn/shibboleth/java-idp/trunk@2618 ab3bd59b-922f-494d-bb5f-6f0a3c29deca

resources/META-INF/spring.handlers
resources/META-INF/spring.schemas
resources/classpath/schema/shibboleth-2.0-idp-service.xsd [deleted file]
resources/conf/internal.xml
resources/conf/service.xml
src/edu/internet2/middleware/shibboleth/idp/config/service/IdPConfigBeanDefinitionParser.java [deleted file]
src/edu/internet2/middleware/shibboleth/idp/config/service/IdPServicesBean.java [deleted file]
src/edu/internet2/middleware/shibboleth/idp/config/service/IdPServicesNamespaceHandler.java [deleted file]
src/edu/internet2/middleware/shibboleth/idp/profile/IdPProfileHandlerManager.java
src/edu/internet2/middleware/shibboleth/idp/session/IdPSessionFilter.java

index cff592f..fdf34a8 100644 (file)
@@ -1,2 +1 @@
-urn\:mace\:shibboleth\:2.0\:idp\:services = edu.internet2.middleware.shibboleth.idp.config.service.IdPServicesNamespaceHandler
 urn\:mace\:shibboleth\:2.0\:idp\:profile-handler = edu.internet2.middleware.shibboleth.idp.config.profile.ProfileHandlerNamespaceHandler
\ No newline at end of file
index c5456d0..c200331 100644 (file)
@@ -1,2 +1 @@
-urn\:mace\:shibboleth\:2.0\:idp\:services = schema/shibboleth-2.0-idp-service.xsd
 urn\:mace\:shibboleth\:2.0\:idp\:profile-handler = schema/shibboleth-2.0-idp-profile-handler.xsd
\ No newline at end of file
diff --git a/resources/classpath/schema/shibboleth-2.0-idp-service.xsd b/resources/classpath/schema/shibboleth-2.0-idp-service.xsd
deleted file mode 100644 (file)
index 568e88c..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:mace:shibboleth:2.0:idp:services"
-    xmlns:idpconf="urn:mace:shibboleth:2.0:idp:services" xmlns:service="urn:mace:shibboleth:2.0:services"
-    elementFormDefault="qualified">
-
-    <import namespace="urn:mace:shibboleth:2.0:services" schemaLocation="classpath:/schema/shibboleth-2.0-services.xsd" />
-
-    <element name="IdPConfig" type="idpconf:IdPConfigType">
-        <annotation>
-            <documentation>Root of the IdP configuration file.</documentation>
-        </annotation>
-    </element>
-
-    <complexType name="IdPConfigType">
-        <sequence>
-            <element ref="service:Service" minOccurs="0" maxOccurs="unbounded">
-                <annotation>
-                    <documentation>List of IdP configured services.</documentation>
-                </annotation>
-            </element>
-        </sequence>
-    </complexType>
-
-</schema>
\ No newline at end of file
index 9de4b7a..dba227b 100644 (file)
         </entry>
     </util:map>
 
-    <bean id="shibboleth.SAML1AttributeAuthority"
-        class="edu.internet2.middleware.shibboleth.common.attribute.provider.ShibbolethSAML1AttributeAuthority" depends-on="shibboleth.LogbackLogging">
-        <constructor-arg ref="shibboleth.AttributeResolver" />
-        <property name="filteringEngine" ref="shibboleth.AttributeFilterEngine" />
-    </bean>
-
-    <bean id="shibboleth.SAML2AttributeAuthority"
-        class="edu.internet2.middleware.shibboleth.common.attribute.provider.ShibbolethSAML2AttributeAuthority" depends-on="shibboleth.LogbackLogging">
-        <constructor-arg ref="shibboleth.AttributeResolver" />
-        <property name="filteringEngine" ref="shibboleth.AttributeFilterEngine" />
-    </bean>
-
     <bean id="shibboleth.ServletAttributeExporter"
         class="org.springframework.web.context.support.ServletContextAttributeExporter" depends-on="shibboleth.LogbackLogging">
         <property name="attributes">
             <map>
                 <entry>
                     <key>
-                        <value>handlerManager</value>
-                    </key>
-                    <ref bean="shibboleth.HandlerManager" />
-                </entry>
-                <entry>
-                    <key>
-                        <value>sessionManager</value>
+                        <value>shibboleth.SessionManager</value>
                     </key>
                     <ref bean="shibboleth.SessionManager" />
                 </entry>
index 4088485..b5d256c 100644 (file)
@@ -1,39 +1,58 @@
 <?xml version="1.0" encoding="UTF-8"?>
 
-<IdPConfig xmlns="urn:mace:shibboleth:2.0:idp:services" xmlns:service="urn:mace:shibboleth:2.0:services"
-    xmlns:profile="urn:mace:shibboleth:2.0:idp:profile-handler" xmlns:relyingParty="urn:mace:shibboleth:2.0:relying-party"
-    xmlns:resolver="urn:mace:shibboleth:2.0:resolver" xmlns:afp="urn:mace:shibboleth:2.0:afp"
-    xmlns:resource="urn:mace:shibboleth:2.0:resource" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-    xsi:schemaLocation="urn:mace:shibboleth:2.0:idp:services classpath:/schema/shibboleth-2.0-idp-service.xsd
-                        urn:mace:shibboleth:2.0:services classpath:/schema/shibboleth-2.0-services.xsd
-                        urn:mace:shibboleth:2.0:idp:profile-handler classpath:/schema/shibboleth-2.0-idp-profile-handler.xsd
-                        urn:mace:shibboleth:2.0:relying-party classpath:/schema/shibboleth-2.0-relying-party.xsd
-                        urn:mace:shibboleth:2.0:resolver classpath:/schema/shibboleth-2.0-attribute-resolver.xsd
-                        urn:mace:shibboleth:2.0:afp classpath:/schema/shibboleth-2.0-afp.xsd 
-                        urn:mace:shibboleth:2.0:resource classpath:/schema/shibboleth-2.0-resource.xsd">
+<Services xmlns="urn:mace:shibboleth:2.0:services"
+          xmlns:attribute-afp="urn:mace:shibboleth:2.0:afp"
+          xmlns:attribute-authority="urn:mace:shibboleth:2.0:attribute:authority"
+          xmlns:attribute-resolver="urn:mace:shibboleth:2.0:resolver"
+          xmlns:profile="urn:mace:shibboleth:2.0:idp:profile-handler"
+          xmlns:relyingParty="urn:mace:shibboleth:2.0:relying-party"
+          xmlns:resource="urn:mace:shibboleth:2.0:resource" 
+          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+          xsi:schemaLocation="urn:mace:shibboleth:2.0:services classpath:/schema/shibboleth-2.0-services.xsd
+                              urn:mace:shibboleth:2.0:afp classpath:/schema/shibboleth-2.0-afp.xsd
+                              urn:mace:shibboleth:2.0:attribute:authority classpath:/schema/shibboleth-2.0-attribute-authority.xsd
+                              urn:mace:shibboleth:2.0:resolver classpath:/schema/shibboleth-2.0-attribute-resolver.xsd
+                              urn:mace:shibboleth:2.0:idp:profile-handler classpath:/schema/shibboleth-2.0-idp-profile-handler.xsd
+                              urn:mace:shibboleth:2.0:relying-party classpath:/schema/shibboleth-2.0-relying-party.xsd
+                              urn:mace:shibboleth:2.0:resource classpath:/schema/shibboleth-2.0-resource.xsd">
 
     <Service id="shibboleth.AttributeResolver"
-             xmlns="urn:mace:shibboleth:2.0:services"
-             xsi:type="resolver:ShibbolethAttributeResolver">
+             xsi:type="attribute-resolver:ShibbolethAttributeResolver">
         <ConfigurationResource file="$IDP_HOME$/conf/attribute-resolver.xml" xsi:type="resource:FilesystemResource" />
     </Service>
 
     <Service id="shibboleth.AttributeFilterEngine"
-             xmlns="urn:mace:shibboleth:2.0:services"
-             xsi:type="afp:ShibbolethAttributeFilteringEngine">
+             xsi:type="attribute-afp:ShibbolethAttributeFilteringEngine">
         <ConfigurationResource file="$IDP_HOME$/conf/attribute-filter.xml" xsi:type="resource:FilesystemResource" />
     </Service>
-
-    <Service id="shibboleth.HandlerManager"
-             xmlns="urn:mace:shibboleth:2.0:services"
-             xsi:type="profile:IdPProfileHandlerManager">
-        <ConfigurationResource file="$IDP_HOME$/conf/handler.xml" xsi:type="resource:FilesystemResource" />
-    </Service>
+    
+    <Service id="shibboleth.SAML1AttributeAuthority"
+             xsi:type="attribute-authority:SAML1AttributeAuthority"
+             depends-on="shibboleth.AttributeResolver shibboleth.AttributeFilterEngine" />
+             
+    <Service id="shibboleth.SAML2AttributeAuthority"
+             xsi:type="attribute-authority:SAML2AttributeAuthority"
+             depends-on="shibboleth.AttributeResolver shibboleth.AttributeFilterEngine" />
 
     <Service id="shibboleth.RelyingPartyConfigurationManager"
-             xmlns="urn:mace:shibboleth:2.0:services"
-             xsi:type="relyingParty:SAMLMDRelyingPartyConfigurationManager">
+             xsi:type="relyingParty:SAMLMDRelyingPartyConfigurationManager"
+             depends-on="shibboleth.SAML1AttributeAuthority shibboleth.SAML2AttributeAuthority">
         <ConfigurationResource file="$IDP_HOME$/conf/relying-party.xml" xsi:type="resource:FilesystemResource" />
     </Service>
 
-</IdPConfig>
\ No newline at end of file
+    <Service id="shibboleth.HandlerManager"
+             depends-on="shibboleth.RelyingPartyConfigurationManager"
+             xsi:type="relyingParty:SAMLMDRelyingPartyConfigurationManager">
+        <ConfigurationResource file="$IDP_HOME$/conf/handler.xml" xsi:type="resource:FilesystemResource" />
+    </Service>
+    
+    <!-- 
+        A special service that exports all services upon which it depends into the ServletContext as an attribute 
+        with the same name as the service's ID.
+    -->
+    <Service id="shibboleth.ServiceServletContextAttributeExporter"
+             depends-on="shibboleth.AttributeResolver shibboleth.AttributeFilterEngine
+                         shibboleth.SAML1AttributeAuthority shibboleth.SAML2AttributeAuthority 
+                         shibboleth.RelyingPartyConfigurationManager shibboleth.HandlerManager"
+             xsi:type="ServletContextAttributeExporter" />
+</Services>
\ No newline at end of file
diff --git a/src/edu/internet2/middleware/shibboleth/idp/config/service/IdPConfigBeanDefinitionParser.java b/src/edu/internet2/middleware/shibboleth/idp/config/service/IdPConfigBeanDefinitionParser.java
deleted file mode 100644 (file)
index 0039134..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright [2007] [University Corporation for Advanced Internet Development, Inc.]
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package edu.internet2.middleware.shibboleth.idp.config.service;
-
-import java.util.List;
-import java.util.Map;
-
-import javax.xml.namespace.QName;
-
-import org.opensaml.xml.util.XMLHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.support.BeanDefinitionBuilder;
-import org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser;
-import org.springframework.beans.factory.xml.ParserContext;
-import org.w3c.dom.Element;
-
-import edu.internet2.middleware.shibboleth.common.config.SpringConfigurationUtils;
-import edu.internet2.middleware.shibboleth.common.config.service.ServiceNamespaceHandler;
-
-/**
- * Bean definition parser for IdP services config root element.
- */
-public class IdPConfigBeanDefinitionParser extends AbstractSimpleBeanDefinitionParser {
-
-    /** Element name. */
-    public static final QName ELEMENT_NAME = new QName(IdPServicesNamespaceHandler.NAMESPACE, "IdPConfig");
-
-    /** Schema type. */
-    public static final QName SCHEMA_TYPE = new QName(IdPServicesNamespaceHandler.NAMESPACE, "IdPConfigType");
-    
-    /** Class logger. */
-    private final Logger log = LoggerFactory.getLogger(IdPConfigBeanDefinitionParser.class);
-
-    /** {@inheritDoc} */
-    protected Class getBeanClass(Element arg0) {
-        return IdPServicesBean.class;
-    }
-
-    /** {@inheritDoc} */
-    protected void doParse(Element config, ParserContext context, BeanDefinitionBuilder builder) {
-        log.info("Beginning to load IdP configuration");
-        Map<QName, List<Element>> configChildren = XMLHelper.getChildElements(config);
-        List<Element> children = configChildren.get(new QName(ServiceNamespaceHandler.NAMESPACE, "Service"));
-        builder.addConstructorArg(SpringConfigurationUtils.parseCustomElements(children, context));
-        log.info("Finished loading IdP configuration");
-    }
-    
-    /** {@inheritDoc} */
-    protected boolean shouldGenerateId() {
-        return true;
-    }
-}
\ No newline at end of file
diff --git a/src/edu/internet2/middleware/shibboleth/idp/config/service/IdPServicesBean.java b/src/edu/internet2/middleware/shibboleth/idp/config/service/IdPServicesBean.java
deleted file mode 100644 (file)
index 8f26976..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright [2007] [University Corporation for Advanced Internet Development, Inc.]
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package edu.internet2.middleware.shibboleth.idp.config.service;
-
-import java.util.List;
-
-import edu.internet2.middleware.shibboleth.common.config.BaseService;
-
-/**
- * Collection of services loaded by the IdP.
- */
-public class IdPServicesBean {
-    
-    /** Service components loaded into the IdP. */
-    private List<BaseService> services;
-
-    /**
-     * Constructor.
-     * 
-     * @param loadedServices service components loaded into the IdP
-     */
-    public IdPServicesBean(List<BaseService> loadedServices) {
-        services = loadedServices;
-    }
-
-    /**
-     * Gets the service components loaded into the IdP.
-     * 
-     * @return service components loaded into the IdP
-     */
-    public List<BaseService> getServices() {
-        return services;
-    }
-}
\ No newline at end of file
diff --git a/src/edu/internet2/middleware/shibboleth/idp/config/service/IdPServicesNamespaceHandler.java b/src/edu/internet2/middleware/shibboleth/idp/config/service/IdPServicesNamespaceHandler.java
deleted file mode 100644 (file)
index b230ac5..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright [2007] [University Corporation for Advanced Internet Development, Inc.]
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package edu.internet2.middleware.shibboleth.idp.config.service;
-
-import edu.internet2.middleware.shibboleth.common.config.BaseSpringNamespaceHandler;
-
-/**
- * Spring namespace handler for IdP service definitions.
- */
-public class IdPServicesNamespaceHandler extends BaseSpringNamespaceHandler {
-
-    /** IdP services namespace URI. */
-    public static final String NAMESPACE = "urn:mace:shibboleth:2.0:idp:services";
-
-    /** {@inheritDoc} */
-    public void init() {
-        IdPConfigBeanDefinitionParser parser = new IdPConfigBeanDefinitionParser();
-        registerBeanDefinitionParser(IdPConfigBeanDefinitionParser.ELEMENT_NAME, parser);
-        registerBeanDefinitionParser(IdPConfigBeanDefinitionParser.SCHEMA_TYPE, parser);
-    }
-}
\ No newline at end of file
index 1d61033..79a78d3 100644 (file)
@@ -26,7 +26,6 @@ import javax.servlet.ServletRequest;
 import javax.servlet.http.HttpServletRequest;
 
 import org.opensaml.util.resource.Resource;
-import org.opensaml.xml.util.Pair;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.context.ApplicationContext;
@@ -37,7 +36,6 @@ import edu.internet2.middleware.shibboleth.common.profile.ProfileHandler;
 import edu.internet2.middleware.shibboleth.common.profile.ProfileHandlerManager;
 import edu.internet2.middleware.shibboleth.common.profile.provider.AbstractRequestURIMappedProfileHandler;
 import edu.internet2.middleware.shibboleth.idp.authn.LoginHandler;
-import edu.internet2.middleware.shibboleth.idp.authn.LoginContext;
 
 /**
  * Implementation of a {@link ProfileHandlerManager} that maps the request path, without the servlet context, to a
index b21b940..e1a6a88 100644 (file)
@@ -74,7 +74,12 @@ public class IdPSessionFilter implements Filter {
 
     /** {@inheritDoc} */
     public void init(FilterConfig filterConfig) throws ServletException {
-        sessionManager = (SessionManager<Session>) filterConfig.getServletContext().getAttribute("sessionManager");
+        String sessionManagerId = filterConfig.getInitParameter("sessionManagedId");
+        if (DatatypeHelper.isEmpty(sessionManagerId)) {
+            sessionManagerId = "shibboleth.SessionManager";
+        }
+
+        sessionManager = (SessionManager<Session>) filterConfig.getServletContext().getAttribute(sessionManagerId);
     }
 
     /**