You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by co...@apache.org on 2017/03/15 09:49:37 UTC

svn commit: r1787008 - /webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/OpenSAMLUtil.java

Author: coheigea
Date: Wed Mar 15 09:49:37 2017
New Revision: 1787008

URL: http://svn.apache.org/viewvc?rev=1787008&view=rev
Log:
WSS-600 - Get the configured ParserPool via OpenSAMLUtil
 - Thanks to Francesco for the patch.

Modified:
    webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/OpenSAMLUtil.java

Modified: webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/OpenSAMLUtil.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/OpenSAMLUtil.java?rev=1787008&r1=1787007&r2=1787008&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/OpenSAMLUtil.java (original)
+++ webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/OpenSAMLUtil.java Wed Mar 15 09:49:37 2017
@@ -22,6 +22,7 @@ package org.apache.wss4j.common.saml;
 import javax.xml.namespace.QName;
 
 import net.shibboleth.utilities.java.support.xml.BasicParserPool;
+import net.shibboleth.utilities.java.support.xml.ParserPool;
 
 import org.apache.wss4j.common.crypto.WSProviderConfig;
 import org.apache.wss4j.common.ext.WSSecurityException;
@@ -56,6 +57,7 @@ public final class OpenSAMLUtil {
     private static final org.slf4j.Logger LOG =
         org.slf4j.LoggerFactory.getLogger(OpenSAMLUtil.class);
 
+    private static XMLObjectProviderRegistry providerRegistry;
     private static XMLObjectBuilderFactory builderFactory;
     private static MarshallerFactory marshallerFactory;
     private static UnmarshallerFactory unmarshallerFactory;
@@ -76,7 +78,7 @@ public final class OpenSAMLUtil {
             Configuration configuration = new MapBasedConfiguration();
             ConfigurationService.setConfiguration(configuration);
 
-            XMLObjectProviderRegistry providerRegistry = new XMLObjectProviderRegistry();
+            providerRegistry = new XMLObjectProviderRegistry();
             configuration.register(XMLObjectProviderRegistry.class, providerRegistry,
                                    ConfigurationService.DEFAULT_PARTITION_NAME);
 
@@ -93,7 +95,7 @@ public final class OpenSAMLUtil {
                 unmarshallerFactory = XMLObjectProviderRegistrySupport.getUnmarshallerFactory();
 
                 try {
-                    configureParserPool(providerRegistry);
+                    configureParserPool();
                 } catch (Throwable t) {
                     LOG.warn("Unable to bootstrap the parser pool part of the opensaml library "
                              + "- some SAML operations may fail", t);
@@ -107,19 +109,28 @@ public final class OpenSAMLUtil {
         }
     }
 
-    private static void configureParserPool(XMLObjectProviderRegistry reg) throws Throwable {
+    private static void configureParserPool() throws Throwable {
         BasicParserPool pp = new BasicParserPool();
         pp.setMaxPoolSize(50);
         pp.initialize();
-        reg.setParserPool(pp);
+        providerRegistry.setParserPool(pp);
     }
 
     /**
+     * Get the configured ParserPool.
+     * 
+     * @return the configured ParserPool
+     */
+    public static ParserPool getParserPool() {
+        return providerRegistry.getParserPool();
+    }    
+    
+    /**
      * Convert a SAML Assertion from a DOM Element to an XMLObject
      *
      * @param root of type Element
      * @return XMLObject
-     * @throws UnmarshallingException
+     * @throws WSSecurityException
      */
     public static XMLObject fromDom(Element root) throws WSSecurityException {
         if (root == null) {
@@ -147,7 +158,7 @@ public final class OpenSAMLUtil {
      * @param xmlObject of type XMLObject
      * @param doc  of type Document
      * @return Element
-     * @throws MarshallingException
+     * @throws WSSecurityException
      */
     public static Element toDom(
         XMLObject xmlObject,
@@ -163,7 +174,7 @@ public final class OpenSAMLUtil {
      * @param doc  of type Document
      * @param signObject whether to sign the XMLObject during marshalling
      * @return Element
-     * @throws MarshallingException
+     * @throws WSSecurityException
      */
     public static Element toDom(
         XMLObject xmlObject,