You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by ay...@apache.org on 2012/11/30 14:17:47 UTC

svn commit: r1415618 - /cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java

Author: ay
Date: Fri Nov 30 13:17:46 2012
New Revision: 1415618

URL: http://svn.apache.org/viewvc?rev=1415618&view=rev
Log:
some addition and minor improvent to CXF-4596

Modified:
    cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java?rev=1415618&r1=1415617&r2=1415618&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java Fri Nov 30 13:17:46 2012
@@ -35,6 +35,7 @@ import java.io.PipedOutputStream;
 import java.io.Reader;
 import java.security.GeneralSecurityException;
 import java.security.Key;
+import java.security.SecureRandom;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
@@ -93,7 +94,6 @@ public class CachedOutputStream extends 
     private String cipherTransformation = defaultCipherTransformation;
     private Cipher enccipher;
     private Cipher deccipher;
-    
 
     private List<CachedOutputStreamCallback> callbacks;
     
@@ -500,7 +500,6 @@ public class CachedOutputStream extends 
             
             currentStream = createOutputStream(tempFile);
             bout.writeTo(currentStream);
-            currentStream = new BufferedOutputStream(currentStream);
             inmem = false;
             streamList.add(currentStream);
         } catch (Exception ex) {
@@ -640,7 +639,9 @@ public class CachedOutputStream extends 
                 a = cipherTransformation;
             }
             try {
-                Key key = KeyGenerator.getInstance(a).generateKey();
+                KeyGenerator keygen = KeyGenerator.getInstance(a);
+                keygen.init(new SecureRandom());
+                Key key = keygen.generateKey();
                 enccipher = Cipher.getInstance(cipherTransformation);
                 deccipher = Cipher.getInstance(cipherTransformation);
                 enccipher.init(Cipher.ENCRYPT_MODE, key);
@@ -655,7 +656,7 @@ public class CachedOutputStream extends 
     }
 
     private OutputStream createOutputStream(File file) throws IOException {
-        OutputStream out = new FileOutputStream(file);
+        OutputStream out = new BufferedOutputStream(new FileOutputStream(file));
         if (cipherTransformation != null) {
             try {
                 initCiphers();