ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject svn commit: r1581921 - in /webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax: WSSec.java ext/InboundWSSec.java impl/WSSecurityStreamReader.java
Date Wed, 26 Mar 2014 16:39:31 GMT
Author: coheigea
Date: Wed Mar 26 16:39:30 2014
New Revision: 1581921

URL: http://svn.apache.org/r1581921
Log:
Configure whether to return a "safe" error message or not depending if we are the initiator
or not

Modified:
    webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/WSSec.java
    webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/ext/InboundWSSec.java
    webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/WSSecurityStreamReader.java

Modified: webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/WSSec.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/WSSec.java?rev=1581921&r1=1581920&r2=1581921&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/WSSec.java
(original)
+++ webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/WSSec.java
Wed Mar 26 16:39:30 2014
@@ -83,12 +83,28 @@ public class WSSec {
      *          if the configuration is invalid
      */
     public static InboundWSSec getInboundWSSec(WSSSecurityProperties securityProperties)
throws WSSecurityException {
+        return getInboundWSSec(securityProperties, false);
+    }
+    
+    /**
+     * Creates and configures an inbound streaming security engine
+     *
+     * @param securityProperties The user-defined security configuration
+     * @param initiator Whether we are the message initiator or not
+     * @return A new InboundWSSec
+     * @throws WSSecurityException
+     *          if the initialisation failed
+     * @throws org.apache.wss4j.stax.ext.WSSConfigurationException
+     *          if the configuration is invalid
+     */
+    public static InboundWSSec getInboundWSSec(WSSSecurityProperties securityProperties,
+            boolean initiator) throws WSSecurityException {
         if (securityProperties == null) {
             throw new WSSConfigurationException(WSSConfigurationException.ErrorCode.FAILURE,
"missingSecurityProperties");
         }
 
         securityProperties = validateAndApplyDefaultsToInboundSecurityProperties(securityProperties);
-        return new InboundWSSec(securityProperties);
+        return new InboundWSSec(securityProperties, initiator);
     }
     
     /**

Modified: webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/ext/InboundWSSec.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/ext/InboundWSSec.java?rev=1581921&r1=1581920&r2=1581921&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/ext/InboundWSSec.java
(original)
+++ webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/ext/InboundWSSec.java
Wed Mar 26 16:39:30 2014
@@ -70,9 +70,15 @@ public class InboundWSSec {
     }
 
     private final WSSSecurityProperties securityProperties;
+    private final boolean initiator;
 
     public InboundWSSec(WSSSecurityProperties securityProperties) {
+        this(securityProperties, false);
+    }
+    
+    public InboundWSSec(WSSSecurityProperties securityProperties, boolean initiator) {
         this.securityProperties = securityProperties;
+        this.initiator = initiator;
     }
 
     /**
@@ -253,6 +259,6 @@ public class InboundWSSec {
             }
         }
 
-        return new WSSecurityStreamReader(inputProcessorChain, securityProperties);
+        return new WSSecurityStreamReader(inputProcessorChain, securityProperties, initiator);
     }
 }

Modified: webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/WSSecurityStreamReader.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/WSSecurityStreamReader.java?rev=1581921&r1=1581920&r2=1581921&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/WSSecurityStreamReader.java
(original)
+++ webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/WSSecurityStreamReader.java
Wed Mar 26 16:39:30 2014
@@ -29,8 +29,12 @@ import javax.xml.stream.XMLStreamExcepti
 
 public class WSSecurityStreamReader extends XMLSecurityStreamReader {
     
-    public WSSecurityStreamReader(InputProcessorChain inputProcessorChain, XMLSecurityProperties
securityProperties) {
+    private final boolean initiator;
+    
+    public WSSecurityStreamReader(InputProcessorChain inputProcessorChain, 
+            XMLSecurityProperties securityProperties, boolean initiator) {
         super(inputProcessorChain, securityProperties);
+        this.initiator = initiator;
     }
 
     @Override
@@ -41,10 +45,10 @@ public class WSSecurityStreamReader exte
             Throwable cause = e.getCause();
             if (cause instanceof WSSecurityException) {
                 // Allow a WSSPolicyException
-                if (cause.getCause() instanceof WSSPolicyException) {
+                if (initiator || cause.getCause() instanceof WSSPolicyException) {
                     throw e;
                 }
-                // Map to a "safe" error message
+                // Map to a "safe" error message if we are not the initiator
                 String error = ((WSSecurityException)cause).getSafeExceptionMessage();
                 throw new XMLStreamException(
                     new WSSecurityException(((WSSecurityException)cause).getErrorCode(),



Mime
View raw message