cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r757966 - in /cxf/branches/2.1.x-fixes: ./ rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyBuilderImpl.java rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/AbstractWSS4JInterceptor.java
Date Tue, 24 Mar 2009 19:19:39 GMT
Author: dkulp
Date: Tue Mar 24 19:19:37 2009
New Revision: 757966

URL: http://svn.apache.org/viewvc?rev=757966&view=rev
Log:
Merged revisions 755365 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r755365 | dkulp | 2009-03-17 15:42:30 -0400 (Tue, 17 Mar 2009) | 2 lines
  
  Updates to make sure streams close.   Cache some properties.
........

Modified:
    cxf/branches/2.1.x-fixes/   (props changed)
    cxf/branches/2.1.x-fixes/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyBuilderImpl.java
    cxf/branches/2.1.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/AbstractWSS4JInterceptor.java

Propchange: cxf/branches/2.1.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Mar 24 19:19:37 2009
@@ -1 +1 @@
-/cxf/trunk:753380,753397,753421,754585
+/cxf/trunk:753380,753397,753421,754585,755365

Propchange: cxf/branches/2.1.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.1.x-fixes/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyBuilderImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyBuilderImpl.java?rev=757966&r1=757965&r2=757966&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyBuilderImpl.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyBuilderImpl.java
Tue Mar 24 19:19:37 2009
@@ -100,10 +100,11 @@
         if (!Constants.ELEM_POLICY_REF.equals(element.getLocalName())) {
             throw new PolicyException(new Message("NOT_A_POLICYREF_ELEMENT_EXC", BUNDLE));
         }
-
-        PolicyReference reference = new PolicyReference();
-        reference.setURI(element.getAttribute("URI"));
-        return reference;
+        synchronized (element) {
+            PolicyReference reference = new PolicyReference();
+            reference.setURI(element.getAttribute("URI"));
+            return reference;
+        }
     }
     
     /**
@@ -141,67 +142,68 @@
     }
 
     private PolicyOperator processOperationElement(Element operationElement, PolicyOperator
operator) {
-        
-        if (Constants.TYPE_POLICY == operator.getType()) {
-            Policy policyOperator = (Policy)operator;
-
-            QName key;
-
-            NamedNodeMap nnm = operationElement.getAttributes();
-            for (int i = 0; i < nnm.getLength(); i++) {
-                Node n = nnm.item(i);
-                if (Node.ATTRIBUTE_NODE == n.getNodeType()) {
-                    String namespace = n.getNamespaceURI();    
-                    if (namespace == null) {
-                        key = new QName(n.getLocalName());
-
-                    } else if (n.getPrefix() == null) {
-                        key = new QName(namespace, n.getLocalName());
-
-                    } else {
-                        key = new QName(namespace, n.getLocalName(), n.getPrefix());
+        synchronized (operationElement) {
+            if (Constants.TYPE_POLICY == operator.getType()) {
+                Policy policyOperator = (Policy)operator;
+    
+                QName key;
+    
+                NamedNodeMap nnm = operationElement.getAttributes();
+                for (int i = 0; i < nnm.getLength(); i++) {
+                    Node n = nnm.item(i);
+                    if (Node.ATTRIBUTE_NODE == n.getNodeType()) {
+                        String namespace = n.getNamespaceURI();    
+                        if (namespace == null) {
+                            key = new QName(n.getLocalName());
+    
+                        } else if (n.getPrefix() == null) {
+                            key = new QName(namespace, n.getLocalName());
+    
+                        } else {
+                            key = new QName(namespace, n.getLocalName(), n.getPrefix());
+                        }
+                        policyOperator.addAttribute(key, n.getNodeValue());
                     }
-                    policyOperator.addAttribute(key, n.getNodeValue());
-                }
-            }            
-        }
-
-        String policyNsURI = 
-            bus == null ? PolicyConstants.NAMESPACE_WS_POLICY
-                        : bus.getExtension(PolicyConstants.class).getNamespace();
-        
-        Element childElement;
-        for (Node n = operationElement.getFirstChild(); n != null; n = n.getNextSibling())
{
-            if (Node.ELEMENT_NODE != n.getNodeType()) {
-                continue;
+                }            
             }
-            childElement = (Element)n;
-            String namespaceURI = childElement.getNamespaceURI();
-            String localName = childElement.getLocalName();
-
-            if (policyNsURI.equals(namespaceURI)) {
-
-                if (Constants.ELEM_POLICY.equals(localName)) {
-                    operator.addPolicyComponent(getPolicyOperator(childElement));
-
-                } else if (Constants.ELEM_EXACTLYONE.equals(localName)) {
-                    operator.addPolicyComponent(getExactlyOneOperator(childElement));
-
-                } else if (Constants.ELEM_ALL.equals(localName)) {
-                    operator.addPolicyComponent(getAllOperator(childElement));
-
-                } else if (Constants.ELEM_POLICY_REF.equals(localName)) {
-                    operator.addPolicyComponent(getPolicyReference(childElement));
+    
+            String policyNsURI = 
+                bus == null ? PolicyConstants.NAMESPACE_WS_POLICY
+                            : bus.getExtension(PolicyConstants.class).getNamespace();
+            
+            Element childElement;
+            for (Node n = operationElement.getFirstChild(); n != null; n = n.getNextSibling())
{
+                if (Node.ELEMENT_NODE != n.getNodeType()) {
+                    continue;
                 }
-
-            } else if (null != assertionBuilderRegistry) {
-                PolicyAssertion a = assertionBuilderRegistry.build(childElement);
-                if (null != a) {
-                    operator.addPolicyComponent(a);
+                childElement = (Element)n;
+                String namespaceURI = childElement.getNamespaceURI();
+                String localName = childElement.getLocalName();
+    
+                if (policyNsURI.equals(namespaceURI)) {
+    
+                    if (Constants.ELEM_POLICY.equals(localName)) {
+                        operator.addPolicyComponent(getPolicyOperator(childElement));
+    
+                    } else if (Constants.ELEM_EXACTLYONE.equals(localName)) {
+                        operator.addPolicyComponent(getExactlyOneOperator(childElement));
+    
+                    } else if (Constants.ELEM_ALL.equals(localName)) {
+                        operator.addPolicyComponent(getAllOperator(childElement));
+    
+                    } else if (Constants.ELEM_POLICY_REF.equals(localName)) {
+                        operator.addPolicyComponent(getPolicyReference(childElement));
+                    }
+    
+                } else if (null != assertionBuilderRegistry) {
+                    PolicyAssertion a = assertionBuilderRegistry.build(childElement);
+                    if (null != a) {
+                        operator.addPolicyComponent(a);
+                    }
                 }
             }
+            return operator;
         }
-        return operator;
     }
     
 }

Modified: cxf/branches/2.1.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/AbstractWSS4JInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/AbstractWSS4JInterceptor.java?rev=757966&r1=757965&r2=757966&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/AbstractWSS4JInterceptor.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/AbstractWSS4JInterceptor.java
Tue Mar 24 19:19:37 2009
@@ -21,10 +21,10 @@
 import java.net.URI;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Hashtable;
 import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
 
 import javax.xml.namespace.QName;
 
@@ -56,7 +56,7 @@
     private Set<String> after = new HashSet<String>();
     private String phase;
     private String id;
-    private Map<String, Crypto> cryptoTable = new Hashtable<String, Crypto>();
+    private Map<String, Crypto> cryptoTable = new ConcurrentHashMap<String, Crypto>();
     
     public AbstractWSS4JInterceptor() {
         super();
@@ -154,13 +154,13 @@
          */
         String sigPropFile = getString(WSHandlerConstants.SIG_PROP_FILE,
                    reqData.getMsgContext());
+        String refId = null;
         if (sigPropFile != null) {
-            if (cryptoTable.get(sigPropFile) == null) {
+            crypto = cryptoTable.get(sigPropFile);
+            if (crypto == null) {
                 crypto = CryptoFactory.getInstance(sigPropFile, this
                         .getClassLoader(reqData.getMsgContext()));
                 cryptoTable.put(sigPropFile, crypto);
-            } else {
-                crypto = cryptoTable.get(sigPropFile);
             }
         } else if (getString(WSHandlerConstants.SIG_PROP_REF_ID, reqData
             .getMsgContext()) != null) {
@@ -168,19 +168,16 @@
              * If the property file is missing then 
              * look for the Properties object 
              */
-            String refId = getString(WSHandlerConstants.SIG_PROP_REF_ID,
+            refId = getString(WSHandlerConstants.SIG_PROP_REF_ID,
                 reqData.getMsgContext());
             if (refId != null) {
                 Object propObj = getProperty(reqData.getMsgContext(), refId);
                 if (propObj instanceof Properties) {
-                    if (cryptoTable.get(refId) == null) {
+                    crypto = cryptoTable.get(refId);
+                    if (crypto == null) {
                         crypto = CryptoFactory.getInstance((Properties)propObj);
                         cryptoTable.put(refId, crypto);
-                    } else {
-                        crypto = cryptoTable.get(refId);
                     }
-                } else {
-                    return crypto;
                 }
             }
         } 
@@ -192,13 +189,13 @@
         Crypto crypto = null;
         String decPropFile = getString(WSHandlerConstants.DEC_PROP_FILE,
                  reqData.getMsgContext());
+        String refId = null;
         if (decPropFile != null) {
-            if (cryptoTable.get(decPropFile) == null) {
+            crypto = cryptoTable.get(decPropFile);
+            if (crypto == null) {
                 crypto = CryptoFactory.getInstance(decPropFile, this
                         .getClassLoader(reqData.getMsgContext()));
                 cryptoTable.put(decPropFile, crypto);
-            } else {
-                crypto = cryptoTable.get(decPropFile);
             }
         } else if (getString(WSHandlerConstants.DEC_PROP_REF_ID, reqData
             .getMsgContext()) != null) {
@@ -206,19 +203,16 @@
              * If the property file is missing then 
              * look for the Properties object 
              */
-            String refId = getString(WSHandlerConstants.DEC_PROP_REF_ID,
+            refId = getString(WSHandlerConstants.DEC_PROP_REF_ID,
                 reqData.getMsgContext());
             if (refId != null) {
                 Object propObj = getProperty(reqData.getMsgContext(), refId);
                 if (propObj instanceof Properties) {
-                    if (cryptoTable.get(refId) == null) {
+                    crypto = cryptoTable.get(refId);
+                    if (crypto == null) {
                         crypto = CryptoFactory.getInstance((Properties)propObj);
                         cryptoTable.put(refId, crypto);
-                    } else {
-                        crypto = cryptoTable.get(refId);
                     }
-                } else {
-                    return crypto;
                 }
             }
         } 
@@ -234,13 +228,13 @@
         */
         String encPropFile = getString(WSHandlerConstants.ENC_PROP_FILE,
                        reqData.getMsgContext());
+        String refId = null;
         if (encPropFile != null) {
-            if (cryptoTable.get(encPropFile) == null) {
+            crypto = cryptoTable.get(encPropFile);
+            if (crypto == null) {
                 crypto = CryptoFactory.getInstance(encPropFile, this
                         .getClassLoader(reqData.getMsgContext()));
                 cryptoTable.put(encPropFile, crypto);
-            } else {
-                crypto = cryptoTable.get(encPropFile);
             }
         } else if (getString(WSHandlerConstants.ENC_PROP_REF_ID, reqData
                 .getMsgContext()) != null) {
@@ -248,19 +242,16 @@
              * If the property file is missing then 
              * look for the Properties object 
              */
-            String refId = getString(WSHandlerConstants.ENC_PROP_REF_ID,
+            refId = getString(WSHandlerConstants.ENC_PROP_REF_ID,
                     reqData.getMsgContext());
             if (refId != null) {
                 Object propObj = getProperty(reqData.getMsgContext(), refId);
                 if (propObj instanceof Properties) {
-                    if (cryptoTable.get(refId) == null) {
+                    crypto = cryptoTable.get(refId);
+                    if (crypto == null) {
                         crypto = CryptoFactory.getInstance((Properties)propObj);
                         cryptoTable.put(refId, crypto);
-                    } else {
-                        crypto = cryptoTable.get(encPropFile);
                     }
-                } else {
-                    return crypto;
                 }
             }
         } else if (reqData.getSigCrypto() == null) {



Mime
View raw message