title: In an multi-tenant enviroment how can I provide different metadata for different Service Providers at runtime on different urls (subdomains)?
body: <p>Working on SP initiated Single Sign On (SSO) with both SP and IdP are self-hosted thus have flexibility of editing both. I am using spring-security-saml2-core-1.0.1.RELEASE for hosting spring application (spring-security-3.2.8, spring-mvc-3.2.14.RELEASE), which serves multiple tenants at urls say:
   <strong>sp1.example.org</strong>,<br/>
   <strong>sp2.example.org</strong> <br/>
  IdP is hosted using Shibboleth IdPv3.2.1 which is working fine with multiple applications hosted on different SP servers.</p>
  
  <p>I am trying to send different metadata from the same server for sp1 &amp; sp2. I read an about multi-tenant SP <a href="https://stackoverflow.com/questions/28056206/how-do-i-automatically-pick-the-configured-saml-identity-provider-in-a-multi-ten">here</a> and <a href="http://forum.spring.io/forum/spring-projects/security/saml/127716-idp-initiated-saml-sign-on-with-multi-tenant-sp-configuration" rel="nofollow noreferrer">here</a> custom logic by overriding SAMLContextProviderImpl <code>populatePeerEntityId</code>, similarly I am trying to override <code>populateLocalEntityId</code> because I can't use <code>alias</code>. </p>
  
  <p><strong>Can someone give an example code for Overriding <code>populateLocalEntityId</code> for handling multi-tenants metadata ?</strong>   </p>
  
  <p>SP configuration is as shown below:</p>
  
  <pre><code>&lt;!-- Filters for processing of SAML messages --&gt;
  &lt;beans:bean id="samlFilter" class="org.springframework.security.web.FilterChainProxy"&gt;
      &lt;filter-chain-map request-matcher="ant"&gt;
          &lt;filter-chain pattern="/saml/login/**" filters="samlEntryPoint" /&gt;
          &lt;filter-chain pattern="/saml/logout/**" filters="samlLogoutFilter" /&gt;
          &lt;filter-chain pattern="/saml/metadata/**" filters="metadataDisplayFilter" /&gt;
          &lt;filter-chain pattern="/saml/SSO/**" filters="samlWebSSOProcessingFilter" /&gt;
          &lt;filter-chain pattern="/saml/SSOHoK/**" filters="samlWebSSOHoKProcessingFilter" /&gt;
          &lt;filter-chain pattern="/saml/SingleLogout/**" filters="samlLogoutProcessingFilter" /&gt;
          &lt;filter-chain pattern="/saml/discovery/**" filters="samlIDPDiscovery" /&gt;
      &lt;/filter-chain-map&gt;
  &lt;/beans:bean&gt;
  
  &lt;!-- Handler deciding where to redirect user after successful login --&gt;
  &lt;beans:bean id="successRedirectHandler" class="com.example.web.sso.CustomAuthenticationSuccessHandler" &gt;&lt;/beans:bean&gt;
  &lt;!-- &lt;beans:bean id="successRedirectHandler" 
          class="org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler"&gt;
     &lt;property name="defaultTargetUrl" value="/WEB-INF/security/idpSelection.jsp"/&gt;
  &lt;/beans:bean&gt;  --&gt; 
  
  
  &lt;!-- Use the following for interpreting RelayState coming from unsolicited 
      response as redirect URL: 
      &lt;beans:bean id="successRedirectHandler" class="org.springframework.security.saml.SAMLRelayStateSuccessHandler"&gt; 
      &lt;property name="defaultTargetUrl" value="/" /&gt; &lt;/beans:bean&gt; --&gt;
  
  &lt;!-- Handler deciding where to redirect user after failed login --&gt;
  &lt;beans:bean id="failureRedirectHandler" class="com.example.web.sso.CustomAuthenticationFailureHandler"&gt;&lt;/beans:bean&gt;
  
  &lt;!-- &lt;beans:bean id="failureRedirectHandler"
      class="org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler"&gt;
      &lt;property name="useForward" value="true" /&gt;
      &lt;property name="defaultFailureUrl" value="/error.jsp" /&gt;
  &lt;/beans:bean&gt;  --&gt;
  
  &lt;!-- Handler for successful logout --&gt;
  &lt;beans:bean id="successLogoutHandler"
      class="com.example.web.sso.CustomLogoutSuccessHandler" &gt;&lt;/beans:bean&gt;
  &lt;!-- &lt;beans:bean id="successLogoutHandler"
      class="org.springframework.security.web.authentication.logout.SimpleUrlLogoutSuccessHandler"&gt;
      &lt;property name="defaultTargetUrl" value="/logout.jsp" /&gt;
  &lt;/beans:bean&gt; --&gt;
  
  &lt;authentication-manager alias="samlauthenticationManager"&gt;
      &lt;!-- Register authentication manager for SAML provider --&gt;
      &lt;authentication-provider ref="samlAuthenticationProvider" /&gt;
      &lt;!-- Register authentication manager for administration UI --&gt;
      &lt;authentication-provider&gt;
          &lt;user-service id="adminInterfaceService"&gt;
              &lt;user name="admin" password="admin" authorities="ROLE_ADMIN" /&gt;
          &lt;/user-service&gt;
      &lt;/authentication-provider&gt;
  &lt;/authentication-manager&gt;
  
  &lt;!-- Logger for SAML messages and events --&gt;
  &lt;beans:bean id="samlLogger" class="org.springframework.security.saml.log.SAMLDefaultLogger" &gt;
      &lt;beans:property name="logMessages" value="true" /&gt;
      &lt;beans:property name="logErrors" value="true" /&gt;
  &lt;/beans:bean&gt;
  
  &lt;!-- Central storage of cryptographic keys --&gt;
  &lt;beans:bean id="keyManager" class="org.springframework.security.saml.key.JKSKeyManager"&gt;
  
      &lt;beans:constructor-arg value="/WEB-INF/keys/samlKeystore.jks"&gt;&lt;/beans:constructor-arg&gt;
      &lt;beans:constructor-arg type="java.lang.String" value="nalle123" /&gt;
      &lt;beans:constructor-arg&gt;
          &lt;beans:map&gt;
              &lt;beans:entry key="apollo" value="nalle123" /&gt;
          &lt;/beans:map&gt;
      &lt;/beans:constructor-arg&gt;
      &lt;beans:constructor-arg type="java.lang.String" value="apollo" /&gt;
  &lt;/beans:bean&gt;
  
  &lt;!-- Entry point to initialize authentication, default values taken from 
      properties file --&gt;
  &lt;beans:bean id="samlEntryPoint" class="com.example.web.sso.CustomSAMLEntryPoint"&gt;
      &lt;beans:property name="defaultProfileOptions"&gt;
          &lt;beans:bean class="org.springframework.security.saml.websso.WebSSOProfileOptions"&gt;
              &lt;beans:property name="binding" value="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"/&gt;
              &lt;beans:property name="nameID" value="urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress" /&gt;
              &lt;beans:property name="includeScoping" value="false" /&gt;
              &lt;beans:property name="forceAuthN" value="false" /&gt;
          &lt;/beans:bean&gt;
      &lt;/beans:property&gt;
  &lt;/beans:bean&gt;
  
  &lt;!-- IDP Discovery Service --&gt;
  &lt;beans:bean id="samlIDPDiscovery" class="org.springframework.security.saml.SAMLDiscovery"&gt;
      &lt;beans:property name="idpSelectionPath" value="/WEB-INF/security/idpSelection.jsp" /&gt;
  &lt;/beans:bean&gt;
  
  &lt;!-- Filter automatically generates default SP metadata --&gt; 
  &lt;beans:bean id="metadataGeneratorFilter"
      class="org.springframework.security.saml.metadata.MetadataGeneratorFilter"&gt;
      &lt;beans:constructor-arg&gt;
          &lt;beans:bean class="org.springframework.security.saml.metadata.MetadataGenerator"&gt;
              &lt;beans:property name="entityId" value="com:example:namespaceId:saml:poc" /&gt;
              &lt;!-- &lt;beans:property name="entityBaseURL" value="https://sp1.example.com:8080/" /&gt; --&gt;
              &lt;beans:property name="requestSigned" value="true" /&gt;
              &lt;beans:property name="wantAssertionSigned" value="true" /&gt;
              &lt;beans:property name="extendedMetadata"&gt;
                  &lt;beans:bean class="org.springframework.security.saml.metadata.ExtendedMetadata"&gt;
                      &lt;beans:property name="idpDiscoveryEnabled" value="true" /&gt;
                  &lt;/beans:bean&gt;
              &lt;/beans:property&gt;
          &lt;/beans:bean&gt;
      &lt;/beans:constructor-arg&gt;
  &lt;/beans:bean&gt;
  
  &lt;beans:bean id="metadataGenerator" class="org.springframework.security.saml.metadata.MetadataGenerator"&gt;
              &lt;beans:property name="entityId" value="com:example:namespaceId:saml:poc" /&gt;
              &lt;beans:property name="entityBaseURL" value="https://sp1.example.com:8080/" /&gt;
              &lt;beans:property name="requestSigned" value="true" /&gt;
              &lt;beans:property name="wantAssertionSigned" value="true" /&gt;
              &lt;beans:property name="extendedMetadata"&gt;
                  &lt;beans:bean class="org.springframework.security.saml.metadata.ExtendedMetadata"&gt;
                      &lt;beans:property name="idpDiscoveryEnabled" value="true" /&gt;
                  &lt;/beans:bean&gt;
              &lt;/beans:property&gt;
          &lt;/beans:bean&gt;
  
  &lt;!-- The filter is waiting for connections on URL suffixed with filterSuffix 
      and presents SP metadata there --&gt;
  &lt;beans:bean id="metadataDisplayFilter"
      class="org.springframework.security.saml.metadata.MetadataDisplayFilter" /&gt;
  
  &lt;!-- Configure HTTP Client to accept certificates from the keystore for 
      HTTPS verification --&gt;
  &lt;!-- &lt;beans:bean class="org.springframework.security.saml.trust.httpclient.TLSProtocolConfigurer"&gt; 
      &lt;beans:property name="sslHostnameVerification" value="default"/&gt; &lt;/beans:bean&gt; --&gt;
  
  &lt;!-- IDP Metadata configuration - paths to metadata of IDPs in circle of 
      trust is here --&gt;
  &lt;beans:bean id="metadata"
      class="org.springframework.security.saml.metadata.CachingMetadataManager"&gt;
      &lt;beans:constructor-arg&gt;
          &lt;beans:list&gt;
              &lt;!-- Example of classpath metadata with Extended Metadata --&gt;
              &lt;beans:bean
                  class="org.springframework.security.saml.metadata.ExtendedMetadataDelegate"&gt;
                  &lt;beans:constructor-arg&gt;
                      &lt;beans:bean
                          class="org.opensaml.saml2.metadata.provider.ResourceBackedMetadataProvider"&gt;
                          &lt;beans:constructor-arg&gt;
                              &lt;beans:bean class="java.util.Timer" /&gt;
                          &lt;/beans:constructor-arg&gt;
                          &lt;beans:constructor-arg&gt;
                              &lt;beans:bean class="org.opensaml.util.resource.ClasspathResource"&gt;
                              &lt;!-- &lt;beans:bean class="org.opensaml.util.resource.FilesystemResource"&gt; --&gt;
                                      &lt;beans:constructor-arg value = "/WEB-INF/metadata/sp1-mymetadata.xml"&gt;&lt;/beans:constructor-arg&gt;
                              &lt;/beans:bean&gt;
                          &lt;/beans:constructor-arg&gt;
                          &lt;beans:property name="parserPool" ref="parserPool" /&gt;
                      &lt;/beans:bean&gt;
                  &lt;/beans:constructor-arg&gt;
                  &lt;beans:constructor-arg&gt;
  
                      &lt;beans:bean
                          class="org.springframework.security.saml.metadata.ExtendedMetadata"&gt;
                          &lt;beans:property name="local" value="true" /&gt;
                          &lt;beans:property name="securityProfile" value="metaiop" /&gt;
                          &lt;beans:property name="sslSecurityProfile" value="pkix" /&gt;
                          &lt;beans:property name="sslHostnameVerification" value="default" /&gt;
                          &lt;!-- &lt;beans:property name="sslHostnameVerification" value="allowAll" /&gt; --&gt;
                          &lt;beans:property name="signMetadata" value="false" /&gt;
                          &lt;beans:property name="signingKey" value="apollo" /&gt;
                          &lt;beans:property name="encryptionKey" value="apollo" /&gt;
                          &lt;beans:property name="requireArtifactResolveSigned" value="false" /&gt;
                          &lt;beans:property name="requireLogoutRequestSigned" value="false" /&gt;
                          &lt;beans:property name="requireLogoutResponseSigned" value="false" /&gt;
                          &lt;beans:property name="idpDiscoveryEnabled" value="false" /&gt;
                          &lt;beans:property name="idpDiscoveryURL" value="https://sp1.example.com/saml/discovery" /&gt;
                          &lt;beans:property name="idpDiscoveryResponseURL" value="https://sp1.example.com/saml/login?disco=true" /&gt;
                      &lt;/beans:bean&gt;
                  &lt;/beans:constructor-arg&gt;
  
              &lt;/beans:bean&gt;
              &lt;!-- Example of HTTP metadata without Extended Metadata --&gt;
              &lt;!-- &lt;beans:bean class="org.opensaml.saml2.metadata.provider.HTTPMetadataProvider"&gt;
                  URL containing the metadata
                  &lt;beans:constructor-arg&gt;
                      &lt;beans:value type="java.lang.String"&gt;https://idp.ssocircle.com/idp-meta.xml&lt;/beans:value&gt;
                      &lt;beans:value type="java.lang.String"&gt;https://sp1.example.com/idp-meta.xml&lt;/beans:value&gt;
                  &lt;/beans:constructor-arg&gt;
                  Timeout for metadata loading in ms
                  &lt;beans:constructor-arg&gt;
                      &lt;beans:value type="int"&gt;15000&lt;/beans:value&gt;
                  &lt;/beans:constructor-arg&gt;
                  &lt;beans:property name="parserPool" ref="parserPool" /&gt;
              &lt;/beans:bean&gt; --&gt;
  
              &lt;beans:bean class="org.springframework.security.saml.metadata.ExtendedMetadataDelegate"&gt;
                  &lt;beans:constructor-arg&gt;
                      &lt;beans:bean class="org.opensaml.saml2.metadata.provider.FilesystemMetadataProvider"&gt;
                          &lt;beans:constructor-arg&gt;
                              &lt;beans:value type="java.io.File"&gt;/shared/saml/idp-metadata-exampleIdp.xml&lt;/beans:value&gt;
                          &lt;/beans:constructor-arg&gt;
                          &lt;beans:property name="parserPool" ref="parserPool"/&gt;
                      &lt;/beans:bean&gt;
                  &lt;/beans:constructor-arg&gt;
                  &lt;beans:constructor-arg&gt;
                      &lt;beans:bean class="org.springframework.security.saml.metadata.ExtendedMetadata"/&gt;
                  &lt;/beans:constructor-arg&gt;
              &lt;/beans:bean&gt;
  
              &lt;!-- Example of file system metadata without Extended Metadata --&gt;
              &lt;!-- &lt;bean class="org.opensaml.saml2.metadata.provider.FilesystemMetadataProvider"&gt; 
                  &lt;constructor-arg&gt; &lt;value type="java.io.File"&gt;/usr/local/metadata/idp.xml&lt;/value&gt; 
                  &lt;/constructor-arg&gt; &lt;property name="parserPool" ref="parserPool"/&gt; &lt;/bean&gt; --&gt;
          &lt;/beans:list&gt;
      &lt;/beans:constructor-arg&gt;
      &lt;!-- OPTIONAL used when one of the metadata files contains information 
          about this service provider --&gt;
      &lt;!-- &lt;property name="hostedSPName" value=""/&gt; --&gt;
      &lt;!-- OPTIONAL property: can tell the system which IDP should be used for 
          authenticating user by default. --&gt;
      &lt;!-- &lt;property name="defaultIDP" value="http://localhost:8080/opensso"/&gt; --&gt;
      &lt;beans:property name="defaultIDP" value="https://login.example.com/idp/shibboleth"/&gt;
  &lt;/beans:bean&gt;
  
  &lt;!-- SAML Authentication Provider responsible for validating of received 
      SAML messages --&gt;
  &lt;beans:bean id="samlAuthenticationProvider"
      class="org.springframework.security.saml.SAMLAuthenticationProvider"&gt;
      &lt;!-- OPTIONAL property: can be used to store/load user data after login --&gt;
      &lt;beans:property name="userDetails" ref="sAMLUserDetailsServiceImpl" /&gt;
      &lt;beans:property name="forcePrincipalAsString" value="false" /&gt;
  &lt;/beans:bean&gt;
  
  &lt;beans:bean id="sAMLUserDetailsServiceImpl"
      class="com.example.service.impl.SAMLUserDetailsServiceImpl"&gt;&lt;/beans:bean&gt;
  
  &lt;!-- Provider of default SAML Context --&gt;
  &lt;!-- &lt;beans:bean id="contextProvider"
      class="org.springframework.security.saml.context.SAMLContextProviderImpl"&gt; --&gt;
  &lt;beans:bean id="contextProvider"
      class="com.example.service.impl.CustomSAMLContextProviderImpl"&gt; 
      &lt;beans:property name="storageFactory"&gt;
          &lt;!-- &lt;beans:bean class="org.springframework.security.saml.storage.EmptyStorageFactory" /&gt; --&gt;
          &lt;beans:bean class="org.springframework.security.saml.storage.HttpSessionStorageFactory" /&gt;
      &lt;/beans:property&gt;
  &lt;/beans:bean&gt;
  
  &lt;!-- &lt;beans:bean id="contextProvider"
      class="org.springframework.security.saml.context.SAMLContextProviderLB"&gt;
      &lt;beans:property name="scheme" value="https" /&gt;
      &lt;beans:property name="serverName" value="https://sp1.example.com" /&gt;
      &lt;beans:property name="serverPort" value="443" /&gt;
      &lt;beans:property name="includeServerPortInRequestURL" value="false" /&gt;
  &lt;/beans:bean&gt;  --&gt;
  
  &lt;!-- Processing filter for WebSSO profile messages --&gt;
  &lt;beans:bean id="samlWebSSOProcessingFilter" class="org.springframework.security.saml.SAMLProcessingFilter"&gt;
      &lt;beans:property name="authenticationManager" ref="samlauthenticationManager" /&gt;
      &lt;beans:property name="authenticationSuccessHandler" ref="successRedirectHandler" /&gt;
      &lt;beans:property name="authenticationFailureHandler" ref="failureRedirectHandler" /&gt;
      &lt;beans:property name="sessionAuthenticationStrategy" ref="sas"/&gt;
  &lt;/beans:bean&gt;
  
  &lt;!-- Processing filter for WebSSO Holder-of-Key profile --&gt;
  &lt;beans:bean id="samlWebSSOHoKProcessingFilter"
      class="org.springframework.security.saml.SAMLWebSSOHoKProcessingFilter"&gt;
      &lt;beans:property name="authenticationManager" ref="samlauthenticationManager" /&gt;
      &lt;beans:property name="authenticationSuccessHandler" ref="successRedirectHandler" /&gt;
      &lt;beans:property name="authenticationFailureHandler" ref="failureRedirectHandler" /&gt;
  &lt;/beans:bean&gt;
  
  &lt;!-- Logout handler terminating local session --&gt;
  &lt;beans:bean id="logoutHandler"
      class="org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler"&gt;
      &lt;beans:property name="invalidateHttpSession" value="true" /&gt;
  &lt;/beans:bean&gt;
  
  &lt;!-- Override default logout processing filter with the one processing SAML 
      messages --&gt;
  &lt;beans:bean id="samlLogoutFilter" class="org.springframework.security.saml.SAMLLogoutFilter"&gt;
      &lt;beans:constructor-arg index="0" ref="successLogoutHandler" /&gt;
      &lt;beans:constructor-arg index="1" ref="logoutHandler" /&gt;
      &lt;beans:constructor-arg index="2" ref="logoutHandler" /&gt;
  &lt;/beans:bean&gt;
  
  &lt;!-- Filter processing incoming logout messages --&gt;
  &lt;!-- First argument determines URL user will be redirected to after successful 
      global logout --&gt;
  &lt;beans:bean id="samlLogoutProcessingFilter"
      class="org.springframework.security.saml.SAMLLogoutProcessingFilter"&gt;
      &lt;beans:constructor-arg index="0" ref="successLogoutHandler" /&gt;
      &lt;beans:constructor-arg index="1" ref="logoutHandler" /&gt;
  &lt;/beans:bean&gt;
  
  &lt;!-- Class loading incoming SAML messages from httpRequest stream --&gt;
  &lt;beans:bean id="processor"
      class="org.springframework.security.saml.processor.SAMLProcessorImpl"&gt;
      &lt;beans:constructor-arg&gt;
          &lt;beans:list&gt;
              &lt;beans:ref bean="postBinding" /&gt;
              &lt;beans:ref bean="redirectBinding" /&gt;
              &lt;beans:ref bean="artifactBinding" /&gt;
              &lt;beans:ref bean="soapBinding" /&gt;
              &lt;beans:ref bean="paosBinding" /&gt;
          &lt;/beans:list&gt;
      &lt;/beans:constructor-arg&gt;
  &lt;/beans:bean&gt;
  
  &lt;!-- SAML 2.0 WebSSO Assertion Consumer --&gt;
  &lt;beans:bean id="webSSOprofileConsumer"
      class="org.springframework.security.saml.websso.WebSSOProfileConsumerImpl" &gt;
      &lt;!-- maximum lifetime of assertion issued by Idp default 3000--&gt;
      &lt;!-- &lt;beans:property name="maxAssertionTime" value="300"&gt;&lt;/beans:property&gt;  --&gt;
      &lt;!-- maximum lifetime of authentication issued default 7200--&gt;
      &lt;!-- &lt;beans:property name="maxAssertionTime" value="300"&gt;&lt;/beans:property&gt;  --&gt;
  &lt;/beans:bean&gt;
  
  &lt;!-- SAML 2.0 Holder-of-Key WebSSO Assertion Consumer --&gt;
  &lt;beans:bean id="hokWebSSOprofileConsumer"
      class="org.springframework.security.saml.websso.WebSSOProfileConsumerHoKImpl" /&gt;
  
  &lt;!-- SAML 2.0 Web SSO profile --&gt;
  &lt;beans:bean id="webSSOprofile"
      class="org.springframework.security.saml.websso.WebSSOProfileImpl" /&gt;
  
  &lt;!-- SAML 2.0 Holder-of-Key Web SSO profile --&gt;
  &lt;beans:bean id="hokWebSSOProfile"
      class="org.springframework.security.saml.websso.WebSSOProfileConsumerHoKImpl" /&gt;
  
  &lt;!-- SAML 2.0 ECP profile --&gt;
  &lt;beans:bean id="ecpprofile"
      class="org.springframework.security.saml.websso.WebSSOProfileECPImpl" /&gt;
  
  &lt;!-- SAML 2.0 Logout Profile --&gt;
  &lt;beans:bean id="logoutprofile"
      class="org.springframework.security.saml.websso.SingleLogoutProfileImpl" /&gt;
  
  &lt;!-- Bindings, encoders and decoders used for creating and parsing messages --&gt;
  &lt;beans:bean id="postBinding"
      class="org.springframework.security.saml.processor.HTTPPostBinding"&gt;
      &lt;beans:constructor-arg ref="parserPool" /&gt;
      &lt;beans:constructor-arg ref="velocityEngine" /&gt;
  &lt;/beans:bean&gt;
  
  &lt;beans:bean id="redirectBinding"
      class="org.springframework.security.saml.processor.HTTPRedirectDeflateBinding"&gt;
      &lt;beans:constructor-arg ref="parserPool" /&gt;
  &lt;/beans:bean&gt;
  
  &lt;beans:bean id="artifactBinding"
      class="org.springframework.security.saml.processor.HTTPArtifactBinding"&gt;
      &lt;beans:constructor-arg ref="parserPool" /&gt;
      &lt;beans:constructor-arg ref="velocityEngine" /&gt;
      &lt;beans:constructor-arg&gt;
          &lt;beans:bean
              class="org.springframework.security.saml.websso.ArtifactResolutionProfileImpl"&gt;
              &lt;beans:constructor-arg&gt;
                  &lt;beans:bean class="org.apache.commons.httpclient.HttpClient"&gt;
                      &lt;beans:constructor-arg&gt;
                          &lt;beans:bean
                              class="org.apache.commons.httpclient.MultiThreadedHttpConnectionManager" /&gt;
                      &lt;/beans:constructor-arg&gt;
                  &lt;/beans:bean&gt;
              &lt;/beans:constructor-arg&gt;
              &lt;beans:property name="processor"&gt;
                  &lt;beans:bean
                      class="org.springframework.security.saml.processor.SAMLProcessorImpl"&gt;
                      &lt;beans:constructor-arg ref="soapBinding" /&gt;
                  &lt;/beans:bean&gt;
              &lt;/beans:property&gt;
          &lt;/beans:bean&gt;
      &lt;/beans:constructor-arg&gt;
  &lt;/beans:bean&gt;
  
  &lt;beans:bean id="soapBinding"
      class="org.springframework.security.saml.processor.HTTPSOAP11Binding"&gt;
      &lt;beans:constructor-arg ref="parserPool" /&gt;
  &lt;/beans:bean&gt;
  
  &lt;beans:bean id="paosBinding"
      class="org.springframework.security.saml.processor.HTTPPAOS11Binding"&gt;
      &lt;beans:constructor-arg ref="parserPool" /&gt;
  &lt;/beans:bean&gt;
  
  &lt;!-- Initialization of OpenSAML library --&gt;
  &lt;beans:bean class="org.springframework.security.saml.SAMLBootstrap" /&gt;
  
  &lt;!-- Initialization of the velocity engine --&gt;
  &lt;beans:bean id="velocityEngine" class="org.springframework.security.saml.util.VelocityFactory"
      factory-method="getEngine" /&gt;
  
  &lt;!-- XML parser pool needed for OpenSAML parsing --&gt;
  &lt;beans:bean id="parserPool" class="org.opensaml.xml.parse.StaticBasicParserPool"
      init-method="initialize"&gt;
      &lt;beans:property name="builderFeatures"&gt;
          &lt;beans:map&gt;
              &lt;beans:entry key="http://apache.org/xml/features/dom/defer-node-expansion"
                  value="false" /&gt;
          &lt;/beans:map&gt;
      &lt;/beans:property&gt;
  &lt;/beans:bean&gt;
  
  &lt;beans:bean id="parserPoolHolder"
      class="org.springframework.security.saml.parser.ParserPoolHolder" &gt;&lt;/beans:bean&gt;
  </code></pre>