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:44:16 UTC
[1/2] cxf git commit: [CXF-7420] Renaming JweCompactProducerBuilder
to JweCompactBuilder
Repository: cxf
Updated Branches:
refs/heads/master 2dc6d0569 -> e9f7d73e6
[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/d34ad648
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/d34ad648
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/d34ad648
Branch: refs/heads/master
Commit: d34ad6485b941698454126d46a378e2099d78446
Parents: 2dc6d05
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:43:26 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/d34ad648/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 bc94db8..68648f4 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/d34ad648/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 37666e5..595948a 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/d34ad648/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();
- }
-}
[2/2] cxf git commit: [CXF-7420] Adding the file
Posted by se...@apache.org.
[CXF-7420] Adding the file
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/e9f7d73e
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/e9f7d73e
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/e9f7d73e
Branch: refs/heads/master
Commit: e9f7d73e6a25b9c8f3236f58dcce3dfd73f97af3
Parents: d34ad64
Author: Sergey Beryozkin <sb...@gmail.com>
Authored: Thu Jun 22 12:44:01 2017 +0100
Committer: Sergey Beryozkin <sb...@gmail.com>
Committed: Thu Jun 22 12:44:01 2017 +0100
----------------------------------------------------------------------
.../rs/security/jose/jwe/JweCompactBuilder.java | 129 +++++++++++++++++++
1 file changed, 129 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/e9f7d73e/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/jwe/JweCompactBuilder.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/jwe/JweCompactBuilder.java b/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/jwe/JweCompactBuilder.java
new file mode 100644
index 0000000..c11322a
--- /dev/null
+++ b/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/jwe/JweCompactBuilder.java
@@ -0,0 +1,129 @@
+/**
+ * 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 JweCompactBuilder {
+ private StringBuilder jweContentBuilder;
+ private String encodedEncryptedContent;
+ private String encodedAuthTag;
+ public JweCompactBuilder(JweHeaders headers,
+ byte[] encryptedContentEncryptionKey,
+ byte[] cipherInitVector,
+ byte[] encryptedContentNoTag,
+ byte[] authenticationTag) {
+ this(getHeadersJson(headers), encryptedContentEncryptionKey,
+ cipherInitVector, encryptedContentNoTag, authenticationTag);
+ }
+
+ public JweCompactBuilder(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 JweCompactBuilder(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();
+ }
+}