Skip to content

Commit ab842b7

Browse files
committed
Use OpenSAML ParserPool Defaults
Originally, Spring Security turned off various features XML parsing feature for the underlying DocumentBuilderFactory that OpenSAML uses. Both OpenSAML 4 and 5 set these values by default, so we can safely accept the defaults at this point. Issue gh-11658
1 parent bc8ba7f commit ab842b7

File tree

1 file changed

+0
-27
lines changed

1 file changed

+0
-27
lines changed

saml2/saml2-service-provider/src/main/java/org/springframework/security/saml2/core/OpenSamlInitializationService.java

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,14 @@
1616

1717
package org.springframework.security.saml2.core;
1818

19-
import java.util.HashMap;
20-
import java.util.Map;
2119
import java.util.concurrent.atomic.AtomicBoolean;
2220
import java.util.function.Consumer;
2321

24-
import javax.xml.XMLConstants;
25-
26-
import net.shibboleth.utilities.java.support.xml.BasicParserPool;
2722
import org.apache.commons.logging.Log;
2823
import org.apache.commons.logging.LogFactory;
2924
import org.opensaml.core.config.ConfigurationService;
3025
import org.opensaml.core.config.InitializationService;
3126
import org.opensaml.core.xml.config.XMLObjectProviderRegistry;
32-
import org.opensaml.core.xml.config.XMLObjectProviderRegistrySupport;
3327

3428
import org.springframework.security.saml2.Saml2Exception;
3529

@@ -124,16 +118,6 @@ private static boolean initialize(Consumer<XMLObjectProviderRegistry> registryCo
124118
catch (Exception ex) {
125119
throw new Saml2Exception(ex);
126120
}
127-
BasicParserPool parserPool = new BasicParserPool();
128-
parserPool.setMaxPoolSize(50);
129-
parserPool.setBuilderFeatures(getParserBuilderFeatures());
130-
try {
131-
parserPool.initialize();
132-
}
133-
catch (Exception ex) {
134-
throw new Saml2Exception(ex);
135-
}
136-
XMLObjectProviderRegistrySupport.setParserPool(parserPool);
137121
registryConsumer.accept(ConfigurationService.get(XMLObjectProviderRegistry.class));
138122
log.debug("Initialized OpenSAML");
139123
return true;
@@ -142,15 +126,4 @@ private static boolean initialize(Consumer<XMLObjectProviderRegistry> registryCo
142126
return false;
143127
}
144128

145-
private static Map<String, Boolean> getParserBuilderFeatures() {
146-
Map<String, Boolean> parserBuilderFeatures = new HashMap<>();
147-
parserBuilderFeatures.put("http://apache.org/xml/features/disallow-doctype-decl", Boolean.TRUE);
148-
parserBuilderFeatures.put(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE);
149-
parserBuilderFeatures.put("http://xml.org/sax/features/external-general-entities", Boolean.FALSE);
150-
parserBuilderFeatures.put("http://apache.org/xml/features/validation/schema/normalized-value", Boolean.FALSE);
151-
parserBuilderFeatures.put("http://xml.org/sax/features/external-parameter-entities", Boolean.FALSE);
152-
parserBuilderFeatures.put("http://apache.org/xml/features/dom/defer-node-expansion", Boolean.FALSE);
153-
return parserBuilderFeatures;
154-
}
155-
156129
}

0 commit comments

Comments
 (0)