cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject svn commit: r1415618 - /cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java
Date Fri, 30 Nov 2012 13:17:47 GMT
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();



Mime
View raw message