cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject git commit: [CXF-5311] Removing JweEncryptorWorkerState
Date Wed, 25 Jun 2014 21:18:24 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 856a0b9ef -> 48b00b30b


[CXF-5311] Removing JweEncryptorWorkerState


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

Branch: refs/heads/master
Commit: 48b00b30b712a55a0e7e5348dead3d666f2309d8
Parents: 856a0b9
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Wed Jun 25 22:18:06 2014 +0100
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Wed Jun 25 22:18:06 2014 +0100

----------------------------------------------------------------------
 .../oauth2/jwe/AbstractJweEncryptor.java        | 12 +++++-
 .../rs/security/oauth2/jwe/JweEncryptor.java    |  4 +-
 .../oauth2/jwe/JweEncryptorWorkerState.java     | 43 --------------------
 .../rs/security/oauth2/jwe/JweOutputStream.java |  7 ++--
 .../oauth2/jwt/jaxrs/JweWriterInterceptor.java  |  4 +-
 5 files changed, 17 insertions(+), 53 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/48b00b30/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/AbstractJweEncryptor.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/AbstractJweEncryptor.java
b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/AbstractJweEncryptor.java
index 0835836..132eca8 100644
--- a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/AbstractJweEncryptor.java
+++ b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/AbstractJweEncryptor.java
@@ -18,6 +18,8 @@
  */
 package org.apache.cxf.rs.security.oauth2.jwe;
 
+import java.io.IOException;
+import java.io.OutputStream;
 import java.security.spec.AlgorithmParameterSpec;
 import java.util.concurrent.atomic.AtomicInteger;
 
@@ -119,7 +121,8 @@ public abstract class AbstractJweEncryptor implements JweEncryptor {
         return producer.getJweContent();
     }
     
-    public JweEncryptorWorkerState newWorkerState(String contentType) {
+    @Override
+    public JweOutputStream createJweStream(OutputStream os, String contentType) {
         JweEncryptorInternalState state = getInternalState(contentType);
         String jweStart = JweCompactProducer.startJweContent(state.theHeaders, 
                                            writer, 
@@ -127,7 +130,12 @@ public abstract class AbstractJweEncryptor implements JweEncryptor {
                                            state.theIv);
         Cipher c = CryptoUtils.initCipher(state.secretKey, state.keyProps, 
                                           Cipher.ENCRYPT_MODE);
-        return new JweEncryptorWorkerState(jweStart, c, getAuthTagLen());
+        try {
+            os.write(jweStart.getBytes("UTF-8"));
+        } catch (IOException ex) {
+            throw new SecurityException(ex);
+        }
+        return new JweOutputStream(os, c, getAuthTagLen());
     }
     
     private JweEncryptorInternalState getInternalState(String contentType) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/48b00b30/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/JweEncryptor.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/JweEncryptor.java
b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/JweEncryptor.java
index b2acb17..a7edd08 100644
--- a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/JweEncryptor.java
+++ b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/JweEncryptor.java
@@ -18,8 +18,10 @@
  */
 package org.apache.cxf.rs.security.oauth2.jwe;
 
+import java.io.OutputStream;
+
 
 public interface JweEncryptor {
     String encrypt(byte[] jweContent, String contentType);
-    JweEncryptorWorkerState newWorkerState(String contentType);
+    JweOutputStream createJweStream(OutputStream os, String contentType);
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/48b00b30/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/JweEncryptorWorkerState.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/JweEncryptorWorkerState.java
b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/JweEncryptorWorkerState.java
deleted file mode 100644
index e73cdf5..0000000
--- a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/JweEncryptorWorkerState.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cxf.rs.security.oauth2.jwe;
-
-import javax.crypto.Cipher;
-
-public class JweEncryptorWorkerState {
-    private String jweContentStart;
-    private Cipher encryptingCipher;
-    private int authTagLengthBits;
-    
-    public JweEncryptorWorkerState(String jweContentStart, Cipher encryptingCipher, int authTagLengthBits)
{
-        this.jweContentStart = jweContentStart;
-        this.encryptingCipher = encryptingCipher;
-        this.authTagLengthBits = authTagLengthBits;
-    }
-    public Cipher getEncryptingCipher() {
-        return encryptingCipher;
-    }
-    public int getAuthTagLengthBits() {
-        return authTagLengthBits;
-    }
-    public String getJweContentStart() {
-        return jweContentStart;
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/cxf/blob/48b00b30/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/JweOutputStream.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/JweOutputStream.java
b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/JweOutputStream.java
index babe28d..fa954f6 100644
--- a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/JweOutputStream.java
+++ b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/JweOutputStream.java
@@ -34,12 +34,11 @@ public class JweOutputStream extends FilterOutputStream {
     private byte[] lastRawDataChunk;
     private byte[] lastEncryptedDataChunk;
     private boolean flushed;
-    public JweOutputStream(OutputStream out, JweEncryptorWorkerState state) throws IOException
{
+    public JweOutputStream(OutputStream out, Cipher encryptingCipher, int authTagLengthBits)
{
         super(out);
-        this.encryptingCipher = state.getEncryptingCipher();
+        this.encryptingCipher = encryptingCipher;
         this.blockSize = encryptingCipher.getBlockSize(); 
-        this.authTagLengthBits = state.getAuthTagLengthBits();
-        out.write(state.getJweContentStart().getBytes("UTF-8"));
+        this.authTagLengthBits = authTagLengthBits;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cxf/blob/48b00b30/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/jaxrs/JweWriterInterceptor.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/jaxrs/JweWriterInterceptor.java
b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/jaxrs/JweWriterInterceptor.java
index 8459052..7d56d28 100644
--- a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/jaxrs/JweWriterInterceptor.java
+++ b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/jaxrs/JweWriterInterceptor.java
@@ -37,7 +37,6 @@ import org.apache.cxf.jaxrs.utils.JAXRSUtils;
 import org.apache.cxf.jaxrs.utils.ResourceUtils;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.rs.security.oauth2.jwe.JweEncryptor;
-import org.apache.cxf.rs.security.oauth2.jwe.JweEncryptorWorkerState;
 import org.apache.cxf.rs.security.oauth2.jwe.JweHeaders;
 import org.apache.cxf.rs.security.oauth2.jwe.JweOutputStream;
 import org.apache.cxf.rs.security.oauth2.jwe.WrappedKeyJweEncryptor;
@@ -68,8 +67,7 @@ public class JweWriterInterceptor implements WriterInterceptor {
         
         
         if (useJweOutputStream) {
-            JweEncryptorWorkerState state = theEncryptor.newWorkerState(ctString);
-            JweOutputStream jweStream = new JweOutputStream(actualOs, state); 
+            JweOutputStream jweStream = theEncryptor.createJweStream(actualOs, ctString);
             ctx.setOutputStream(jweStream);
             ctx.proceed();
             jweStream.flush();


Mime
View raw message