You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2017/06/22 11:45:35 UTC
[2/2] cxf git commit: [CXF-7420] Renaming JweCompactProducerBuilder
to JweCompactBuilder
[CXF-7420] Renaming JweCompactProducerBuilder to JweCompactBuilder
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/cc6f6e8e
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/cc6f6e8e
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/cc6f6e8e
Branch: refs/heads/3.1.x-fixes
Commit: cc6f6e8e05b9ccf227d45bf532f149c69197c8b8
Parents: df314e5
Author: Sergey Beryozkin <sb...@gmail.com>
Authored: Thu Jun 22 12:43:26 2017 +0100
Committer: Sergey Beryozkin <sb...@gmail.com>
Committed: Thu Jun 22 12:45:17 2017 +0100
----------------------------------------------------------------------
.../jose/jaxrs/JweWriterInterceptor.java | 4 +-
.../jose/jwe/AbstractJweEncryption.java | 2 +-
.../jose/jwe/JweCompactProducerBuilder.java | 129 -------------------
3 files changed, 3 insertions(+), 132 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/cc6f6e8e/rt/rs/security/jose-parent/jose-jaxrs/src/main/java/org/apache/cxf/rs/security/jose/jaxrs/JweWriterInterceptor.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/jose-parent/jose-jaxrs/src/main/java/org/apache/cxf/rs/security/jose/jaxrs/JweWriterInterceptor.java b/rt/rs/security/jose-parent/jose-jaxrs/src/main/java/org/apache/cxf/rs/security/jose/jaxrs/JweWriterInterceptor.java
index 5f34768..981730a 100644
--- a/rt/rs/security/jose-parent/jose-jaxrs/src/main/java/org/apache/cxf/rs/security/jose/jaxrs/JweWriterInterceptor.java
+++ b/rt/rs/security/jose-parent/jose-jaxrs/src/main/java/org/apache/cxf/rs/security/jose/jaxrs/JweWriterInterceptor.java
@@ -38,7 +38,7 @@ import org.apache.cxf.io.CachedOutputStream;
import org.apache.cxf.jaxrs.utils.JAXRSUtils;
import org.apache.cxf.rs.security.jose.common.JoseConstants;
import org.apache.cxf.rs.security.jose.common.JoseUtils;
-import org.apache.cxf.rs.security.jose.jwe.JweCompactProducerBuilder;
+import org.apache.cxf.rs.security.jose.jwe.JweCompactBuilder;
import org.apache.cxf.rs.security.jose.jwe.JweEncryptionInput;
import org.apache.cxf.rs.security.jose.jwe.JweEncryptionOutput;
import org.apache.cxf.rs.security.jose.jwe.JweEncryptionProvider;
@@ -83,7 +83,7 @@ public class JweWriterInterceptor implements WriterInterceptor {
theEncryptionProvider.getEncryptionOutput(new JweEncryptionInput(jweHeaders));
JoseUtils.traceHeaders(encryption.getHeaders());
try {
- JweCompactProducerBuilder.startJweContent(actualOs,
+ JweCompactBuilder.startJweContent(actualOs,
encryption.getHeaders(),
encryption.getContentEncryptionKey(),
encryption.getIv());
http://git-wip-us.apache.org/repos/asf/cxf/blob/cc6f6e8e/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/jwe/AbstractJweEncryption.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/jwe/AbstractJweEncryption.java b/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/jwe/AbstractJweEncryption.java
index 4435fb9..ae2e0b5 100644
--- a/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/jwe/AbstractJweEncryption.java
+++ b/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/jwe/AbstractJweEncryption.java
@@ -76,7 +76,7 @@ public abstract class AbstractJweEncryption implements JweEncryptionProvider {
byte[] encryptedContent = encryptInternal(state, content);
byte[] cipher = getActualCipher(encryptedContent);
byte[] authTag = getAuthenticationTag(state, encryptedContent);
- JweCompactProducerBuilder producer = new JweCompactProducerBuilder(state.protectedHeadersJson,
+ JweCompactBuilder producer = new JweCompactBuilder(state.protectedHeadersJson,
state.jweContentEncryptionKey,
state.theIv,
cipher,
http://git-wip-us.apache.org/repos/asf/cxf/blob/cc6f6e8e/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/jwe/JweCompactProducerBuilder.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/jwe/JweCompactProducerBuilder.java b/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/jwe/JweCompactProducerBuilder.java
deleted file mode 100644
index 93f15bf..0000000
--- a/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/jwe/JweCompactProducerBuilder.java
+++ /dev/null
@@ -1,129 +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.jose.jwe;
-
-import java.io.IOException;
-import java.io.OutputStream;
-
-import org.apache.cxf.common.util.Base64UrlUtility;
-import org.apache.cxf.common.util.StringUtils;
-import org.apache.cxf.jaxrs.json.basic.JsonMapObjectReaderWriter;
-
-
-public class JweCompactProducerBuilder {
- private StringBuilder jweContentBuilder;
- private String encodedEncryptedContent;
- private String encodedAuthTag;
- public JweCompactProducerBuilder(JweHeaders headers,
- byte[] encryptedContentEncryptionKey,
- byte[] cipherInitVector,
- byte[] encryptedContentNoTag,
- byte[] authenticationTag) {
- this(getHeadersJson(headers), encryptedContentEncryptionKey,
- cipherInitVector, encryptedContentNoTag, authenticationTag);
- }
-
- public JweCompactProducerBuilder(String headersJson,
- byte[] encryptedContentEncryptionKey,
- byte[] cipherInitVector,
- byte[] encryptedContentNoTag,
- byte[] authenticationTag) {
- jweContentBuilder = startJweContent(new StringBuilder(), headersJson,
- encryptedContentEncryptionKey, cipherInitVector);
- this.encodedEncryptedContent = Base64UrlUtility.encode(encryptedContentNoTag);
- this.encodedAuthTag = Base64UrlUtility.encode(authenticationTag);
-
- }
-
- public JweCompactProducerBuilder(JweHeaders headers,
- byte[] encryptedContentEncryptionKey,
- byte[] cipherInitVector,
- byte[] encryptedContentWithTag,
- int authTagLengthBits) {
- jweContentBuilder = startJweContent(new StringBuilder(), headers,
- encryptedContentEncryptionKey, cipherInitVector);
- this.encodedEncryptedContent = Base64UrlUtility.encodeChunk(
- encryptedContentWithTag,
- 0,
- encryptedContentWithTag.length - authTagLengthBits / 8);
- this.encodedAuthTag = Base64UrlUtility.encodeChunk(
- encryptedContentWithTag,
- encryptedContentWithTag.length - authTagLengthBits / 8,
- authTagLengthBits / 8);
-
- }
- public static String startJweContent(JweHeaders headers,
- byte[] encryptedContentEncryptionKey,
- byte[] cipherInitVector) {
- return startJweContent(new StringBuilder(),
- headers, encryptedContentEncryptionKey, cipherInitVector).toString();
- }
- public static StringBuilder startJweContent(StringBuilder sb,
- JweHeaders headers,
- byte[] encryptedContentEncryptionKey,
- byte[] cipherInitVector) {
- return startJweContent(sb,
- getHeadersJson(headers),
- encryptedContentEncryptionKey,
- cipherInitVector);
- }
- private static String getHeadersJson(JweHeaders headers) {
- return new JsonMapObjectReaderWriter().toJson(headers);
-
- }
- public static StringBuilder startJweContent(StringBuilder sb,
- String headersJson,
- byte[] encryptedContentEncryptionKey,
- byte[] cipherInitVector) {
- String encodedHeaders = Base64UrlUtility.encode(headersJson);
- String encodedContentEncryptionKey = Base64UrlUtility.encode(encryptedContentEncryptionKey);
- String encodedInitVector = Base64UrlUtility.encode(cipherInitVector);
- sb.append(encodedHeaders)
- .append('.')
- .append(encodedContentEncryptionKey == null ? "" : encodedContentEncryptionKey)
- .append('.')
- .append(encodedInitVector == null ? "" : encodedInitVector)
- .append('.');
- return sb;
- }
-
- public static void startJweContent(OutputStream os,
- JweHeaders headers,
- byte[] encryptedContentEncryptionKey,
- byte[] cipherInitVector) throws IOException {
- byte[] jsonBytes = StringUtils.toBytesUTF8(getHeadersJson(headers));
- Base64UrlUtility.encodeAndStream(jsonBytes, 0, jsonBytes.length, os);
- byte[] dotBytes = new byte[]{'.'};
- os.write(dotBytes);
- Base64UrlUtility.encodeAndStream(encryptedContentEncryptionKey, 0,
- encryptedContentEncryptionKey.length, os);
- os.write(dotBytes);
- Base64UrlUtility.encodeAndStream(cipherInitVector, 0, cipherInitVector.length, os);
- os.write(dotBytes);
- os.flush();
- }
-
- public String getJweContent() {
- return jweContentBuilder.append(encodedEncryptedContent)
- .append('.')
- .append(encodedAuthTag)
- .toString();
- }
-}