cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: [CXF-6579] Finalizing it with the code prepared by Phillip Klinefelter
Date Thu, 10 Sep 2015 09:42:31 GMT
Repository: cxf
Updated Branches:
  refs/heads/2.7.x-fixes 6e5cfc6c1 -> b41bf2602


[CXF-6579] Finalizing it with the code prepared by Phillip Klinefelter


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/b41bf260
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/b41bf260
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/b41bf260

Branch: refs/heads/2.7.x-fixes
Commit: b41bf260253133719068f1f2d6a20043dc45e0c6
Parents: 6e5cfc6
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Thu Sep 10 10:31:49 2015 +0100
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Thu Sep 10 10:42:11 2015 +0100

----------------------------------------------------------------------
 .../rs/security/saml/DeflateEncoderDecoder.java | 43 +++++++-------------
 1 file changed, 15 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/b41bf260/rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/saml/DeflateEncoderDecoder.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/saml/DeflateEncoderDecoder.java
b/rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/saml/DeflateEncoderDecoder.java
index 951de15..739c5af 100644
--- a/rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/saml/DeflateEncoderDecoder.java
+++ b/rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/saml/DeflateEncoderDecoder.java
@@ -19,8 +19,8 @@
 package org.apache.cxf.rs.security.saml;
 
 import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.InputStream;
-import java.io.SequenceInputStream;
 import java.util.zip.DataFormatException;
 import java.util.zip.Deflater;
 import java.util.zip.Inflater;
@@ -33,37 +33,24 @@ public class DeflateEncoderDecoder {
         throws DataFormatException {
         Inflater inflater = new Inflater(true);
         inflater.setInput(deflatedToken);
-        
-        byte[] input = new byte[deflatedToken.length * 2];
-        int inflatedLen = 0;
-        int inputLen = 0;
-        byte[] inflatedToken = input;
+
+        byte[] buffer = new byte[deflatedToken.length];
+        int inflateLen;
+        ByteArrayOutputStream inflatedToken = new ByteArrayOutputStream();
         while (!inflater.finished()) {
-            inputLen = inflater.inflate(input);
-            if (!inflater.finished()) {
-                
-                if (inputLen == 0) {
-                    if (inflater.needsInput()) {
-                        throw new DataFormatException("Inflater can not inflate all the token
bytes");
-                    } else {
-                        break;
-                    }
-                }
-                byte[] lastInflatedToken = inflatedToken;
-                inflatedToken = new byte[input.length + inflatedLen];
-                if (lastInflatedToken != input) {
-                    System.arraycopy(lastInflatedToken, 0, inflatedToken, 0, inflatedLen);
+            inflateLen = inflater.inflate(buffer, 0, deflatedToken.length);
+            if (inflateLen == 0 && !inflater.finished()) {
+                if (inflater.needsInput()) {
+                    throw new DataFormatException("Inflater can not inflate all the token
bytes");
+                } else {
+                    break;
                 }
-                System.arraycopy(input, 0, inflatedToken, inflatedLen, inputLen);
-                inflatedLen += inputLen;
             }
+            
+            inflatedToken.write(buffer, 0, inflateLen);
         }
-        InputStream is = new ByteArrayInputStream(input, 0, inputLen);
-        if (inflatedToken != input) {
-            is = new SequenceInputStream(new ByteArrayInputStream(inflatedToken, 0, inflatedLen),
-                                         is);
-        }
-        return is;
+
+        return new ByteArrayInputStream(inflatedToken.toByteArray());
     }
     
     public byte[] deflateToken(byte[] tokenBytes) {


Mime
View raw message