ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject svn commit: r1683136 - in /webservices/wss4j/trunk: ws-security-common/src/main/java/org/apache/wss4j/common/token/BinarySecurity.java ws-security-dom/src/main/java/org/apache/wss4j/dom/processor/BinarySecurityTokenProcessor.java
Date Tue, 02 Jun 2015 16:48:06 GMT
Author: coheigea
Date: Tue Jun  2 16:48:06 2015
New Revision: 1683136

URL: http://svn.apache.org/r1683136
Log:
[WSS-539] - Avoid Base-64 (re)coding for BinarySecurityTokens

Modified:
    webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/token/BinarySecurity.java
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/processor/BinarySecurityTokenProcessor.java

Modified: webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/token/BinarySecurity.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/token/BinarySecurity.java?rev=1683136&r1=1683135&r2=1683136&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/token/BinarySecurity.java
(original)
+++ webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/token/BinarySecurity.java
Tue Jun  2 16:48:06 2015
@@ -48,6 +48,7 @@ public class BinarySecurity {
         org.slf4j.LoggerFactory.getLogger(BinarySecurity.class);
     
     private Element element;
+    private byte[] data;
 
     /**
      * Constructor.
@@ -177,11 +178,15 @@ public class BinarySecurity {
      * @return the byte array containing token information
      */
     public byte[] getToken() {
+        if (data != null) {
+            return data;
+        }
         try {
             String text = XMLUtils.getElementText(element);
             if (text == null) {
                 return null;
             }
+            
             return Base64.decode(text);
         } catch (Exception ex) {
             if (LOG.isDebugEnabled()) {
@@ -202,6 +207,14 @@ public class BinarySecurity {
         }
         Text node = getFirstNode();
         node.setData(Base64.encode(data));
+        setRawToken(data);
+    }
+    
+    /**
+     * Set the raw token data, without Base-64 encoding it into the Element.
+     */
+    public void setRawToken(byte[] data) {
+        this.data = Arrays.copyOf(data, data.length);
     }
 
     /**

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/processor/BinarySecurityTokenProcessor.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/processor/BinarySecurityTokenProcessor.java?rev=1683136&r1=1683135&r2=1683136&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/processor/BinarySecurityTokenProcessor.java
(original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/processor/BinarySecurityTokenProcessor.java
Tue Jun  2 16:48:06 2015
@@ -176,7 +176,7 @@ public class BinarySecurityTokenProcesso
             String xopUri = elementChild.getAttributeNS(null, "href");
             if (xopUri != null && xopUri.startsWith("cid:")) {
                 byte[] content = WSSecurityUtil.getBytesFromAttachment(xopUri, data);
-                token.setToken(content);
+                token.setRawToken(content);
             }
         }
         



Mime
View raw message