[commons-crypto] branch master updated: Add test
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-crypto.git The following commit(s) were added to refs/heads/master by this push: new 6a159f4 Add test 6a159f4 is described below commit 6a159f4ff55c5a2ce7a7b6e16f5467ca59cc2bcd Author: Gary Gregory AuthorDate: Sun Dec 11 20:13:15 2022 -0500 Add test --- .../apache/commons/crypto/jna/OpenSslJnaTest.java | 28 ++ 1 file changed, 28 insertions(+) diff --git a/src/test/java/org/apache/commons/crypto/jna/OpenSslJnaTest.java b/src/test/java/org/apache/commons/crypto/jna/OpenSslJnaTest.java new file mode 100644 index 000..96911e5 --- /dev/null +++ b/src/test/java/org/apache/commons/crypto/jna/OpenSslJnaTest.java @@ -0,0 +1,28 @@ +/* + * 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.commons.crypto.jna; + +import org.junit.jupiter.api.Test; + +public class OpenSslJnaTest { + +@Test +public void testMain() throws Throwable { +OpenSslJna.main(new String[0]); +} +}
[commons-crypto] branch master updated: Javadoc
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-crypto.git The following commit(s) were added to refs/heads/master by this push: new 7b4d5be Javadoc 7b4d5be is described below commit 7b4d5bee79c8ef5c0463fc4b820ea407c6b223ca Author: Gary Gregory AuthorDate: Sun Dec 11 20:10:30 2022 -0500 Javadoc --- .../org/apache/commons/crypto/stream/input/ChannelInput.java | 8 +--- .../java/org/apache/commons/crypto/stream/input/Input.java | 10 +++--- .../org/apache/commons/crypto/stream/input/StreamInput.java| 6 -- .../org/apache/commons/crypto/stream/output/ChannelOutput.java | 6 -- .../java/org/apache/commons/crypto/stream/output/Output.java | 10 +++--- .../org/apache/commons/crypto/stream/output/StreamOutput.java | 6 -- 6 files changed, 31 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/apache/commons/crypto/stream/input/ChannelInput.java b/src/main/java/org/apache/commons/crypto/stream/input/ChannelInput.java index b2f26c0..e820e25 100644 --- a/src/main/java/org/apache/commons/crypto/stream/input/ChannelInput.java +++ b/src/main/java/org/apache/commons/crypto/stream/input/ChannelInput.java @@ -21,10 +21,12 @@ import java.io.IOException; import java.nio.ByteBuffer; import java.nio.channels.ReadableByteChannel; +import org.apache.commons.crypto.stream.CryptoInputStream; + /** - * The ChannelInput class takes a {@code ReadableByteChannel} object and - * wraps it as {@code Input} object acceptable by - * {@code CryptoInputStream}. + * The ChannelInput class takes a {@link ReadableByteChannel} object and + * wraps it as {@link Input} object acceptable by + * {@link CryptoInputStream}. */ public class ChannelInput implements Input { private static final int SKIP_BUFFER_SIZE = 2048; diff --git a/src/main/java/org/apache/commons/crypto/stream/input/Input.java b/src/main/java/org/apache/commons/crypto/stream/input/Input.java index b7d6f92..8e1b605 100644 --- a/src/main/java/org/apache/commons/crypto/stream/input/Input.java +++ b/src/main/java/org/apache/commons/crypto/stream/input/Input.java @@ -19,14 +19,18 @@ package org.apache.commons.crypto.stream.input; import java.io.Closeable; import java.io.IOException; +import java.io.InputStream; import java.nio.ByteBuffer; +import java.nio.channels.ReadableByteChannel; + +import org.apache.commons.crypto.stream.CryptoInputStream; /** * The Input interface abstract the input source of - * {@code CryptoInputStream} so that different implementation of input can + * {@link CryptoInputStream} so that different implementation of input can * be used. The implementation Input interface will usually wraps an input - * mechanism such as {@code InputStream} or - * {@code ReadableByteChannel}. + * mechanism such as {@link InputStream} or + * {@link ReadableByteChannel}. */ public interface Input extends Closeable { /** diff --git a/src/main/java/org/apache/commons/crypto/stream/input/StreamInput.java b/src/main/java/org/apache/commons/crypto/stream/input/StreamInput.java index 38d542c..9dce567 100644 --- a/src/main/java/org/apache/commons/crypto/stream/input/StreamInput.java +++ b/src/main/java/org/apache/commons/crypto/stream/input/StreamInput.java @@ -23,9 +23,11 @@ import java.io.IOException; import java.io.InputStream; import java.nio.ByteBuffer; +import org.apache.commons.crypto.stream.CryptoInputStream; + /** - * The StreamInput class takes a {@code InputStream} object and wraps it as - * {@code Input} object acceptable by {@code CryptoInputStream}. + * The StreamInput class takes a {@link InputStream} object and wraps it as + * {@link Input} object acceptable by {@link CryptoInputStream}. */ public class StreamInput implements Input { diff --git a/src/main/java/org/apache/commons/crypto/stream/output/ChannelOutput.java b/src/main/java/org/apache/commons/crypto/stream/output/ChannelOutput.java index 8f517c8..9fcf3a3 100644 --- a/src/main/java/org/apache/commons/crypto/stream/output/ChannelOutput.java +++ b/src/main/java/org/apache/commons/crypto/stream/output/ChannelOutput.java @@ -21,10 +21,12 @@ import java.io.IOException; import java.nio.ByteBuffer; import java.nio.channels.WritableByteChannel; +import org.apache.commons.crypto.stream.CryptoOutputStream; + /** - * The ChannelOutput class takes a {@code WritableByteChannel} object and + * The ChannelOutput class takes a {@link WritableByteChannel} object and * wraps it as {@code Output} object acceptable by - * {@code CryptoOutputStream} as the output target. + * {@link CryptoOutputStream} as the output target. */ public class ChannelOutput implements Output { diff --git a/src/main/java/org/apache/commons/crypto/stream/output/Output.java b/src/main/java/org/apache/commons/crypto/stream/output/Output.java index 7df87fa..d5ecc35 100644 ---
[commons-crypto] branch master updated: New test, formatting
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-crypto.git The following commit(s) were added to refs/heads/master by this push: new 385f15e New test, formatting 385f15e is described below commit 385f15e87edf1fec47268b60badd4a954ebfa98f Author: Gary Gregory AuthorDate: Sun Dec 11 20:07:00 2022 -0500 New test, formatting --- .../java/org/apache/commons/crypto/Crypto.java | 11 +-- .../java/org/apache/commons/crypto/OsInfo.java | 99 +++--- .../commons/crypto/jna/OpenSslJnaCryptoRandom.java | 16 ++-- .../java/org/apache/commons/crypto/CryptoTest.java | 69 --- .../java/org/apache/commons/crypto/OsInfoTest.java | 30 +++ .../crypto/jna/OpenSslJnaCryptoRandomTest.java | 43 +- 6 files changed, 145 insertions(+), 123 deletions(-) diff --git a/src/main/java/org/apache/commons/crypto/Crypto.java b/src/main/java/org/apache/commons/crypto/Crypto.java index 44c2191..5780129 100644 --- a/src/main/java/org/apache/commons/crypto/Crypto.java +++ b/src/main/java/org/apache/commons/crypto/Crypto.java @@ -30,7 +30,7 @@ import org.apache.commons.crypto.utils.AES; /** * Provides diagnostic information about Commons Crypto and keys for native - * class loading + * class loading. */ public final class Crypto { @@ -49,7 +49,6 @@ public final class Crypto { if (url != null) { try (InputStream inputStream = url.openStream()) { versionData.load(inputStream); -return versionData; } catch (final IOException e) { // NOPMD } } @@ -151,7 +150,7 @@ public final class Crypto { * @throws Exception if getCryptoRandom or getCryptoCipher get error. */ public static void main(final String[] args) throws Exception { -quiet = args.length ==1 && args[0].equals("-q"); +quiet = args.length == 1 && args[0].equals("-q"); info("%s %s", getComponentName(), getComponentVersion()); if (isNativeCodeLoaded()) { info("Native code loaded OK: %s", OpenSslInfoNative.NativeVersion()); @@ -163,16 +162,14 @@ public final class Crypto { info("DLL path: %s", OpenSslInfoNative.DLLPath()); { // CryptoRandom final Properties props = new Properties(); -props.setProperty(CryptoRandomFactory.CLASSES_KEY, - CryptoRandomFactory.RandomProvider.OPENSSL.getClassName()); +props.setProperty(CryptoRandomFactory.CLASSES_KEY, CryptoRandomFactory.RandomProvider.OPENSSL.getClassName()); try (CryptoRandom cryptoRandom = CryptoRandomFactory.getCryptoRandom(props)) { info("Random instance created OK: %s", cryptoRandom); } } { // CryptoCipher final Properties props = new Properties(); -props.setProperty(CryptoCipherFactory.CLASSES_KEY, - CryptoCipherFactory.CipherProvider.OPENSSL.getClassName()); +props.setProperty(CryptoCipherFactory.CLASSES_KEY, CryptoCipherFactory.CipherProvider.OPENSSL.getClassName()); try (CryptoCipher cryptoCipher = CryptoCipherFactory.getCryptoCipher(AES.CTR_NO_PADDING, props)) { info("Cipher %s instance created OK: %s", AES.CTR_NO_PADDING, cryptoCipher); } diff --git a/src/main/java/org/apache/commons/crypto/OsInfo.java b/src/main/java/org/apache/commons/crypto/OsInfo.java index 01cca69..5ec55a6 100644 --- a/src/main/java/org/apache/commons/crypto/OsInfo.java +++ b/src/main/java/org/apache/commons/crypto/OsInfo.java @@ -65,12 +65,6 @@ final class OsInfo { */ static final String PPC64 = "ppc64"; -/** - * The private constructor of {@link OsInfo}. - */ -private OsInfo() { -} - static { // x86 mappings archMapping.put(X86, X86); @@ -110,23 +104,33 @@ final class OsInfo { } /** - * The main method. This is used by the JNI make processing in Makefile.common + * Gets the architecture name. * - * @param args the argv. + * @return the architecture name. */ -public static void main(final String[] args) { -if (args.length >= 1) { -if ("--os".equals(args[0])) { -System.out.print(getOSName()); -return; +static String getArchName() { +// if running Linux on ARM, need to determine ABI of JVM +final String osArch = System.getProperty("os.arch"); +if (osArch.startsWith("arm") && getOsNameProperty().contains("Linux")) { +final String javaHome = System.getProperty("java.home"); +try { +// determine if first JVM found uses ARM hard-float ABI +final String[]
[commons-crypto] 01/02: Format
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-crypto.git commit e56a5ffd2f1c4228e6c3183b61ed1bdb120f5e91 Author: Gary Gregory AuthorDate: Sun Dec 11 18:48:30 2022 -0500 Format --- src/main/java/org/apache/commons/crypto/jna/OpenSslJnaCryptoRandom.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/apache/commons/crypto/jna/OpenSslJnaCryptoRandom.java b/src/main/java/org/apache/commons/crypto/jna/OpenSslJnaCryptoRandom.java index 204bce7..75e5b92 100644 --- a/src/main/java/org/apache/commons/crypto/jna/OpenSslJnaCryptoRandom.java +++ b/src/main/java/org/apache/commons/crypto/jna/OpenSslJnaCryptoRandom.java @@ -172,7 +172,7 @@ class OpenSslJnaCryptoRandom extends Random implements CryptoRandom { */ private void closeRdrandEngine() { -if(rdrandEngine != null) { +if (rdrandEngine != null) { OpenSslNativeJna.ENGINE_finish(rdrandEngine); OpenSslNativeJna.ENGINE_free(rdrandEngine); }
[commons-crypto] 02/02: Address TODOs in package private class
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-crypto.git commit 7ac44567ed446bf8eb5175f2454d2907f53fac0d Author: Gary Gregory AuthorDate: Sun Dec 11 19:40:58 2022 -0500 Address TODOs in package private class --- .../org/apache/commons/crypto/jna/OpenSslNativeJna.java | 13 + 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/apache/commons/crypto/jna/OpenSslNativeJna.java b/src/main/java/org/apache/commons/crypto/jna/OpenSslNativeJna.java index 57929d8..f5ab128 100644 --- a/src/main/java/org/apache/commons/crypto/jna/OpenSslNativeJna.java +++ b/src/main/java/org/apache/commons/crypto/jna/OpenSslNativeJna.java @@ -87,14 +87,12 @@ class OpenSslNativeJna { return JnaImplementation._ENGINE_by_id(string); } -// TODO: native method returns int -public static void ENGINE_finish(final PointerByReference rdrandEngine) { -JnaImplementation._ENGINE_finish(rdrandEngine); +public static int ENGINE_finish(final PointerByReference rdrandEngine) { +return JnaImplementation._ENGINE_finish(rdrandEngine); } -// TODO: native method returns int -public static void ENGINE_free(final PointerByReference rdrandEngine) { -JnaImplementation._ENGINE_free(rdrandEngine); +public static int ENGINE_free(final PointerByReference rdrandEngine) { +return JnaImplementation._ENGINE_free(rdrandEngine); } public static int ENGINE_init(final PointerByReference rdrandEngine) { @@ -105,8 +103,7 @@ class OpenSslNativeJna { return JnaImplementation._ENGINE_set_default(rdrandEngine, eNGINE_METHOD_RAND); } -// TODO: native method expects char[] buffer -public static String ERR_error_string(final NativeLong err, final Object object) { +public static String ERR_error_string(final NativeLong err, final char[] object) { return JnaImplementation._ERR_error_string(err, null); }
[commons-crypto] branch master updated (8391625 -> 7ac4456)
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/commons-crypto.git from 8391625 Make instance variable final new e56a5ff Format new 7ac4456 Address TODOs in package private class The 2 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: .../apache/commons/crypto/jna/OpenSslJnaCryptoRandom.java | 2 +- .../org/apache/commons/crypto/jna/OpenSslNativeJna.java | 13 + 2 files changed, 6 insertions(+), 9 deletions(-)
[commons-scxml] branch dependabot/maven/org.apache.commons-commons-parent-55 created (now 3c9607d)
This is an automated email from the ASF dual-hosted git repository. github-bot pushed a change to branch dependabot/maven/org.apache.commons-commons-parent-55 in repository https://gitbox.apache.org/repos/asf/commons-scxml.git at 3c9607d Bump commons-parent from 54 to 55 No new revisions were added by this update.
[commons-crypto] branch master updated: Make instance variable final
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-crypto.git The following commit(s) were added to refs/heads/master by this push: new 8391625 Make instance variable final 8391625 is described below commit 8391625ee3dc5734695f19a1649652499b8d54b9 Author: Gary Gregory AuthorDate: Sun Dec 11 18:34:34 2022 -0500 Make instance variable final --- .../commons/crypto/random/JavaCryptoRandom.java| 24 +++--- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/apache/commons/crypto/random/JavaCryptoRandom.java b/src/main/java/org/apache/commons/crypto/random/JavaCryptoRandom.java index 13e2538..627532e 100644 --- a/src/main/java/org/apache/commons/crypto/random/JavaCryptoRandom.java +++ b/src/main/java/org/apache/commons/crypto/random/JavaCryptoRandom.java @@ -26,6 +26,10 @@ import org.apache.commons.crypto.utils.Utils; /** * A CryptoRandom of Java implementation. + * + * N.B. this class is not public/protected so does not appear in the main Javadoc Please ensure that property use is documented in the enum + * CryptoRandomFactory.RandomProvider + * */ class JavaCryptoRandom extends Random implements CryptoRandom { @@ -34,7 +38,7 @@ class JavaCryptoRandom extends Random implements CryptoRandom { */ private static final long serialVersionUID = 551747589810050L; -private SecureRandom instance; +private final SecureRandom instance; /** * Constructs a {@link JavaCryptoRandom}. @@ -44,18 +48,14 @@ class JavaCryptoRandom extends Random implements CryptoRandom { * to get the name of the algorithm, with a default of * {@link CryptoRandomFactory#JAVA_ALGORITHM_DEFAULT} */ -// N.B. this class is not public/protected so does not appear in the main Javadoc -// Please ensure that property use is documented in the enum CryptoRandomFactory.RandomProvider public JavaCryptoRandom(final Properties properties) { - try { -instance = SecureRandom -.getInstance(properties -.getProperty( -CryptoRandomFactory.JAVA_ALGORITHM_KEY, -CryptoRandomFactory.JAVA_ALGORITHM_DEFAULT)); - } catch (final NoSuchAlgorithmException e) { -instance = new SecureRandom(); - } +SecureRandom tmp; +try { +tmp = SecureRandom.getInstance(properties.getProperty(CryptoRandomFactory.JAVA_ALGORITHM_KEY, CryptoRandomFactory.JAVA_ALGORITHM_DEFAULT)); +} catch (final NoSuchAlgorithmException e) { +tmp = new SecureRandom(); +} +instance = tmp; } /**
[commons-crypto] branch master updated: Move comment
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-crypto.git The following commit(s) were added to refs/heads/master by this push: new 4ec0dab Move comment 4ec0dab is described below commit 4ec0dab70d0fde34f95e78e5498b8b219084038e Author: Gary Gregory AuthorDate: Sun Dec 11 18:31:02 2022 -0500 Move comment --- src/changes/changes.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index c751156..0a4d7ad 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -62,8 +62,8 @@ - Enhance the quality of JavaCryptoRandom as a subclass of Random by overwriting Random.next(int). + Enhance the quality of JavaCryptoRandom as a subclass of Random by overwriting Random.next(int). Makefile does not recompile objects if local include files are changed License header should be a plain comment #113. Fix PMD warning and don't init to defaults #128.
[commons-crypto] 03/03: Merge branch 'master' of https://gitbox.apache.org/repos/asf/commons-crypto.git
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-crypto.git commit 0e424a2cdc4167e47dc1c929b3eb7a742f7fadc3 Merge: f410436 096b32c Author: Gary Gregory AuthorDate: Sun Dec 11 18:29:04 2022 -0500 Merge branch 'master' of https://gitbox.apache.org/repos/asf/commons-crypto.git src/changes/changes.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
[commons-crypto] 01/03: Add Javadoc archive and security page
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-crypto.git commit fdb4bb86333eb42ac9c9fc9fda61404a9434caa6 Author: Gary Gregory AuthorDate: Sun Dec 11 18:23:07 2022 -0500 Add Javadoc archive and security page --- pom.xml| 2 +- src/site/site.xml | 13 +++-- src/site/xdoc/security.xml | 45 + 3 files changed, 53 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index ae5202a..6730502 100644 --- a/pom.xml +++ b/pom.xml @@ -18,7 +18,7 @@ org.apache.commons commons-parent -54 +55 commons-crypto diff --git a/src/site/site.xml b/src/site/site.xml index 7b1dd23..a669ab0 100644 --- a/src/site/site.xml +++ b/src/site/site.xml @@ -24,12 +24,13 @@ - -https://commons.apache.org/proper/commons-crypto/download_crypto.cgi"/> - - - + +https://commons.apache.org/proper/commons-crypto/download_crypto.cgi"/> + + + +https://javadoc.io/doc/org.apache.commons/commons-crypto/"/> + diff --git a/src/site/xdoc/security.xml b/src/site/xdoc/security.xml new file mode 100644 index 000..e2bffb0 --- /dev/null +++ b/src/site/xdoc/security.xml @@ -0,0 +1,45 @@ + + + + +Apache Commons Crypto Security Reports +Commons Team + + + + +For information about reporting or asking questions about +security, please see the +https://commons.apache.org/security.html;>security page +of the Apache Commons project. + + +This page lists all security vulnerabilities fixed in released versions of this component. + + + +Please note that binary patches are never provided. If you need to apply a source code patch, use the +building instructions for the component version that you are using. + + + +If you need help on building this component or other help on following the instructions to +mitigate the known vulnerabilities listed here, please send your questions to the public +user mailing list. + + + +If you have encountered an unlisted security vulnerability or other unexpected behavior that has security +impact, or if the descriptions here are incomplete, please report them privately to the Apache Security +Team. Thank you. + + + + +
[commons-crypto] 02/03: ONly print init error if there is one
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-crypto.git commit f41043605f5209aa2b9ad66a97020165adb40069 Author: Gary Gregory AuthorDate: Sun Dec 11 18:28:56 2022 -0500 ONly print init error if there is one --- src/main/java/org/apache/commons/crypto/jna/OpenSslJna.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/apache/commons/crypto/jna/OpenSslJna.java b/src/main/java/org/apache/commons/crypto/jna/OpenSslJna.java index 739f1d2..842b298 100644 --- a/src/main/java/org/apache/commons/crypto/jna/OpenSslJna.java +++ b/src/main/java/org/apache/commons/crypto/jna/OpenSslJna.java @@ -81,13 +81,13 @@ public final class OpenSslJna { public static void main(final String[] args) throws Throwable { info("isEnabled(): %s", isEnabled()); final Throwable initialisationError = initialisationError(); -info("initialisationError(): %s", initialisationError); if (initialisationError != null) { +info("initialisationError(): %s", initialisationError); System.err.flush(); // helpful for stack traces to not mix in other output. throw initialisationError; // propagate to make error obvious } -for(int i = 0; i <= 5; i++) { - info("OpenSSLVersion(%d): %s", i, OpenSSLVersion(i)); +for (int i = 0; i <= 5; i++) { +info("OpenSSLVersion(%d): %s", i, OpenSSLVersion(i)); } }
[commons-crypto] branch master updated (096b32c -> 0e424a2)
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/commons-crypto.git from 096b32c Bump commons-parent from 54 to 55 #196 new fdb4bb8 Add Javadoc archive and security page new f410436 ONly print init error if there is one new 0e424a2 Merge branch 'master' of https://gitbox.apache.org/repos/asf/commons-crypto.git The 3 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: .../org/apache/commons/crypto/jna/OpenSslJna.java | 6 +-- src/site/site.xml | 13 --- src/site/xdoc/security.xml | 45 ++ 3 files changed, 55 insertions(+), 9 deletions(-) create mode 100644 src/site/xdoc/security.xml
[commons-text] branch master updated: Bump commons-parent from 54 to 55 #392
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-text.git The following commit(s) were added to refs/heads/master by this push: new 15cb90bc Bump commons-parent from 54 to 55 #392 15cb90bc is described below commit 15cb90bc62cb03e0dc36633c6081fe4bf9cfa3b9 Author: Gary Gregory AuthorDate: Sun Dec 11 16:58:29 2022 -0500 Bump commons-parent from 54 to 55 #392 --- src/changes/changes.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 13a8ef18..3183c82d 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -61,6 +61,7 @@ The type attribute can be add,update,fix,remove. Bump spotbugs from 4.7.2 to 4.7.3 #373. Bump mockito-inline from 4.8.0 to 4.9.0 #380, #389. Bump jmh.version from 1.35 to 1.36 #388. +Bump commons-parent from 54 to 55 #392.
[commons-text] branch master updated: Bump commons-parent from 54 to 55 (#392)
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-text.git The following commit(s) were added to refs/heads/master by this push: new 8f17f106 Bump commons-parent from 54 to 55 (#392) 8f17f106 is described below commit 8f17f1069b237a61dd74e7a1f6ea18f5bb12bdf9 Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> AuthorDate: Sun Dec 11 16:54:37 2022 -0500 Bump commons-parent from 54 to 55 (#392) Bumps [commons-parent](https://github.com/apache/commons-parent) from 54 to 55. - [Release notes](https://github.com/apache/commons-parent/releases) - [Changelog](https://github.com/apache/commons-parent/blob/master/RELEASE-NOTES.txt) - [Commits](https://github.com/apache/commons-parent/commits) --- updated-dependencies: - dependency-name: org.apache.commons:commons-parent dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5cebfe41..80f3dff2 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ org.apache.commons commons-parent -54 +55 commons-text 1.10.1-SNAPSHOT
[commons-csv] branch master updated: Bump commons-parent from 54 to 55 #288
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-csv.git The following commit(s) were added to refs/heads/master by this push: new 4319feb0 Bump commons-parent from 54 to 55 #288 4319feb0 is described below commit 4319feb07ab02d1cf0294d69389920209218d74b Author: Gary Gregory AuthorDate: Sun Dec 11 16:52:30 2022 -0500 Bump commons-parent from 54 to 55 #288 --- src/changes/changes.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 3f8c8b75..c72afafb 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -66,7 +66,7 @@ Bump actions/checkout from 2.3.4 to 3.1.0 #188, #195, #220, #272. Bump actions/setup-java from 2 to 3.5.1. Bump actions/upload-artifact from 3.1.0 to 3.1.1 #280. - Bump commons-parent from 52 to 54 #264. + Bump commons-parent from 52 to 55 #264, #288. Bump checkstyle from 8.44 to 9.2.1 #180, #190, #194, #202, #207. Bump junit-jupiter from 5.8.0-M1 to 5.9.1 #179, #186, #201, #244, #263. Bump jmh-core from 1.32 to 1.36 #176, #208, #229, #285.
[commons-csv] branch master updated (5158d7eb -> dea2165e)
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/commons-csv.git from 5158d7eb Merge pull request #287 from apache/dependabot/github_actions/actions/setup-java-3.8.0 add a716828e Bump commons-parent from 54 to 55 add dea2165e Merge pull request #288 from apache/dependabot/maven/org.apache.commons-commons-parent-55 No new revisions were added by this update. Summary of changes: pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
[commons-pool] branch dependabot/maven/org.apache.commons-commons-parent-55 created (now ceaa3783)
This is an automated email from the ASF dual-hosted git repository. github-bot pushed a change to branch dependabot/maven/org.apache.commons-commons-parent-55 in repository https://gitbox.apache.org/repos/asf/commons-pool.git at ceaa3783 Bump commons-parent from 54 to 55 No new revisions were added by this update.
[commons-text] branch dependabot/maven/org.apache.commons-commons-parent-55 created (now 931fb9b4)
This is an automated email from the ASF dual-hosted git repository. github-bot pushed a change to branch dependabot/maven/org.apache.commons-commons-parent-55 in repository https://gitbox.apache.org/repos/asf/commons-text.git at 931fb9b4 Bump commons-parent from 54 to 55 No new revisions were added by this update.
[commons-csv] branch dependabot/maven/org.apache.commons-commons-parent-55 created (now a716828e)
This is an automated email from the ASF dual-hosted git repository. github-bot pushed a change to branch dependabot/maven/org.apache.commons-commons-parent-55 in repository https://gitbox.apache.org/repos/asf/commons-csv.git at a716828e Bump commons-parent from 54 to 55 No new revisions were added by this update.
[commons-crypto] branch master updated: Bump commons-parent from 54 to 55 #196
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-crypto.git The following commit(s) were added to refs/heads/master by this push: new 096b32c Bump commons-parent from 54 to 55 #196 096b32c is described below commit 096b32c54ae5ca9a97301a1e762bbafca8530dea Author: Gary Gregory AuthorDate: Sun Dec 11 15:35:09 2022 -0500 Bump commons-parent from 54 to 55 #196 --- src/changes/changes.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index b6d8c7d..c751156 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -95,7 +95,7 @@ Bump pmd from 6.44.0 to 6.52.0. Bump taglist-maven-plugin from 2.4 to 3.0.0 #147. Bump spotbugs-maven-plugin from 4.5.3.0 to 4.7.3.0 #152, #160, #168, #174, #179, #189, #193. - Bump commons-parent from 52 to 54 #182 + Bump commons-parent from 52 to 55 #182, #196. Bump commons.surefire.version from 3.0.0-M5 to 3.0.0-M7. Bump maven-resources-plugin from 3.2.0 to 3.3.0 #172. Bump jaxb-impl from 2.3.6 to 2.3.7.
[commons-crypto] branch master updated: Bump commons-parent from 54 to 55 (#196)
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-crypto.git The following commit(s) were added to refs/heads/master by this push: new 8c413d4 Bump commons-parent from 54 to 55 (#196) 8c413d4 is described below commit 8c413d47a9dc869c83d422eae8820b3fbf8d0d42 Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> AuthorDate: Sun Dec 11 15:33:50 2022 -0500 Bump commons-parent from 54 to 55 (#196) Bumps [commons-parent](https://github.com/apache/commons-parent) from 54 to 55. - [Release notes](https://github.com/apache/commons-parent/releases) - [Changelog](https://github.com/apache/commons-parent/blob/master/RELEASE-NOTES.txt) - [Commits](https://github.com/apache/commons-parent/commits) --- updated-dependencies: - dependency-name: org.apache.commons:commons-parent dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ae5202a..6730502 100644 --- a/pom.xml +++ b/pom.xml @@ -18,7 +18,7 @@ org.apache.commons commons-parent -54 +55 commons-crypto
[commons-crypto] branch dependabot/maven/org.apache.commons-commons-parent-55 created (now b69e37e)
This is an automated email from the ASF dual-hosted git repository. github-bot pushed a change to branch dependabot/maven/org.apache.commons-commons-parent-55 in repository https://gitbox.apache.org/repos/asf/commons-crypto.git at b69e37e Bump commons-parent from 54 to 55 No new revisions were added by this update.
[commons-bcel] branch master updated: Bump commons-parent from 54 to 55 #189
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-bcel.git The following commit(s) were added to refs/heads/master by this push: new 137808f8 Bump commons-parent from 54 to 55 #189 137808f8 is described below commit 137808f891f7423d6d14a7765d2284aacf3ad41f Author: Gary Gregory AuthorDate: Sun Dec 11 13:03:50 2022 -0500 Bump commons-parent from 54 to 55 #189 --- src/changes/changes.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index c55e979f..611c1bf1 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -68,6 +68,7 @@ The type attribute can be add,update,fix,remove. When parsing an class with an invalid constant reference, ensure ClassParser.parse() throws ClassFormatException, not NullPointerException. Ensure that references to a constant pool entry with index zero trigger a ClassFormatException, not a NullPointerException. + Bump commons-parent from 54 to 55 #189.
[commons-bcel] branch master updated: Bump commons-parent from 54 to 55 (#189)
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-bcel.git The following commit(s) were added to refs/heads/master by this push: new 329d3321 Bump commons-parent from 54 to 55 (#189) 329d3321 is described below commit 329d3321e66372f4aa334cb335ac6874a5b8ca20 Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> AuthorDate: Sun Dec 11 13:00:22 2022 -0500 Bump commons-parent from 54 to 55 (#189) Bumps [commons-parent](https://github.com/apache/commons-parent) from 54 to 55. - [Release notes](https://github.com/apache/commons-parent/releases) - [Changelog](https://github.com/apache/commons-parent/blob/master/RELEASE-NOTES.txt) - [Commits](https://github.com/apache/commons-parent/commits) --- updated-dependencies: - dependency-name: org.apache.commons:commons-parent dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7231153c..2f1da017 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ org.apache.commons commons-parent -54 +55 org.apache.bcel
[commons-crypto] branch master updated: PositionedCryptoInputStream does not close its CryptoCipher instances
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-crypto.git The following commit(s) were added to refs/heads/master by this push: new 34a37c9 PositionedCryptoInputStream does not close its CryptoCipher instances 34a37c9 is described below commit 34a37c9d27dc77d3fbccc9ef996dc7b28bb74315 Author: Gary Gregory AuthorDate: Sun Dec 11 12:33:34 2022 -0500 PositionedCryptoInputStream does not close its CryptoCipher instances --- src/changes/changes.xml| 3 ++- .../crypto/stream/PositionedCryptoInputStream.java | 18 -- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index ad0a889..b6d8c7d 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -61,7 +61,7 @@ --> - + Enhance the quality of JavaCryptoRandom as a subclass of Random by overwriting Random.next(int). Makefile does not recompile objects if local include files are changed @@ -72,6 +72,7 @@ Fix build on Java 11. Fix build on Java 17. Minor improvement #115, #125. + PositionedCryptoInputStream does not close its CryptoCipher instances. Add github/codeql-action 2 #159. Add AES utility class. diff --git a/src/main/java/org/apache/commons/crypto/stream/PositionedCryptoInputStream.java b/src/main/java/org/apache/commons/crypto/stream/PositionedCryptoInputStream.java index 632a552..5a180fb 100644 --- a/src/main/java/org/apache/commons/crypto/stream/PositionedCryptoInputStream.java +++ b/src/main/java/org/apache/commons/crypto/stream/PositionedCryptoInputStream.java @@ -136,13 +136,25 @@ public class PositionedCryptoInputStream extends CtrCryptoInputStream { } /** Cleans direct buffer pool */ -private void cleanBufferPool() { +private void cleanByteBufferPool() { ByteBuffer buf; while ((buf = byteBufferPool.poll()) != null) { CryptoInputStream.freeDirectBuffer(buf); } } +/** Cleans direct buffer pool */ +private void cleanCipherStatePool() { +CipherState cs; +while ((cs = cipherStatePool.poll()) != null) { +try { +cs.getCryptoCipher().close(); +} catch (IOException ignored) { +// ignore +} +} +} + /** * Overrides the {@link CryptoInputStream#close()}. Closes this input stream * and releases any system resources associated with the stream. @@ -155,7 +167,8 @@ public class PositionedCryptoInputStream extends CtrCryptoInputStream { return; } -cleanBufferPool(); +cleanByteBufferPool(); +cleanCipherStatePool(); super.close(); } @@ -277,6 +290,7 @@ public class PositionedCryptoInputStream extends CtrCryptoInputStream { * @return the CipherState instance. * @throws IOException if an I/O error occurs. */ +@SuppressWarnings("resource") // Caller calls #returnToPool(CipherState) private CipherState getCipherState() throws IOException { CipherState state = cipherStatePool.poll(); return state != null ? state : new CipherState(Utils.getCipherInstance(AES.CTR_NO_PADDING, properties));
[commons-crypto] branch master updated: Reuse own API and use ternary expressions
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-crypto.git The following commit(s) were added to refs/heads/master by this push: new d669943 Reuse own API and use ternary expressions d669943 is described below commit d669943573a9ef2df1f684e32f81ffe1e09b08fd Author: Gary Gregory AuthorDate: Sun Dec 11 12:26:32 2022 -0500 Reuse own API and use ternary expressions --- .../crypto/stream/PositionedCryptoInputStream.java | 352 ++--- .../org/apache/commons/crypto/utils/Utils.java | 4 +- 2 files changed, 170 insertions(+), 186 deletions(-) diff --git a/src/main/java/org/apache/commons/crypto/stream/PositionedCryptoInputStream.java b/src/main/java/org/apache/commons/crypto/stream/PositionedCryptoInputStream.java index a0e7b04..632a552 100644 --- a/src/main/java/org/apache/commons/crypto/stream/PositionedCryptoInputStream.java +++ b/src/main/java/org/apache/commons/crypto/stream/PositionedCryptoInputStream.java @@ -28,7 +28,6 @@ import javax.crypto.Cipher; import javax.crypto.spec.IvParameterSpec; import org.apache.commons.crypto.cipher.CryptoCipher; -import org.apache.commons.crypto.cipher.CryptoCipherFactory; import org.apache.commons.crypto.stream.input.Input; import org.apache.commons.crypto.utils.AES; import org.apache.commons.crypto.utils.IoUtils; @@ -41,15 +40,58 @@ import org.apache.commons.crypto.utils.Utils; */ public class PositionedCryptoInputStream extends CtrCryptoInputStream { +private static class CipherState { + +private final CryptoCipher cryptoCipher; +private boolean reset; + +/** + * Constructs a new instance. + * + * @param cryptoCipher the CryptoCipher instance. + */ +public CipherState(final CryptoCipher cryptoCipher) { +this.cryptoCipher = cryptoCipher; +this.reset = false; +} + +/** + * Gets the CryptoCipher instance. + * + * @return the cipher. + */ +public CryptoCipher getCryptoCipher() { +return cryptoCipher; +} + +/** + * Gets the reset. + * + * @return the value of reset. + */ +public boolean isReset() { +return reset; +} + +/** + * Sets the value of reset. + * + * @param reset the reset. + */ +public void reset(final boolean reset) { +this.reset = reset; +} +} + /** * DirectBuffer pool */ -private final Queue bufferPool = new ConcurrentLinkedQueue<>(); +private final Queue byteBufferPool = new ConcurrentLinkedQueue<>(); /** * CryptoCipher pool */ -private final Queue cipherPool = new ConcurrentLinkedQueue<>(); +private final Queue cipherStatePool = new ConcurrentLinkedQueue<>(); /** * properties for constructing a CryptoCipher @@ -93,62 +135,60 @@ public class PositionedCryptoInputStream extends CtrCryptoInputStream { this.properties = properties; } -/** - * Reads up to the specified number of bytes from a given position within a - * stream and return the number of bytes read. This does not change the - * current offset of the stream, and is thread-safe. - * - * @param buffer the buffer into which the data is read. - * @param length the maximum number of bytes to read. - * @param offset the start offset in the data. - * @param position the offset from the start of the stream. - * @throws IOException if an I/O error occurs. - * @return int the total number of decrypted data bytes read into the - * buffer. - */ -public int read(final long position, final byte[] buffer, final int offset, final int length) -throws IOException { -checkStream(); -final int n = input.read(position, buffer, offset, length); -if (n > 0) { -// This operation does not change the current offset of the file -decrypt(position, buffer, offset, n); +/** Cleans direct buffer pool */ +private void cleanBufferPool() { +ByteBuffer buf; +while ((buf = byteBufferPool.poll()) != null) { +CryptoInputStream.freeDirectBuffer(buf); } -return n; } /** - * Reads the specified number of bytes from a given position within a - * stream. This does not change the current offset of the stream and is - * thread-safe. + * Overrides the {@link CryptoInputStream#close()}. Closes this input stream + * and releases any system resources associated with the stream. * - * @param buffer the buffer into which the data is read. - * @param length the maximum number of bytes to read. - * @param offset the start offset in the data. - * @param position the
[commons-crypto] branch master updated: Add @SuppressWarnings
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-crypto.git The following commit(s) were added to refs/heads/master by this push: new 637d89b Add @SuppressWarnings 637d89b is described below commit 637d89bb1779c1024b7de2660ab32afab9726c86 Author: Gary Gregory AuthorDate: Sun Dec 11 12:12:58 2022 -0500 Add @SuppressWarnings --- .../apache/commons/crypto/cipher/CryptoCipherFactory.java| 10 +++--- .../org/apache/commons/crypto/stream/CryptoInputStream.java | 6 -- .../org/apache/commons/crypto/stream/CryptoOutputStream.java | 2 ++ .../apache/commons/crypto/stream/CtrCryptoInputStream.java | 2 ++ .../apache/commons/crypto/stream/CtrCryptoOutputStream.java | 10 +- .../commons/crypto/stream/PositionedCryptoInputStream.java | 12 +++- 6 files changed, 23 insertions(+), 19 deletions(-) diff --git a/src/main/java/org/apache/commons/crypto/cipher/CryptoCipherFactory.java b/src/main/java/org/apache/commons/crypto/cipher/CryptoCipherFactory.java index 8824b32..e86c969 100644 --- a/src/main/java/org/apache/commons/crypto/cipher/CryptoCipherFactory.java +++ b/src/main/java/org/apache/commons/crypto/cipher/CryptoCipherFactory.java @@ -144,9 +144,7 @@ public class CryptoCipherFactory { * @throws GeneralSecurityException if cipher initialize failed * @throws IllegalArgumentException if no classname(s) were provided */ -public static CryptoCipher getCryptoCipher(final String transformation, final Properties properties) -throws GeneralSecurityException { - +public static CryptoCipher getCryptoCipher(final String transformation, final Properties properties) throws GeneralSecurityException { final List names = Utils.splitClassNames(getCipherClassString(properties), ","); if (names.isEmpty()) { throw new IllegalArgumentException("No classname(s) provided"); @@ -158,8 +156,7 @@ public class CryptoCipherFactory { for (final String klass : names) { try { final Class cls = ReflectionUtils.getClassByName(klass); -cipher = ReflectionUtils.newInstance(cls.asSubclass -(CryptoCipher.class), properties, transformation); +cipher = ReflectionUtils.newInstance(cls.asSubclass(CryptoCipher.class), properties, transformation); break; } catch (final Exception e) { lastException = e; @@ -170,8 +167,7 @@ public class CryptoCipherFactory { if (cipher != null) { return cipher; } -errorMessage.append(" is not available or transformation " + -transformation + " is not supported."); +errorMessage.append(" is not available or transformation " + transformation + " is not supported."); throw new GeneralSecurityException(errorMessage.toString(), lastException); } diff --git a/src/main/java/org/apache/commons/crypto/stream/CryptoInputStream.java b/src/main/java/org/apache/commons/crypto/stream/CryptoInputStream.java index bc5a16e..5c4b46e 100644 --- a/src/main/java/org/apache/commons/crypto/stream/CryptoInputStream.java +++ b/src/main/java/org/apache/commons/crypto/stream/CryptoInputStream.java @@ -49,8 +49,8 @@ import org.apache.commons.crypto.utils.Utils; * */ -public class CryptoInputStream extends InputStream implements -ReadableByteChannel { +public class CryptoInputStream extends InputStream implements ReadableByteChannel { + private final byte[] oneByteBuf = new byte[1]; /** @@ -163,6 +163,7 @@ public class CryptoInputStream extends InputStream implements * @param params the algorithm parameters. * @throws IOException if an I/O error occurs. */ +@SuppressWarnings("resource") // Closing the instance closes the StreamInput protected CryptoInputStream(final InputStream inputStream, final CryptoCipher cipher, final int bufferSize, final Key key, final AlgorithmParameterSpec params) throws IOException { @@ -179,6 +180,7 @@ public class CryptoInputStream extends InputStream implements * @param params the algorithm parameters. * @throws IOException if an I/O error occurs. */ +@SuppressWarnings("resource") // Closing the instance closes the ChannelInput protected CryptoInputStream(final ReadableByteChannel channel, final CryptoCipher cipher, final int bufferSize, final Key key, final AlgorithmParameterSpec params) throws IOException { diff --git a/src/main/java/org/apache/commons/crypto/stream/CryptoOutputStream.java b/src/main/java/org/apache/commons/crypto/stream/CryptoOutputStream.java index 443b2b3..c2e49de 100644 --- a/src/main/java/org/apache/commons/crypto/stream/CryptoOutputStream.java +++
[commons-crypto] 04/08: Javadoc
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-crypto.git commit e7731f4c554157c157ce6e66b5aa5610216dae7f Author: Gary Gregory AuthorDate: Sun Dec 11 11:18:13 2022 -0500 Javadoc --- .../java/org/apache/commons/crypto/stream/output/StreamOutput.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/apache/commons/crypto/stream/output/StreamOutput.java b/src/main/java/org/apache/commons/crypto/stream/output/StreamOutput.java index dd293b4..6803f2b 100644 --- a/src/main/java/org/apache/commons/crypto/stream/output/StreamOutput.java +++ b/src/main/java/org/apache/commons/crypto/stream/output/StreamOutput.java @@ -32,11 +32,10 @@ public class StreamOutput implements Output { private final OutputStream out; /** - * Constructs a {@link org.apache.commons.crypto.stream.output.StreamOutput} - * . + * Constructs a new instance. * * @param out the OutputStream object. - * @param bufferSize the buffersize. + * @param bufferSize the buffer size. */ public StreamOutput(final OutputStream out, final int bufferSize) { this.out = out;
[commons-crypto] branch master updated (4c2fa88 -> 265fc99)
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/commons-crypto.git from 4c2fa88 Minor bullet-proofing new 481b802 Consistent this usage in ctor new 55b11c6 Format new 1e9d484 Javadoc new e7731f4 Javadoc new 3107441 Javadoc and format new 3898a76 Use File constant new 6851bd7 Better use of String API new 265fc99 Better exception message The 8 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: .../apache/commons/crypto/NativeCodeLoader.java| 6 +- .../java/org/apache/commons/crypto/OsInfo.java | 3 +- .../org/apache/commons/crypto/cipher/OpenSsl.java | 65 +- .../commons/crypto/jna/OpenSslJnaCipher.java | 33 +-- .../commons/crypto/stream/input/StreamInput.java | 16 +++--- .../commons/crypto/stream/output/StreamOutput.java | 5 +- 6 files changed, 53 insertions(+), 75 deletions(-)
[commons-crypto] 05/08: Javadoc and format
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-crypto.git commit 3107441f584461cd0e84ffa84165ac0b5a9047c6 Author: Gary Gregory AuthorDate: Sun Dec 11 11:29:26 2022 -0500 Javadoc and format --- .../org/apache/commons/crypto/cipher/OpenSsl.java | 65 +- 1 file changed, 25 insertions(+), 40 deletions(-) diff --git a/src/main/java/org/apache/commons/crypto/cipher/OpenSsl.java b/src/main/java/org/apache/commons/crypto/cipher/OpenSsl.java index c8f3d98..0be781c 100644 --- a/src/main/java/org/apache/commons/crypto/cipher/OpenSsl.java +++ b/src/main/java/org/apache/commons/crypto/cipher/OpenSsl.java @@ -37,6 +37,8 @@ import org.apache.commons.crypto.utils.Utils; */ final class OpenSsl { +private static final String TRANSFORMATION_DELIM = "/"; + // Mode constant defined by OpenSsl JNI public static final int ENCRYPT_MODE = 1; public static final int DECRYPT_MODE = 0; @@ -55,14 +57,11 @@ final class OpenSsl { * @return the Algorithm mode. * @throws NoSuchAlgorithmException if the algorithm is not available. */ -static int get(final String algorithm, final String mode) -throws NoSuchAlgorithmException { +static int get(final String algorithm, final String mode) throws NoSuchAlgorithmException { try { return AlgorithmMode.valueOf(algorithm + "_" + mode).ordinal(); } catch (final Exception e) { -throw new NoSuchAlgorithmException( -"Doesn't support algorithm: " + algorithm -+ " and mode: " + mode); +throw new NoSuchAlgorithmException("Doesn't support algorithm: " + algorithm + " and mode: " + mode); } } } @@ -81,8 +80,7 @@ final class OpenSsl { try { return Padding.valueOf(padding).ordinal(); } catch (final Exception e) { -throw new NoSuchPaddingException("Doesn't support padding: " -+ padding); +throw new NoSuchPaddingException("Doesn't support padding: " + padding); } } } @@ -129,7 +127,7 @@ final class OpenSsl { } /** - * Return an {@code OpenSslCipher} object that implements the specified + * Gets an {@code OpenSslCipher} that implements the specified * transformation. * * @param transformation the name of the transformation, e.g., @@ -148,8 +146,7 @@ final class OpenSsl { throw new IllegalStateException(loadingFailureReason); } final Transform transform = tokenizeTransformation(transformation); -final int algorithmMode = AlgorithmMode.get(transform.algorithm, -transform.mode); +final int algorithmMode = AlgorithmMode.get(transform.algorithm, transform.mode); final int padding = Padding.get(transform.padding); final long context = OpenSslNative.initContext(algorithmMode, padding); return new OpenSsl(context, algorithmMode, padding); @@ -188,42 +185,38 @@ final class OpenSsl { throw new NoSuchAlgorithmException("No transformation given."); } -/* - * Array containing the components of a Cipher transformation: index 0: - * algorithm (e.g., AES) index 1: mode (e.g., CTR) index 2: padding - * (e.g., NoPadding) - */ +// +// Array containing the components of a Cipher transformation: index 0: +// algorithm (e.g., AES) index 1: mode (e.g., CTR) index 2: padding +// (e.g., NoPadding) +// final String[] parts = new String[3]; int count = 0; -final StringTokenizer parser = new StringTokenizer(transformation, "/"); +final StringTokenizer parser = new StringTokenizer(transformation, TRANSFORMATION_DELIM); while (parser.hasMoreTokens() && count < 3) { parts[count++] = parser.nextToken().trim(); } if (count != 3 || parser.hasMoreTokens()) { -throw new NoSuchAlgorithmException( -"Invalid transformation format: " + transformation); +throw new NoSuchAlgorithmException("Invalid transformation format: " + transformation); } return new Transform(parts[0], parts[1], parts[2]); } /** - * Initialize this cipher with a key and IV. + * Initializes this cipher with a key and IV. * * @param mode {@link #ENCRYPT_MODE} or {@link #DECRYPT_MODE} * @param key crypto key * @param params the algorithm parameters * @throws InvalidAlgorithmParameterException if IV length is wrong */ -public void init(final int mode, final byte[] key, final AlgorithmParameterSpec params) -throws
[commons-crypto] 08/08: Better exception message
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-crypto.git commit 265fc991efdfba0b76bac350b3174f446b7f67f3 Author: Gary Gregory AuthorDate: Sun Dec 11 11:50:42 2022 -0500 Better exception message --- src/main/java/org/apache/commons/crypto/cipher/OpenSsl.java | 4 ++-- src/main/java/org/apache/commons/crypto/jna/OpenSslJnaCipher.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/apache/commons/crypto/cipher/OpenSsl.java b/src/main/java/org/apache/commons/crypto/cipher/OpenSsl.java index 0be781c..415677e 100644 --- a/src/main/java/org/apache/commons/crypto/cipher/OpenSsl.java +++ b/src/main/java/org/apache/commons/crypto/cipher/OpenSsl.java @@ -61,7 +61,7 @@ final class OpenSsl { try { return AlgorithmMode.valueOf(algorithm + "_" + mode).ordinal(); } catch (final Exception e) { -throw new NoSuchAlgorithmException("Doesn't support algorithm: " + algorithm + " and mode: " + mode); +throw new NoSuchAlgorithmException("Algorithm not supported: " + algorithm + " and mode: " + mode); } } } @@ -80,7 +80,7 @@ final class OpenSsl { try { return Padding.valueOf(padding).ordinal(); } catch (final Exception e) { -throw new NoSuchPaddingException("Doesn't support padding: " + padding); +throw new NoSuchPaddingException("Algorithm not supported: " + padding); } } } diff --git a/src/main/java/org/apache/commons/crypto/jna/OpenSslJnaCipher.java b/src/main/java/org/apache/commons/crypto/jna/OpenSslJnaCipher.java index 88a72b2..4af27f8 100644 --- a/src/main/java/org/apache/commons/crypto/jna/OpenSslJnaCipher.java +++ b/src/main/java/org/apache/commons/crypto/jna/OpenSslJnaCipher.java @@ -405,7 +405,7 @@ class OpenSslJnaCipher implements CryptoCipher { try { return AlgorithmMode.valueOf(algorithm + "_" + mode); } catch (final Exception e) { -throw new NoSuchAlgorithmException("Doesn't support algorithm: " + algorithm + " and mode: " + mode); +throw new NoSuchAlgorithmException("Algorithm not supported: " + algorithm + " and mode: " + mode); } } } @@ -427,7 +427,7 @@ class OpenSslJnaCipher implements CryptoCipher { try { return Padding.valueOf(padding).ordinal(); } catch (final Exception e) { -throw new NoSuchPaddingException("Doesn't support padding: " + padding); +throw new NoSuchPaddingException("Algorithm not supported: " + padding); } } }
[commons-crypto] 03/08: Javadoc
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-crypto.git commit 1e9d4842524d21f4fb96c1c05b5ecf6f44da4a89 Author: Gary Gregory AuthorDate: Sun Dec 11 11:15:44 2022 -0500 Javadoc --- src/main/java/org/apache/commons/crypto/stream/input/StreamInput.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/apache/commons/crypto/stream/input/StreamInput.java b/src/main/java/org/apache/commons/crypto/stream/input/StreamInput.java index b617c96..38d542c 100644 --- a/src/main/java/org/apache/commons/crypto/stream/input/StreamInput.java +++ b/src/main/java/org/apache/commons/crypto/stream/input/StreamInput.java @@ -36,8 +36,8 @@ public class StreamInput implements Input { /** * Constructs a {@link org.apache.commons.crypto.stream.input.StreamInput}. * - * @param inputStream the inputstream object. - * @param bufferSize the buffersize. + * @param inputStream the InputStream object. + * @param bufferSize the buffer size. */ public StreamInput(final InputStream inputStream, final int bufferSize) { this.in = inputStream;
[commons-crypto] 06/08: Use File constant
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-crypto.git commit 3898a76f5975472ff671c934fdca77a2c408fb76 Author: Gary Gregory AuthorDate: Sun Dec 11 11:35:01 2022 -0500 Use File constant --- src/main/java/org/apache/commons/crypto/NativeCodeLoader.java | 6 +++--- src/main/java/org/apache/commons/crypto/OsInfo.java | 3 ++- src/main/java/org/apache/commons/crypto/jna/OpenSslJnaCipher.java | 3 ++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/apache/commons/crypto/NativeCodeLoader.java b/src/main/java/org/apache/commons/crypto/NativeCodeLoader.java index 2808345..83da968 100644 --- a/src/main/java/org/apache/commons/crypto/NativeCodeLoader.java +++ b/src/main/java/org/apache/commons/crypto/NativeCodeLoader.java @@ -135,7 +135,7 @@ final class NativeCodeLoader { */ private static File extractLibraryFile(final String libFolderForCurrentOS, final String libraryFileName, final String targetFolder) { -final String nativeLibraryFilePath = libFolderForCurrentOS + "/" + libraryFileName; +final String nativeLibraryFilePath = libFolderForCurrentOS + File.separator + libraryFileName; // Attach UUID to the native library file to ensure multiple class loaders // can read the libcommons-crypto multiple times. @@ -214,10 +214,10 @@ final class NativeCodeLoader { // Load an OS-dependent native library inside a jar file nativeLibraryPath = "/org/apache/commons/crypto/native/" + OsInfo.getNativeLibFolderPathForCurrentOS(); -boolean hasNativeLib = hasResource(nativeLibraryPath + "/" + nativeLibraryName); +boolean hasNativeLib = hasResource(nativeLibraryPath + File.separator + nativeLibraryName); if (!hasNativeLib) { final String altName = "libcommons-crypto.jnilib"; -if (OsInfo.getOSName().equals("Mac") && hasResource(nativeLibraryPath + "/" + altName)) { +if (OsInfo.getOSName().equals("Mac") && hasResource(nativeLibraryPath + File.separator + altName)) { // Fix for openjdk7 for Mac nativeLibraryName = altName; hasNativeLib = true; diff --git a/src/main/java/org/apache/commons/crypto/OsInfo.java b/src/main/java/org/apache/commons/crypto/OsInfo.java index c2a7cca..01cca69 100644 --- a/src/main/java/org/apache/commons/crypto/OsInfo.java +++ b/src/main/java/org/apache/commons/crypto/OsInfo.java @@ -17,6 +17,7 @@ */ package org.apache.commons.crypto; +import java.io.File; import java.io.IOException; import java.util.HashMap; import java.util.Locale; @@ -134,7 +135,7 @@ final class OsInfo { * @return the current OS's native lib folder. */ static String getNativeLibFolderPathForCurrentOS() { -return getOSName() + "/" + getArchName(); +return getOSName() + File.separator + getArchName(); } /** diff --git a/src/main/java/org/apache/commons/crypto/jna/OpenSslJnaCipher.java b/src/main/java/org/apache/commons/crypto/jna/OpenSslJnaCipher.java index acf46ca..fad80dd 100644 --- a/src/main/java/org/apache/commons/crypto/jna/OpenSslJnaCipher.java +++ b/src/main/java/org/apache/commons/crypto/jna/OpenSslJnaCipher.java @@ -46,6 +46,7 @@ import com.sun.jna.ptr.PointerByReference; */ class OpenSslJnaCipher implements CryptoCipher { +private static final String TRANSFORMATION_DELIM = "/"; private PointerByReference algo; private final PointerByReference context; private final AlgorithmMode algMode; @@ -382,7 +383,7 @@ class OpenSslJnaCipher implements CryptoCipher { */ final String[] parts = new String[3]; int count = 0; -final StringTokenizer parser = new StringTokenizer(transformation, "/"); +final StringTokenizer parser = new StringTokenizer(transformation, TRANSFORMATION_DELIM); while (parser.hasMoreTokens() && count < 3) { parts[count++] = parser.nextToken().trim(); }
[commons-crypto] 07/08: Better use of String API
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-crypto.git commit 6851bd7f5a3cfdd1b641aa17582a181694f6f968 Author: Gary Gregory AuthorDate: Sun Dec 11 11:45:47 2022 -0500 Better use of String API --- .../commons/crypto/jna/OpenSslJnaCipher.java | 30 +- 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/src/main/java/org/apache/commons/crypto/jna/OpenSslJnaCipher.java b/src/main/java/org/apache/commons/crypto/jna/OpenSslJnaCipher.java index fad80dd..88a72b2 100644 --- a/src/main/java/org/apache/commons/crypto/jna/OpenSslJnaCipher.java +++ b/src/main/java/org/apache/commons/crypto/jna/OpenSslJnaCipher.java @@ -26,7 +26,6 @@ import java.security.NoSuchAlgorithmException; import java.security.spec.AlgorithmParameterSpec; import java.util.Objects; import java.util.Properties; -import java.util.StringTokenizer; import javax.crypto.BadPaddingException; import javax.crypto.Cipher; @@ -46,7 +45,6 @@ import com.sun.jna.ptr.PointerByReference; */ class OpenSslJnaCipher implements CryptoCipher { -private static final String TRANSFORMATION_DELIM = "/"; private PointerByReference algo; private final PointerByReference context; private final AlgorithmMode algMode; @@ -159,8 +157,7 @@ class OpenSslJnaCipher implements CryptoCipher { @Override public int update(final ByteBuffer inBuffer, final ByteBuffer outBuffer) throws ShortBufferException { final int[] outlen = new int[1]; -final int retVal = OpenSslNativeJna.EVP_CipherUpdate(context, outBuffer, outlen, inBuffer, -inBuffer.remaining()); +final int retVal = OpenSslNativeJna.EVP_CipherUpdate(context, outBuffer, outlen, inBuffer, inBuffer.remaining()); throwOnError(retVal); final int len = outlen[0]; inBuffer.position(inBuffer.limit()); @@ -262,6 +259,7 @@ class OpenSslJnaCipher implements CryptoCipher { * such as AEAD (GCM). If this opensslEngine is operating in either GCM mode, * all AAD must be supplied before beginning operations on the ciphertext (via * the {@code update} and {@code doFinal} methods). + * * * @param aad the buffer containing the Additional Authentication Data * @@ -291,6 +289,7 @@ class OpenSslJnaCipher implements CryptoCipher { * such as AEAD (GCM). If this opensslEngine is operating in either GCM mode, * all AAD must be supplied before beginning operations on the ciphertext (via * the {@code update} and {@code doFinal} methods). + * * * @param aad the buffer containing the Additional Authentication Data * @@ -323,7 +322,7 @@ class OpenSslJnaCipher implements CryptoCipher { // Freeing the context multiple times causes a JVM crash // A work-round is to only free it at finalize time // TODO is that sufficient? -//OpenSslNativeJna.EVP_CIPHER_CTX_free(context); +// OpenSslNativeJna.EVP_CIPHER_CTX_free(context); } } @@ -365,7 +364,7 @@ class OpenSslJnaCipher implements CryptoCipher { } /** - * Tokenize the transformation. + * Tokenizes a transformation. * * @param transformation current transformation * @return the Transform @@ -376,18 +375,13 @@ class OpenSslJnaCipher implements CryptoCipher { throw new NoSuchAlgorithmException("No transformation given."); } -/* - * Array containing the components of a Cipher transformation: index 0: - * algorithm (e.g., AES) index 1: mode (e.g., CTR) index 2: padding (e.g., - * NoPadding) - */ -final String[] parts = new String[3]; -int count = 0; -final StringTokenizer parser = new StringTokenizer(transformation, TRANSFORMATION_DELIM); -while (parser.hasMoreTokens() && count < 3) { -parts[count++] = parser.nextToken().trim(); -} -if (count != 3 || parser.hasMoreTokens()) { +// +// Array containing the components of a Cipher transformation: index 0: +// algorithm (e.g., AES) index 1: mode (e.g., CTR) index 2: padding (e.g., +// NoPadding) +// +final String[] parts = transformation.split("/", 4); +if (parts.length != 3) { throw new NoSuchAlgorithmException("Invalid transformation format: " + transformation); } return new Transform(parts[0], parts[1], parts[2]);
[commons-crypto] 01/08: Consistent this usage in ctor
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-crypto.git commit 481b802a663095897fabc3eebf6f1dfdf2af1143 Author: Gary Gregory AuthorDate: Sun Dec 11 10:55:10 2022 -0500 Consistent this usage in ctor --- src/main/java/org/apache/commons/crypto/stream/input/StreamInput.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/apache/commons/crypto/stream/input/StreamInput.java b/src/main/java/org/apache/commons/crypto/stream/input/StreamInput.java index 18d468d..94d04ec 100644 --- a/src/main/java/org/apache/commons/crypto/stream/input/StreamInput.java +++ b/src/main/java/org/apache/commons/crypto/stream/input/StreamInput.java @@ -41,7 +41,7 @@ public class StreamInput implements Input { public StreamInput(final InputStream inputStream, final int bufferSize) { this.in = inputStream; this.bufferSize = bufferSize; -buf = new byte[bufferSize]; +this.buf = new byte[bufferSize]; } /**
[commons-crypto] 02/08: Format
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-crypto.git commit 55b11c6574d607df6f5e811e34a14fd40ab232a6 Author: Gary Gregory AuthorDate: Sun Dec 11 11:15:17 2022 -0500 Format --- .../org/apache/commons/crypto/stream/input/StreamInput.java| 10 -- 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/apache/commons/crypto/stream/input/StreamInput.java b/src/main/java/org/apache/commons/crypto/stream/input/StreamInput.java index 94d04ec..b617c96 100644 --- a/src/main/java/org/apache/commons/crypto/stream/input/StreamInput.java +++ b/src/main/java/org/apache/commons/crypto/stream/input/StreamInput.java @@ -28,6 +28,7 @@ import java.nio.ByteBuffer; * {@code Input} object acceptable by {@code CryptoInputStream}. */ public class StreamInput implements Input { + private final byte[] buf; private final int bufferSize; final InputStream in; @@ -127,10 +128,8 @@ public class StreamInput implements Input { * @throws IOException if an I/O error occurs. */ @Override -public int read(final long position, final byte[] buffer, final int offset, final int length) -throws IOException { -throw new UnsupportedOperationException( -"Positioned read is not supported by this implementation"); +public int read(final long position, final byte[] buffer, final int offset, final int length) throws IOException { +throw new UnsupportedOperationException("Positioned read is not supported by this implementation"); } /** @@ -144,8 +143,7 @@ public class StreamInput implements Input { */ @Override public void seek(final long position) throws IOException { -throw new UnsupportedOperationException( -"Seek is not supported by this implementation"); +throw new UnsupportedOperationException("Seek is not supported by this implementation"); } /**
[commons-bcel] branch master updated: Use of File API
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-bcel.git The following commit(s) were added to refs/heads/master by this push: new e6780ebd Use of File API e6780ebd is described below commit e6780ebd86615a970f1735eda6c48775eef5aaec Author: Gary Gregory AuthorDate: Sun Dec 11 11:27:32 2022 -0500 Use of File API --- src/test/java/org/apache/bcel/verifier/VerifyBadClassesTestCase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/org/apache/bcel/verifier/VerifyBadClassesTestCase.java b/src/test/java/org/apache/bcel/verifier/VerifyBadClassesTestCase.java index 152da9ee..46af8c80 100644 --- a/src/test/java/org/apache/bcel/verifier/VerifyBadClassesTestCase.java +++ b/src/test/java/org/apache/bcel/verifier/VerifyBadClassesTestCase.java @@ -185,7 +185,7 @@ public class VerifyBadClassesTestCase { */ private void testVerify(final String directory, final String className) { final String baseDir = "target/test-classes"; -final String testDir = baseDir + (directory.isEmpty() ? "" : "/" + directory); +final String testDir = baseDir + (directory.isEmpty() ? "" : File.separator + directory); final File origFile = new File(testDir, className + ".classx"); final File testFile = new File(testDir, className + JavaClass.EXTENSION);
[commons-bcel] branch master updated: Better use of File API
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-bcel.git The following commit(s) were added to refs/heads/master by this push: new 19fd1f14 Better use of File API 19fd1f14 is described below commit 19fd1f140c6f84b48a6c7a2ecba915c0896c2201 Author: Gary Gregory AuthorDate: Sun Dec 11 11:26:17 2022 -0500 Better use of File API --- src/test/java/org/apache/bcel/verifier/VerifyBadClassesTestCase.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/apache/bcel/verifier/VerifyBadClassesTestCase.java b/src/test/java/org/apache/bcel/verifier/VerifyBadClassesTestCase.java index 688e1737..152da9ee 100644 --- a/src/test/java/org/apache/bcel/verifier/VerifyBadClassesTestCase.java +++ b/src/test/java/org/apache/bcel/verifier/VerifyBadClassesTestCase.java @@ -187,8 +187,8 @@ public class VerifyBadClassesTestCase { final String baseDir = "target/test-classes"; final String testDir = baseDir + (directory.isEmpty() ? "" : "/" + directory); -final File origFile = new File(testDir + "/" + className + ".classx"); -final File testFile = new File(testDir + "/" + className + JavaClass.EXTENSION); +final File origFile = new File(testDir, className + ".classx"); +final File testFile = new File(testDir, className + JavaClass.EXTENSION); if (!origFile.renameTo(testFile)) { fail("Failed to rename orig file");
[commons-crypto] branch master updated: Minor bullet-proofing
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-crypto.git The following commit(s) were added to refs/heads/master by this push: new 4c2fa88 Minor bullet-proofing 4c2fa88 is described below commit 4c2fa88f16b96d150fef4553a4674d23c627e22a Author: Gary Gregory AuthorDate: Sun Dec 11 10:52:59 2022 -0500 Minor bullet-proofing --- .../commons/crypto/stream/CryptoInputStream.java | 42 +++--- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/src/main/java/org/apache/commons/crypto/stream/CryptoInputStream.java b/src/main/java/org/apache/commons/crypto/stream/CryptoInputStream.java index bf939b0..bc5a16e 100644 --- a/src/main/java/org/apache/commons/crypto/stream/CryptoInputStream.java +++ b/src/main/java/org/apache/commons/crypto/stream/CryptoInputStream.java @@ -210,8 +210,7 @@ public class CryptoInputStream extends InputStream implements } inBuffer = ByteBuffer.allocateDirect(this.bufferSize); -outBuffer = ByteBuffer.allocateDirect(this.bufferSize -+ cipher.getBlockSize()); +outBuffer = ByteBuffer.allocateDirect(this.bufferSize + cipher.getBlockSize()); outBuffer.limit(0); initCipher(); @@ -587,26 +586,29 @@ public class CryptoInputStream extends InputStream implements * @param buffer the bytebuffer to be freed. */ static void freeDirectBuffer(final ByteBuffer buffer) { -try { -/* Using reflection to implement sun.nio.ch.DirectBuffer.cleaner() -.clean(); */ -final String SUN_CLASS = "sun.nio.ch.DirectBuffer"; -final Class[] interfaces = buffer.getClass().getInterfaces(); -final Object[] EMPTY_OBJECT_ARRAY = {}; - -for (final Class clazz : interfaces) { -if (clazz.getName().equals(SUN_CLASS)) { -/* DirectBuffer#cleaner() */ -final Method getCleaner = Class.forName(SUN_CLASS).getMethod("cleaner"); -final Object cleaner = getCleaner.invoke(buffer, EMPTY_OBJECT_ARRAY); -/* Cleaner#clean() */ -final Method cleanMethod = Class.forName("sun.misc.Cleaner").getMethod("clean"); -cleanMethod.invoke(cleaner, EMPTY_OBJECT_ARRAY); -return; +if (buffer != null) { +try { +/* + * Using reflection to implement sun.nio.ch.DirectBuffer.cleaner() .clean(); + */ +final String SUN_CLASS = "sun.nio.ch.DirectBuffer"; +final Class[] interfaces = buffer.getClass().getInterfaces(); +final Object[] EMPTY_OBJECT_ARRAY = {}; + +for (final Class clazz : interfaces) { +if (clazz.getName().equals(SUN_CLASS)) { +/* DirectBuffer#cleaner() */ +final Method getCleaner = Class.forName(SUN_CLASS).getMethod("cleaner"); +final Object cleaner = getCleaner.invoke(buffer, EMPTY_OBJECT_ARRAY); +/* Cleaner#clean() */ +final Method cleanMethod = Class.forName("sun.misc.Cleaner").getMethod("clean"); +cleanMethod.invoke(cleaner, EMPTY_OBJECT_ARRAY); +return; +} } +} catch (final ReflectiveOperationException e) { // NOPMD +// Ignore the Reflection exception. } -} catch (final ReflectiveOperationException e) { // NOPMD -// Ignore the Reflection exception. } }
[commons-crypto] branch master updated: Account for spirit of Add isEmpty method check if an String is empty or null. #133 with a new public method
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-crypto.git The following commit(s) were added to refs/heads/master by this push: new 9d62e9d Account for spirit of Add isEmpty method check if an String is empty or null. #133 with a new public method 9d62e9d is described below commit 9d62e9d666a83de00d1d32711549698fb8536341 Author: Gary Gregory AuthorDate: Sun Dec 11 10:51:13 2022 -0500 Account for spirit of Add isEmpty method check if an String is empty or null. #133 with a new public method --- .../java/org/apache/commons/crypto/cipher/JceCipher.java | 14 ++ .../apache/commons/crypto/stream/CryptoInputStream.java| 13 - 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/src/main/java/org/apache/commons/crypto/cipher/JceCipher.java b/src/main/java/org/apache/commons/crypto/cipher/JceCipher.java index 8bdb493..3a81922 100644 --- a/src/main/java/org/apache/commons/crypto/cipher/JceCipher.java +++ b/src/main/java/org/apache/commons/crypto/cipher/JceCipher.java @@ -33,6 +33,10 @@ import javax.crypto.ShortBufferException; /** * Implements the {@link CryptoCipher} using JCE provider. + * + * N.B. this class is not public/protected so does not appear in the main Javadoc. Please ensure that property use is documented in the enum + * CryptoRandomFactory.RandomProvider + * */ class JceCipher implements CryptoCipher { private final Cipher cipher; @@ -44,16 +48,10 @@ class JceCipher implements CryptoCipher { * @param transformation transformation for JCE cipher (algorithm/mode/padding) * @throws GeneralSecurityException if JCE cipher initialize failed */ -// N.B. this class is not public/protected so does not appear in the main Javadoc -// Please ensure that property use is documented in the enum CryptoRandomFactory.RandomProvider public JceCipher(final Properties props, final String transformation) throws GeneralSecurityException { -final String provider = props.getProperty(CryptoCipherFactory.JCE_PROVIDER_KEY); -if (provider == null || provider.isEmpty()) { -cipher = Cipher.getInstance(transformation); -} else { -cipher = Cipher.getInstance(transformation, provider); -} +final String provider = props.getProperty(CryptoCipherFactory.JCE_PROVIDER_KEY, ""); +cipher = provider.isEmpty() ? Cipher.getInstance(transformation) : Cipher.getInstance(transformation, provider); } /** diff --git a/src/main/java/org/apache/commons/crypto/stream/CryptoInputStream.java b/src/main/java/org/apache/commons/crypto/stream/CryptoInputStream.java index 95c0b38..bf939b0 100644 --- a/src/main/java/org/apache/commons/crypto/stream/CryptoInputStream.java +++ b/src/main/java/org/apache/commons/crypto/stream/CryptoInputStream.java @@ -618,11 +618,8 @@ public class CryptoInputStream extends InputStream implements * @return the buffer size. * */ static int getBufferSize(final Properties props) { -final String bufferSizeStr = props.getProperty(CryptoInputStream.STREAM_BUFFER_SIZE_KEY); -if (bufferSizeStr == null || bufferSizeStr.isEmpty()) { -return CryptoInputStream.STREAM_BUFFER_SIZE_DEFAULT; -} -return Integer.parseInt(bufferSizeStr); +final String bufferSizeStr = props.getProperty(CryptoInputStream.STREAM_BUFFER_SIZE_KEY, ""); +return bufferSizeStr.isEmpty() ? CryptoInputStream.STREAM_BUFFER_SIZE_DEFAULT : Integer.parseInt(bufferSizeStr); } /** @@ -631,8 +628,7 @@ public class CryptoInputStream extends InputStream implements * @param cipher the {@link CryptoCipher} instance. * @throws IOException if an I/O error occurs. */ -static void checkStreamCipher(final CryptoCipher cipher) -throws IOException { +static void checkStreamCipher(final CryptoCipher cipher) throws IOException { if (!cipher.getAlgorithm().equals(AES.CTR_NO_PADDING)) { throw new IOException(AES.CTR_NO_PADDING + " is required"); } @@ -648,7 +644,6 @@ public class CryptoInputStream extends InputStream implements static int checkBufferSize(final CryptoCipher cipher, final int bufferSize) { Utils.checkArgument(bufferSize >= CryptoInputStream.MIN_BUFFER_SIZE, "Minimum value of buffer size is " + CryptoInputStream.MIN_BUFFER_SIZE + "."); -return bufferSize - bufferSize -% cipher.getBlockSize(); +return bufferSize - bufferSize % cipher.getBlockSize(); } }
[commons-bcel] branch dependabot/maven/org.apache.commons-commons-parent-55 created (now fa621c98)
This is an automated email from the ASF dual-hosted git repository. github-bot pushed a change to branch dependabot/maven/org.apache.commons-commons-parent-55 in repository https://gitbox.apache.org/repos/asf/commons-bcel.git at fa621c98 Bump commons-parent from 54 to 55 No new revisions were added by this update.
[commons-crypto] branch dependabot/maven/com.sun.xml.bind-jaxb-impl-4.0.1 updated (0576baa -> 6178f5e)
This is an automated email from the ASF dual-hosted git repository. github-bot pushed a change to branch dependabot/maven/com.sun.xml.bind-jaxb-impl-4.0.1 in repository https://gitbox.apache.org/repos/asf/commons-crypto.git discard 0576baa Bump jaxb-impl from 2.3.6 to 4.0.1 add efc1c28 Bump jaxb-impl from 2.3.6 to 2.3.7 add 6178f5e Bump jaxb-impl from 2.3.6 to 4.0.1 This update added new revisions after undoing existing revisions. That is to say, some revisions that were in the old version of the branch are not in the new version. This situation occurs when a user --force pushes a change and generates a repository containing something like this: * -- * -- B -- O -- O -- O (0576baa) \ N -- N -- N refs/heads/dependabot/maven/com.sun.xml.bind-jaxb-impl-4.0.1 (6178f5e) You should already have received notification emails for all of the O revisions, and so the following emails describe only the N revisions from the common base, B. Any revisions marked "omit" are not gone; other references still refer to them. Any revisions marked "discard" are gone forever. No new revisions were added by this update. Summary of changes: src/changes/changes.xml | 1 + 1 file changed, 1 insertion(+)
[commons-crypto] branch master updated: Bump jaxb-impl from 2.3.6 to 2.3.7
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-crypto.git The following commit(s) were added to refs/heads/master by this push: new efc1c28 Bump jaxb-impl from 2.3.6 to 2.3.7 efc1c28 is described below commit efc1c28ac268156e48919f2d17e573af13d19517 Author: Gary Gregory AuthorDate: Sun Dec 11 09:02:44 2022 -0500 Bump jaxb-impl from 2.3.6 to 2.3.7 --- pom.xml | 2 +- src/changes/changes.xml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 18edd4e..ae5202a 100644 --- a/pom.xml +++ b/pom.xml @@ -454,7 +454,7 @@ The following provides more details on the included cryptographic software: com.sun.xml.bind jaxb-impl - 2.3.6 + 2.3.7 diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 0a7e8d3..ad0a889 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -97,6 +97,7 @@ Bump commons-parent from 52 to 54 #182 Bump commons.surefire.version from 3.0.0-M5 to 3.0.0-M7. Bump maven-resources-plugin from 3.2.0 to 3.3.0 #172. + Bump jaxb-impl from 2.3.6 to 2.3.7. Support Galois/Counter Mode (GCM).
[commons-crypto] branch dependabot/maven/com.sun.xml.bind-jaxb-impl-4.0.1 updated (afe93a1 -> 0576baa)
This is an automated email from the ASF dual-hosted git repository. github-bot pushed a change to branch dependabot/maven/com.sun.xml.bind-jaxb-impl-4.0.1 in repository https://gitbox.apache.org/repos/asf/commons-crypto.git discard afe93a1 Bump jaxb-impl from 2.3.6 to 4.0.1 add bcfd8b8 Bump junit-bom from 5.9.0 to 5.9.1 (#183) add c45ea91 Bump junit-bom from 5.9.0 to 5.9.1 #183 add 6d67a8b Bump commons-parent from 53 to 54 (#182) add f67d9b5 Bump commons-parent from 53 to 54 #182 add 01b5700 Drop Clirr property since commons-parent has replaced Clirr with JApiCmp. add 8a147a3 Bump japicmp-maven-plugin from 0.15.7 to 0.16.0 add 99e5889 Bump actions/cache from 3.0.8 to 3.0.9 (#184) add b3467e2 Bump actions/cache from 3.0.8 to 3.0.9 #184 add c774449 Move an entry add 77f1068 Bump actions/setup-java from 3 to 3.5.1 add 7a4d715 Use Java 8 API add 40fa73c GitHub Actions build: no top level permission defined add 485541c Set to level permissions to 'read' add 3925b46 Don't persist credentials unnecessarily add 979f772 Bump spotbugs-maven-plugin from 4.7.2.0 to 4.7.2.1 (#189) add 89facea Bump spotbugs-maven-plugin from 4.7.2.0 to 4.7.2.1 #189 add 92a814b Bump actions/checkout from 3.0.2 to 3.1.0 (#187) add 584c53d Bump actions/checkout from 3.0.2 to 3.1.0 #187 add 755f758 Bump actions/cache from 3.0.9 to 3.0.11 (#188) add a3bcde7 Bump actions/setup-java from 3.5.1 to 3.6.0 (#190) add 4fce0e5 Bump actions/setup-java from 3.5.1 to 3.6.0 #190 add 22b5c3c Bump Scorecards from 1 to 2 add daf21a4 Reuse version of JUnit from parent POM add b1c96d9 Bump actions/upload-artifact from 3.1.0 to 3.1.1 (#192) add b195b92 Bump actions/upload-artifact from 3.1.0 to 3.1.1 #192 add 9710aaf Merge branch 'master' of https://gitbox.apache.org/repos/asf/commons-crypto.git add 3849ca6 Reuse JUnit dependency from parent POM add d35b183 Bump pmd from 6.48.0 to 6.51.0. add 150990d Bump spotbugs-maven-plugin from 4.7.2.1 to 4.7.3.0 (#193) add 6e42421 Bump spotbugs-maven-plugin from 4.7.2.1 to 4.7.3.0 #193 add 38da6ea Bump jmh.version from 1.35 to 1.36 (#194) add 47863c6 Bump jmh.version from 1.35 to 1.36 #194 add 18ddb50 Add GHitHub robots file add 9930483 Bump pmd from 6.51.0 to 6.52.0 add 7ce4638 Lookup key in map only once add 20e845b Bump actions/setup-java from 3.6.0 to 3.7.0 #126 add 6806ad8 Undo Bump actions/setup-java from 3.6.0 to 3.7.0 add ed0bfb4 Bump actions/setup-java from 3.6.0 to 3.8.0 (#195) add 22ad077 Refactor common code add e4b05cb Remove unused imports and clean up add 58ed69f Use try-with-resources add 317f7b2 ubuntu-latest uses OpenSSL 3 which breaks tests add 8e31a74 Use try-with-resources add 6eea05a ubuntu-latest uses OpenSSL 3 which breaks tests add 853c7db Use try-with-resources add 5bd55b5 Use JUnit Assumptions add fa52049 Bump commons.japicmp.version from 0.16.0 to 0.17.1. add ab08594 Bump commons.animal-sniffer.version from 1.20 to 1.22. add ff26c0d Remove useless parens add 9d97ebe Add AES utility class add 8fdf651 Remove unused import add 26c0a43 Document Animal Sniffer failures and revert version bump. add 0576baa Bump jaxb-impl from 2.3.6 to 4.0.1 This update added new revisions after undoing existing revisions. That is to say, some revisions that were in the old version of the branch are not in the new version. This situation occurs when a user --force pushes a change and generates a repository containing something like this: * -- * -- B -- O -- O -- O (afe93a1) \ N -- N -- N refs/heads/dependabot/maven/com.sun.xml.bind-jaxb-impl-4.0.1 (0576baa) You should already have received notification emails for all of the O revisions, and so the following emails describe only the N revisions from the common base, B. Any revisions marked "omit" are not gone; other references still refer to them. Any revisions marked "discard" are gone forever. No new revisions were added by this update. Summary of changes: .gitattributes => .github/GH-ROBOTS.txt| 13 +- .github/workflows/adhoctest.yml| 6 +- .github/workflows/codeql-analysis.yml | 13 +- .github/workflows/coverage.yml | 10 +- .github/workflows/maven.yml| 18 +- .github/workflows/scorecards-analysis.yml | 14 +- pom.xml| 30 +- src/changes/changes.xml| 22 +- .../java/org/apache/commons/crypto/Crypto.java | 6 +- .../java/org/apache/commons/crypto/OsInfo.java | 6 +- .../crypto/jna/OpenSslInterfaceNativeJna.java | 2 +- .../commons/crypto/stream/CryptoInputStream.java | 7 +-
svn commit: r58631 - /dev/commons/commons-parent/55-RC1/
Author: ggregory Date: Sun Dec 11 13:39:52 2022 New Revision: 58631 Log: Remove Apache Commons Parent release candidate Removed: dev/commons/commons-parent/55-RC1/
[commons-parent] annotated tag rel/commons-parent-55 created (now 7d8a1b7)
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a change to annotated tag rel/commons-parent-55 in repository https://gitbox.apache.org/repos/asf/commons-parent.git at 7d8a1b7 (tag) tagging 1a8382d227787216d76c1fea62b641158d0a265e (commit) replaces rel/commons-parent-54 by Gary Gregory on Sun Dec 11 08:34:04 2022 -0500 - Log - Create release tag for Apache Commons Parent release 55. -BEGIN PGP SIGNATURE- iQEzBAABCAAdFiEELbTx7w+nYezE6pNchv3H4qESYssFAmOV3EwACgkQhv3H4qES YssJ9Af9F+zM2JwTNVIGEjLuToGY6ZWxnnK6jnBXyO1HopU40B2uCEqvS5Dy8KbM htmcPNbwpXAUaD4essDN+eVzuvHZFqRGs6InjKqVIH9zKBhjUZD4LXT2f6e2PSDu H3W4XdyAYxX4LYxEHXsEMlYplpS1Yok8AA2C2ld9FZAYyAUOhrOmzTqeofsen/mY vgbrDxiBJXDxDIE9J3QQoqiGL8XqU4ZCMxXJpUhVWJQ4BBkVjixgUvTaESMu/sg5 EQH0k0KFx7x9PKGwqFCwLI64etnmPFMb+1QgnSEOcWOmEiuK97y5sh7uC6fHhzJo Lfub8CLXgl1so7AlNFeV8+rVtSmd2w== =m25S -END PGP SIGNATURE- --- No new revisions were added by this update.
Nexus: Promotion Completed
Message from: https://repository.apache.orgDescription:Release Apache Commons Parent 55Deployer properties:"userAgent" = "Apache-Maven/3.8.6 (Java 1.8.0_352; Mac OS X 13.0.1)""userId" = "ggregory""ip" = "98.180.80.161"Details:The following artifacts have been promoted to the "Releases" [id=releases] repository/org/apache/commons/commons-parent/55/commons-parent-55-cyclonedx.xml.asc(SHA1: 1231990b347f2c491fc937d904d836d38348b5ee)/org/apache/commons/commons-parent/55/commons-parent-55.spdx.json.asc(SHA1: 394ad6d4565f534fd75f48961f6eb3a351cfa5d1)/org/apache/commons/commons-parent/55/commons-parent-55-site.xml.asc(SHA1: 164d4e8e1091affe35b9c61b0b304ee34c8746a1)/org/apache/commons/commons-parent/55/commons-parent-55-cyclonedx.json(SHA1: c8c035c8c0fc668a8004af715a98dd3aebb302b7)/org/apache/commons/commons-parent/55/commons-parent-55.pom.asc(SHA1: 948657ea6b0e82eb4def13aa6059c4e90ba9)/org/apache/commons/commons-parent/55/commons-parent-55.spdx.json(SHA1: 81ed2f2510e25647f20fd7bb4192cb67a27fcd63)/org/apache/commons/commons-parent/55/commons-parent-55-cyclonedx.xml(SHA1: e2051cf42d05f094ee848d80fb713bc13ac314bb)/org/apache/commons/commons-parent/55/commons-parent-55.pom(SHA1: 46dd529e664ea72355b71d230a518bb1be8b755b)/org/apache/commons/commons-parent/55/commons-parent-55-site.xml(SHA1: 953a5c0ecc84b0141007ef3e65c1d0fe8eeb5558)/org/apache/commons/commons-parent/55/commons-parent-55-cyclonedx.json.asc(SHA1: 8db756153dd27bd861bb2f1fb9692f90124dc2ec)Action performed by Gary D. Gregory (ggregory)
svn commit: r58630 - in /release/commons/commons-parent: commons-parent-54-src.tar.gz commons-parent-54-src.tar.gz.asc commons-parent-54-src.tar.gz.sha512 commons-parent-54-src.zip commons-parent-54-s
Author: ggregory Date: Sun Dec 11 13:32:15 2022 New Revision: 58630 Log: Remove previous version Removed: release/commons/commons-parent/commons-parent-54-src.tar.gz release/commons/commons-parent/commons-parent-54-src.tar.gz.asc release/commons/commons-parent/commons-parent-54-src.tar.gz.sha512 release/commons/commons-parent/commons-parent-54-src.zip release/commons/commons-parent/commons-parent-54-src.zip.asc release/commons/commons-parent/commons-parent-54-src.zip.sha512
svn commit: r58629 - /dev/commons/commons-parent/55-RC1/ /dev/commons/commons-parent/55-RC1/source/ /release/commons/commons-parent/
Author: ggregory Date: Sun Dec 11 13:27:28 2022 New Revision: 58629 Log: Publish commons-parent 55 Release Added: release/commons/commons-parent/RELEASE-NOTES.txt - copied unchanged from r58628, dev/commons/commons-parent/55-RC1/RELEASE-NOTES.txt release/commons/commons-parent/commons-parent-55-src.tar.gz - copied unchanged from r58628, dev/commons/commons-parent/55-RC1/source/commons-parent-55-src.tar.gz release/commons/commons-parent/commons-parent-55-src.tar.gz.asc - copied unchanged from r58628, dev/commons/commons-parent/55-RC1/source/commons-parent-55-src.tar.gz.asc release/commons/commons-parent/commons-parent-55-src.tar.gz.sha512 - copied unchanged from r58628, dev/commons/commons-parent/55-RC1/source/commons-parent-55-src.tar.gz.sha512 release/commons/commons-parent/commons-parent-55-src.zip - copied unchanged from r58628, dev/commons/commons-parent/55-RC1/source/commons-parent-55-src.zip release/commons/commons-parent/commons-parent-55-src.zip.asc - copied unchanged from r58628, dev/commons/commons-parent/55-RC1/source/commons-parent-55-src.zip.asc release/commons/commons-parent/commons-parent-55-src.zip.sha512 - copied unchanged from r58628, dev/commons/commons-parent/55-RC1/source/commons-parent-55-src.zip.sha512 Removed: dev/commons/commons-parent/55-RC1/RELEASE-NOTES.txt dev/commons/commons-parent/55-RC1/source/commons-parent-55-src.tar.gz dev/commons/commons-parent/55-RC1/source/commons-parent-55-src.tar.gz.asc dev/commons/commons-parent/55-RC1/source/commons-parent-55-src.tar.gz.sha512 dev/commons/commons-parent/55-RC1/source/commons-parent-55-src.zip dev/commons/commons-parent/55-RC1/source/commons-parent-55-src.zip.asc dev/commons/commons-parent/55-RC1/source/commons-parent-55-src.zip.sha512
[commons-compress] 05/05: Use Files APIs and try-with-resources
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-compress.git commit 8e112661e3b4494b5e6e4371817b9a6e56e5080a Author: Gary Gregory AuthorDate: Sun Dec 11 03:02:36 2022 -0500 Use Files APIs and try-with-resources --- .../apache/commons/compress/AbstractTestCase.java | 15 ++-- .../commons/compress/archivers/ArTestCase.java | 88 ++ .../archivers/ArchiveOutputStreamTest.java | 12 +-- .../commons/compress/archivers/CpioTestCase.java | 12 ++- .../commons/compress/archivers/DumpTestCase.java | 12 +-- .../commons/compress/archivers/JarTestCase.java| 52 ++--- .../commons/compress/archivers/TarTestCase.java| 31 +++- .../commons/compress/archivers/ZipTestCase.java| 20 ++--- .../cpio/CpioArchiveOutputStreamTest.java | 22 +- .../archivers/tar/TarArchiveInputStreamTest.java | 4 +- .../compress/archivers/zip/ExplodeSupportTest.java | 22 +++--- .../commons/compress/archivers/zip/Lister.java | 4 +- .../zip/ParallelScatterZipCreatorTest.java | 19 ++--- .../compress/archivers/zip/Zip64SupportIT.java | 3 +- .../zip/ZipFileIgnoringLocalFileHeaderTest.java| 6 +- .../compress/compressors/BZip2TestCase.java| 35 - .../compress/compressors/DeflateTestCase.java | 22 +++--- .../compress/compressors/FramedSnappyTestCase.java | 21 +++--- .../commons/compress/compressors/GZipTestCase.java | 41 -- .../commons/compress/compressors/LZMATestCase.java | 54 + .../compress/compressors/Pack200TestCase.java | 8 +- .../commons/compress/compressors/ZTestCase.java| 20 ++--- .../brotli/BrotliCompressorInputStreamTest.java| 6 +- .../lz4/BlockLZ4CompressorRoundtripTest.java | 10 +-- .../compress/compressors/lz4/FactoryTest.java | 12 ++- .../lz4/FramedLZ4CompressorRoundtripTest.java | 8 +- .../compressors/pack200/Pack200UtilsTest.java | 37 +++-- .../FramedSnappyCompressorInputStreamTest.java | 47 +++- .../compressors/snappy/SnappyRoundtripTest.java| 14 ++-- .../zstandard/ZstdCompressorInputStreamTest.java | 6 +- .../compressors/zstandard/ZstdRoundtripTest.java | 19 ++--- 31 files changed, 250 insertions(+), 432 deletions(-) diff --git a/src/test/java/org/apache/commons/compress/AbstractTestCase.java b/src/test/java/org/apache/commons/compress/AbstractTestCase.java index 9b4d5f9b..c4fcdc6d 100644 --- a/src/test/java/org/apache/commons/compress/AbstractTestCase.java +++ b/src/test/java/org/apache/commons/compress/AbstractTestCase.java @@ -141,7 +141,7 @@ public abstract class AbstractTestCase { throws IOException, FileNotFoundException { final ArchiveEntry entry = out.createArchiveEntry(infile, filename); out.putArchiveEntry(entry); -IOUtils.copy(infile, out); +Files.copy(infile.toPath(), out); out.closeArchiveEntry(); archiveList.add(filename); } @@ -175,20 +175,17 @@ public abstract class AbstractTestCase { try { ArchiveEntry entry = null; while ((entry = in.getNextEntry()) != null) { -final File outfile = new File(result.getCanonicalPath() + "/result/" -+ entry.getName()); -long copied=0; -if (entry.isDirectory()){ +final File outfile = new File(result.getCanonicalPath() + "/result/" + entry.getName()); +long copied = 0; +if (entry.isDirectory()) { outfile.mkdirs(); } else { outfile.getParentFile().mkdirs(); -try (OutputStream out = Files.newOutputStream(outfile.toPath())) { -copied = IOUtils.copy(in, out); -} +copied = Files.copy(in, outfile.toPath()); } final long size = entry.getSize(); if (size != ArchiveEntry.SIZE_UNKNOWN) { -assertEquals("Entry.size should equal bytes read.",size, copied); +assertEquals("Entry.size should equal bytes read.", size, copied); } if (!outfile.exists()) { diff --git a/src/test/java/org/apache/commons/compress/archivers/ArTestCase.java b/src/test/java/org/apache/commons/compress/archivers/ArTestCase.java index dd1b548c..51641aec 100644 --- a/src/test/java/org/apache/commons/compress/archivers/ArTestCase.java +++ b/src/test/java/org/apache/commons/compress/archivers/ArTestCase.java @@ -47,17 +47,16 @@ public final class ArTestCase extends AbstractTestCase { final File file1 = getFile("test1.xml"); final File file2 = getFile("test2.xml"); -final OutputStream out = Files.newOutputStream(output.toPath()); -final ArchiveOutputStream os =
[commons-compress] 03/05: Replace hack with standard code
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-compress.git commit 32add381d9da3d5c738a1694887f48429e480f7b Author: Gary Gregory AuthorDate: Sun Dec 11 01:51:18 2022 -0500 Replace hack with standard code Fixes serialVersionUID warnings --- .../commons/compress/archivers/ZipTestCase.java| 35 +- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/src/test/java/org/apache/commons/compress/archivers/ZipTestCase.java b/src/test/java/org/apache/commons/compress/archivers/ZipTestCase.java index b053d04f..209d3884 100644 --- a/src/test/java/org/apache/commons/compress/archivers/ZipTestCase.java +++ b/src/test/java/org/apache/commons/compress/archivers/ZipTestCase.java @@ -269,53 +269,46 @@ public final class ZipTestCase extends AbstractTestCase { @Test public void inputStreamStatisticsForBzip2Entry() throws IOException, ArchiveException { -final Map> expected = new HashMap>() {{ -put("lots-of-as", Arrays.asList(42L, 39L)); -}}; +final Map> expected = new HashMap<>(); +expected.put("lots-of-as", Arrays.asList(42L, 39L)); testInputStreamStatistics("bzip2-zip.zip", expected); } @Test public void inputStreamStatisticsForDeflate64Entry() throws IOException, ArchiveException { -final Map> expected = new HashMap>() {{ -put("input2", Arrays.asList(3072L, 2111L)); -}}; +final Map> expected = new HashMap<>(); +expected.put("input2", Arrays.asList(3072L, 2111L)); testInputStreamStatistics("COMPRESS-380/COMPRESS-380.zip", expected); } @Test public void inputStreamStatisticsForImplodedEntry() throws IOException, ArchiveException { -final Map> expected = new HashMap>() {{ -put("LICENSE.TXT", Arrays.asList(11560L, 4131L)); -}}; +final Map> expected = new HashMap<>(); +expected.put("LICENSE.TXT", Arrays.asList(11560L, 4131L)); testInputStreamStatistics("imploding-8Kdict-3trees.zip", expected); } - @Test public void inputStreamStatisticsForShrunkEntry() throws IOException, ArchiveException { -final Map> expected = new HashMap>() {{ -put("TEST1.XML", Arrays.asList(76L, 66L)); -put("TEST2.XML", Arrays.asList(81L, 76L)); -}}; +final Map> expected = new HashMap<>(); +expected.put("TEST1.XML", Arrays.asList(76L, 66L)); +expected.put("TEST2.XML", Arrays.asList(81L, 76L)); testInputStreamStatistics("SHRUNK.ZIP", expected); } @Test public void inputStreamStatisticsForStoredEntry() throws IOException, ArchiveException { -final Map> expected = new HashMap>() {{ -put("test.txt", Arrays.asList(5L, 5L)); -}}; +final Map> expected = new HashMap<>(); +expected.put("test.txt", Arrays.asList(5L, 5L)); testInputStreamStatistics("COMPRESS-264.zip", expected); } @Test public void inputStreamStatisticsOfZipBombExcel() throws IOException, ArchiveException { -final Map> expected = new HashMap>() {{ -put("[Content_Types].xml", Arrays.asList(8390036L, 8600L)); -put("xl/worksheets/sheet1.xml", Arrays.asList(1348L, 508L)); -}}; +final Map> expected = new HashMap<>(); +expected.put("[Content_Types].xml", Arrays.asList(8390036L, 8600L)); +expected.put("xl/worksheets/sheet1.xml", Arrays.asList(1348L, 508L)); testInputStreamStatistics("zipbomb.xlsx", expected); }
[commons-compress] 02/05: Fix spelling
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-compress.git commit 71579a2074e09aee83c0fcdc9e7fe002d49e6d80 Author: Gary Gregory AuthorDate: Sun Dec 11 01:41:36 2022 -0500 Fix spelling --- .../apache/commons/compress/archivers/sevenz/AES256SHA256Decoder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/apache/commons/compress/archivers/sevenz/AES256SHA256Decoder.java b/src/main/java/org/apache/commons/compress/archivers/sevenz/AES256SHA256Decoder.java index 0a77fa6e..827cabc5 100644 --- a/src/main/java/org/apache/commons/compress/archivers/sevenz/AES256SHA256Decoder.java +++ b/src/main/java/org/apache/commons/compress/archivers/sevenz/AES256SHA256Decoder.java @@ -66,7 +66,7 @@ class AES256SHA256Decoder extends AbstractCoder { } /** - * Convenience method that encodes Unicode characters into bytes in UTF-16 (ittle-endian byte order) charset + * Convenience method that encodes Unicode characters into bytes in UTF-16 (little-endian byte order) charset * * @param chars characters to encode * @return encoded characters
[commons-compress] 04/05: Normalize formatting
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-compress.git commit da55b9247936c9bb4d40255443affe7e71ec Author: Gary Gregory AuthorDate: Sun Dec 11 01:51:44 2022 -0500 Normalize formatting --- .../archivers/zip/X5455_ExtendedTimestamp.java | 56 -- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/X5455_ExtendedTimestamp.java b/src/main/java/org/apache/commons/compress/archivers/zip/X5455_ExtendedTimestamp.java index d4a5d36c..b8964682 100644 --- a/src/main/java/org/apache/commons/compress/archivers/zip/X5455_ExtendedTimestamp.java +++ b/src/main/java/org/apache/commons/compress/archivers/zip/X5455_ExtendedTimestamp.java @@ -113,8 +113,9 @@ public class X5455_ExtendedTimestamp implements ZipExtraField, Cloneable, Serial * @return ZipLong */ private static ZipLong dateToZipLong(final Date d) { -if (d == null) { return null; } - +if (d == null) { +return null; +} return unixTimeToZipLong(d.getTime() / 1000); } @@ -124,9 +125,11 @@ public class X5455_ExtendedTimestamp implements ZipExtraField, Cloneable, Serial } return new ZipLong(l); } + private static Date zipLongToDate(final ZipLong unixTime) { return unixTime != null ? new Date(unixTime.getIntValue() * 1000L) : null; } + // The 3 boolean fields (below) come from this flags byte. The remaining 5 bits // are ignored according to the current version of the spec (December 2012). private byte flags; @@ -189,7 +192,9 @@ public class X5455_ExtendedTimestamp implements ZipExtraField, Cloneable, Serial * * @return access time (seconds since epoch) or null. */ -public ZipLong getAccessTime() { return accessTime; } +public ZipLong getAccessTime() { +return accessTime; +} /** * The actual data to put into central directory data - without Header-ID @@ -216,9 +221,7 @@ public class X5455_ExtendedTimestamp implements ZipExtraField, Cloneable, Serial */ @Override public ZipShort getCentralDirectoryLength() { -return new ZipShort(1 + -(bit0_modifyTimePresent ? 4 : 0) -); +return new ZipShort(1 + (bit0_modifyTimePresent ? 4 : 0)); } /** @@ -252,7 +255,9 @@ public class X5455_ExtendedTimestamp implements ZipExtraField, Cloneable, Serial * * @return create time (seconds since epoch) or null. */ -public ZipLong getCreateTime() { return createTime; } +public ZipLong getCreateTime() { +return createTime; +} /** * Gets flags byte. The flags byte tells us which of the @@ -369,7 +374,9 @@ public class X5455_ExtendedTimestamp implements ZipExtraField, Cloneable, Serial * * @return true if bit0 of the flags byte is set. */ -public boolean isBit0_modifyTimePresent() { return bit0_modifyTimePresent; } +public boolean isBit0_modifyTimePresent() { +return bit0_modifyTimePresent; +} /** * Returns whether bit1 of the flags byte is set or not, @@ -378,7 +385,9 @@ public class X5455_ExtendedTimestamp implements ZipExtraField, Cloneable, Serial * * @return true if bit1 of the flags byte is set. */ -public boolean isBit1_accessTimePresent() { return bit1_accessTimePresent; } +public boolean isBit1_accessTimePresent() { +return bit1_accessTimePresent; +} /** * Returns whether bit2 of the flags byte is set or not, @@ -387,16 +396,16 @@ public class X5455_ExtendedTimestamp implements ZipExtraField, Cloneable, Serial * * @return true if bit2 of the flags byte is set. */ -public boolean isBit2_createTimePresent() { return bit2_createTimePresent; } +public boolean isBit2_createTimePresent() { +return bit2_createTimePresent; +} /** * Doesn't do anything special since this class always uses the * same parsing logic for both central directory and local file data. */ @Override -public void parseFromCentralDirectoryData( -final byte[] buffer, final int offset, final int length -) throws ZipException { +public void parseFromCentralDirectoryData(final byte[] buffer, final int offset, final int length) throws ZipException { reset(); parseFromLocalFileData(buffer, offset, length); } @@ -410,9 +419,7 @@ public class X5455_ExtendedTimestamp implements ZipExtraField, Cloneable, Serial * @throws java.util.zip.ZipException on error */ @Override -public void parseFromLocalFileData( -final byte[] data, int offset, final int length -) throws ZipException { +public void parseFromLocalFileData(final byte[] data, int offset,
[commons-compress] branch master updated (01bfe335 -> 8e112661)
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/commons-compress.git from 01bfe335 Remove unused imports new f5a37de3 Sort members new 71579a20 Fix spelling new 32add381 Replace hack with standard code new da55b924 Normalize formatting new 8e112661 Use Files APIs and try-with-resources The 5 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: .../commons/compress/MemoryLimitException.java | 16 +- .../commons/compress/archivers/ArchiveEntry.java | 22 +- .../compress/archivers/ArchiveInputStream.java | 88 +- .../compress/archivers/ArchiveOutputStream.java| 118 +- .../compress/archivers/ArchiveStreamFactory.java | 298 +- .../apache/commons/compress/archivers/Lister.java | 100 +- .../compress/archivers/ar/ArArchiveEntry.java | 108 +- .../archivers/ar/ArArchiveInputStream.java | 364 +-- .../archivers/ar/ArArchiveOutputStream.java| 154 +- .../compress/archivers/arj/ArjArchiveEntry.java| 140 +- .../archivers/arj/ArjArchiveInputStream.java | 314 +- .../compress/archivers/arj/LocalFileHeader.java| 126 +- .../commons/compress/archivers/arj/MainHeader.java | 44 +- .../compress/archivers/cpio/CpioArchiveEntry.java | 390 +-- .../archivers/cpio/CpioArchiveInputStream.java | 222 +- .../archivers/cpio/CpioArchiveOutputStream.java| 466 +-- .../commons/compress/archivers/cpio/CpioUtil.java | 14 +- .../commons/compress/archivers/dump/Dirent.java| 22 +- .../archivers/dump/DumpArchiveConstants.java | 72 +- .../compress/archivers/dump/DumpArchiveEntry.java | 782 ++--- .../archivers/dump/DumpArchiveException.java |6 +- .../archivers/dump/DumpArchiveInputStream.java | 330 +-- .../archivers/dump/DumpArchiveSummary.java | 248 +- .../compress/archivers/dump/DumpArchiveUtil.java | 76 +- .../compress/archivers/dump/TapeInputStream.java | 290 +- .../compress/archivers/examples/Archiver.java | 18 +- .../examples/CloseableConsumerAdapter.java | 10 +- .../compress/archivers/jar/JarArchiveEntry.java| 30 +- .../archivers/jar/JarArchiveInputStream.java | 34 +- .../archivers/sevenz/AES256SHA256Decoder.java | 144 +- .../commons/compress/archivers/sevenz/Archive.java | 16 +- .../BoundedSeekableByteChannelInputStream.java | 10 +- .../commons/compress/archivers/sevenz/CLI.java | 46 +- .../commons/compress/archivers/sevenz/Coders.java | 228 +- .../compress/archivers/sevenz/DeltaDecoder.java| 10 +- .../commons/compress/archivers/sevenz/Folder.java | 46 +- .../compress/archivers/sevenz/LZMA2Decoder.java| 46 +- .../compress/archivers/sevenz/LZMADecoder.java | 26 +- .../compress/archivers/sevenz/SevenZFile.java | 3036 ++-- .../archivers/sevenz/SevenZFileOptions.java| 170 +- .../compress/archivers/sevenz/SevenZMethod.java| 18 +- .../sevenz/SevenZMethodConfiguration.java | 26 +- .../archivers/sevenz/SevenZOutputFile.java | 872 +++--- .../archivers/tar/TarArchiveInputStream.java | 766 ++--- .../archivers/tar/TarArchiveOutputStream.java | 726 ++--- .../archivers/tar/TarArchiveSparseEntry.java |8 +- .../archivers/tar/TarArchiveStructSparse.java | 16 +- .../commons/compress/archivers/tar/TarFile.java| 766 ++--- .../commons/compress/archivers/tar/TarUtils.java | 1004 +++ .../archivers/zip/AbstractUnicodeExtraField.java | 124 +- .../compress/archivers/zip/AsiExtraField.java | 234 +- .../commons/compress/archivers/zip/BinaryTree.java | 138 +- .../compress/archivers/zip/CircularBuffer.java | 30 +- .../archivers/zip/ExplodingInputStream.java| 110 +- .../compress/archivers/zip/ExtraFieldUtils.java| 474 +-- .../compress/archivers/zip/GeneralPurposeBit.java | 214 +- .../zip/InflaterInputStreamWithStatistics.java | 20 +- .../commons/compress/archivers/zip/JarMarker.java | 64 +- .../compress/archivers/zip/NioZipEncoding.java | 154 +- .../compress/archivers/zip/PKWareExtraHeader.java | 322 +-- .../archivers/zip/ParallelScatterZipCreator.java | 120 +- .../archivers/zip/ResourceAlignmentExtraField.java | 44 +- .../archivers/zip/ScatterZipOutputStream.java | 180 +- .../compress/archivers/zip/StreamCompressor.java | 328 +-- .../archivers/zip/UnicodeCommentExtraField.java| 22 +- .../archivers/zip/UnicodePathExtraField.java | 18 +- .../archivers/zip/UnparseableExtraFieldData.java | 58 +- .../archivers/zip/UnrecognizedExtraField.java | 122 +- .../archivers/zip/UnshrinkingInputStream.java