ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject svn commit: r1686176 - in /webservices/wss4j/trunk: ws-security-common/src/main/java/org/apache/wss4j/common/saml/ ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/
Date Thu, 18 Jun 2015 10:41:35 GMT
Author: coheigea
Date: Thu Jun 18 10:41:35 2015
New Revision: 1686176

URL: http://svn.apache.org/r1686176
Log:
Configure BasicParserPool to avoid a NPE

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

Modified: webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/OpenSAMLBootstrap.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/OpenSAMLBootstrap.java?rev=1686176&r1=1686175&r2=1686176&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/OpenSAMLBootstrap.java
(original)
+++ webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/OpenSAMLBootstrap.java
Thu Jun 18 10:41:35 2015
@@ -95,24 +95,4 @@ public class OpenSAMLBootstrap {
         }
     }
     
-    
-    /*
-    protected static void initializeParserPool() throws ConfigurationException {
-        StaticBasicParserPool pp = new StaticBasicParserPool();
-        pp.setMaxPoolSize(50);
-        
-        Map<String, Boolean> features = new HashMap<String, Boolean>();
-        features.put(XMLConstants.FEATURE_SECURE_PROCESSING, true);
-        features.put("http://apache.org/xml/features/disallow-doctype-decl", true);
-        pp.setBuilderFeatures(features);
-        pp.setExpandEntityReferences(false);
-        
-        try {
-            pp.initialize();
-        } catch (XMLParserException e) {
-            throw new ConfigurationException("Error initializing parser pool", e);
-        }
-        Configuration.setParserPool(pp);
-    }
-    */
 }
\ No newline at end of file

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=1686176&r1=1686175&r2=1686176&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
Thu Jun 18 10:41:35 2015
@@ -21,6 +21,9 @@ package org.apache.wss4j.common.saml;
 
 import javax.xml.namespace.QName;
 
+import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
+import net.shibboleth.utilities.java.support.xml.BasicParserPool;
+
 import org.apache.wss4j.common.crypto.WSProviderConfig;
 import org.apache.wss4j.common.ext.WSSecurityException;
 import org.opensaml.core.config.Configuration;
@@ -90,11 +93,16 @@ public final class OpenSAMLUtil {
                 marshallerFactory = XMLObjectProviderRegistrySupport.getMarshallerFactory();
                 unmarshallerFactory = XMLObjectProviderRegistrySupport.getUnmarshallerFactory();
                 
+                BasicParserPool pp = new BasicParserPool();
+                pp.setMaxPoolSize(50);
+                pp.initialize();
+                providerRegistry.setParserPool(pp);
+                
                 samlEngineInitialized = true;
                 if (LOG.isDebugEnabled()) {
                     LOG.debug("opensaml3 library bootstrap complete");
                 }
-            } catch (XMLConfigurationException ex) {
+            } catch (XMLConfigurationException | ComponentInitializationException ex) {
                 LOG.error("Unable to bootstrap the opensaml3 library - all SAML operations
will fail", ex);
             }
         }

Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlTokenTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlTokenTest.java?rev=1686176&r1=1686175&r2=1686176&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlTokenTest.java
(original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlTokenTest.java
Thu Jun 18 10:41:35 2015
@@ -872,6 +872,31 @@ public class SamlTokenTest extends org.j
     }
     
     @org.junit.Test
+    public void testAssertionWrapperNoDocument() throws Exception {
+        SAML1CallbackHandler callbackHandler = new SAML1CallbackHandler();
+        callbackHandler.setStatement(SAML1CallbackHandler.Statement.AUTHN);
+        callbackHandler.setIssuer("www.example.com");
+        
+        SAMLCallback samlCallback = new SAMLCallback();
+        SAMLUtil.doSAMLCallback(callbackHandler, samlCallback);
+        SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
+        
+        String assertionString = DOM2Writer.nodeToString(samlAssertion.toDOM(null));
+        
+        // Convert String to DOM + into an assertionWrapper
+        InputStream in = new ByteArrayInputStream(assertionString.getBytes());
+        
+        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+        dbf.setNamespaceAware(true);
+        Document newDoc = dbf.newDocumentBuilder().parse(in);
+        
+        SamlAssertionWrapper newAssertion = 
+            new SamlAssertionWrapper(newDoc.getDocumentElement());
+        String secondAssertionString = newAssertion.assertionToString();
+        assertEquals(assertionString, secondAssertionString);
+    }
+    
+    @org.junit.Test
     public void testRequiredSubjectConfirmationMethod() throws Exception {
         SAML2CallbackHandler callbackHandler = new SAML2CallbackHandler();
         callbackHandler.setStatement(SAML2CallbackHandler.Statement.AUTHN);



Mime
View raw message