[java-identity-provider] 06/06: IDP-1423 Remove deprecated attributes around HTTP caching

Rod Widdowson rdw at steadingsoftware.com
Sun Mar 3 09:59:39 EST 2019


This is an automated email from the git hooks/post-receive script.

rdw pushed a commit to branch master
in repository java-identity-provider.

View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=9fb493526b70d9ac0b03a9c368077ab9df2c5e3d

commit 9fb493526b70d9ac0b03a9c368077ab9df2c5e3d
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Sun Mar 3 14:45:48 2019 +0000

    IDP-1423 Remove deprecated attributes around HTTP caching
    
    https://issues.shibboleth.net/jira/browse/IDP-1423
    
    httpCaching, httpCacheDirectory, httpMaxCacheEntries, httpMaxCacheEntrySize
---
 .../AbstractDynamicHTTPMetadataProviderParser.java | 18 +++---
 .../metadata/impl/HTTPMetadataProviderParser.java  |  6 +-
 .../impl/HTTPMetadataProvidersParserSupport.java   | 65 +-------------------
 .../metadata/dynamic-httpCaching-memory.xml        |  3 +-
 .../metadata/http-entity-httpCaching-none.xml      |  1 -
 .../main/resources/schema/shibboleth-metadata.xsd  | 71 ++--------------------
 6 files changed, 22 insertions(+), 142 deletions(-)

diff --git a/idp-profile-spring/src/main/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/impl/AbstractDynamicHTTPMetadataProviderParser.java b/idp-profile-spring/src/main/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/impl/AbstractDynamicHTTPMetadataProviderParser.java
index 4bb507e..bf3afcd 100644
--- a/idp-profile-spring/src/main/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/impl/AbstractDynamicHTTPMetadataProviderParser.java
+++ b/idp-profile-spring/src/main/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/impl/AbstractDynamicHTTPMetadataProviderParser.java
@@ -21,10 +21,6 @@ import java.util.List;
 
 import javax.annotation.Nullable;
 
-import net.shibboleth.utilities.java.support.primitive.StringSupport;
-import net.shibboleth.utilities.java.support.xml.ElementSupport;
-import net.shibboleth.utilities.java.support.xml.XMLConstants;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.config.BeanDefinition;
@@ -32,13 +28,18 @@ import org.springframework.beans.factory.support.BeanDefinitionBuilder;
 import org.springframework.beans.factory.xml.ParserContext;
 import org.w3c.dom.Element;
 
+import net.shibboleth.idp.profile.spring.relyingparty.metadata.InMemoryCachingHttpClientFactoryBean;
+import net.shibboleth.utilities.java.support.primitive.StringSupport;
+import net.shibboleth.utilities.java.support.xml.ElementSupport;
+import net.shibboleth.utilities.java.support.xml.XMLConstants;
+
 /**
  * Parser for abstract dynamic HTTP metadata resolvers.
  */
 public abstract class AbstractDynamicHTTPMetadataProviderParser extends AbstractDynamicMetadataProviderParser {
 
     /** Default caching type . */
-    private static final String DEFAULT_CACHING = "memory";
+    private static final Class DEFAULT_CACHING_CLASS = InMemoryCachingHttpClientFactoryBean.class;
 
     /** Default max total connections. */
     private static final Integer DEFAULT_MAX_CONNECTIONS_TOTAL = 100;
@@ -135,8 +136,11 @@ public abstract class AbstractDynamicHTTPMetadataProviderParser extends Abstract
             @Nullable final BeanDefinition httpClientSecurityParameters) {
 
         final BeanDefinitionBuilder clientBuilder = 
-                HTTPMetadataProvidersParserSupport.buildCommonClientBuilder(element, parserContext, DEFAULT_CACHING,
-                        httpClientSecurityParametersRef, httpClientSecurityParameters);
+                HTTPMetadataProvidersParserSupport.buildCommonClientBuilder(element,
+                        parserContext,
+                        DEFAULT_CACHING_CLASS ,
+                        httpClientSecurityParametersRef,
+                        httpClientSecurityParameters);
 
         // Set up non standard defaults
         if (!element.hasAttributeNS(null, "connectionTimeout")) {
diff --git a/idp-profile-spring/src/main/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/impl/HTTPMetadataProviderParser.java b/idp-profile-spring/src/main/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/impl/HTTPMetadataProviderParser.java
index cf7d597..05f330f 100644
--- a/idp-profile-spring/src/main/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/impl/HTTPMetadataProviderParser.java
+++ b/idp-profile-spring/src/main/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/impl/HTTPMetadataProviderParser.java
@@ -27,7 +27,7 @@ import org.springframework.beans.factory.support.BeanDefinitionBuilder;
 import org.springframework.beans.factory.xml.ParserContext;
 import org.w3c.dom.Element;
 
-import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
+import net.shibboleth.idp.profile.spring.relyingparty.metadata.HttpClientFactoryBean;
 import net.shibboleth.utilities.java.support.primitive.StringSupport;
 import net.shibboleth.utilities.java.support.xml.ElementSupport;
 
@@ -37,7 +37,7 @@ import net.shibboleth.utilities.java.support.xml.ElementSupport;
 public abstract class HTTPMetadataProviderParser extends AbstractReloadingMetadataProviderParser {
 
     /** Default caching type. */
-    @Nonnull @NotEmpty private static final String DEFAULT_CACHING = "none";
+    private static final Class DEFAULT_CACHING_CLASS = HttpClientFactoryBean.class;
 
     /** Logger. */
     @Nonnull private final Logger log = LoggerFactory.getLogger(HTTPMetadataProviderParser.class);
@@ -111,7 +111,7 @@ public abstract class HTTPMetadataProviderParser extends AbstractReloadingMetada
             @Nullable final BeanDefinition httpClientSecurityParameters) {
 
         return HTTPMetadataProvidersParserSupport.buildCommonClientBuilder(element, parserContext,
-                HTTPMetadataProviderParser.DEFAULT_CACHING, httpClientSecurityParametersRef,
+                HTTPMetadataProviderParser.DEFAULT_CACHING_CLASS, httpClientSecurityParametersRef,
                 httpClientSecurityParameters).getBeanDefinition();
     }
     
diff --git a/idp-profile-spring/src/main/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/impl/HTTPMetadataProvidersParserSupport.java b/idp-profile-spring/src/main/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/impl/HTTPMetadataProvidersParserSupport.java
index 87f91cb..68acfca 100644
--- a/idp-profile-spring/src/main/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/impl/HTTPMetadataProvidersParserSupport.java
+++ b/idp-profile-spring/src/main/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/impl/HTTPMetadataProvidersParserSupport.java
@@ -188,77 +188,18 @@ public final class HTTPMetadataProvidersParserSupport {
      * 
      * @param element the configuration
      * @param parserContext context
-     * @param defaultCaching what to use if caching not supplied.
+     * @param clientBuildClass the type of builder to create.
      * @param httpClientSecurityParametersRef the client security parameters ref to be used
      * @param httpClientSecurityParameters the client security parameters to be used
      * 
      * @return an appropriate builder
      */
     @Nonnull protected static BeanDefinitionBuilder buildCommonClientBuilder(@Nonnull final Element element,
-            @Nonnull final ParserContext parserContext, @Nonnull final String defaultCaching,
+            @Nonnull final ParserContext parserContext, @Nonnull final Class<?> clientBuildClass,
             @Nullable final String httpClientSecurityParametersRef,
             @Nullable final BeanDefinition httpClientSecurityParameters) {
-        final String caching;
-        if (element.hasAttributeNS(null, "httpCaching")) {
-            DeprecationSupport.warnOnce(ObjectType.ATTRIBUTE, "httpCaching", 
-                    parserContext.getReaderContext().getResource().getDescription(), 
-                    "HttpClient bean via httpClientRef");
-            caching = StringSupport.trimOrNull(element.getAttributeNS(null, "httpCaching"));
-        } else {
-            caching = defaultCaching;
-        }
-        
-        final BeanDefinitionBuilder clientBuilder;
-        switch (caching) {
-            case "none":
-                clientBuilder = BeanDefinitionBuilder.genericBeanDefinition(HttpClientFactoryBean.class);
-                break;
-            case "file":
-                clientBuilder = BeanDefinitionBuilder.genericBeanDefinition(FileCachingHttpClientFactoryBean.class);
-                if (element.hasAttributeNS(null, "httpCacheDirectory")) {
-                    DeprecationSupport.warnOnce(ObjectType.ATTRIBUTE, "httpCacheDirectory", 
-                            parserContext.getReaderContext().getResource().getDescription(), 
-                            "HttpClient bean via httpClientRef");
-                    clientBuilder.addPropertyValue("cacheDirectory",
-                            StringSupport.trimOrNull(element.getAttributeNS(null, "httpCacheDirectory")));
-                }
-                if (element.hasAttributeNS(null, "httpMaxCacheEntries")) {
-                    DeprecationSupport.warnOnce(ObjectType.ATTRIBUTE, "httpMaxCacheEntries", 
-                            parserContext.getReaderContext().getResource().getDescription(), 
-                            "HttpClient bean via httpClientRef");
-                    clientBuilder.addPropertyValue("maxCacheEntries",
-                            StringSupport.trimOrNull(element.getAttributeNS(null, "httpMaxCacheEntries")));
-                }
-                if (element.hasAttributeNS(null, "httpMaxCacheEntrySize")) {
-                    DeprecationSupport.warnOnce(ObjectType.ATTRIBUTE, "httpMaxCacheEntrySize", 
-                            parserContext.getReaderContext().getResource().getDescription(), 
-                            "HttpClient bean via httpClientRef");
-                    clientBuilder.addPropertyValue("maxCacheEntrySize",
-                            StringSupport.trimOrNull(element.getAttributeNS(null, "httpMaxCacheEntrySize")));
-                }
-                break;
-            case "memory":
-                clientBuilder = BeanDefinitionBuilder.genericBeanDefinition(InMemoryCachingHttpClientFactoryBean.class);
-                if (element.hasAttributeNS(null, "httpMaxCacheEntries")) {
-                    DeprecationSupport.warnOnce(ObjectType.ATTRIBUTE, "httpMaxCacheEntries", 
-                            parserContext.getReaderContext().getResource().getDescription(), 
-                            "HttpClient bean via httpClientRef");
-                    clientBuilder.addPropertyValue("maxCacheEntries",
-                            StringSupport.trimOrNull(element.getAttributeNS(null, "httpMaxCacheEntries")));
-                }
-                if (element.hasAttributeNS(null, "httpMaxCacheEntrySize")) {
-                    DeprecationSupport.warnOnce(ObjectType.ATTRIBUTE, "httpMaxCacheEntrySize", 
-                            parserContext.getReaderContext().getResource().getDescription(), 
-                            "HttpClient bean via httpClientRef");
-                    clientBuilder.addPropertyValue("maxCacheEntrySize",
-                            StringSupport.trimOrNull(element.getAttributeNS(null, "httpMaxCacheEntrySize")));
-                }
-                break;
-            default:
-                throw new BeanDefinitionParsingException(new Problem(String.format("Caching value '%s' is unsupported",
-                        caching), new Location(parserContext.getReaderContext().getResource())));
-        }
 
+        final BeanDefinitionBuilder clientBuilder = BeanDefinitionBuilder.genericBeanDefinition(clientBuildClass);
         clientBuilder.setLazyInit(true);
 
         if (element.hasAttributeNS(null, "connectionTimeout")) {
diff --git a/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/relyingparty/metadata/dynamic-httpCaching-memory.xml b/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/relyingparty/metadata/dynamic-httpCaching-memory.xml
index 1f5b03e..486dde7 100644
--- a/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/relyingparty/metadata/dynamic-httpCaching-memory.xml
+++ b/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/relyingparty/metadata/dynamic-httpCaching-memory.xml
@@ -4,8 +4,7 @@
 	xsi:schemaLocation="urn:mace:shibboleth:2.0:metadata http://shibboleth.net/schema/idp/shibboleth-metadata.xsd
                        urn:oasis:names:tc:SAML:2.0:metadata http://docs.oasis-open.org/security/saml/v2.0/saml-schema-metadata-2.0.xsd"
 
-	id="dynamicHttpCachingMemory" 
-    httpClientRef="memClient"
+	id="dynamicHttpCachingMemory"
     xsi:type="metadata:DynamicHTTPMetadataProvider" >
     
     <!-- Note: use of the transformRef here is mostly just to facilitate testing. -->
diff --git a/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/relyingparty/metadata/http-entity-httpCaching-none.xml b/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/relyingparty/metadata/http-entity-httpCaching-none.xml
index b1e5051..e21b001 100644
--- a/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/relyingparty/metadata/http-entity-httpCaching-none.xml
+++ b/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/relyingparty/metadata/http-entity-httpCaching-none.xml
@@ -7,7 +7,6 @@
 	id="HTTPEntity" 
     xsi:type="metadata:FileBackedHTTPMetadataProvider"
     backingFile="%{DIR}/spoolhttpentitycaching none.xml"
-    httpClientRef="noneClient"
     metadataURL="%{metadataURL}"> 
 
 </metadata:MetadataProvider>
diff --git a/idp-schema/src/main/resources/schema/shibboleth-metadata.xsd b/idp-schema/src/main/resources/schema/shibboleth-metadata.xsd
index b33eece..aa1ea90 100644
--- a/idp-schema/src/main/resources/schema/shibboleth-metadata.xsd
+++ b/idp-schema/src/main/resources/schema/shibboleth-metadata.xsd
@@ -1,7 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:mace:shibboleth:2.0:metadata" xmlns:shibmd="urn:mace:shibboleth:2.0:metadata"
-    xmlns:security="urn:mace:shibboleth:2.0:security" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"
-    xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata" elementFormDefault="qualified">
+<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:mace:shibboleth:2.0:metadata"
+    xmlns:shibmd="urn:mace:shibboleth:2.0:metadata" xmlns:security="urn:mace:shibboleth:2.0:security"
+    xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata"
+    elementFormDefault="qualified">
 
     <annotation>
         <documentation>Schema describing metadata providers and filters.</documentation>
@@ -234,38 +235,6 @@
                         </documentation>
                     </annotation>
                 </attribute>
-                <attribute name="httpCaching" type="shibmd:HttpClientCachingType">
-                    <annotation>
-                        <documentation>
-                            The type of HttpClient caching to perform. Defaults to 'none'.
-                            Deprecated in favor of httpClientRef.
-                        </documentation>
-                    </annotation>
-                </attribute>
-                <attribute name="httpCacheDirectory" type="string">
-                    <annotation>
-                        <documentation>
-                            The path to the HttpClient cache directory. Only used if caching type is 'file'.
-                            Deprecated in favor of httpClientRef.
-                        </documentation>
-                    </annotation>
-                </attribute>
-                <attribute name="httpMaxCacheEntries" type="string">
-                    <annotation>
-                        <documentation>
-                            The maximum number of responses to cache.
-                            Deprecated in favor of httpClientRef.
-                        </documentation>
-                    </annotation>
-                </attribute>
-                <attribute name="httpMaxCacheEntrySize" type="string">
-                    <annotation>
-                        <documentation>
-                            The maximum response body size which may be cached, in bytes. 
-                            Deprecated in favor of httpClientRef.
-                        </documentation>
-                    </annotation>
-                </attribute>
                 <attribute name="tlsTrustEngineRef" type="string">
                     <annotation>
                         <documentation>
@@ -570,38 +539,6 @@
                         </documentation>
                     </annotation>
                 </attribute>
-                <attribute name="httpCaching" type="shibmd:HttpClientCachingType">
-                    <annotation>
-                        <documentation>
-                            The type of HttpClient caching to perform. Defaults to 'memory'.
-                            Deprecated in favor of httpClientRef.
-                        </documentation>
-                    </annotation>
-                </attribute>
-                <attribute name="httpCacheDirectory" type="string">
-                    <annotation>
-                        <documentation>
-                            The path to the HttpClient cache directory. Only used if caching type is 'file'.
-                            Deprecated in favor of httpClientRef.
-                        </documentation>
-                    </annotation>
-                </attribute>
-                <attribute name="httpMaxCacheEntries" type="string">
-                    <annotation>
-                        <documentation>
-                            The maximum number of responses to cache.
-                            Deprecated in favor of httpClientRef.
-                        </documentation>
-                    </annotation>
-                </attribute>
-                <attribute name="httpMaxCacheEntrySize" type="string">
-                    <annotation>
-                        <documentation>
-                            The maximum response body size which may be cached, in bytes.
-                            Deprecated in favor of httpClientRef.
-                        </documentation>
-                    </annotation>
-                </attribute>
                 <attribute name="tlsTrustEngineRef" type="string">
                     <annotation>
                         <documentation>

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list