ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject svn commit: r1045235 - in /webservices/wss4j/trunk/src/main/java/org/apache/ws/security: ./ message/ processor/ saml/ transform/
Date Mon, 13 Dec 2010 17:04:12 GMT
Author: coheigea
Date: Mon Dec 13 17:04:12 2010
New Revision: 1045235

URL: http://svn.apache.org/viewvc?rev=1045235&view=rev
Log:
[WSS-259] - Remove static WSDocInfoStore
 - This is unnecesary with the new STRTransform implementation, as we can just pass through
the WSDocInfo structure to the transform instead as a property.
 - This avoids insertion and deletion into a ConcurrentHashMap with each sign/verify, and
so it should speed things up a bit.

Removed:
    webservices/wss4j/trunk/src/main/java/org/apache/ws/security/WSDocInfoStore.java
Modified:
    webservices/wss4j/trunk/src/main/java/org/apache/ws/security/WSDocInfo.java
    webservices/wss4j/trunk/src/main/java/org/apache/ws/security/message/WSSecDKSign.java
    webservices/wss4j/trunk/src/main/java/org/apache/ws/security/message/WSSecSignature.java
    webservices/wss4j/trunk/src/main/java/org/apache/ws/security/processor/SignatureProcessor.java
    webservices/wss4j/trunk/src/main/java/org/apache/ws/security/saml/WSSecSignatureSAML.java
    webservices/wss4j/trunk/src/main/java/org/apache/ws/security/transform/STRTransform.java

Modified: webservices/wss4j/trunk/src/main/java/org/apache/ws/security/WSDocInfo.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/WSDocInfo.java?rev=1045235&r1=1045234&r2=1045235&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/main/java/org/apache/ws/security/WSDocInfo.java (original)
+++ webservices/wss4j/trunk/src/main/java/org/apache/ws/security/WSDocInfo.java Mon Dec 13
17:04:12 2010
@@ -20,17 +20,16 @@
 package org.apache.ws.security;
 
 /**
- * WSDocInfo holds information about the document to process. Together
- * with the WSDocInfoStore it provides a method to store and access document
- * information about BinarySecurityToken, used Crypto, and others.
- * </p>
+ * WSDocInfo holds information about the document to process. It provides a 
+ * method to store and access document information about BinarySecurityToken, 
+ * used Crypto, and others.
+ * 
  * Using the Document's hash a caller can identify a document and get
  * the stored information that me be necessary to process the document.
  * The main usage for this is (are) the transformation functions that
  * are called during Signature/Verification process. 
  * 
  * @author Werner Dittmann (Werner.Dittmann@siemens.com)
- *
  */
 
 import org.apache.ws.security.components.crypto.Crypto;
@@ -53,9 +52,6 @@ public class WSDocInfo {
         // This is a bit of a hack. When the Document is a SAAJ SOAPPart instance, it may
         // be that the "owner" document of any child elements is an internal Document, rather
         // than the SOAPPart. This is the case for the SUN SAAJ implementation.
-        // This causes problems with STRTransform, as:
-        // WSDocInfoStore.lookup(transformObject.getDocument())
-        // will not work. 
         //
         this.doc = doc.getDocumentElement().getOwnerDocument();
     }

Modified: webservices/wss4j/trunk/src/main/java/org/apache/ws/security/message/WSSecDKSign.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/message/WSSecDKSign.java?rev=1045235&r1=1045234&r2=1045235&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/main/java/org/apache/ws/security/message/WSSecDKSign.java
(original)
+++ webservices/wss4j/trunk/src/main/java/org/apache/ws/security/message/WSSecDKSign.java
Mon Dec 13 17:04:12 2010
@@ -23,7 +23,6 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.ws.security.WSConstants;
 import org.apache.ws.security.WSDocInfo;
-import org.apache.ws.security.WSDocInfoStore;
 import org.apache.ws.security.WSEncryptionPart;
 import org.apache.ws.security.WSSecurityException;
 import org.apache.ws.security.conversation.ConversationException;
@@ -221,7 +220,6 @@ public class WSSecDKSign extends WSSecDe
         boolean prepend,
         Element siblingElement
     ) throws WSSecurityException {
-        boolean remove = WSDocInfoStore.store(wsDocInfo);
         try {
             java.security.Key key = 
                 WSSecurityUtil.prepareSecretKey(sigAlgo, derivedKeyBytes);
@@ -272,10 +270,6 @@ public class WSSecDKSign extends WSSecDe
             throw new WSSecurityException(
                 WSSecurityException.FAILED_SIGNATURE, null, null, ex
             );
-        } finally {
-            if (remove) {
-                WSDocInfoStore.delete(wsDocInfo);
-            }
         }
     }
     

Modified: webservices/wss4j/trunk/src/main/java/org/apache/ws/security/message/WSSecSignature.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/message/WSSecSignature.java?rev=1045235&r1=1045234&r2=1045235&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/main/java/org/apache/ws/security/message/WSSecSignature.java
(original)
+++ webservices/wss4j/trunk/src/main/java/org/apache/ws/security/message/WSSecSignature.java
Mon Dec 13 17:04:12 2010
@@ -23,7 +23,6 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.ws.security.WSConstants;
 import org.apache.ws.security.WSDocInfo;
-import org.apache.ws.security.WSDocInfoStore;
 import org.apache.ws.security.WSEncryptionPart;
 import org.apache.ws.security.WSSecurityException;
 import org.apache.ws.security.components.crypto.Crypto;
@@ -34,6 +33,7 @@ import org.apache.ws.security.message.to
 import org.apache.ws.security.message.token.Reference;
 import org.apache.ws.security.message.token.SecurityTokenReference;
 import org.apache.ws.security.message.token.X509Security;
+import org.apache.ws.security.transform.STRTransform;
 import org.apache.ws.security.util.Base64;
 import org.apache.ws.security.util.WSSecurityUtil;
 
@@ -415,7 +415,6 @@ public class WSSecSignature extends WSSe
         boolean prepend,
         Element siblingElement
     ) throws WSSecurityException {
-        boolean remove = WSDocInfoStore.store(wsDocInfo);
         try {
             java.security.Key key;
             if (secretKey == null) {
@@ -459,6 +458,7 @@ public class WSSecSignature extends WSSe
                     WSConstants.C14N_EXCL_OMIT_COMMENTS_PREFIX
                 );
             }
+            signContext.setProperty(STRTransform.TRANSFORM_WS_DOC_INFO, wsDocInfo);
             URIDereferencer dereferencer = new DOMURIDereferencer();
             ((DOMURIDereferencer)dereferencer).setWsDocInfo(wsDocInfo);
             signContext.setURIDereferencer(dereferencer);
@@ -470,12 +470,7 @@ public class WSSecSignature extends WSSe
             throw new WSSecurityException(
                 WSSecurityException.FAILED_SIGNATURE, null, null, ex
             );
-        } finally {
-            if (remove) {
-                WSDocInfoStore.delete(wsDocInfo);
-            }
         }
-
     }
     
     

Modified: webservices/wss4j/trunk/src/main/java/org/apache/ws/security/processor/SignatureProcessor.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/processor/SignatureProcessor.java?rev=1045235&r1=1045234&r2=1045235&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/main/java/org/apache/ws/security/processor/SignatureProcessor.java
(original)
+++ webservices/wss4j/trunk/src/main/java/org/apache/ws/security/processor/SignatureProcessor.java
Mon Dec 13 17:04:12 2010
@@ -27,7 +27,6 @@ import org.apache.ws.security.PublicKeyP
 import org.apache.ws.security.WSConstants;
 import org.apache.ws.security.WSDataRef;
 import org.apache.ws.security.WSDocInfo;
-import org.apache.ws.security.WSDocInfoStore;
 import org.apache.ws.security.WSPasswordCallback;
 import org.apache.ws.security.WSSConfig;
 import org.apache.ws.security.WSSecurityEngine;
@@ -113,7 +112,6 @@ public class SignatureProcessor implemen
         if (log.isDebugEnabled()) {
             log.debug("Found signature element");
         }
-        boolean remove = WSDocInfoStore.store(wsDocInfo);
         List<WSDataRef> protectedRefs = new java.util.ArrayList<WSDataRef>();
         Principal lastPrincipalFound = null;
         certs = null;
@@ -128,10 +126,6 @@ public class SignatureProcessor implemen
                 );
         } catch (WSSecurityException ex) {
             throw ex;
-        } finally {
-            if (remove) {
-                WSDocInfoStore.delete(wsDocInfo);
-            }
         }
         int actionPerformed = WSConstants.SIGN;
         if (lastPrincipalFound instanceof WSUsernameTokenPrincipal) {
@@ -417,6 +411,7 @@ public class SignatureProcessor implemen
         URIDereferencer dereferencer = new DOMURIDereferencer();
         ((DOMURIDereferencer)dereferencer).setWsDocInfo(wsDocInfo);
         context.setURIDereferencer(dereferencer);
+        context.setProperty(STRTransform.TRANSFORM_WS_DOC_INFO, wsDocInfo);
         try {
             XMLSignature xmlSignature = signatureFactory.unmarshalXMLSignature(context);
             boolean signatureOk = xmlSignature.validate(context);

Modified: webservices/wss4j/trunk/src/main/java/org/apache/ws/security/saml/WSSecSignatureSAML.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/saml/WSSecSignatureSAML.java?rev=1045235&r1=1045234&r2=1045235&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/main/java/org/apache/ws/security/saml/WSSecSignatureSAML.java
(original)
+++ webservices/wss4j/trunk/src/main/java/org/apache/ws/security/saml/WSSecSignatureSAML.java
Mon Dec 13 17:04:12 2010
@@ -23,7 +23,6 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.ws.security.WSConstants;
 import org.apache.ws.security.WSDocInfo;
-import org.apache.ws.security.WSDocInfoStore;
 import org.apache.ws.security.WSEncryptionPart;
 import org.apache.ws.security.WSSecurityException;
 import org.apache.ws.security.components.crypto.Crypto;
@@ -33,6 +32,7 @@ import org.apache.ws.security.message.WS
 import org.apache.ws.security.message.token.Reference;
 import org.apache.ws.security.message.token.SecurityTokenReference;
 import org.apache.ws.security.message.token.X509Security;
+import org.apache.ws.security.transform.STRTransform;
 import org.apache.ws.security.util.WSSecurityUtil;
 
 import org.opensaml.SAMLAssertion;
@@ -499,7 +499,6 @@ public class WSSecSignatureSAML extends 
         WSSecHeader secHeader, 
         Element siblingElement
     ) throws WSSecurityException {
-        boolean remove = WSDocInfoStore.store(wsDocInfo);
         try {
             java.security.Key key;
             if (senderVouches) {
@@ -537,6 +536,7 @@ public class WSSecSignatureSAML extends 
                     WSConstants.C14N_EXCL_OMIT_COMMENTS_PREFIX
                 );
             }
+            signContext.setProperty(STRTransform.TRANSFORM_WS_DOC_INFO, wsDocInfo);
             URIDereferencer dereferencer = new DOMURIDereferencer();
             ((DOMURIDereferencer)dereferencer).setWsDocInfo(wsDocInfo);
             signContext.setURIDereferencer(dereferencer);
@@ -548,12 +548,7 @@ public class WSSecSignatureSAML extends 
             throw new WSSecurityException(
                 WSSecurityException.FAILED_SIGNATURE, null, null, ex
             );
-        } finally {
-            if (remove) {
-                WSDocInfoStore.delete(wsDocInfo);
-            }
         }
-
     }
 
     

Modified: webservices/wss4j/trunk/src/main/java/org/apache/ws/security/transform/STRTransform.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/transform/STRTransform.java?rev=1045235&r1=1045234&r2=1045235&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/main/java/org/apache/ws/security/transform/STRTransform.java
(original)
+++ webservices/wss4j/trunk/src/main/java/org/apache/ws/security/transform/STRTransform.java
Mon Dec 13 17:04:12 2010
@@ -23,7 +23,6 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.ws.security.WSConstants;
 import org.apache.ws.security.WSDocInfo;
-import org.apache.ws.security.WSDocInfoStore;
 import org.apache.ws.security.message.token.PKIPathSecurity;
 import org.apache.ws.security.message.token.SecurityTokenReference;
 import org.apache.ws.security.message.token.X509Security;
@@ -62,6 +61,8 @@ public class STRTransform extends Transf
 
     public static final String TRANSFORM_URI = 
         "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#STR-Transform";
+    
+    public static final String TRANSFORM_WS_DOC_INFO = "transform_ws_doc_info";
 
     private TransformParameterSpec params;
     
@@ -141,7 +142,6 @@ public class STRTransform extends Transf
                 );
             canonAlgo = canonElem.getAttribute("Algorithm");
         }
-        xc.getDefaultNamespacePrefix();
         try {
             //
             // Get the input (node) to transform. Currently we support only an
@@ -185,12 +185,12 @@ public class STRTransform extends Transf
             //
             // Third and fourth step are performed by dereferenceSTR()
             //
-            Document doc = str.getOwnerDocument();
-            WSDocInfo wsDocInfo = WSDocInfoStore.lookup(doc);
+            WSDocInfo wsDocInfo = (WSDocInfo)xc.getProperty(TRANSFORM_WS_DOC_INFO);
             if (wsDocInfo == null) {
                 throw new TransformException("no WSDocInfo found");
             }
 
+            Document doc = str.getOwnerDocument();
             Element dereferencedToken = 
                 STRTransformUtil.dereferenceSTR(doc, secRef, wsDocInfo);
             



Mime
View raw message