cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r704955 - in /cxf/trunk: api/src/main/java/org/apache/cxf/ws/policy/ rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/interceptors/ rt/ws/security/src/main/java/org/apache/c...
Date Wed, 15 Oct 2008 16:47:19 GMT
Author: dkulp
Date: Wed Oct 15 09:47:18 2008
New Revision: 704955

URL: http://svn.apache.org/viewvc?rev=704955&view=rev
Log:
Change to throwing exceptions for various policy issues during out processing.

Added:
    cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/interceptors/Messages.properties
  (with props)
    cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AbstractBindingBuilder.java
  (contents, props changed)
      - copied, changed from r704938, cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/BindingBuilder.java
Removed:
    cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/BindingBuilder.java
Modified:
    cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/APIMessages.properties
    cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyException.java
    cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationOutInterceptor.java
    cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/interceptors/HttpsTokenInterceptorProvider.java
    cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AsymmetricBindingHandler.java
    cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/SymmetricBindingHandler.java
    cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/TransportBindingHandler.java

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/APIMessages.properties
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/APIMessages.properties?rev=704955&r1=704954&r2=704955&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/APIMessages.properties (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/APIMessages.properties Wed Oct 15
09:47:18 2008
@@ -19,4 +19,5 @@
 #
 #
 NO_ALTERNATIVE_EXC = These policy alternatives can not be satisfied: {0}
-NOT_ASSERTED_EXC = Assertion of type {0} could not be asserted.
\ No newline at end of file
+NOT_ASSERTED_EXC = Assertion of type {0} could not be asserted.
+ASSERTION_NOT_ASSERTED = Assertion of type {0} could not be asserted: {1}
\ No newline at end of file

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyException.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyException.java?rev=704955&r1=704954&r2=704955&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyException.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyException.java Wed Oct 15 09:47:18
2008
@@ -19,6 +19,9 @@
 
 package org.apache.cxf.ws.policy;
 
+import java.util.ResourceBundle;
+
+import org.apache.cxf.common.i18n.BundleUtils;
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.i18n.UncheckedException;
 
@@ -27,16 +30,24 @@
  * by the policy framework.
  */
 public class PolicyException extends UncheckedException {
+    private static final ResourceBundle BUNDLE 
+        = BundleUtils.getBundle(PolicyException.class, "APIMessages");
+
+    
     public PolicyException(Message msg, Throwable t) {
         super(msg, t);
     }
 
-    public PolicyException(Message msg) {
-        super(msg);
+    public PolicyException(Message message) {
+        super(message);
     }
 
     public PolicyException(Throwable cause) {
         super(cause);
     }
 
+    public PolicyException(AssertionInfo info) {
+        super(new Message("ASSERTION_NOT_ASSERTED", BUNDLE,
+                          info.getAssertion().getName(), info.getErrorMessage()));
+    }
 }
\ No newline at end of file

Modified: cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationOutInterceptor.java?rev=704955&r1=704954&r2=704955&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationOutInterceptor.java
(original)
+++ cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationOutInterceptor.java
Wed Oct 15 09:47:18 2008
@@ -68,27 +68,13 @@
         // on the outbound-server side of a response
         try {
             aim.checkEffectivePolicy(policy.getPolicy());
-        } catch (final PolicyException e) {
-            if (isOutboundServer(message)) {
-                LOG.fine("An exception was thrown when verifying that the effective policy
for "
-                         + "this request was satisfied.  However, this exception will not
result in "
-                         + "a fault.  The exception raised is: "
-                         + e.toString());
-                return;
-            } else {
-                throw e;
-            }
+        } catch (PolicyException e) {
+            LOG.fine("An exception was thrown when verifying that the effective policy for
"
+                     + "this request was satisfied.  However, this exception will not result
in "
+                     + "a fault.  The exception raised is: "
+                     + e.toString());
+            return;
         }
         LOG.fine("Verified policies for outbound message.");
     }
-    
-    private boolean isOutboundServer(final Message message) {
-        final Object role = message.get(Message.REQUESTOR_ROLE);
-        final boolean isClient =
-            role != null ? Boolean.TRUE.equals(role) : false;
-        final boolean isOutbound =
-            message == message.getExchange().getOutMessage()
-            || message == message.getExchange().getOutFaultMessage();
-        return !isClient && isOutbound;
-    }
 }

Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/interceptors/HttpsTokenInterceptorProvider.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/interceptors/HttpsTokenInterceptorProvider.java?rev=704955&r1=704954&r2=704955&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/interceptors/HttpsTokenInterceptorProvider.java
(original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/interceptors/HttpsTokenInterceptorProvider.java
Wed Oct 15 09:47:18 2008
@@ -37,6 +37,7 @@
 import org.apache.cxf.ws.policy.AbstractPolicyInterceptorProvider;
 import org.apache.cxf.ws.policy.AssertionInfo;
 import org.apache.cxf.ws.policy.AssertionInfoMap;
+import org.apache.cxf.ws.policy.PolicyException;
 import org.apache.cxf.ws.security.policy.SP11Constants;
 import org.apache.cxf.ws.security.policy.SP12Constants;
 import org.apache.cxf.ws.security.policy.model.HttpsToken;
@@ -118,6 +119,9 @@
                 } else {
                     ai.setNotAsserted("HttpURLConnection is not a HttpsURLConnection");
                 }
+                if (!ai.isAsserted()) {
+                    throw new PolicyException(ai);
+                }
             }            
         }
 

Added: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/interceptors/Messages.properties
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/interceptors/Messages.properties?rev=704955&view=auto
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/interceptors/Messages.properties
(added)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/interceptors/Messages.properties
Wed Oct 15 09:47:18 2008
@@ -0,0 +1,21 @@
+#
+#
+#    Licensed to the Apache Software Foundation (ASF) under one
+#    or more contributor license agreements. See the NOTICE file
+#    distributed with this work for additional information
+#    regarding copyright ownership. The ASF licenses this file
+#    to you under the Apache License, Version 2.0 (the
+#    "License"); you may not use this file except in compliance
+#    with the License. You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing,
+#    software distributed under the License is distributed on an
+#    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#    KIND, either express or implied. See the License for the
+#    specific language governing permissions and limitations
+#    under the License.
+#
+#
+HTTPS_NOT_ASSERTED: Token {0} was not asserted: {1}
\ No newline at end of file

Propchange: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/interceptors/Messages.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/interceptors/Messages.properties
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/interceptors/Messages.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AbstractBindingBuilder.java
(from r704938, cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/BindingBuilder.java)
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AbstractBindingBuilder.java?p2=cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AbstractBindingBuilder.java&p1=cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/BindingBuilder.java&r1=704938&r2=704955&rev=704955&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/BindingBuilder.java
(original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AbstractBindingBuilder.java
Wed Oct 15 09:47:18 2008
@@ -51,6 +51,7 @@
 import org.apache.cxf.Bus;
 import org.apache.cxf.binding.soap.SoapMessage;
 import org.apache.cxf.common.classloader.ClassLoaderUtils;
+import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.helpers.DOMUtils;
@@ -60,6 +61,7 @@
 import org.apache.cxf.ws.policy.AssertionInfoMap;
 import org.apache.cxf.ws.policy.PolicyAssertion;
 import org.apache.cxf.ws.policy.PolicyConstants;
+import org.apache.cxf.ws.policy.PolicyException;
 import org.apache.cxf.ws.security.SecurityConstants;
 import org.apache.cxf.ws.security.policy.SP12Constants;
 import org.apache.cxf.ws.security.policy.SPConstants;
@@ -102,8 +104,8 @@
 /**
  * 
  */
-public class BindingBuilder {
-    private static final Logger LOG = LogUtils.getL7dLogger(BindingBuilder.class); 
+public abstract class AbstractBindingBuilder {
+    private static final Logger LOG = LogUtils.getL7dLogger(AbstractBindingBuilder.class);

     
     protected SOAPMessage saaj;
     protected WSSecHeader secHeader;
@@ -128,7 +130,7 @@
     Element bottomUpElement;
     Element topDownElement;
     
-    public BindingBuilder(Binding binding,
+    public AbstractBindingBuilder(Binding binding,
                            SOAPMessage saaj,
                            WSSecHeader secHeader,
                            AssertionInfoMap aim,
@@ -230,6 +232,7 @@
                 }
             }
         }
+        throw new PolicyException(reason);
     }
     protected void policyNotAsserted(PolicyAssertion assertion, String reason) {
         LOG.log(Level.INFO, "Not asserting " + assertion.getName() + ": " + reason);
@@ -242,6 +245,7 @@
                 }
             }
         }
+        throw new PolicyException(new Message(reason, LOG));
     }
     protected void policyAsserted(PolicyAssertion assertion) {
         LOG.log(Level.INFO, "Asserting " + assertion.getName());

Propchange: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AbstractBindingBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AbstractBindingBuilder.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AbstractBindingBuilder.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AsymmetricBindingHandler.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AsymmetricBindingHandler.java?rev=704955&r1=704954&r2=704955&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AsymmetricBindingHandler.java
(original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AsymmetricBindingHandler.java
Wed Oct 15 09:47:18 2008
@@ -55,7 +55,7 @@
 /**
  * 
  */
-public class AsymmetricBindingHandler extends BindingBuilder {
+public class AsymmetricBindingHandler extends AbstractBindingBuilder {
     AsymmetricBinding abinding;
     
     private WSSecEncryptedKey encrKey;

Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/SymmetricBindingHandler.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/SymmetricBindingHandler.java?rev=704955&r1=704954&r2=704955&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/SymmetricBindingHandler.java
(original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/SymmetricBindingHandler.java
Wed Oct 15 09:47:18 2008
@@ -69,7 +69,7 @@
 /**
  * 
  */
-public class SymmetricBindingHandler extends BindingBuilder {
+public class SymmetricBindingHandler extends AbstractBindingBuilder {
     SymmetricBinding sbinding;
     TokenStore tokenStore;
     

Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/TransportBindingHandler.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/TransportBindingHandler.java?rev=704955&r1=704954&r2=704955&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/TransportBindingHandler.java
(original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/TransportBindingHandler.java
Wed Oct 15 09:47:18 2008
@@ -35,7 +35,7 @@
 /**
  * 
  */
-public class TransportBindingHandler extends BindingBuilder {
+public class TransportBindingHandler extends AbstractBindingBuilder {
     TransportBinding tbinding;
     
     public TransportBindingHandler(TransportBinding binding,



Mime
View raw message