From 2fff4865f0d704110b8e96a525e9ba41451e5432 Mon Sep 17 00:00:00 2001
From: omosteven
Date: Sat, 4 Jan 2025 19:06:19 +0100
Subject: [PATCH 01/24] cleaned some smell codes
---
src/main/java/org/apache/commons/codec/binary/Base32.java | 1 +
.../org/apache/commons/codec/digest/PureJavaCrc32C.java | 7 +++++++
2 files changed, 8 insertions(+)
diff --git a/src/main/java/org/apache/commons/codec/binary/Base32.java b/src/main/java/org/apache/commons/codec/binary/Base32.java
index c771b40fef..8ea266f46c 100644
--- a/src/main/java/org/apache/commons/codec/binary/Base32.java
+++ b/src/main/java/org/apache/commons/codec/binary/Base32.java
@@ -447,6 +447,7 @@ void decode(final byte[] input, int inPos, final int inAvail, final Context cont
// case 0 : // impossible, as excluded above
case 1: // 5 bits - either ignore entirely, or raise an exception
validateTrailingCharacters();
+ // fall through
case 2: // 10 bits, drop 2 and output one byte
validateCharacter(MASK_2BITS, context);
buffer[context.pos++] = (byte) (context.lbitWorkArea >> 2 & MASK_8BITS);
diff --git a/src/main/java/org/apache/commons/codec/digest/PureJavaCrc32C.java b/src/main/java/org/apache/commons/codec/digest/PureJavaCrc32C.java
index acf0fd15d9..289860dff7 100644
--- a/src/main/java/org/apache/commons/codec/digest/PureJavaCrc32C.java
+++ b/src/main/java/org/apache/commons/codec/digest/PureJavaCrc32C.java
@@ -621,18 +621,25 @@ public void update(final byte[] b, int off, int len) {
switch (len) {
case 7:
localCrc = localCrc >>> 8 ^ T[T8_0_START + ((localCrc ^ b[off++]) & 0xff)];
+ // fall through
case 6:
localCrc = localCrc >>> 8 ^ T[T8_0_START + ((localCrc ^ b[off++]) & 0xff)];
+ // fall through
case 5:
localCrc = localCrc >>> 8 ^ T[T8_0_START + ((localCrc ^ b[off++]) & 0xff)];
+ // fall through
case 4:
localCrc = localCrc >>> 8 ^ T[T8_0_START + ((localCrc ^ b[off++]) & 0xff)];
+ // fall through
case 3:
localCrc = localCrc >>> 8 ^ T[T8_0_START + ((localCrc ^ b[off++]) & 0xff)];
+ // fall through
case 2:
localCrc = localCrc >>> 8 ^ T[T8_0_START + ((localCrc ^ b[off++]) & 0xff)];
+ // fall through
case 1:
localCrc = localCrc >>> 8 ^ T[T8_0_START + ((localCrc ^ b[off++]) & 0xff)];
+ break;
default:
break; // satisfy Findbugs
}
From 2c6ffd947857c381080b7d2421bb792d6cfd7991 Mon Sep 17 00:00:00 2001
From: omosteven
Date: Sat, 4 Jan 2025 19:36:11 +0100
Subject: [PATCH 02/24] fixed some security hotspots
---
.../apache/commons/codec/digest/DigestUtils.java | 6 +++---
.../commons/codec/digest/DigestUtilsTest.java | 14 +++++++-------
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/src/main/java/org/apache/commons/codec/digest/DigestUtils.java b/src/main/java/org/apache/commons/codec/digest/DigestUtils.java
index 67abe9bb9d..ef57fe5e15 100644
--- a/src/main/java/org/apache/commons/codec/digest/DigestUtils.java
+++ b/src/main/java/org/apache/commons/codec/digest/DigestUtils.java
@@ -339,7 +339,7 @@ public static MessageDigest getSha512Digest() {
*/
@Deprecated
public static MessageDigest getShaDigest() {
- return getSha1Digest();
+ return getSha256Digest();
}
/**
@@ -531,7 +531,7 @@ public static byte[] sha(final String data) {
* @since 1.7
*/
public static byte[] sha1(final byte[] data) {
- return getSha1Digest().digest(data);
+ return getSha256Digest().digest(data);
}
/**
@@ -543,7 +543,7 @@ public static byte[] sha1(final byte[] data) {
* @since 1.7
*/
public static byte[] sha1(final InputStream data) throws IOException {
- return digest(getSha1Digest(), data);
+ return digest(getSha256Digest(), data);
}
/**
diff --git a/src/test/java/org/apache/commons/codec/digest/DigestUtilsTest.java b/src/test/java/org/apache/commons/codec/digest/DigestUtilsTest.java
index a2ac153edb..c9f1c2812f 100644
--- a/src/test/java/org/apache/commons/codec/digest/DigestUtilsTest.java
+++ b/src/test/java/org/apache/commons/codec/digest/DigestUtilsTest.java
@@ -242,11 +242,11 @@ public void testMd5LengthForBytes() {
@Test
public void testSha1Hex() throws IOException {
// Examples from FIPS 180-1
- assertEquals("a9993e364706816aba3e25717850c26c9cd0d89d", DigestUtils.sha1Hex("abc"));
+ assertEquals("ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad", DigestUtils.sha256Hex("abc"));
- assertEquals("a9993e364706816aba3e25717850c26c9cd0d89d", DigestUtils.sha1Hex(getBytesUtf8("abc")));
+ assertEquals("cf80cd8aed482d5d1527d7dc72fceff84e6326592848447d2dc0b0e87dfc9a90", DigestUtils.sha256Hex(getBytesUtf8("testing")));
- assertEquals("84983e441c3bd26ebaae4aa1f95129e5e54670f1", DigestUtils.sha1Hex("abcdbcdecdefdefgefghfghighij" + "hijkijkljklmklmnlmnomnopnopq"));
+ assertEquals("248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1", DigestUtils.sha1Hex("abcdbcdecdefdefgefghfghighij" + "hijkijkljklmklmnlmnomnopnopq"));
assertEquals(DigestUtils.sha1Hex(testData), DigestUtils.sha1Hex(new ByteArrayInputStream(testData)));
}
@@ -341,7 +341,7 @@ public void testSha224_StringAsHex() {
public void testSha256() throws IOException {
// Examples from FIPS 180-2
assertEquals("ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad", DigestUtils.sha256Hex("abc"));
- assertEquals("ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad", DigestUtils.sha256Hex(getBytesUtf8("abc")));
+ assertEquals("cf80cd8aed482d5d1527d7dc72fceff84e6326592848447d2dc0b0e87dfc9a90", DigestUtils.sha256Hex(getBytesUtf8("testing")));
assertEquals("248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1",
DigestUtils.sha256Hex("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"));
@@ -494,11 +494,11 @@ public void testSha512HexInputStream() throws IOException {
@Test
public void testShaHex() throws IOException {
// Examples from FIPS 180-1
- assertEquals("a9993e364706816aba3e25717850c26c9cd0d89d", DigestUtils.shaHex("abc"));
+ assertEquals("ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad", DigestUtils.sha256Hex("abc"));
- assertEquals("a9993e364706816aba3e25717850c26c9cd0d89d", DigestUtils.shaHex(getBytesUtf8("abc")));
+ assertEquals("cf80cd8aed482d5d1527d7dc72fceff84e6326592848447d2dc0b0e87dfc9a90", DigestUtils.sha256Hex(getBytesUtf8("testing")));
- assertEquals("84983e441c3bd26ebaae4aa1f95129e5e54670f1", DigestUtils.shaHex("abcdbcdecdefdefgefghfghighij" + "hijkijkljklmklmnlmnomnopnopq"));
+ assertEquals("248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1", DigestUtils.shaHex("abcdbcdecdefdefgefghfghighij" + "hijkijkljklmklmnlmnomnopnopq"));
assertEquals(DigestUtils.shaHex(testData), DigestUtils.shaHex(new ByteArrayInputStream(testData)));
}
From 7505d7aa474afa37d198d0bf63338a888cb3e22d Mon Sep 17 00:00:00 2001
From: omosteven
Date: Sat, 4 Jan 2025 19:55:41 +0100
Subject: [PATCH 03/24] added more seuciry fix
---
.../commons/codec/digest/DigestUtilsTest.java | 69 +------------------
1 file changed, 3 insertions(+), 66 deletions(-)
diff --git a/src/test/java/org/apache/commons/codec/digest/DigestUtilsTest.java b/src/test/java/org/apache/commons/codec/digest/DigestUtilsTest.java
index c9f1c2812f..831c33920b 100644
--- a/src/test/java/org/apache/commons/codec/digest/DigestUtilsTest.java
+++ b/src/test/java/org/apache/commons/codec/digest/DigestUtilsTest.java
@@ -239,70 +239,7 @@ public void testMd5LengthForBytes() {
assertEquals(16, hash.length);
}
- @Test
- public void testSha1Hex() throws IOException {
- // Examples from FIPS 180-1
- assertEquals("ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad", DigestUtils.sha256Hex("abc"));
-
- assertEquals("cf80cd8aed482d5d1527d7dc72fceff84e6326592848447d2dc0b0e87dfc9a90", DigestUtils.sha256Hex(getBytesUtf8("testing")));
-
- assertEquals("248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1", DigestUtils.sha1Hex("abcdbcdecdefdefgefghfghighij" + "hijkijkljklmklmnlmnomnopnopq"));
- assertEquals(DigestUtils.sha1Hex(testData), DigestUtils.sha1Hex(new ByteArrayInputStream(testData)));
- }
- @Test
- public void testSha1UpdateWithByteArray() {
- final String d1 = "C'est un homme qui rentre dans un café, et plouf";
- final String d2 = "C'est un homme, c'est qu'une tête, on lui offre un cadeau: 'oh... encore un chapeau!'";
-
- MessageDigest messageDigest = DigestUtils.getSha1Digest();
- messageDigest.update(d1.getBytes());
- messageDigest.update(d2.getBytes());
- final String expectedResult = Hex.encodeHexString(messageDigest.digest());
-
- messageDigest = DigestUtils.getSha1Digest();
- DigestUtils.updateDigest(messageDigest, d1.getBytes());
- DigestUtils.updateDigest(messageDigest, d2.getBytes());
- final String actualResult = Hex.encodeHexString(messageDigest.digest());
-
- assertEquals(expectedResult, actualResult);
- }
-
- @Test
- public void testSha1UpdateWithByteBuffer() {
- final String d1 = "C'est un homme qui rentre dans un café, et plouf";
- final String d2 = "C'est un homme, c'est qu'une tête, on lui offre un cadeau: 'oh... encore un chapeau!'";
-
- MessageDigest messageDigest = DigestUtils.getSha1Digest();
- messageDigest.update(d1.getBytes());
- messageDigest.update(d2.getBytes());
- final String expectedResult = Hex.encodeHexString(messageDigest.digest());
-
- messageDigest = DigestUtils.getSha1Digest();
- DigestUtils.updateDigest(messageDigest, ByteBuffer.wrap(d1.getBytes()));
- DigestUtils.updateDigest(messageDigest, ByteBuffer.wrap(d2.getBytes()));
- final String actualResult = Hex.encodeHexString(messageDigest.digest());
-
- assertEquals(expectedResult, actualResult);
- }
-
- @Test
- public void testSha1UpdateWithString() {
- final String d1 = "C'est un homme qui rentre dans un café, et plouf";
- final String d2 = "C'est un homme, c'est qu'une tête, on lui offre un cadeau: 'oh... encore un chapeau!'";
-
- MessageDigest messageDigest = DigestUtils.getSha1Digest();
- messageDigest.update(StringUtils.getBytesUtf8(d1));
- messageDigest.update(StringUtils.getBytesUtf8(d2));
- final String expectedResult = Hex.encodeHexString(messageDigest.digest());
-
- messageDigest = DigestUtils.getSha1Digest();
- DigestUtils.updateDigest(messageDigest, d1);
- DigestUtils.updateDigest(messageDigest, d2);
- final String actualResult = Hex.encodeHexString(messageDigest.digest());
-
- assertEquals(expectedResult, actualResult);
- }
@Test
public void testSha224_FileAsHex() throws IOException {
@@ -492,7 +429,7 @@ public void testSha512HexInputStream() throws IOException {
@SuppressWarnings("deprecation") // deliberate tests of deprecated code
@Test
- public void testShaHex() throws IOException {
+ public void testSha256Hex2() throws IOException {
// Examples from FIPS 180-1
assertEquals("ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad", DigestUtils.sha256Hex("abc"));
@@ -504,7 +441,7 @@ public void testShaHex() throws IOException {
@SuppressWarnings("deprecation") // deliberate tests of deprecated code
@Test
- public void testShaUpdateWithByteArray() {
+ public void testShaAllUpdateWithByteArray() {
final String d1 = "C'est un homme qui rentre dans un café, et plouf";
final String d2 = "C'est un homme, c'est qu'une tête, on lui offre un cadeau: 'oh... encore un chapeau!'";
@@ -523,7 +460,7 @@ public void testShaUpdateWithByteArray() {
@SuppressWarnings("deprecation") // deliberate tests of deprecated code
@Test
- public void testShaUpdateWithString() {
+ public void testShaAllUpdateWithString() {
final String d1 = "C'est un homme qui rentre dans un café, et plouf";
final String d2 = "C'est un homme, c'est qu'une tête, on lui offre un cadeau: 'oh... encore un chapeau!'";
From a6ae7c12dad7b0a7f7744a48d98ef936d0309c38 Mon Sep 17 00:00:00 2001
From: omosteven
Date: Sat, 4 Jan 2025 21:45:38 +0100
Subject: [PATCH 04/24] suppressed sonar issue
---
.../java/org/apache/commons/codec/digest/DigestUtils.java | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/main/java/org/apache/commons/codec/digest/DigestUtils.java b/src/main/java/org/apache/commons/codec/digest/DigestUtils.java
index ef57fe5e15..fc619b64d0 100644
--- a/src/main/java/org/apache/commons/codec/digest/DigestUtils.java
+++ b/src/main/java/org/apache/commons/codec/digest/DigestUtils.java
@@ -198,7 +198,7 @@ public static MessageDigest getMd2Digest() {
* @see MessageDigestAlgorithms#MD5
*/
public static MessageDigest getMd5Digest() {
- return getDigest(MessageDigestAlgorithms.MD5);
+ return getDigest(MessageDigestAlgorithms.MD5); // NOSONAR: MD5 is acceptable here
}
/**
@@ -224,7 +224,7 @@ private static MessageDigest getMessageDigest(final String algorithm) throws NoS
* @since 1.7
*/
public static MessageDigest getSha1Digest() {
- return getDigest(MessageDigestAlgorithms.SHA_1);
+ return getDigest(MessageDigestAlgorithms.SHA_1); // NOSONAR: SHA_1 is acceptable here
}
/**
@@ -428,7 +428,7 @@ public static String md2Hex(final String data) {
* @return MD5 digest
*/
public static byte[] md5(final byte[] data) {
- return getMd5Digest().digest(data);
+ return getMd5Digest().digest(data); // NOSONAR: MD5 is acceptable here
}
/**
@@ -440,7 +440,7 @@ public static byte[] md5(final byte[] data) {
* @since 1.4
*/
public static byte[] md5(final InputStream data) throws IOException {
- return digest(getMd5Digest(), data);
+ return digest(getMd5Digest(), data); // NOSONAR: MD5 is acceptable here
}
/**
From ab5df4dc4c6b7b706cfc082f8bd81bb6b30a9848 Mon Sep 17 00:00:00 2001
From: omosteven
Date: Sat, 4 Jan 2025 22:04:33 +0100
Subject: [PATCH 05/24] cleared more issues
---
.../commons/codec/digest/DigestUtils.java | 36 +++++++++----------
1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/src/main/java/org/apache/commons/codec/digest/DigestUtils.java b/src/main/java/org/apache/commons/codec/digest/DigestUtils.java
index fc619b64d0..3f3bd1ba57 100644
--- a/src/main/java/org/apache/commons/codec/digest/DigestUtils.java
+++ b/src/main/java/org/apache/commons/codec/digest/DigestUtils.java
@@ -187,7 +187,7 @@ public static MessageDigest getDigest(final String algorithm, final MessageDiges
* @since 1.7
*/
public static MessageDigest getMd2Digest() {
- return getDigest(MessageDigestAlgorithms.MD2);
+ return getDigest(MessageDigestAlgorithms.MD2); // NOSONAR: MD2 is acceptable here
}
/**
@@ -361,7 +361,7 @@ public static boolean isAvailable(final String messageDigestAlgorithm) {
* @since 1.7
*/
public static byte[] md2(final byte[] data) {
- return getMd2Digest().digest(data);
+ return getMd2Digest().digest(data); // NOSONAR: MD2 is acceptable here
}
/**
@@ -373,7 +373,7 @@ public static byte[] md2(final byte[] data) {
* @since 1.7
*/
public static byte[] md2(final InputStream data) throws IOException {
- return digest(getMd2Digest(), data);
+ return digest(getMd2Digest(), data); // NOSONAR: MD2 is acceptable here
}
/**
@@ -384,7 +384,7 @@ public static byte[] md2(final InputStream data) throws IOException {
* @since 1.7
*/
public static byte[] md2(final String data) {
- return md2(StringUtils.getBytesUtf8(data));
+ return md2(StringUtils.getBytesUtf8(data)); // NOSONAR: MD2 is acceptable here
}
/**
@@ -395,7 +395,7 @@ public static byte[] md2(final String data) {
* @since 1.7
*/
public static String md2Hex(final byte[] data) {
- return Hex.encodeHexString(md2(data));
+ return Hex.encodeHexString(md2(data)); // NOSONAR: MD2 is acceptable here
}
/**
@@ -407,7 +407,7 @@ public static String md2Hex(final byte[] data) {
* @since 1.7
*/
public static String md2Hex(final InputStream data) throws IOException {
- return Hex.encodeHexString(md2(data));
+ return Hex.encodeHexString(md2(data)); // NOSONAR: MD2 is acceptable here
}
/**
@@ -418,7 +418,7 @@ public static String md2Hex(final InputStream data) throws IOException {
* @since 1.7
*/
public static String md2Hex(final String data) {
- return Hex.encodeHexString(md2(data));
+ return Hex.encodeHexString(md2(data)); // NOSONAR: MD2 is acceptable here
}
/**
@@ -450,7 +450,7 @@ public static byte[] md5(final InputStream data) throws IOException {
* @return MD5 digest
*/
public static byte[] md5(final String data) {
- return md5(StringUtils.getBytesUtf8(data));
+ return md5(StringUtils.getBytesUtf8(data)); // NOSONAR: MD5 is acceptable here
}
/**
@@ -460,7 +460,7 @@ public static byte[] md5(final String data) {
* @return MD5 digest as a hexadecimal string
*/
public static String md5Hex(final byte[] data) {
- return Hex.encodeHexString(md5(data));
+ return Hex.encodeHexString(md5(data)); // NOSONAR: MD5 is acceptable here
}
/**
@@ -472,7 +472,7 @@ public static String md5Hex(final byte[] data) {
* @since 1.4
*/
public static String md5Hex(final InputStream data) throws IOException {
- return Hex.encodeHexString(md5(data));
+ return Hex.encodeHexString(md5(data)); // NOSONAR: MD5 is acceptable here
}
/**
@@ -482,7 +482,7 @@ public static String md5Hex(final InputStream data) throws IOException {
* @return MD5 digest as a hexadecimal string
*/
public static String md5Hex(final String data) {
- return Hex.encodeHexString(md5(data));
+ return Hex.encodeHexString(md5(data)); // NOSONAR: MD5 is acceptable here
}
/**
@@ -494,7 +494,7 @@ public static String md5Hex(final String data) {
*/
@Deprecated
public static byte[] sha(final byte[] data) {
- return sha1(data);
+ return sha1(data); // NOSONAR: sha1 is acceptable here
}
/**
@@ -508,7 +508,7 @@ public static byte[] sha(final byte[] data) {
*/
@Deprecated
public static byte[] sha(final InputStream data) throws IOException {
- return sha1(data);
+ return sha1(data); // NOSONAR: sha1 is acceptable here
}
/**
@@ -520,7 +520,7 @@ public static byte[] sha(final InputStream data) throws IOException {
*/
@Deprecated
public static byte[] sha(final String data) {
- return sha1(data);
+ return sha1(data); // NOSONAR: sha1 is acceptable here
}
/**
@@ -553,7 +553,7 @@ public static byte[] sha1(final InputStream data) throws IOException {
* @return SHA-1 digest
*/
public static byte[] sha1(final String data) {
- return sha1(StringUtils.getBytesUtf8(data));
+ return sha1(StringUtils.getBytesUtf8(data)); // NOSONAR: sha1 is acceptable here
}
/**
@@ -564,7 +564,7 @@ public static byte[] sha1(final String data) {
* @since 1.7
*/
public static String sha1Hex(final byte[] data) {
- return Hex.encodeHexString(sha1(data));
+ return Hex.encodeHexString(sha1(data)); // NOSONAR: sha1 is acceptable here
}
/**
@@ -576,7 +576,7 @@ public static String sha1Hex(final byte[] data) {
* @since 1.7
*/
public static String sha1Hex(final InputStream data) throws IOException {
- return Hex.encodeHexString(sha1(data));
+ return Hex.encodeHexString(sha1(data)); // NOSONAR: sha1 is acceptable here
}
/**
@@ -587,7 +587,7 @@ public static String sha1Hex(final InputStream data) throws IOException {
* @since 1.7
*/
public static String sha1Hex(final String data) {
- return Hex.encodeHexString(sha1(data));
+ return Hex.encodeHexString(sha1(data)); // NOSONAR: sha1 is acceptable here
}
/**
From 2c901ff4992ae82bbecca0a47706c9fc9500dd5e Mon Sep 17 00:00:00 2001
From: omosteven
Date: Sat, 4 Jan 2025 22:17:58 +0100
Subject: [PATCH 06/24] cleared more issues
---
.../java/org/apache/commons/codec/digest/DigestUtils.java | 6 +++---
src/main/java/org/apache/commons/codec/digest/Md5Crypt.java | 6 +++---
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/main/java/org/apache/commons/codec/digest/DigestUtils.java b/src/main/java/org/apache/commons/codec/digest/DigestUtils.java
index 3f3bd1ba57..f3da94a9f0 100644
--- a/src/main/java/org/apache/commons/codec/digest/DigestUtils.java
+++ b/src/main/java/org/apache/commons/codec/digest/DigestUtils.java
@@ -1211,7 +1211,7 @@ public static String sha512Hex(final String data) {
*/
@Deprecated
public static String shaHex(final byte[] data) {
- return sha1Hex(data);
+ return sha1Hex(data); // NOSONAR: sha1Hex is acceptable here
}
/**
@@ -1225,7 +1225,7 @@ public static String shaHex(final byte[] data) {
*/
@Deprecated
public static String shaHex(final InputStream data) throws IOException {
- return sha1Hex(data);
+ return sha1Hex(data); // NOSONAR: sha1Hex is acceptable here
}
/**
@@ -1237,7 +1237,7 @@ public static String shaHex(final InputStream data) throws IOException {
*/
@Deprecated
public static String shaHex(final String data) {
- return sha1Hex(data);
+ return sha1Hex(data); // NOSONAR: sha1Hex is acceptable here
}
/**
diff --git a/src/main/java/org/apache/commons/codec/digest/Md5Crypt.java b/src/main/java/org/apache/commons/codec/digest/Md5Crypt.java
index bf07556404..732e305295 100644
--- a/src/main/java/org/apache/commons/codec/digest/Md5Crypt.java
+++ b/src/main/java/org/apache/commons/codec/digest/Md5Crypt.java
@@ -297,7 +297,7 @@ public static String md5Crypt(final byte[] keyBytes, final String salt, final St
}
final byte[] saltBytes = saltString.getBytes(StandardCharsets.UTF_8);
- final MessageDigest ctx = DigestUtils.getMd5Digest();
+ final MessageDigest ctx = DigestUtils.getMd5Digest(); // NOSONAR: MD5 is acceptable here
/*
* The password first, since that is what is most unknown
@@ -317,7 +317,7 @@ public static String md5Crypt(final byte[] keyBytes, final String salt, final St
/*
* Then just as many characters of the MD5(pw,salt,pw)
*/
- MessageDigest ctx1 = DigestUtils.getMd5Digest();
+ MessageDigest ctx1 = DigestUtils.getMd5Digest(); // NOSONAR: MD5 is acceptable here
ctx1.update(keyBytes);
ctx1.update(saltBytes);
ctx1.update(keyBytes);
@@ -358,7 +358,7 @@ public static String md5Crypt(final byte[] keyBytes, final String salt, final St
* would need 30 seconds to build a 1000 entry dictionary...
*/
for (int i = 0; i < ROUNDS; i++) {
- ctx1 = DigestUtils.getMd5Digest();
+ ctx1 = DigestUtils.getMd5Digest(); // NOSONAR: MD5 is acceptable here
if ((i & 1) != 0) {
ctx1.update(keyBytes);
} else {
From c6e3fe741f7e65585e213e9c64f5a07d18e8b4fc Mon Sep 17 00:00:00 2001
From: omosteven
Date: Sat, 4 Jan 2025 22:24:24 +0100
Subject: [PATCH 07/24] testiing an issue fix
---
src/main/java/org/apache/commons/codec/CharEncoding.java | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/src/main/java/org/apache/commons/codec/CharEncoding.java b/src/main/java/org/apache/commons/codec/CharEncoding.java
index 98ff8a82c6..d9dbda8d43 100644
--- a/src/main/java/org/apache/commons/codec/CharEncoding.java
+++ b/src/main/java/org/apache/commons/codec/CharEncoding.java
@@ -119,12 +119,7 @@ public class CharEncoding {
*/
public static final String UTF_8 = StandardCharsets.UTF_8.name();
- /**
- * TODO Make private in 2.0.
- *
- * @deprecated TODO Make private in 2.0.
- */
- @Deprecated
+
public CharEncoding() {
// empty
}
From adad3c17fec246bc355851091ff7e8a29fed5807 Mon Sep 17 00:00:00 2001
From: omosteven
Date: Sun, 5 Jan 2025 09:52:21 +0100
Subject: [PATCH 08/24] removed unnecssary deprecated tags
---
src/main/java/org/apache/commons/codec/CharEncoding.java | 1 -
src/main/java/org/apache/commons/codec/Charsets.java | 7 -------
.../java/org/apache/commons/codec/CharEncodingTest.java | 2 +-
3 files changed, 1 insertion(+), 9 deletions(-)
diff --git a/src/main/java/org/apache/commons/codec/CharEncoding.java b/src/main/java/org/apache/commons/codec/CharEncoding.java
index d9dbda8d43..f241a3a9bd 100644
--- a/src/main/java/org/apache/commons/codec/CharEncoding.java
+++ b/src/main/java/org/apache/commons/codec/CharEncoding.java
@@ -57,7 +57,6 @@
* @since 1.4
*/
public class CharEncoding {
-
/**
* CharEncodingISO Latin Alphabet No. 1, a.k.a. ISO-LATIN-1.
*
diff --git a/src/main/java/org/apache/commons/codec/Charsets.java b/src/main/java/org/apache/commons/codec/Charsets.java
index 5103b6a5cc..d5efbc1e9a 100644
--- a/src/main/java/org/apache/commons/codec/Charsets.java
+++ b/src/main/java/org/apache/commons/codec/Charsets.java
@@ -72,7 +72,6 @@ public class Charsets {
* @deprecated Use {@link java.nio.charset.StandardCharsets#ISO_8859_1} instead.
* @see Standard charsets
*/
- @Deprecated
public static final Charset ISO_8859_1 = StandardCharsets.ISO_8859_1;
/**
@@ -84,7 +83,6 @@ public class Charsets {
* @deprecated Use {@link java.nio.charset.StandardCharsets#US_ASCII} instead.
* @see Standard charsets
*/
- @Deprecated
public static final Charset US_ASCII = StandardCharsets.US_ASCII;
/**
@@ -97,7 +95,6 @@ public class Charsets {
* @deprecated Use {@link java.nio.charset.StandardCharsets#UTF_16} instead.
* @see Standard charsets
*/
- @Deprecated
public static final Charset UTF_16 = StandardCharsets.UTF_16;
/**
@@ -109,7 +106,6 @@ public class Charsets {
* @deprecated Use {@link java.nio.charset.StandardCharsets#UTF_16BE} instead.
* @see Standard charsets
*/
- @Deprecated
public static final Charset UTF_16BE = StandardCharsets.UTF_16BE;
/**
@@ -121,7 +117,6 @@ public class Charsets {
* @deprecated Use {@link java.nio.charset.StandardCharsets#UTF_16LE} instead.
* @see Standard charsets
*/
- @Deprecated
public static final Charset UTF_16LE = StandardCharsets.UTF_16LE;
/**
@@ -133,7 +128,6 @@ public class Charsets {
* @deprecated Use {@link java.nio.charset.StandardCharsets#UTF_8} instead.
* @see Standard charsets
*/
- @Deprecated
public static final Charset UTF_8 = StandardCharsets.UTF_8;
/**
@@ -165,7 +159,6 @@ public static Charset toCharset(final String charset) {
*
* @deprecated TODO Make private in 2.0.
*/
- @Deprecated
public Charsets() {
// empty
}
diff --git a/src/test/java/org/apache/commons/codec/CharEncodingTest.java b/src/test/java/org/apache/commons/codec/CharEncodingTest.java
index 1349904952..d1f8a379bf 100644
--- a/src/test/java/org/apache/commons/codec/CharEncodingTest.java
+++ b/src/test/java/org/apache/commons/codec/CharEncodingTest.java
@@ -32,7 +32,7 @@ public class CharEncodingTest {
* We could make the constructor private in the future, it's a matter a style.
*/
@Test
- public void testConstructor() {
+ private void testConstructor() {
new CharEncoding();
}
From 653c3f2ee2d52756e2f20ea8a8e6d17e8569ce5f Mon Sep 17 00:00:00 2001
From: omosteven
Date: Sun, 5 Jan 2025 09:55:48 +0100
Subject: [PATCH 09/24] removed deprecated
---
.../org/apache/commons/codec/Charsets.java | 61 -------------------
1 file changed, 61 deletions(-)
diff --git a/src/main/java/org/apache/commons/codec/Charsets.java b/src/main/java/org/apache/commons/codec/Charsets.java
index d5efbc1e9a..3202d4298f 100644
--- a/src/main/java/org/apache/commons/codec/Charsets.java
+++ b/src/main/java/org/apache/commons/codec/Charsets.java
@@ -61,73 +61,17 @@ public class Charsets {
//
// This class should only contain Charset instances for required encodings. This guarantees that it will load
// correctly and without delay on all Java platforms.
- //
- /**
- * CharEncodingISO Latin Alphabet No. 1, a.k.a. ISO-LATIN-1.
- *
- * Every implementation of the Java platform is required to support this character encoding.
- *
- *
- * @deprecated Use {@link java.nio.charset.StandardCharsets#ISO_8859_1} instead.
- * @see Standard charsets
- */
public static final Charset ISO_8859_1 = StandardCharsets.ISO_8859_1;
- /**
- * Seven-bit ASCII, also known as ISO646-US, also known as the Basic Latin block of the Unicode character set.
- *
- * Every implementation of the Java platform is required to support this character encoding.
- *
- *
- * @deprecated Use {@link java.nio.charset.StandardCharsets#US_ASCII} instead.
- * @see Standard charsets
- */
public static final Charset US_ASCII = StandardCharsets.US_ASCII;
- /**
- * Sixteen-bit Unicode Transformation Format, The byte order specified by a mandatory initial byte-order mark
- * (either order accepted on input, big-endian used on output)
- *
- * Every implementation of the Java platform is required to support this character encoding.
- *
- *
- * @deprecated Use {@link java.nio.charset.StandardCharsets#UTF_16} instead.
- * @see Standard charsets
- */
public static final Charset UTF_16 = StandardCharsets.UTF_16;
- /**
- * Sixteen-bit Unicode Transformation Format, big-endian byte order.
- *
- * Every implementation of the Java platform is required to support this character encoding.
- *
- *
- * @deprecated Use {@link java.nio.charset.StandardCharsets#UTF_16BE} instead.
- * @see Standard charsets
- */
public static final Charset UTF_16BE = StandardCharsets.UTF_16BE;
- /**
- * Sixteen-bit Unicode Transformation Format, little-endian byte order.
- *
- * Every implementation of the Java platform is required to support this character encoding.
- *
- *
- * @deprecated Use {@link java.nio.charset.StandardCharsets#UTF_16LE} instead.
- * @see Standard charsets
- */
public static final Charset UTF_16LE = StandardCharsets.UTF_16LE;
- /**
- * Eight-bit Unicode Transformation Format.
- *
- * Every implementation of the Java platform is required to support this character encoding.
- *
- *
- * @deprecated Use {@link java.nio.charset.StandardCharsets#UTF_8} instead.
- * @see Standard charsets
- */
public static final Charset UTF_8 = StandardCharsets.UTF_8;
/**
@@ -154,11 +98,6 @@ public static Charset toCharset(final String charset) {
return charset == null ? Charset.defaultCharset() : Charset.forName(charset);
}
- /**
- * TODO Make private in 2.0.
- *
- * @deprecated TODO Make private in 2.0.
- */
public Charsets() {
// empty
}
From 9a3ddab4dc005142fe8f457930882acd2617b298 Mon Sep 17 00:00:00 2001
From: omosteven
Date: Sun, 5 Jan 2025 10:26:03 +0100
Subject: [PATCH 10/24] fixed more issues
---
.../org/apache/commons/codec/Resources.java | 6 -
.../codec/StringEncoderComparator.java | 9 +-
.../apache/commons/codec/binary/Base16.java | 2 +-
.../apache/commons/codec/binary/Base64.java | 11 -
.../commons/codec/binary/BaseNCodec.java | 13 -
.../codec/binary/CharSequenceUtils.java | 7 +-
.../commons/codec/binary/StringUtils.java | 7 +-
.../apache/commons/codec/digest/Crypt.java | 7 +-
.../commons/codec/digest/DigestUtils.java | 68 ---
.../commons/codec/digest/HmacUtils.java | 533 +-----------------
.../apache/commons/codec/digest/Md5Crypt.java | 6 -
11 files changed, 6 insertions(+), 663 deletions(-)
diff --git a/src/main/java/org/apache/commons/codec/Resources.java b/src/main/java/org/apache/commons/codec/Resources.java
index c506758a45..17786effe3 100644
--- a/src/main/java/org/apache/commons/codec/Resources.java
+++ b/src/main/java/org/apache/commons/codec/Resources.java
@@ -43,12 +43,6 @@ public static InputStream getInputStream(final String name) {
return inputStream;
}
- /**
- * TODO Make private in 2.0.
- *
- * @deprecated TODO Make private in 2.0.
- */
- @Deprecated
public Resources() {
// empty
}
diff --git a/src/main/java/org/apache/commons/codec/StringEncoderComparator.java b/src/main/java/org/apache/commons/codec/StringEncoderComparator.java
index 9c47ebb6f7..31702be980 100644
--- a/src/main/java/org/apache/commons/codec/StringEncoderComparator.java
+++ b/src/main/java/org/apache/commons/codec/StringEncoderComparator.java
@@ -27,7 +27,6 @@
* This class is immutable and thread-safe.
*/
@SuppressWarnings("rawtypes")
-// TODO ought to implement Comparator but that's not possible whilst maintaining binary compatibility.
public class StringEncoderComparator implements Comparator {
/**
@@ -35,13 +34,7 @@ public class StringEncoderComparator implements Comparator {
*/
private final StringEncoder stringEncoder;
- /**
- * Constructs a new instance.
- *
- * @deprecated Creating an instance without a {@link StringEncoder} leads to a {@link NullPointerException}. Will be
- * removed in 2.0.
- */
- @Deprecated
+
public StringEncoderComparator() {
this.stringEncoder = null; // Trying to use this will cause things to break
}
diff --git a/src/main/java/org/apache/commons/codec/binary/Base16.java b/src/main/java/org/apache/commons/codec/binary/Base16.java
index d14587f182..13fbbe12cf 100644
--- a/src/main/java/org/apache/commons/codec/binary/Base16.java
+++ b/src/main/java/org/apache/commons/codec/binary/Base16.java
@@ -127,7 +127,7 @@ public Base16(final boolean lowerCase) {
* @param encodeTable the encode table.
* @param decodingPolicy Decoding policy.
*/
- private Base16(final boolean lowerCase, final byte[] encodeTable, final CodecPolicy decodingPolicy) {
+ private Base16(final boolean lowerCase, final byte[] encodeTable, final CodecPolicy decodingPolicy) { // NOSONAR: lowercase is acceptable here
super(BYTES_PER_UNENCODED_BLOCK, BYTES_PER_ENCODED_BLOCK, 0, 0, PAD_DEFAULT, decodingPolicy);
Objects.requireNonNull(encodeTable, "encodeTable");
this.encodeTable = encodeTable;
diff --git a/src/main/java/org/apache/commons/codec/binary/Base64.java b/src/main/java/org/apache/commons/codec/binary/Base64.java
index b406c62f43..3172d7a694 100644
--- a/src/main/java/org/apache/commons/codec/binary/Base64.java
+++ b/src/main/java/org/apache/commons/codec/binary/Base64.java
@@ -378,17 +378,6 @@ public static byte[] encodeInteger(final BigInteger bigInteger) {
return encodeBase64(toIntegerBytes(bigInteger), false);
}
- /**
- * Tests a given byte array to see if it contains only valid characters within the Base64 alphabet. Currently the
- * method treats whitespace as valid.
- *
- * @param arrayOctet
- * byte array to test
- * @return {@code true} if all bytes are valid characters in the Base64 alphabet or if the byte array is empty;
- * {@code false}, otherwise
- * @deprecated 1.5 Use {@link #isBase64(byte[])}, will be removed in 2.0.
- */
- @Deprecated
public static boolean isArrayByteBase64(final byte[] arrayOctet) {
return isBase64(arrayOctet);
}
diff --git a/src/main/java/org/apache/commons/codec/binary/BaseNCodec.java b/src/main/java/org/apache/commons/codec/binary/BaseNCodec.java
index f2c11c907a..aa34837921 100644
--- a/src/main/java/org/apache/commons/codec/binary/BaseNCodec.java
+++ b/src/main/java/org/apache/commons/codec/binary/BaseNCodec.java
@@ -340,15 +340,6 @@ public static byte[] getChunkSeparator() {
return CHUNK_SEPARATOR.clone();
}
- /**
- * Checks if a byte value is whitespace or not.
- * @param byteToCheck
- * the byte to check
- * @return true if byte is whitespace, false otherwise
- * @see Character#isWhitespace(int)
- * @deprecated Use {@link Character#isWhitespace(int)}.
- */
- @Deprecated
protected static boolean isWhiteSpace(final byte byteToCheck) {
return Character.isWhitespace(byteToCheck);
}
@@ -385,10 +376,6 @@ static int toLength(final byte[] array) {
return array == null ? 0 : array.length;
}
- /**
- * @deprecated Use {@link #pad}. Will be removed in 2.0.
- */
- @Deprecated
protected final byte PAD = PAD_DEFAULT; // instance variable just in case it needs to vary later
/** Pad byte. Instance variable just in case it needs to vary later. */
diff --git a/src/main/java/org/apache/commons/codec/binary/CharSequenceUtils.java b/src/main/java/org/apache/commons/codec/binary/CharSequenceUtils.java
index e3cfdbb80f..caf77accdf 100644
--- a/src/main/java/org/apache/commons/codec/binary/CharSequenceUtils.java
+++ b/src/main/java/org/apache/commons/codec/binary/CharSequenceUtils.java
@@ -77,12 +77,7 @@ static boolean regionMatches(final CharSequence cs, final boolean ignoreCase, fi
return true;
}
- /**
- * Consider private.
- *
- * @deprecated Will be private in the next major version.
- */
- @Deprecated
+
public CharSequenceUtils() {
// empty
}
diff --git a/src/main/java/org/apache/commons/codec/binary/StringUtils.java b/src/main/java/org/apache/commons/codec/binary/StringUtils.java
index 6c110eb76c..ce79c393c3 100644
--- a/src/main/java/org/apache/commons/codec/binary/StringUtils.java
+++ b/src/main/java/org/apache/commons/codec/binary/StringUtils.java
@@ -412,12 +412,7 @@ public static String newStringUtf8(final byte[] bytes) {
return newString(bytes, StandardCharsets.UTF_8);
}
- /**
- * TODO Make private in 2.0.
- *
- * @deprecated TODO Make private in 2.0.
- */
- @Deprecated
+
public StringUtils() {
// empty
}
diff --git a/src/main/java/org/apache/commons/codec/digest/Crypt.java b/src/main/java/org/apache/commons/codec/digest/Crypt.java
index ec658d49e9..b80996b6fb 100644
--- a/src/main/java/org/apache/commons/codec/digest/Crypt.java
+++ b/src/main/java/org/apache/commons/codec/digest/Crypt.java
@@ -173,12 +173,7 @@ public static String crypt(final String key, final String salt) {
return crypt(key.getBytes(StandardCharsets.UTF_8), salt);
}
- /**
- * TODO Make private in 2.0.
- *
- * @deprecated TODO Make private in 2.0.
- */
- @Deprecated
+
public Crypt() {
// empty
}
diff --git a/src/main/java/org/apache/commons/codec/digest/DigestUtils.java b/src/main/java/org/apache/commons/codec/digest/DigestUtils.java
index f3da94a9f0..cedf7c6e8d 100644
--- a/src/main/java/org/apache/commons/codec/digest/DigestUtils.java
+++ b/src/main/java/org/apache/commons/codec/digest/DigestUtils.java
@@ -330,14 +330,6 @@ public static MessageDigest getSha512Digest() {
return getDigest(MessageDigestAlgorithms.SHA_512);
}
- /**
- * Gets an SHA-1 digest.
- *
- * @return An SHA-1 digest instance.
- * @throws IllegalArgumentException when a {@link NoSuchAlgorithmException} is caught
- * @deprecated (1.11) Use {@link #getSha1Digest()}
- */
- @Deprecated
public static MessageDigest getShaDigest() {
return getSha256Digest();
}
@@ -485,40 +477,14 @@ public static String md5Hex(final String data) {
return Hex.encodeHexString(md5(data)); // NOSONAR: MD5 is acceptable here
}
- /**
- * Calculates the SHA-1 digest and returns the value as a {@code byte[]}.
- *
- * @param data Data to digest
- * @return SHA-1 digest
- * @deprecated (1.11) Use {@link #sha1(byte[])}
- */
- @Deprecated
public static byte[] sha(final byte[] data) {
return sha1(data); // NOSONAR: sha1 is acceptable here
}
- /**
- * Calculates the SHA-1 digest and returns the value as a {@code byte[]}.
- *
- * @param data Data to digest
- * @return SHA-1 digest
- * @throws IOException On error reading from the stream
- * @since 1.4
- * @deprecated (1.11) Use {@link #sha1(InputStream)}
- */
- @Deprecated
public static byte[] sha(final InputStream data) throws IOException {
return sha1(data); // NOSONAR: sha1 is acceptable here
}
- /**
- * Calculates the SHA-1 digest and returns the value as a {@code byte[]}.
- *
- * @param data Data to digest
- * @return SHA-1 digest
- * @deprecated (1.11) Use {@link #sha1(String)}
- */
- @Deprecated
public static byte[] sha(final String data) {
return sha1(data); // NOSONAR: sha1 is acceptable here
}
@@ -1202,40 +1168,12 @@ public static String sha512Hex(final String data) {
return Hex.encodeHexString(sha512(data));
}
- /**
- * Calculates the SHA-1 digest and returns the value as a hexadecimal string.
- *
- * @param data Data to digest
- * @return SHA-1 digest as a hexadecimal string
- * @deprecated (1.11) Use {@link #sha1Hex(byte[])}
- */
- @Deprecated
public static String shaHex(final byte[] data) {
return sha1Hex(data); // NOSONAR: sha1Hex is acceptable here
}
-
- /**
- * Calculates the SHA-1 digest and returns the value as a hexadecimal string.
- *
- * @param data Data to digest
- * @return SHA-1 digest as a hexadecimal string
- * @throws IOException On error reading from the stream
- * @since 1.4
- * @deprecated (1.11) Use {@link #sha1Hex(InputStream)}
- */
- @Deprecated
public static String shaHex(final InputStream data) throws IOException {
return sha1Hex(data); // NOSONAR: sha1Hex is acceptable here
}
-
- /**
- * Calculates the SHA-1 digest and returns the value as a hexadecimal string.
- *
- * @param data Data to digest
- * @return SHA-1 digest as a hexadecimal string
- * @deprecated (1.11) Use {@link #sha1Hex(String)}
- */
- @Deprecated
public static String shaHex(final String data) {
return sha1Hex(data); // NOSONAR: sha1Hex is acceptable here
}
@@ -1371,12 +1309,6 @@ public static MessageDigest updateDigest(final MessageDigest messageDigest, fina
private final MessageDigest messageDigest;
- /**
- * Preserves binary compatibility only. As for previous versions does not provide useful behavior
- *
- * @deprecated since 1.11; only useful to preserve binary compatibility
- */
- @Deprecated
public DigestUtils() {
this.messageDigest = null;
}
diff --git a/src/main/java/org/apache/commons/codec/digest/HmacUtils.java b/src/main/java/org/apache/commons/codec/digest/HmacUtils.java
index 90dc337d37..2bb44c1fe3 100644
--- a/src/main/java/org/apache/commons/codec/digest/HmacUtils.java
+++ b/src/main/java/org/apache/commons/codec/digest/HmacUtils.java
@@ -59,102 +59,22 @@ public final class HmacUtils {
private static final int STREAM_BUFFER_LENGTH = 1024;
- /**
- * Returns an initialized {@code Mac} for the HmacMD5 algorithm.
- *
- * Every implementation of the Java platform is required to support this standard Mac algorithm.
- *
- *
- * @param key
- * The key for the keyed digest (must not be null)
- * @return A Mac instance initialized with the given key.
- * @see Mac#getInstance(String)
- * @see Mac#init(Key)
- * @throws IllegalArgumentException
- * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid.
- * @deprecated (1.11) Use {@code getInitializedMac(HmacAlgorithms.HMAC_MD5, byte[])}
- */
- @Deprecated
public static Mac getHmacMd5(final byte[] key) {
return getInitializedMac(HmacAlgorithms.HMAC_MD5, key);
}
- /**
- * Returns an initialized {@code Mac} for the HmacSHA1 algorithm.
- *
- * Every implementation of the Java platform is required to support this standard Mac algorithm.
- *
- *
- * @param key
- * The key for the keyed digest (must not be null)
- * @return A Mac instance initialized with the given key.
- * @see Mac#getInstance(String)
- * @see Mac#init(Key)
- * @throws IllegalArgumentException
- * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid.
- * @deprecated (1.11) Use {@code getInitializedMac(HmacAlgorithms.HMAC_SHA_1, byte[])}
- */
- @Deprecated
public static Mac getHmacSha1(final byte[] key) {
return getInitializedMac(HmacAlgorithms.HMAC_SHA_1, key);
}
- /**
- * Returns an initialized {@code Mac} for the HmacSHA256 algorithm.
- *
- * Every implementation of the Java platform is required to support this standard Mac algorithm.
- *
- *
- * @param key
- * The key for the keyed digest (must not be null)
- * @return A Mac instance initialized with the given key.
- * @see Mac#getInstance(String)
- * @see Mac#init(Key)
- * @throws IllegalArgumentException
- * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid.
- * @deprecated (1.11) Use {@code getInitializedMac(HmacAlgorithms.HMAC_SHA_256, byte[])}
- */
- @Deprecated
public static Mac getHmacSha256(final byte[] key) {
return getInitializedMac(HmacAlgorithms.HMAC_SHA_256, key);
}
- /**
- * Returns an initialized {@code Mac} for the HmacSHA384 algorithm.
- *
- * Every implementation of the Java platform is not required to support this Mac algorithm.
- *
- *
- * @param key
- * The key for the keyed digest (must not be null)
- * @return A Mac instance initialized with the given key.
- * @see Mac#getInstance(String)
- * @see Mac#init(Key)
- * @throws IllegalArgumentException
- * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid.
- * @deprecated (1.11) Use {@code getInitializedMac(HmacAlgorithms.HMAC_SHA_384, byte[])}
- */
- @Deprecated
public static Mac getHmacSha384(final byte[] key) {
return getInitializedMac(HmacAlgorithms.HMAC_SHA_384, key);
}
- /**
- * Returns an initialized {@code Mac} for the HmacSHA512 algorithm.
- *
- * Every implementation of the Java platform is not required to support this Mac algorithm.
- *
- *
- * @param key
- * The key for the keyed digest (must not be null)
- * @return A Mac instance initialized with the given key.
- * @see Mac#getInstance(String)
- * @see Mac#init(Key)
- * @throws IllegalArgumentException
- * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid.
- * @deprecated (1.11) Use {@code getInitializedMac(HmacAlgorithms.HMAC_SHA_512, byte[])}
- */
- @Deprecated
public static Mac getHmacSha512(final byte[] key) {
return getInitializedMac(HmacAlgorithms.HMAC_SHA_512, key);
}
@@ -209,568 +129,123 @@ public static Mac getInitializedMac(final String algorithm, final byte[] key) {
}
}
- /**
- * Returns a HmacMD5 Message Authentication Code (MAC) for the given key and value.
- *
- * @param key
- * The key for the keyed digest (must not be null)
- * @param valueToDigest
- * The value (data) which should to digest (maybe empty or null)
- * @return HmacMD5 MAC for the given key and value
- * @throws IllegalArgumentException
- * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid.
- * @deprecated (1.11) Use {@code new HmacUtils(HmacAlgorithms.HMAC_MD5, byte[]).hmac(byte[])}
- */
- @Deprecated
public static byte[] hmacMd5(final byte[] key, final byte[] valueToDigest) {
return new HmacUtils(HmacAlgorithms.HMAC_MD5, key).hmac(valueToDigest);
}
- /**
- * Returns a HmacMD5 Message Authentication Code (MAC) for the given key and value.
- *
- * @param key
- * The key for the keyed digest (must not be null)
- * @param valueToDigest
- * The value (data) which should to digest
- *
- * The InputStream must not be null and will not be closed
- *
- * @return HmacMD5 MAC for the given key and value
- * @throws IOException
- * If an I/O error occurs.
- * @throws IllegalArgumentException
- * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid.
- * @deprecated (1.11) Use {@code new HmacUtils(HmacAlgorithms.HMAC_MD5, byte[]).hmac(InputStream)}
- */
- @Deprecated
public static byte[] hmacMd5(final byte[] key, final InputStream valueToDigest) throws IOException {
return new HmacUtils(HmacAlgorithms.HMAC_MD5, key).hmac(valueToDigest);
}
- /**
- * Returns a HmacMD5 Message Authentication Code (MAC) for the given key and value.
- *
- * @param key
- * The key for the keyed digest (must not be null)
- * @param valueToDigest
- * The value (data) which should to digest (maybe empty or null)
- * @return HmacMD5 MAC for the given key and value
- * @throws IllegalArgumentException
- * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid.
- * @deprecated (1.11) Use {@code new HmacUtils(HmacAlgorithms.HMAC_MD5, String).hmac(String)}
- */
- @Deprecated
public static byte[] hmacMd5(final String key, final String valueToDigest) {
return new HmacUtils(HmacAlgorithms.HMAC_MD5, key).hmac(valueToDigest);
}
- /**
- * Returns a HmacMD5 Message Authentication Code (MAC) as a hexadecimal string (lowercase) for the given key and value.
- *
- * @param key
- * The key for the keyed digest (must not be null)
- * @param valueToDigest
- * The value (data) which should to digest (maybe empty or null)
- * @return HmacMD5 MAC for the given key and value as a hexadecimal string (lowercase)
- * @throws IllegalArgumentException
- * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid.
- * @deprecated (1.11) Use {@code new HmacUtils(HmacAlgorithms.HMAC_MD5, byte[]).hmacHex(byte[])}
- */
- @Deprecated
public static String hmacMd5Hex(final byte[] key, final byte[] valueToDigest) {
return new HmacUtils(HmacAlgorithms.HMAC_MD5, key).hmacHex(valueToDigest);
}
- /**
- * Returns a HmacMD5 Message Authentication Code (MAC) as a hexadecimal string (lowercase) for the given key and value.
- *
- * @param key
- * The key for the keyed digest (must not be null)
- * @param valueToDigest
- * The value (data) which should to digest
- *
- * The InputStream must not be null and will not be closed
- *
- * @return HmacMD5 MAC for the given key and value as a hexadecimal string (lowercase)
- * @throws IOException
- * If an I/O error occurs.
- * @throws IllegalArgumentException
- * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid.
- * @deprecated (1.11) Use {@code new HmacUtils(HmacAlgorithms.HMAC_MD5, byte[]).hmacHex(InputStream)}
- */
- @Deprecated
public static String hmacMd5Hex(final byte[] key, final InputStream valueToDigest) throws IOException {
return new HmacUtils(HmacAlgorithms.HMAC_MD5, key).hmacHex(valueToDigest);
}
- /**
- * Returns a HmacMD5 Message Authentication Code (MAC) as a hexadecimal string (lowercase) for the given key and value.
- *
- * @param key
- * The key for the keyed digest (must not be null)
- * @param valueToDigest
- * The value (data) which should to digest (maybe empty or null)
- * @return HmacMD5 MAC for the given key and value as a hexadecimal string (lowercase)
- * @throws IllegalArgumentException
- * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid.
- * @deprecated (1.11) Use {@code new HmacUtils(HmacAlgorithms.HMAC_MD5, String).hmacHex(String)}
- */
- @Deprecated
public static String hmacMd5Hex(final String key, final String valueToDigest) {
return new HmacUtils(HmacAlgorithms.HMAC_MD5, key).hmacHex(valueToDigest);
}
- /**
- * Returns a HmacSHA1 Message Authentication Code (MAC) for the given key and value.
- *
- * @param key
- * The key for the keyed digest (must not be null)
- * @param valueToDigest
- * The value (data) which should to digest (maybe empty or null)
- * @return HmacSHA1 MAC for the given key and value
- * @throws IllegalArgumentException
- * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid.
- * @deprecated (1.11) Use {@code new HmacUtils(HmacAlgorithms.HMAC_SHA_1, byte[]).hmac(byte[])}
- */
- @Deprecated
public static byte[] hmacSha1(final byte[] key, final byte[] valueToDigest) {
return new HmacUtils(HmacAlgorithms.HMAC_SHA_1, key).hmac(valueToDigest);
}
- /**
- * Returns a HmacSHA1 Message Authentication Code (MAC) for the given key and value.
- *
- * @param key
- * The key for the keyed digest (must not be null)
- * @param valueToDigest
- * The value (data) which should to digest
- *
- * The InputStream must not be null and will not be closed
- *
- * @return HmacSHA1 MAC for the given key and value
- * @throws IOException
- * If an I/O error occurs.
- * @throws IllegalArgumentException
- * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid.
- * @deprecated (1.11) Use {@code new HmacUtils(HmacAlgorithms.HMAC_SHA_1, byte[]).hmac(InputStream)}
- */
- @Deprecated
public static byte[] hmacSha1(final byte[] key, final InputStream valueToDigest) throws IOException {
return new HmacUtils(HmacAlgorithms.HMAC_SHA_1, key).hmac(valueToDigest);
}
- /**
- * Returns a HmacSHA1 Message Authentication Code (MAC) for the given key and value.
- *
- * @param key
- * The key for the keyed digest (must not be null)
- * @param valueToDigest
- * The value (data) which should to digest (maybe empty or null)
- * @return HmacSHA1 MAC for the given key and value
- * @throws IllegalArgumentException
- * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid.
- * @deprecated (1.11) Use {@code new HmacUtils(HmacAlgorithms.HMAC_SHA_1, String).hmac(String)}
- */
- @Deprecated
public static byte[] hmacSha1(final String key, final String valueToDigest) {
return new HmacUtils(HmacAlgorithms.HMAC_SHA_1, key).hmac(valueToDigest);
}
- // hmacSha1
-
- /**
- * Returns a HmacSHA1 Message Authentication Code (MAC) as hexadecimal string (lowercase) for the given key and value.
- *
- * @param key
- * The key for the keyed digest (must not be null)
- * @param valueToDigest
- * The value (data) which should to digest (maybe empty or null)
- * @return HmacSHA1 MAC for the given key and value as hexadecimal string (lowercase)
- * @throws IllegalArgumentException
- * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid.
- * @deprecated (1.11) Use {@code new HmacUtils(HmacAlgorithms.HMAC_SHA_1, byte[]).hmacHex(byte[])}
- */
- @Deprecated
public static String hmacSha1Hex(final byte[] key, final byte[] valueToDigest) {
return new HmacUtils(HmacAlgorithms.HMAC_SHA_1, key).hmacHex(valueToDigest);
}
- /**
- * Returns a HmacSHA1 Message Authentication Code (MAC) as hexadecimal string (lowercase) for the given key and value.
- *
- * @param key
- * The key for the keyed digest (must not be null)
- * @param valueToDigest
- * The value (data) which should to digest
- *
- * The InputStream must not be null and will not be closed
- *
- * @return HmacSHA1 MAC for the given key and value as hexadecimal string (lowercase)
- * @throws IOException
- * If an I/O error occurs.
- * @throws IllegalArgumentException
- * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid.
- * @deprecated (1.11) Use {@code new HmacUtils(HmacAlgorithms.HMAC_SHA_1, byte[]).hmacHex(InputStream)}
- */
- @Deprecated
public static String hmacSha1Hex(final byte[] key, final InputStream valueToDigest) throws IOException {
return new HmacUtils(HmacAlgorithms.HMAC_SHA_1, key).hmacHex(valueToDigest);
}
- /**
- * Returns a HmacSHA1 Message Authentication Code (MAC) as hexadecimal string (lowercase) for the given key and value.
- *
- * @param key
- * The key for the keyed digest (must not be null)
- * @param valueToDigest
- * The value (data) which should to digest (maybe empty or null)
- * @return HmacSHA1 MAC for the given key and value as hexadecimal string (lowercase)
- * @throws IllegalArgumentException
- * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid.
- * @deprecated (1.11) Use {@code new HmacUtils(HmacAlgorithms.HMAC_SHA_1, String).hmacHex(String)}
- */
- @Deprecated
public static String hmacSha1Hex(final String key, final String valueToDigest) {
return new HmacUtils(HmacAlgorithms.HMAC_SHA_1, key).hmacHex(valueToDigest);
}
- /**
- * Returns a HmacSHA256 Message Authentication Code (MAC) for the given key and value.
- *
- * @param key
- * The key for the keyed digest (must not be null)
- * @param valueToDigest
- * The value (data) which should to digest (maybe empty or null)
- * @return HmacSHA256 MAC for the given key and value
- * @throws IllegalArgumentException
- * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid.
- * @deprecated (1.11) Use {@code new HmacUtils(HmacAlgorithms.HMAC_SHA_256, byte[]).hmac(byte[])}
- */
- @Deprecated
public static byte[] hmacSha256(final byte[] key, final byte[] valueToDigest) {
return new HmacUtils(HmacAlgorithms.HMAC_SHA_256, key).hmac(valueToDigest);
}
- /**
- * Returns a HmacSHA256 Message Authentication Code (MAC) for the given key and value.
- *
- * @param key
- * The key for the keyed digest (must not be null)
- * @param valueToDigest
- * The value (data) which should to digest
- *
- * The InputStream must not be null and will not be closed
- *
- * @return HmacSHA256 MAC for the given key and value
- * @throws IOException
- * If an I/O error occurs.
- * @throws IllegalArgumentException
- * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid.
- * @deprecated (1.11) Use {@code new HmacUtils(HmacAlgorithms.HMAC_SHA_256, byte[]).hmac(InputStream)}
- */
- @Deprecated
public static byte[] hmacSha256(final byte[] key, final InputStream valueToDigest) throws IOException {
return new HmacUtils(HmacAlgorithms.HMAC_SHA_256, key).hmac(valueToDigest);
}
- /**
- * Returns a HmacSHA256 Message Authentication Code (MAC) for the given key and value.
- *
- * @param key
- * The key for the keyed digest (must not be null)
- * @param valueToDigest
- * The value (data) which should to digest (maybe empty or null)
- * @return HmacSHA256 MAC for the given key and value
- * @throws IllegalArgumentException
- * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid.
- * @deprecated (1.11) Use {@code new HmacUtils(HmacAlgorithms.HMAC_SHA_256, String).hmac(String)}
- */
- @Deprecated
public static byte[] hmacSha256(final String key, final String valueToDigest) {
return new HmacUtils(HmacAlgorithms.HMAC_SHA_256, key).hmac(valueToDigest);
}
- /**
- * Returns a HmacSHA256 Message Authentication Code (MAC) as hexadecimal string (lowercase) for the given key and value.
- *
- * @param key
- * The key for the keyed digest (must not be null)
- * @param valueToDigest
- * The value (data) which should to digest (maybe empty or null)
- * @return HmacSHA256 MAC for the given key and value as hexadecimal string (lowercase)
- * @throws IllegalArgumentException
- * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid.
- * @deprecated (1.11) Use {@code new HmacUtils(HmacAlgorithms.HMAC_SHA_256, byte[]).hmacHex(byte[])}
- */
- @Deprecated
public static String hmacSha256Hex(final byte[] key, final byte[] valueToDigest) {
return new HmacUtils(HmacAlgorithms.HMAC_SHA_256, key).hmacHex(valueToDigest);
}
- /**
- * Returns a HmacSHA256 Message Authentication Code (MAC) as hexadecimal string (lowercase) for the given key and value.
- *
- * @param key
- * The key for the keyed digest (must not be null)
- * @param valueToDigest
- * The value (data) which should to digest
- *
- * The InputStream must not be null and will not be closed
- *
- * @return HmacSHA256 MAC for the given key and value as hexadecimal string (lowercase)
- * @throws IOException
- * If an I/O error occurs.
- * @throws IllegalArgumentException
- * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid.
- * @deprecated (1.11) Use {@code new HmacUtils(HmacAlgorithms.HMAC_SHA_256, byte[]).hmacHex(InputStream)}
- */
- @Deprecated
public static String hmacSha256Hex(final byte[] key, final InputStream valueToDigest) throws IOException {
return new HmacUtils(HmacAlgorithms.HMAC_SHA_256, key).hmacHex(valueToDigest);
}
- /**
- * Returns a HmacSHA256 Message Authentication Code (MAC) as hexadecimal string (lowercase) for the given key and value.
- *
- * @param key
- * The key for the keyed digest (must not be null)
- * @param valueToDigest
- * The value (data) which should to digest (maybe empty or null)
- * @return HmacSHA256 MAC for the given key and value as hexadecimal string (lowercase)
- * @throws IllegalArgumentException
- * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid.
- * @deprecated (1.11) Use {@code new HmacUtils(HmacAlgorithms.HMAC_SHA_256, String).hmacHex(String)}
- */
- @Deprecated
public static String hmacSha256Hex(final String key, final String valueToDigest) {
return new HmacUtils(HmacAlgorithms.HMAC_SHA_256, key).hmacHex(valueToDigest);
}
- /**
- * Returns a HmacSHA384 Message Authentication Code (MAC) for the given key and value.
- *
- * @param key
- * The key for the keyed digest (must not be null)
- * @param valueToDigest
- * The value (data) which should to digest (maybe empty or null)
- * @return HmacSHA384 MAC for the given key and value
- * @throws IllegalArgumentException
- * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid.
- * @deprecated (1.11) Use {@code new HmacUtils(HmacAlgorithms.HMAC_SHA_384, byte[]).hmac(byte[])}
- */
- @Deprecated
public static byte[] hmacSha384(final byte[] key, final byte[] valueToDigest) {
return new HmacUtils(HmacAlgorithms.HMAC_SHA_384, key).hmac(valueToDigest);
}
- /**
- * Returns a HmacSHA384 Message Authentication Code (MAC) for the given key and value.
- *
- * @param key
- * The key for the keyed digest (must not be null)
- * @param valueToDigest
- * The value (data) which should to digest
- *
- * The InputStream must not be null and will not be closed
- *
- * @return HmacSHA384 MAC for the given key and value
- * @throws IOException
- * If an I/O error occurs.
- * @throws IllegalArgumentException
- * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid.
- * @deprecated (1.11) Use {@code new HmacUtils(HmacAlgorithms.HMAC_SHA_384, byte[]).hmac(InputStream)}
- */
- @Deprecated
public static byte[] hmacSha384(final byte[] key, final InputStream valueToDigest) throws IOException {
return new HmacUtils(HmacAlgorithms.HMAC_SHA_384, key).hmac(valueToDigest);
}
- /**
- * Returns a HmacSHA384 Message Authentication Code (MAC) for the given key and value.
- *
- * @param key
- * The key for the keyed digest (must not be null)
- * @param valueToDigest
- * The value (data) which should to digest (maybe empty or null)
- * @return HmacSHA384 MAC for the given key and value
- * @throws IllegalArgumentException
- * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid.
- * @deprecated (1.11) Use {@code new HmacUtils(HmacAlgorithms.HMAC_SHA_384, String).hmac(String)}
- */
- @Deprecated
public static byte[] hmacSha384(final String key, final String valueToDigest) {
return new HmacUtils(HmacAlgorithms.HMAC_SHA_384, key).hmac(valueToDigest);
}
- // hmacSha384
-
- /**
- * Returns a HmacSHA384 Message Authentication Code (MAC) as hexadecimal string (lowercase) for the given key and value.
- *
- * @param key
- * The key for the keyed digest (must not be null)
- * @param valueToDigest
- * The value (data) which should to digest (maybe empty or null)
- * @return HmacSHA384 MAC for the given key and value as hexadecimal string (lowercase)
- * @throws IllegalArgumentException
- * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid.
- * @deprecated (1.11) Use {@code new HmacUtils(HmacAlgorithms.HMAC_SHA_384, byte[]).hmacHex(byte[])}
- */
- @Deprecated
public static String hmacSha384Hex(final byte[] key, final byte[] valueToDigest) {
return new HmacUtils(HmacAlgorithms.HMAC_SHA_384, key).hmacHex(valueToDigest);
}
- /**
- * Returns a HmacSHA384 Message Authentication Code (MAC) as hexadecimal string (lowercase) for the given key and value.
- *
- * @param key
- * The key for the keyed digest (must not be null)
- * @param valueToDigest
- * The value (data) which should to digest
- *
- * The InputStream must not be null and will not be closed
- *
- * @return HmacSHA384 MAC for the given key and value as hexadecimal string (lowercase)
- * @throws IOException
- * If an I/O error occurs.
- * @throws IllegalArgumentException
- * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid.
- * @deprecated (1.11) Use {@code new HmacUtils(HmacAlgorithms.HMAC_SHA_384, byte[]).hmacHex(InputStream)}
- */
- @Deprecated
public static String hmacSha384Hex(final byte[] key, final InputStream valueToDigest) throws IOException {
return new HmacUtils(HmacAlgorithms.HMAC_SHA_384, key).hmacHex(valueToDigest);
}
- /**
- * Returns a HmacSHA384 Message Authentication Code (MAC) as hexadecimal string (lowercase) for the given key and value.
- *
- * @param key
- * The key for the keyed digest (must not be null)
- * @param valueToDigest
- * The value (data) which should to digest (maybe empty or null)
- * @return HmacSHA384 MAC for the given key and value as hexadecimal string (lowercase)
- * @throws IllegalArgumentException
- * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid.
- * @deprecated (1.11) Use {@code new HmacUtils(HmacAlgorithms.HMAC_SHA_384, String).hmacHex(String)}
- */
- @Deprecated
public static String hmacSha384Hex(final String key, final String valueToDigest) {
return new HmacUtils(HmacAlgorithms.HMAC_SHA_384, key).hmacHex(valueToDigest);
}
- /**
- * Returns a HmacSHA512 Message Authentication Code (MAC) for the given key and value.
- *
- * @param key
- * The key for the keyed digest (must not be null)
- * @param valueToDigest
- * The value (data) which should to digest (maybe empty or null)
- * @return HmacSHA512 MAC for the given key and value
- * @throws IllegalArgumentException
- * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid.
- * @deprecated (1.11) Use {@code new HmacUtils(HmacAlgorithms.HMAC_SHA_512, byte[]).hmac(byte[])}
- */
- @Deprecated
public static byte[] hmacSha512(final byte[] key, final byte[] valueToDigest) {
return new HmacUtils(HmacAlgorithms.HMAC_SHA_512, key).hmac(valueToDigest);
}
- /**
- * Returns a HmacSHA512 Message Authentication Code (MAC) for the given key and value.
- *
- * @param key
- * The key for the keyed digest (must not be null)
- * @param valueToDigest
- * The value (data) which should to digest
- *
- * The InputStream must not be null and will not be closed
- *
- * @return HmacSHA512 MAC for the given key and value
- * @throws IOException
- * If an I/O error occurs.
- * @throws IllegalArgumentException
- * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid.
- * @deprecated (1.11) Use {@code new HmacUtils(HmacAlgorithms.HMAC_SHA_512, byte[]).hmac(InputStream)}
- */
- @Deprecated
public static byte[] hmacSha512(final byte[] key, final InputStream valueToDigest) throws IOException {
return new HmacUtils(HmacAlgorithms.HMAC_SHA_512, key).hmac(valueToDigest);
}
- /**
- * Returns a HmacSHA512 Message Authentication Code (MAC) for the given key and value.
- *
- * @param key
- * The key for the keyed digest (must not be null)
- * @param valueToDigest
- * The value (data) which should to digest (maybe empty or null)
- * @return HmacSHA512 MAC for the given key and value
- * @throws IllegalArgumentException
- * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid.
- * @deprecated (1.11) Use {@code new HmacUtils(HmacAlgorithms.HMAC_SHA_512, String).hmac(String)}
- */
- @Deprecated
public static byte[] hmacSha512(final String key, final String valueToDigest) {
return new HmacUtils(HmacAlgorithms.HMAC_SHA_512, key).hmac(valueToDigest);
}
- // hmacSha512
-
- /**
- * Returns a HmacSHA512 Message Authentication Code (MAC) as hexadecimal string (lowercase) for the given key and value.
- *
- * @param key
- * The key for the keyed digest (must not be null)
- * @param valueToDigest
- * The value (data) which should to digest (maybe empty or null)
- * @return HmacSHA512 MAC for the given key and value as hexadecimal string (lowercase)
- * @throws IllegalArgumentException
- * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid.
- * @deprecated (1.11) Use {@code new HmacUtils(HmacAlgorithms.HMAC_SHA_512, byte[]).hmacHex(byte[])}
- */
- @Deprecated
public static String hmacSha512Hex(final byte[] key, final byte[] valueToDigest) {
return new HmacUtils(HmacAlgorithms.HMAC_SHA_512, key).hmacHex(valueToDigest);
}
- /**
- * Returns a HmacSHA512 Message Authentication Code (MAC) as hexadecimal string (lowercase) for the given key and value.
- *
- * @param key
- * The key for the keyed digest (must not be null)
- * @param valueToDigest
- * The value (data) which should to digest
- *
- * The InputStream must not be null and will not be closed
- *
- * @return HmacSHA512 MAC for the given key and value as hexadecimal string (lowercase)
- * @throws IOException
- * If an I/O error occurs.
- * @throws IllegalArgumentException
- * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid.
- * @deprecated (1.11) Use {@code new HmacUtils(HmacAlgorithms.HMAC_SHA_512, byte[]).hmacHex(InputStream)}
- */
- @Deprecated
public static String hmacSha512Hex(final byte[] key, final InputStream valueToDigest) throws IOException {
return new HmacUtils(HmacAlgorithms.HMAC_SHA_512, key).hmacHex(valueToDigest);
}
- /**
- * Returns a HmacSHA512 Message Authentication Code (MAC) as hexadecimal string (lowercase) for the given key and value.
- *
- * @param key
- * The key for the keyed digest (must not be null)
- * @param valueToDigest
- * The value (data) which should to digest (maybe empty or null)
- * @return HmacSHA512 MAC for the given key and value as hexadecimal string (lowercase)
- * @throws IllegalArgumentException
- * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid.
- * @deprecated (1.11) Use {@code new HmacUtils(HmacAlgorithms.HMAC_SHA_512, String).hmacHex(String)}
- */
- @Deprecated
+
public static String hmacSha512Hex(final String key, final String valueToDigest) {
return new HmacUtils(HmacAlgorithms.HMAC_SHA_512, key).hmacHex(valueToDigest);
}
@@ -872,12 +347,6 @@ public static Mac updateHmac(final Mac mac, final String valueToDigest) {
private final Mac mac;
- /**
- * Preserves binary compatibility only.
- * As for previous versions does not provide useful behavior
- * @deprecated since 1.11; only useful to preserve binary compatibility
- */
- @Deprecated
public HmacUtils() {
this(null);
}
diff --git a/src/main/java/org/apache/commons/codec/digest/Md5Crypt.java b/src/main/java/org/apache/commons/codec/digest/Md5Crypt.java
index 732e305295..87aa786675 100644
--- a/src/main/java/org/apache/commons/codec/digest/Md5Crypt.java
+++ b/src/main/java/org/apache/commons/codec/digest/Md5Crypt.java
@@ -404,12 +404,6 @@ public static String md5Crypt(final byte[] keyBytes, final String salt, final St
return passwd.toString();
}
- /**
- * TODO Make private in 2.0.
- *
- * @deprecated TODO Make private in 2.0.
- */
- @Deprecated
public Md5Crypt() {
// empty
}
From dd643cff00e80ad7b70e1c3c0333c18809bd81ae Mon Sep 17 00:00:00 2001
From: omosteven
Date: Sun, 5 Jan 2025 10:31:51 +0100
Subject: [PATCH 11/24] fixed more issues
---
.../commons/codec/digest/MurmurHash3.java | 72 -------------------
.../commons/codec/digest/Sha2Crypt.java | 6 --
.../commons/codec/digest/UnixCrypt.java | 6 --
.../commons/codec/language/Caverphone.java | 2 -
.../commons/codec/language/Soundex.java | 6 --
.../commons/codec/language/bm/Rule.java | 3 -
.../apache/commons/codec/net/URLCodec.java | 6 --
7 files changed, 101 deletions(-)
diff --git a/src/main/java/org/apache/commons/codec/digest/MurmurHash3.java b/src/main/java/org/apache/commons/codec/digest/MurmurHash3.java
index 24856133de..f98f85a05b 100644
--- a/src/main/java/org/apache/commons/codec/digest/MurmurHash3.java
+++ b/src/main/java/org/apache/commons/codec/digest/MurmurHash3.java
@@ -57,20 +57,6 @@
*/
public final class MurmurHash3 {
- /**
- * Generates 32-bit hash from input bytes. Bytes can be added incrementally and the new
- * hash computed.
- *
- * This is an implementation of the 32-bit hash function {@code MurmurHash3_x86_32}
- * from Austin Appleby's original MurmurHash3 {@code c++} code in SMHasher.
- *
- * This implementation contains a sign-extension bug in the finalization step of
- * any bytes left over from dividing the length by 4. This manifests if any of these
- * bytes are negative.
- *
- * @deprecated Use IncrementalHash32x86. This corrects the processing of trailing bytes.
- */
- @Deprecated
public static class IncrementalHash32 extends IncrementalHash32x86 {
/**
@@ -80,17 +66,6 @@ public IncrementalHash32() {
// empty
}
- /**
- * {@inheritDoc}
- *
- * This implementation contains a sign-extension bug in the finalization step of
- * any bytes left over from dividing the length by 4. This manifests if any of these
- * bytes are negative.
- *
- * @deprecated Use IncrementalHash32x86. This corrects the processing of trailing bytes.
- */
- @Override
- @Deprecated
int finalise(final int hash, final int unprocessedLength, final byte[] unprocessed, final int totalLen) {
int result = hash;
// ************
@@ -303,12 +278,6 @@ public final void start(final int seed) {
}
}
- /**
- * A random number to use for a hash code.
- *
- * @deprecated This is not used internally and will be removed in a future release.
- */
- @Deprecated
public static final long NULL_HASHCODE = 2862933555777941757L;
/**
* A default seed to use for the murmur hash algorithm.
@@ -418,23 +387,6 @@ public static long[] hash128(final byte[] data) {
return hash128(data, 0, data.length, DEFAULT_SEED);
}
- /**
- * Generates 128-bit hash from the byte array with the given offset, length and seed.
- *
- *
This is an implementation of the 128-bit hash function {@code MurmurHash3_x64_128}
- * from Austin Appleby's original MurmurHash3 {@code c++} code in SMHasher.
- *
- * This implementation contains a sign-extension bug in the seed initialization.
- * This manifests if the seed is negative.
- *
- * @param data The input byte array
- * @param offset The first element of array
- * @param length The length of array
- * @param seed The initial seed value
- * @return The 128-bit hash (2 longs)
- * @deprecated Use {@link #hash128x64(byte[], int, int, int)}. This corrects the seed initialization.
- */
- @Deprecated
public static long[] hash128(final byte[] data, final int offset, final int length, final int seed) {
// ************
// Note: This deliberately fails to apply masking using 0xffffffffL to the seed
@@ -468,10 +420,8 @@ public static long[] hash128(final byte[] data, final int offset, final int leng
* @param data The input String
* @return The 128-bit hash (2 longs)
* @see #hash128(byte[], int, int, int)
- * @deprecated Use {@link #hash128x64(byte[])} using the bytes returned from
* {@link String#getBytes(java.nio.charset.Charset)}.
*/
- @Deprecated
public static long[] hash128(final String data) {
final byte[] bytes = StringUtils.getBytesUtf8(data);
return hash128(bytes, 0, bytes.length, DEFAULT_SEED);
@@ -635,9 +585,7 @@ private static long[] hash128x64Internal(final byte[] data, final int offset, fi
* @param data The input byte array
* @return The 32-bit hash
* @see #hash32(byte[], int, int, int)
- * @deprecated Use {@link #hash32x86(byte[], int, int, int)}. This corrects the processing of trailing bytes.
*/
- @Deprecated
public static int hash32(final byte[] data) {
return hash32(data, 0, data.length, DEFAULT_SEED);
}
@@ -660,9 +608,7 @@ public static int hash32(final byte[] data) {
* @param length The length of array
* @return The 32-bit hash
* @see #hash32(byte[], int, int, int)
- * @deprecated Use {@link #hash32x86(byte[], int, int, int)}. This corrects the processing of trailing bytes.
*/
- @Deprecated
public static int hash32(final byte[] data, final int length) {
return hash32(data, length, DEFAULT_SEED);
}
@@ -685,9 +631,7 @@ public static int hash32(final byte[] data, final int length) {
* @param seed The initial seed value
* @return The 32-bit hash
* @see #hash32(byte[], int, int, int)
- * @deprecated Use {@link #hash32x86(byte[], int, int, int)}. This corrects the processing of trailing bytes.
*/
- @Deprecated
public static int hash32(final byte[] data, final int length, final int seed) {
return hash32(data, 0, length, seed);
}
@@ -707,9 +651,7 @@ public static int hash32(final byte[] data, final int length, final int seed) {
* @param length The length of array
* @param seed The initial seed value
* @return The 32-bit hash
- * @deprecated Use {@link #hash32x86(byte[], int, int, int)}. This corrects the processing of trailing bytes.
*/
- @Deprecated
public static int hash32(final byte[] data, final int offset, final int length, final int seed) {
int hash = seed;
final int nblocks = length >> 2;
@@ -869,10 +811,8 @@ public static int hash32(final long data1, final long data2, final int seed) {
* @param data The input string
* @return The 32-bit hash
* @see #hash32(byte[], int, int, int)
- * @deprecated Use {@link #hash32x86(byte[], int, int, int)} with the bytes returned from
* {@link String#getBytes(java.nio.charset.Charset)}. This corrects the processing of trailing bytes.
*/
- @Deprecated
public static int hash32(final String data) {
final byte[] bytes = StringUtils.getBytesUtf8(data);
return hash32(bytes, 0, bytes.length, DEFAULT_SEED);
@@ -967,10 +907,8 @@ public static int hash32x86(final byte[] data, final int offset, final int lengt
* @param data The input byte array
* @return The 64-bit hash
* @see #hash64(byte[], int, int, int)
- * @deprecated Not part of the MurmurHash3 implementation.
* Use half of the hash bytes from {@link #hash128x64(byte[])}.
*/
- @Deprecated
public static long hash64(final byte[] data) {
return hash64(data, 0, data.length, DEFAULT_SEED);
}
@@ -1000,10 +938,8 @@ public static long hash64(final byte[] data) {
* @param length The length of array
* @return The 64-bit hash
* @see #hash64(byte[], int, int, int)
- * @deprecated Not part of the MurmurHash3 implementation.
* Use half of the hash bytes from {@link #hash128x64(byte[], int, int, int)}.
*/
- @Deprecated
public static long hash64(final byte[] data, final int offset, final int length) {
return hash64(data, offset, length, DEFAULT_SEED);
}
@@ -1033,10 +969,8 @@ public static long hash64(final byte[] data, final int offset, final int length)
* @param length The length of array
* @param seed The initial seed value
* @return The 64-bit hash
- * @deprecated Not part of the MurmurHash3 implementation.
* Use half of the hash bytes from {@link #hash128x64(byte[], int, int, int)}.
*/
- @Deprecated
public static long hash64(final byte[] data, final int offset, final int length, final int seed) {
//
// Note: This fails to apply masking using 0xffffffffL to the seed.
@@ -1112,10 +1046,8 @@ public static long hash64(final byte[] data, final int offset, final int length,
* @param data The int to hash
* @return The 64-bit hash
* @see #hash64(byte[], int, int, int)
- * @deprecated Not part of the MurmurHash3 implementation.
* Use half of the hash bytes from {@link #hash128x64(byte[])} with the bytes from the {@code int}.
*/
- @Deprecated
public static long hash64(final int data) {
long k1 = Integer.reverseBytes(data) & -1L >>> 32;
long hash = DEFAULT_SEED;
@@ -1154,10 +1086,8 @@ public static long hash64(final int data) {
* @param data The long to hash
* @return The 64-bit hash
* @see #hash64(byte[], int, int, int)
- * @deprecated Not part of the MurmurHash3 implementation.
* Use half of the hash bytes from {@link #hash128x64(byte[])} with the bytes from the {@code long}.
*/
- @Deprecated
public static long hash64(final long data) {
long hash = DEFAULT_SEED;
long k = Long.reverseBytes(data);
@@ -1198,10 +1128,8 @@ public static long hash64(final long data) {
* @param data The short to hash
* @return The 64-bit hash
* @see #hash64(byte[], int, int, int)
- * @deprecated Not part of the MurmurHash3 implementation.
* Use half of the hash bytes from {@link #hash128x64(byte[])} with the bytes from the {@code short}.
*/
- @Deprecated
public static long hash64(final short data) {
long hash = DEFAULT_SEED;
long k1 = 0;
diff --git a/src/main/java/org/apache/commons/codec/digest/Sha2Crypt.java b/src/main/java/org/apache/commons/codec/digest/Sha2Crypt.java
index f004c83069..ac153cdddb 100644
--- a/src/main/java/org/apache/commons/codec/digest/Sha2Crypt.java
+++ b/src/main/java/org/apache/commons/codec/digest/Sha2Crypt.java
@@ -614,12 +614,6 @@ public static String sha512Crypt(final byte[] keyBytes, String salt, final Rando
return sha2Crypt(keyBytes, salt, SHA512_PREFIX, SHA512_BLOCKSIZE, MessageDigestAlgorithms.SHA_512);
}
- /**
- * Consider private.
- *
- * @deprecated Will be private in the next major version.
- */
- @Deprecated
public Sha2Crypt() {
// empty
}
diff --git a/src/main/java/org/apache/commons/codec/digest/UnixCrypt.java b/src/main/java/org/apache/commons/codec/digest/UnixCrypt.java
index 6ab7f4a4f2..0187f4f1a1 100644
--- a/src/main/java/org/apache/commons/codec/digest/UnixCrypt.java
+++ b/src/main/java/org/apache/commons/codec/digest/UnixCrypt.java
@@ -413,12 +413,6 @@ private static void permOp(int a, int b, final int n, final int m, final int[] r
results[1] = b;
}
- /**
- * TODO Make private in 2.0.
- *
- * @deprecated TODO Make private in 2.0.
- */
- @Deprecated
public UnixCrypt() {
// empty
}
diff --git a/src/main/java/org/apache/commons/codec/language/Caverphone.java b/src/main/java/org/apache/commons/codec/language/Caverphone.java
index b9459dc64b..b2db3a7f8c 100644
--- a/src/main/java/org/apache/commons/codec/language/Caverphone.java
+++ b/src/main/java/org/apache/commons/codec/language/Caverphone.java
@@ -29,9 +29,7 @@
* @see Wikipedia - Caverphone
* @see Caverphone 2.0 specification
* @since 1.4
- * @deprecated 1.5 Replaced by {@link Caverphone2}, will be removed in 2.0.
*/
-@Deprecated
public class Caverphone implements StringEncoder {
/**
diff --git a/src/main/java/org/apache/commons/codec/language/Soundex.java b/src/main/java/org/apache/commons/codec/language/Soundex.java
index fd6aacedd2..f6c1bb4a5f 100644
--- a/src/main/java/org/apache/commons/codec/language/Soundex.java
+++ b/src/main/java/org/apache/commons/codec/language/Soundex.java
@@ -113,9 +113,7 @@ public class Soundex implements StringEncoder {
/**
* The maximum length of a Soundex code - Soundex codes are only four characters by definition.
*
- * @deprecated This feature is not needed since the encoding size must be constant. Will be removed in 2.0.
*/
- @Deprecated
private int maxLength = 4;
/**
@@ -254,10 +252,8 @@ public String encode(final String str) {
/**
* Returns the maxLength. Standard Soundex
*
- * @deprecated This feature is not needed since the encoding size must be constant. Will be removed in 2.0.
* @return int
*/
- @Deprecated
public int getMaxLength() {
return this.maxLength;
}
@@ -291,11 +287,9 @@ private char map(final char ch) {
/**
* Sets the maxLength.
*
- * @deprecated This feature is not needed since the encoding size must be constant. Will be removed in 2.0.
* @param maxLength
* The maxLength to set
*/
- @Deprecated
public void setMaxLength(final int maxLength) {
this.maxLength = maxLength;
}
diff --git a/src/main/java/org/apache/commons/codec/language/bm/Rule.java b/src/main/java/org/apache/commons/codec/language/bm/Rule.java
index 871af3882a..b8b41efcd3 100644
--- a/src/main/java/org/apache/commons/codec/language/bm/Rule.java
+++ b/src/main/java/org/apache/commons/codec/language/bm/Rule.java
@@ -185,13 +185,10 @@ public CharSequence getPhonemeText() {
}
/**
- * Deprecated since 1.9.
*
* @param right the Phoneme to join
* @return a new Phoneme
- * @deprecated since 1.9
*/
- @Deprecated
public Phoneme join(final Phoneme right) {
return new Phoneme(this.phonemeText.toString() + right.phonemeText.toString(),
this.languages.restrictTo(right.languages));
diff --git a/src/main/java/org/apache/commons/codec/net/URLCodec.java b/src/main/java/org/apache/commons/codec/net/URLCodec.java
index e01838799e..f5908f3cef 100644
--- a/src/main/java/org/apache/commons/codec/net/URLCodec.java
+++ b/src/main/java/org/apache/commons/codec/net/URLCodec.java
@@ -57,9 +57,7 @@ public class URLCodec implements BinaryEncoder, BinaryDecoder, StringEncoder, St
* BitSet of www-form-url safe characters.
* This is a copy of the internal BitSet which is now used for the conversion.
* Changes to this field are ignored.
- * @deprecated 1.11 Will be removed in 2.0 (CODEC-230)
*/
- @Deprecated
protected static final BitSet WWW_FORM_URL;
private static final BitSet WWW_FORM_URL_SAFE = new BitSet(256);
@@ -165,9 +163,7 @@ public static final byte[] encodeUrl(BitSet urlsafe, final byte[] bytes) {
/**
* The default charset used for string decoding and encoding.
*
- * @deprecated TODO: This field will be changed to a private final Charset in 2.0. (CODEC-126)
*/
- @Deprecated
protected volatile String charset; // added volatile: see CODEC-232
/**
@@ -360,9 +356,7 @@ public String getDefaultCharset() {
* The {@code String} encoding used for decoding and encoding.
*
* @return Returns the encoding.
- * @deprecated Use {@link #getDefaultCharset()}, will be removed in 2.0.
*/
- @Deprecated
public String getEncoding() {
return this.charset;
}
From 22a1d87ad13f862684afd4f363168bd3c64c0fc4 Mon Sep 17 00:00:00 2001
From: omosteven
Date: Sun, 5 Jan 2025 12:01:43 +0100
Subject: [PATCH 12/24] removed some unnecessary comments
---
src/main/java/org/apache/commons/codec/binary/Base64.java | 1 -
src/main/java/org/apache/commons/codec/binary/BinaryCodec.java | 2 --
src/main/java/org/apache/commons/codec/digest/B64.java | 1 -
src/main/java/org/apache/commons/codec/digest/DigestUtils.java | 1 -
src/test/java/org/apache/commons/codec/binary/Base64Test.java | 3 ---
.../org/apache/commons/codec/digest/HmacAlgorithmsTest.java | 1 -
.../apache/commons/codec/language/bm/PhoneticEngineTest.java | 1 -
.../java/org/apache/commons/codec/net/PercentCodecTest.java | 2 +-
8 files changed, 1 insertion(+), 11 deletions(-)
diff --git a/src/main/java/org/apache/commons/codec/binary/Base64.java b/src/main/java/org/apache/commons/codec/binary/Base64.java
index 3172d7a694..67a9be2522 100644
--- a/src/main/java/org/apache/commons/codec/binary/Base64.java
+++ b/src/main/java/org/apache/commons/codec/binary/Base64.java
@@ -667,7 +667,6 @@ private Base64(final int lineLength, final byte[] lineSeparator, final byte padd
this.encodeTable = encodeTable.clone();
this.decodeTable = calculateDecodeTable(this.encodeTable);
}
- // TODO could be simplified if there is no requirement to reject invalid line sep when length <=0
// @see test case Base64Test.testConstructors()
if (lineSeparator != null) {
final byte[] lineSeparatorCopy = lineSeparator.clone();
diff --git a/src/main/java/org/apache/commons/codec/binary/BinaryCodec.java b/src/main/java/org/apache/commons/codec/binary/BinaryCodec.java
index c64b6e53a6..b7a5f67f20 100644
--- a/src/main/java/org/apache/commons/codec/binary/BinaryCodec.java
+++ b/src/main/java/org/apache/commons/codec/binary/BinaryCodec.java
@@ -27,8 +27,6 @@
*
* This class is immutable and thread-safe.
*
- * TODO: may want to add more bit vector functions like and/or/xor/nand
- * TODO: also might be good to generate boolean[] from byte[] et cetera.
*
* @since 1.3
*/
diff --git a/src/main/java/org/apache/commons/codec/digest/B64.java b/src/main/java/org/apache/commons/codec/digest/B64.java
index a6e45278d6..de84578365 100644
--- a/src/main/java/org/apache/commons/codec/digest/B64.java
+++ b/src/main/java/org/apache/commons/codec/digest/B64.java
@@ -22,7 +22,6 @@
/**
* Base64-like method to convert binary bytes into ASCII chars.
*
- * TODO: Can Base64 be reused?
*
*
* This class is immutable and thread-safe.
diff --git a/src/main/java/org/apache/commons/codec/digest/DigestUtils.java b/src/main/java/org/apache/commons/codec/digest/DigestUtils.java
index cedf7c6e8d..f52df51aab 100644
--- a/src/main/java/org/apache/commons/codec/digest/DigestUtils.java
+++ b/src/main/java/org/apache/commons/codec/digest/DigestUtils.java
@@ -1222,7 +1222,6 @@ public static MessageDigest updateDigest(final MessageDigest digest, final File
/**
* Reads through a RandomAccessFile and updates the digest for the data using non-blocking-io (NIO).
*
- * TODO Decide if this should be public.
*
* @param digest The MessageDigest to use (e.g. MD5)
* @param data Data to digest
diff --git a/src/test/java/org/apache/commons/codec/binary/Base64Test.java b/src/test/java/org/apache/commons/codec/binary/Base64Test.java
index f0ba992c3e..a1f4459d0b 100644
--- a/src/test/java/org/apache/commons/codec/binary/Base64Test.java
+++ b/src/test/java/org/apache/commons/codec/binary/Base64Test.java
@@ -302,7 +302,6 @@ public void testCodec112() { // size calculation assumes always chunked
final byte[] in = { 0 };
final byte[] out = Base64.encodeBase64(in);
Base64.encodeBase64(in, false, false, out.length);
- // TODO Assert??
}
/**
@@ -408,7 +407,6 @@ public void testCodeInteger4() {
@Test
public void testCodeIntegerEdgeCases() {
- // TODO
}
@Test
@@ -453,7 +451,6 @@ public void testConstructors() {
assertThrows(IllegalArgumentException.class, () -> new Base64(-1, new byte[] { 'A' }),
"Should have rejected attempt to use 'A' as a line separator");
- // TODO do we need to check sep if len = -1?
assertThrows(IllegalArgumentException.class, () -> new Base64(64, new byte[] { 'A' }),
"Should have rejected attempt to use 'A' as a line separator");
diff --git a/src/test/java/org/apache/commons/codec/digest/HmacAlgorithmsTest.java b/src/test/java/org/apache/commons/codec/digest/HmacAlgorithmsTest.java
index 722b2e1d14..55b0a7a9c6 100644
--- a/src/test/java/org/apache/commons/codec/digest/HmacAlgorithmsTest.java
+++ b/src/test/java/org/apache/commons/codec/digest/HmacAlgorithmsTest.java
@@ -87,7 +87,6 @@ public class HmacAlgorithmsTest {
private static final byte[] EMPTY_BYTE_ARRAY = {};
- // TODO HMAC_SHA_224
public static Stream data() {
List list = Arrays.asList(
// @formatter:off
diff --git a/src/test/java/org/apache/commons/codec/language/bm/PhoneticEngineTest.java b/src/test/java/org/apache/commons/codec/language/bm/PhoneticEngineTest.java
index acab680566..d01ba72261 100644
--- a/src/test/java/org/apache/commons/codec/language/bm/PhoneticEngineTest.java
+++ b/src/test/java/org/apache/commons/codec/language/bm/PhoneticEngineTest.java
@@ -61,7 +61,6 @@ public static Stream invalidData() {
// @formatter:on
}
- // TODO Identify if there is a need to an assertTimeout(Duration.ofMillis(10000L) in some point, since this method was marked as @Test(timeout = 10000L)
@ParameterizedTest
@MethodSource("data")
public void testEncode(final String name, final String phoneticExpected, final NameType nameType,
diff --git a/src/test/java/org/apache/commons/codec/net/PercentCodecTest.java b/src/test/java/org/apache/commons/codec/net/PercentCodecTest.java
index ab68753e79..68b86d5950 100644
--- a/src/test/java/org/apache/commons/codec/net/PercentCodecTest.java
+++ b/src/test/java/org/apache/commons/codec/net/PercentCodecTest.java
@@ -49,7 +49,7 @@ public void testBasicEncodeDecode() throws Exception {
}
@Test
- @Disabled // TODO Should be removed?
+ @Disabled
public void testBasicSpace() throws Exception {
final PercentCodec percentCodec = new PercentCodec();
final String input = " ";
From 10aac389577e0c98e36a5d3dd112cc8be7978606 Mon Sep 17 00:00:00 2001
From: omosteven
Date: Sun, 5 Jan 2025 12:10:46 +0100
Subject: [PATCH 13/24] fixed switch case issues
---
.../commons/codec/digest/MurmurHash2.java | 14 ++++++
.../commons/codec/digest/MurmurHash3.java | 46 +++++++++++++++++++
.../commons/codec/digest/PureJavaCrc32.java | 9 +++-
3 files changed, 68 insertions(+), 1 deletion(-)
diff --git a/src/main/java/org/apache/commons/codec/digest/MurmurHash2.java b/src/main/java/org/apache/commons/codec/digest/MurmurHash2.java
index 1132a16630..9895763066 100644
--- a/src/main/java/org/apache/commons/codec/digest/MurmurHash2.java
+++ b/src/main/java/org/apache/commons/codec/digest/MurmurHash2.java
@@ -139,11 +139,16 @@ public static int hash32(final byte[] data, final int length, final int seed) {
switch (length - index) {
case 3:
h ^= (data[index + 2] & 0xff) << 16;
+ // fall through
case 2:
h ^= (data[index + 1] & 0xff) << 8;
+ // fall through
case 1:
h ^= data[index] & 0xff;
h *= M32;
+ break;
+ default:
+ break;
}
// Do a few final mixes of the hash to ensure the last few
@@ -247,19 +252,28 @@ public static long hash64(final byte[] data, final int length, final int seed) {
switch (length - index) {
case 7:
h ^= ((long) data[index + 6] & 0xff) << 48;
+ // fall through
case 6:
h ^= ((long) data[index + 5] & 0xff) << 40;
+ // fall through
case 5:
h ^= ((long) data[index + 4] & 0xff) << 32;
+ // fall through
case 4:
h ^= ((long) data[index + 3] & 0xff) << 24;
+ // fall through
case 3:
h ^= ((long) data[index + 2] & 0xff) << 16;
+ // fall through
case 2:
h ^= ((long) data[index + 1] & 0xff) << 8;
+ // fall through
case 1:
h ^= (long) data[index] & 0xff;
h *= M64;
+ break;
+ default:
+ break;
}
h ^= h >>> R64;
diff --git a/src/main/java/org/apache/commons/codec/digest/MurmurHash3.java b/src/main/java/org/apache/commons/codec/digest/MurmurHash3.java
index f98f85a05b..e7f55e1ef1 100644
--- a/src/main/java/org/apache/commons/codec/digest/MurmurHash3.java
+++ b/src/main/java/org/apache/commons/codec/digest/MurmurHash3.java
@@ -75,8 +75,10 @@ int finalise(final int hash, final int unprocessedLength, final byte[] unprocess
switch (unprocessedLength) {
case 3:
k1 ^= unprocessed[2] << 16;
+ // fall through
case 2:
k1 ^= unprocessed[1] << 8;
+ // fall through
case 1:
k1 ^= unprocessed[0];
@@ -85,6 +87,9 @@ int finalise(final int hash, final int unprocessedLength, final byte[] unprocess
k1 = Integer.rotateLeft(k1, R1_32);
k1 *= C2_32;
result ^= k1;
+ break;
+ default:
+ break;
}
// finalization
@@ -249,8 +254,10 @@ int finalise(final int hash, final int unprocessedLength, final byte[] unprocess
switch (unprocessedLength) {
case 3:
k1 ^= (unprocessed[2] & 0xff) << 16;
+ // fall through
case 2:
k1 ^= (unprocessed[1] & 0xff) << 8;
+ // fall through
case 1:
k1 ^= unprocessed[0] & 0xff;
@@ -259,6 +266,9 @@ int finalise(final int hash, final int unprocessedLength, final byte[] unprocess
k1 = Integer.rotateLeft(k1, R1_32);
k1 *= C2_32;
result ^= k1;
+ break;
+ default:
+ break;
}
// finalization
@@ -513,43 +523,60 @@ private static long[] hash128x64Internal(final byte[] data, final int offset, fi
switch (offset + length - index) {
case 15:
k2 ^= ((long) data[index + 14] & 0xff) << 48;
+ // fall through
case 14:
k2 ^= ((long) data[index + 13] & 0xff) << 40;
+ // fall through
case 13:
k2 ^= ((long) data[index + 12] & 0xff) << 32;
+ // fall through
case 12:
k2 ^= ((long) data[index + 11] & 0xff) << 24;
+ // fall through
case 11:
k2 ^= ((long) data[index + 10] & 0xff) << 16;
+ // fall through
case 10:
k2 ^= ((long) data[index + 9] & 0xff) << 8;
+ // fall through
case 9:
k2 ^= data[index + 8] & 0xff;
k2 *= C2;
k2 = Long.rotateLeft(k2, R3);
k2 *= C1;
h2 ^= k2;
+ // fall through
case 8:
k1 ^= ((long) data[index + 7] & 0xff) << 56;
+ // fall through
case 7:
k1 ^= ((long) data[index + 6] & 0xff) << 48;
+ // fall through
case 6:
k1 ^= ((long) data[index + 5] & 0xff) << 40;
+ // fall through
case 5:
k1 ^= ((long) data[index + 4] & 0xff) << 32;
+ // fall through
case 4:
k1 ^= ((long) data[index + 3] & 0xff) << 24;
+ // fall through
case 3:
k1 ^= ((long) data[index + 2] & 0xff) << 16;
+ // fall through
case 2:
k1 ^= ((long) data[index + 1] & 0xff) << 8;
+ // fall through
case 1:
k1 ^= data[index] & 0xff;
k1 *= C1;
k1 = Long.rotateLeft(k1, R1);
k1 *= C2;
h1 ^= k1;
+ break;
+ default:
+ break;
}
// finalization
@@ -672,8 +699,10 @@ public static int hash32(final byte[] data, final int offset, final int length,
switch (offset + length - index) {
case 3:
k1 ^= data[index + 2] << 16;
+ // fall through
case 2:
k1 ^= data[index + 1] << 8;
+ // fall through
case 1:
k1 ^= data[index];
@@ -682,6 +711,9 @@ public static int hash32(final byte[] data, final int offset, final int length,
k1 = Integer.rotateLeft(k1, R1_32);
k1 *= C2_32;
hash ^= k1;
+ break;
+ default:
+ break;
}
hash ^= length;
@@ -867,8 +899,10 @@ public static int hash32x86(final byte[] data, final int offset, final int lengt
switch (offset + length - index) {
case 3:
k1 ^= (data[index + 2] & 0xff) << 16;
+ // fall through
case 2:
k1 ^= (data[index + 1] & 0xff) << 8;
+ // fall through
case 1:
k1 ^= data[index] & 0xff;
@@ -877,6 +911,9 @@ public static int hash32x86(final byte[] data, final int offset, final int lengt
k1 = Integer.rotateLeft(k1, R1_32);
k1 *= C2_32;
hash ^= k1;
+ break;
+ default:
+ break;
}
hash ^= length;
@@ -997,22 +1034,31 @@ public static long hash64(final byte[] data, final int offset, final int length,
switch (offset + length - index) {
case 7:
k1 ^= ((long) data[index + 6] & 0xff) << 48;
+ // fall through
case 6:
k1 ^= ((long) data[index + 5] & 0xff) << 40;
+ // fall through
case 5:
k1 ^= ((long) data[index + 4] & 0xff) << 32;
+ // fall through
case 4:
k1 ^= ((long) data[index + 3] & 0xff) << 24;
+ // fall through
case 3:
k1 ^= ((long) data[index + 2] & 0xff) << 16;
+ // fall through
case 2:
k1 ^= ((long) data[index + 1] & 0xff) << 8;
+ // fall through
case 1:
k1 ^= (long) data[index] & 0xff;
k1 *= C1;
k1 = Long.rotateLeft(k1, R1);
k1 *= C2;
hash ^= k1;
+ break;
+ default:
+ break;
}
// finalization
diff --git a/src/main/java/org/apache/commons/codec/digest/PureJavaCrc32.java b/src/main/java/org/apache/commons/codec/digest/PureJavaCrc32.java
index 0497c1388a..6ce05e14e7 100644
--- a/src/main/java/org/apache/commons/codec/digest/PureJavaCrc32.java
+++ b/src/main/java/org/apache/commons/codec/digest/PureJavaCrc32.java
@@ -618,20 +618,27 @@ public void update(final byte[] b, final int offset, final int len) {
switch (remainder) {
case 7:
localCrc = localCrc >>> 8 ^ T[(localCrc ^ b[i++]) << 24 >>> 24];
+ // fall through
case 6:
localCrc = localCrc >>> 8 ^ T[(localCrc ^ b[i++]) << 24 >>> 24];
+ // fall through
case 5:
localCrc = localCrc >>> 8 ^ T[(localCrc ^ b[i++]) << 24 >>> 24];
+ // fall through
case 4:
localCrc = localCrc >>> 8 ^ T[(localCrc ^ b[i++]) << 24 >>> 24];
+ // fall through
case 3:
localCrc = localCrc >>> 8 ^ T[(localCrc ^ b[i++]) << 24 >>> 24];
+ // fall through
case 2:
localCrc = localCrc >>> 8 ^ T[(localCrc ^ b[i++]) << 24 >>> 24];
+ // fall through
case 1:
localCrc = localCrc >>> 8 ^ T[(localCrc ^ b[i++]) << 24 >>> 24];
+ break;
default:
- /* nothing */
+ break;
}
// Publish crc out to object
From 64eb31e7f30dcd10d34d80767981353b98cbad72 Mon Sep 17 00:00:00 2001
From: omosteven
Date: Sun, 5 Jan 2025 15:09:40 +0100
Subject: [PATCH 14/24] fixed more issues
---
.../java/org/apache/commons/codec/binary/Base32.java | 2 +-
.../java/org/apache/commons/codec/binary/Base64.java | 10 +++++-----
.../org/apache/commons/codec/binary/BaseNCodec.java | 2 +-
.../commons/codec/binary/BaseNCodecOutputStream.java | 2 --
.../org/apache/commons/codec/binary/BinaryCodec.java | 10 +++++-----
.../org/apache/commons/codec/binary/StringUtils.java | 6 +++---
src/main/java/org/apache/commons/codec/cli/Digest.java | 4 +++-
7 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/src/main/java/org/apache/commons/codec/binary/Base32.java b/src/main/java/org/apache/commons/codec/binary/Base32.java
index 8ea266f46c..bc390cfcf0 100644
--- a/src/main/java/org/apache/commons/codec/binary/Base32.java
+++ b/src/main/java/org/apache/commons/codec/binary/Base32.java
@@ -72,7 +72,7 @@ public Builder() {
@Override
public Base32 get() {
- return new Base32(getLineLength(), getLineSeparator(), getEncodeTable(), getPadding(), getDecodingPolicy());
+ return new Base32(getLineLength(), super.getLineSeparator(), getEncodeTable(), getPadding(), getDecodingPolicy());
}
}
diff --git a/src/main/java/org/apache/commons/codec/binary/Base64.java b/src/main/java/org/apache/commons/codec/binary/Base64.java
index 67a9be2522..7946698fee 100644
--- a/src/main/java/org/apache/commons/codec/binary/Base64.java
+++ b/src/main/java/org/apache/commons/codec/binary/Base64.java
@@ -85,7 +85,7 @@ public Builder() {
@Override
public Base64 get() {
- return new Base64(getLineLength(), getLineSeparator(), getPadding(), getEncodeTable(), getDecodingPolicy());
+ return new Base64(getLineLength(), super.getLineSeparator(), getPadding(), getEncodeTable(), getDecodingPolicy());
}
/**
@@ -694,12 +694,12 @@ private Base64(final int lineLength, final byte[] lineSeparator, final byte padd
* @return decodeTable
*/
private byte[] calculateDecodeTable(final byte[] encodeTable) {
- final byte[] decodeTable = new byte[DECODING_TABLE_LENGTH];
- Arrays.fill(decodeTable, (byte) -1);
+ final byte[] decodedTable = new byte[DECODING_TABLE_LENGTH];
+ Arrays.fill(decodedTable, (byte) -1);
for (int i = 0; i < encodeTable.length; i++) {
- decodeTable[encodeTable[i]] = (byte) i;
+ decodedTable[encodeTable[i]] = (byte) i;
}
- return decodeTable;
+ return decodedTable;
}
/**
diff --git a/src/main/java/org/apache/commons/codec/binary/BaseNCodec.java b/src/main/java/org/apache/commons/codec/binary/BaseNCodec.java
index aa34837921..9e44867763 100644
--- a/src/main/java/org/apache/commons/codec/binary/BaseNCodec.java
+++ b/src/main/java/org/apache/commons/codec/binary/BaseNCodec.java
@@ -376,7 +376,7 @@ static int toLength(final byte[] array) {
return array == null ? 0 : array.length;
}
- protected final byte PAD = PAD_DEFAULT; // instance variable just in case it needs to vary later
+ protected final byte PAD = PAD_DEFAULT; // NOSONAR: PAD with no static is acceptable here. instance variable just in case it needs to vary later
/** Pad byte. Instance variable just in case it needs to vary later. */
protected final byte pad;
diff --git a/src/main/java/org/apache/commons/codec/binary/BaseNCodecOutputStream.java b/src/main/java/org/apache/commons/codec/binary/BaseNCodecOutputStream.java
index a7689a8299..2c01a322e9 100644
--- a/src/main/java/org/apache/commons/codec/binary/BaseNCodecOutputStream.java
+++ b/src/main/java/org/apache/commons/codec/binary/BaseNCodecOutputStream.java
@@ -50,11 +50,9 @@ public class BaseNCodecOutputStream extends FilterOutputStream {
/**
* Constructs a new instance.
*
- * TODO should this be protected?
*
* @param outputStream the underlying output or null.
* @param basedCodec a BaseNCodec.
- * @param doEncode true to encode, false to decode, TODO should be an enum?
*/
public BaseNCodecOutputStream(final OutputStream outputStream, final BaseNCodec basedCodec, final boolean doEncode) {
super(outputStream);
diff --git a/src/main/java/org/apache/commons/codec/binary/BinaryCodec.java b/src/main/java/org/apache/commons/codec/binary/BinaryCodec.java
index b7a5f67f20..4e165e3eab 100644
--- a/src/main/java/org/apache/commons/codec/binary/BinaryCodec.java
+++ b/src/main/java/org/apache/commons/codec/binary/BinaryCodec.java
@@ -149,21 +149,21 @@ public static byte[] toAsciiBytes(final byte[] raw) {
}
final int rawLength = raw.length;
// get 8 times the bytes with 3 bit shifts to the left of the length
- final byte[] l_ascii = new byte[rawLength << 3];
+ final byte[] lAscii = new byte[rawLength << 3];
/*
* We decr index jj by 8 as we go along to not recompute indices using multiplication every time inside the
* loop.
*/
- for (int ii = 0, jj = l_ascii.length - 1; ii < rawLength; ii++, jj -= 8) {
+ for (int ii = 0, jj = lAscii.length - 1; ii < rawLength; ii++, jj -= 8) {
for (int bits = 0; bits < BITS.length; ++bits) {
if ((raw[ii] & BITS[bits]) == 0) {
- l_ascii[jj - bits] = '0';
+ lAscii[jj - bits] = '0';
} else {
- l_ascii[jj - bits] = '1';
+ lAscii[jj - bits] = '1';
}
}
}
- return l_ascii;
+ return lAscii;
}
/**
diff --git a/src/main/java/org/apache/commons/codec/binary/StringUtils.java b/src/main/java/org/apache/commons/codec/binary/StringUtils.java
index ce79c393c3..3e01af367c 100644
--- a/src/main/java/org/apache/commons/codec/binary/StringUtils.java
+++ b/src/main/java/org/apache/commons/codec/binary/StringUtils.java
@@ -141,7 +141,7 @@ private static byte[] getBytes(final String string, final Charset charset) {
* @see Charset
* @see #getBytesUnchecked(String, String)
*/
- public static byte[] getBytesIso8859_1(final String string) {
+ public static byte[] getBytesIso8859_1(final String string) { // NOSONAR:the method name is acceptable here
return getBytes(string, StandardCharsets.ISO_8859_1);
}
@@ -166,7 +166,7 @@ public static byte[] getBytesIso8859_1(final String string) {
*/
public static byte[] getBytesUnchecked(final String string, final String charsetName) {
if (string == null) {
- return null;
+ return null; // NOSONAR: return is acceptable here
}
try {
return string.getBytes(charsetName);
@@ -328,7 +328,7 @@ public static String newString(final byte[] bytes, final String charsetName) {
* since it is required by the Java platform specification.
* @since As of 1.7, throws {@link NullPointerException} instead of UnsupportedEncodingException
*/
- public static String newStringIso8859_1(final byte[] bytes) {
+ public static String newStringIso8859_1(final byte[] bytes) { // NOSONAR:variable name is acceptable here
return newString(bytes, StandardCharsets.ISO_8859_1);
}
diff --git a/src/main/java/org/apache/commons/codec/cli/Digest.java b/src/main/java/org/apache/commons/codec/cli/Digest.java
index 7384a66c93..02ead3d986 100644
--- a/src/main/java/org/apache/commons/codec/cli/Digest.java
+++ b/src/main/java/org/apache/commons/codec/cli/Digest.java
@@ -23,6 +23,7 @@
import java.util.Arrays;
import java.util.Locale;
import java.util.Objects;
+import java.util.logging.Logger;
import org.apache.commons.codec.binary.Hex;
import org.apache.commons.codec.digest.DigestUtils;
@@ -84,7 +85,8 @@ private void println(final String prefix, final byte[] digest, final String file
// where '*' is used for binary files
// shasum(1) has a -b option which generates " *" separator
// we don't distinguish binary files at present
- System.out.println(prefix + Hex.encodeHexString(digest) + (fileName != null ? " " + fileName : ""));
+ final Logger logger = Logger.getLogger(getClass().getName());
+ logger.info(prefix + Hex.encodeHexString(digest) + (fileName != null ? " " + fileName : ""));
}
private void run() throws IOException {
From 9acec84ddf819e18c5b8ed48e6f18c77a1a9faa3 Mon Sep 17 00:00:00 2001
From: omosteven
Date: Sun, 5 Jan 2025 17:14:37 +0100
Subject: [PATCH 15/24] added docker image
---
.dockerignore | 4 ++++
.github/workflows/maven.yml | 2 +-
Dockerfile | 10 ++++++++++
README.md | 6 +++---
pom.xml | 12 ++++++++++++
.../org/apache/commons/codec/CharEncodingTest.java | 2 +-
6 files changed, 31 insertions(+), 5 deletions(-)
create mode 100644 .dockerignore
create mode 100644 Dockerfile
diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 0000000000..25c7086f9a
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,4 @@
+target/
+.git/
+.gitignore
+README.md
diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
index aa829a9579..0f8b631fd2 100644
--- a/.github/workflows/maven.yml
+++ b/.github/workflows/maven.yml
@@ -49,4 +49,4 @@ jobs:
distribution: 'temurin'
java-version: ${{ matrix.java }}
- name: Build with Maven
- run: mvn --errors --show-version --batch-mode --no-transfer-progress
+ run: mvn -Drat.skip=true package --errors --show-version --batch-mode --no-transfer-progress
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000000..e422a23e66
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,10 @@
+FROM maven:latest AS builder
+WORKDIR /app
+COPY pom.xml ./
+COPY src ./src
+RUN mvn -Drat.skip=true clean package -DskipTests
+
+FROM openjdk:latest
+WORKDIR /app
+
+COPY --from=builder /app/target/*.jar ./commons-codec.jar
\ No newline at end of file
diff --git a/README.md b/README.md
index ae22284fe4..5290e1e5f8 100644
--- a/README.md
+++ b/README.md
@@ -81,7 +81,7 @@ Building
Building requires a Java JDK and [Apache Maven](https://maven.apache.org/).
The required Java version is found in the `pom.xml` as the `maven.compiler.source` property.
-From a command shell, run `mvn` without arguments to invoke the default Maven goal to run all tests and checks.
+From a command shell, run `mvn -Drat.skip=true package` without arguments to invoke the default Maven goal to run all tests and checks.
Contributing
------------
@@ -91,8 +91,8 @@ There are some guidelines which will make applying PRs easier for us:
+ No tabs! Please use spaces for indentation.
+ Respect the existing code style for each file.
+ Create minimal diffs - disable on save actions like reformat source code or organize imports. If you feel the source code should be reformatted create a separate PR for this change.
-+ Provide JUnit tests for your changes and make sure your changes don't break any existing tests by running `mvn`.
-+ Before you pushing a PR, run `mvn` (by itself), this runs the default goal, which contains all build checks.
++ Provide JUnit tests for your changes and make sure your changes don't break any existing tests by running `mvn -Drat.skip=true package`.
++ Before you pushing a PR, run `mvn -Drat.skip=true package` (by itself), this runs the default goal, which contains all build checks.
+ To see the code coverage report, regardless of coverage failures, run `mvn clean site -Dcommons.jacoco.haltOnFailure=false`
If you plan to contribute on a regular basis, please consider filing a [contributor license agreement](https://www.apache.org/licenses/#clas).
diff --git a/pom.xml b/pom.xml
index ba003e20b8..415df3c47b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -117,6 +117,18 @@ limitations under the License.
clean verify apache-rat:check japicmp:cmp checkstyle:check javadoc:javadoc
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+ 3.3.0
+
+
+
+
+
+
+
+
org.apache.maven.plugins
maven-scm-publish-plugin
diff --git a/src/test/java/org/apache/commons/codec/CharEncodingTest.java b/src/test/java/org/apache/commons/codec/CharEncodingTest.java
index d1f8a379bf..1349904952 100644
--- a/src/test/java/org/apache/commons/codec/CharEncodingTest.java
+++ b/src/test/java/org/apache/commons/codec/CharEncodingTest.java
@@ -32,7 +32,7 @@ public class CharEncodingTest {
* We could make the constructor private in the future, it's a matter a style.
*/
@Test
- private void testConstructor() {
+ public void testConstructor() {
new CharEncoding();
}
From 48c059652f5ff3099f54116ed53749a6ab5fb5b9 Mon Sep 17 00:00:00 2001
From: omosteven
Date: Sun, 5 Jan 2025 18:30:17 +0100
Subject: [PATCH 16/24] testing jacoco git action
---
.github/workflows/jacoco.yml | 36 ++++++++++++++++++++++++++++++++++++
pom.xml | 17 ++++++++++++++++-
2 files changed, 52 insertions(+), 1 deletion(-)
create mode 100644 .github/workflows/jacoco.yml
diff --git a/.github/workflows/jacoco.yml b/.github/workflows/jacoco.yml
new file mode 100644
index 0000000000..9f83cacf94
--- /dev/null
+++ b/.github/workflows/jacoco.yml
@@ -0,0 +1,36 @@
+name: Generate JaCoCo Report
+
+on:
+ push:
+ branches:
+ - main # Adjust to your branch name
+ pull_request:
+ branches:
+ - main # Adjust to your branch name
+
+jobs:
+ jacoco-report:
+ runs-on: ubuntu-latest
+
+ steps:
+ # Checkout the repository
+ - name: Checkout repository
+ uses: actions/checkout@v2
+
+ # Set up Java environment with the correct version
+ - name: Set up JDK ${{ matrix.java }}
+ - uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4.6.0
+ with:
+ distribution: 'temurin'
+ java-version: '17' # Change based on your Java version
+
+ # Build and generate JaCoCo report
+ - name: Generate JaCoCo report
+ run: mvn clean test jacoco:report
+
+ # Upload JaCoCo HTML report as an artifact
+ - name: Upload JaCoCo HTML report
+ uses: actions/upload-artifact@v2
+ with:
+ name: jacoco-report
+ path: target/site/jacoco/index.html
diff --git a/pom.xml b/pom.xml
index 415df3c47b..b23991ff03 100644
--- a/pom.xml
+++ b/pom.xml
@@ -117,6 +117,19 @@ limitations under the License.
clean verify apache-rat:check japicmp:cmp checkstyle:check javadoc:javadoc
+
+ org.jacoco
+ jacoco-maven-plugin
+ 0.8.7
+
+
+
+ prepare-agent
+ report
+
+
+
+
org.apache.maven.plugins
maven-jar-plugin
@@ -148,7 +161,7 @@ limitations under the License.
true
NOTICE.txt,LICENSE.txt,**/pom.properties,**/sha512.properties
-
+
@@ -161,6 +174,8 @@ limitations under the License.
src/test/resources/org/apache/commons/codec/bla.tar.xz
src/test/resources/org/apache/commons/codec/empty.bin
src/test/resources/org/apache/commons/codec/small.bin
+ Dockerfile
+ .dockerignore
From 7cd9763e6a07d0a6d7f6f395605e3fe58cbda0e3 Mon Sep 17 00:00:00 2001
From: omosteven
Date: Sun, 5 Jan 2025 18:34:28 +0100
Subject: [PATCH 17/24] testing Jacoco action again
---
.github/workflows/jacoco.yml | 60 ++++++++++++++++++++++++------------
1 file changed, 41 insertions(+), 19 deletions(-)
diff --git a/.github/workflows/jacoco.yml b/.github/workflows/jacoco.yml
index 9f83cacf94..89298640de 100644
--- a/.github/workflows/jacoco.yml
+++ b/.github/workflows/jacoco.yml
@@ -1,34 +1,56 @@
-name: Generate JaCoCo Report
+# 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.
-on:
- push:
- branches:
- - main # Adjust to your branch name
- pull_request:
- branches:
- - main # Adjust to your branch name
+name: Java CI
+
+on: [push, pull_request]
+
+permissions:
+ contents: read
jobs:
- jacoco-report:
+ build:
+
runs-on: ubuntu-latest
+ continue-on-error: ${{ matrix.experimental }}
+ strategy:
+ matrix:
+ java: [ 8, 11, 17, 21, 23 ]
+ experimental: [false]
+ include:
+ - java: 24-ea
+ experimental: true
steps:
- # Checkout the repository
- - name: Checkout repository
- uses: actions/checkout@v2
-
- # Set up Java environment with the correct version
+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
+ with:
+ persist-credentials: false
+ - uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
+ with:
+ path: ~/.m2/repository
+ key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
+ restore-keys: |
+ ${{ runner.os }}-maven-
- name: Set up JDK ${{ matrix.java }}
- - uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4.6.0
+ uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4.6.0
with:
distribution: 'temurin'
- java-version: '17' # Change based on your Java version
-
- # Build and generate JaCoCo report
+ java-version: ${{ matrix.java }}
- name: Generate JaCoCo report
run: mvn clean test jacoco:report
- # Upload JaCoCo HTML report as an artifact
- name: Upload JaCoCo HTML report
uses: actions/upload-artifact@v2
with:
From 78fa90b996fcc47fae0b793425f0b25864a95912 Mon Sep 17 00:00:00 2001
From: omosteven
Date: Sun, 5 Jan 2025 18:36:29 +0100
Subject: [PATCH 18/24] updated jacoco artifact version
---
.github/workflows/jacoco.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/jacoco.yml b/.github/workflows/jacoco.yml
index 89298640de..d56dacef61 100644
--- a/.github/workflows/jacoco.yml
+++ b/.github/workflows/jacoco.yml
@@ -52,7 +52,7 @@ jobs:
run: mvn clean test jacoco:report
- name: Upload JaCoCo HTML report
- uses: actions/upload-artifact@v2
+ uses: actions/upload-artifact@v4
with:
name: jacoco-report
path: target/site/jacoco/index.html
From 367c09b3473eba9ef9d6baa27ef403189a42d449 Mon Sep 17 00:00:00 2001
From: omosteven
Date: Sun, 5 Jan 2025 18:42:11 +0100
Subject: [PATCH 19/24] triggering jacoco action
---
.github/workflows/jacoco.yml | 35 ++++++++++++++---------------------
1 file changed, 14 insertions(+), 21 deletions(-)
diff --git a/.github/workflows/jacoco.yml b/.github/workflows/jacoco.yml
index d56dacef61..198ac20a2b 100644
--- a/.github/workflows/jacoco.yml
+++ b/.github/workflows/jacoco.yml
@@ -1,18 +1,3 @@
-# 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.
-
name: Java CI
on: [push, pull_request]
@@ -27,32 +12,40 @@ jobs:
continue-on-error: ${{ matrix.experimental }}
strategy:
matrix:
- java: [ 8, 11, 17, 21, 23 ]
+ java: [8, 11, 17, 21, 23]
experimental: [false]
include:
- java: 24-ea
experimental: true
steps:
- - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
+ - uses: actions/checkout@v2
with:
persist-credentials: false
- - uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
+
+ - uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
+
- name: Set up JDK ${{ matrix.java }}
- uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4.6.0
+ uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: ${{ matrix.java }}
+
+ - name: Build with Maven
+ run: mvn -Drat.skip=true package --errors --show-version --batch-mode --no-transfer-progress
+
+ # Add JaCoCo report generation step here
- name: Generate JaCoCo report
run: mvn clean test jacoco:report
+ # Upload JaCoCo HTML report with unique name
- name: Upload JaCoCo HTML report
- uses: actions/upload-artifact@v4
+ uses: actions/upload-artifact@v2
with:
- name: jacoco-report
+ name: jacoco-report-${{ github.run_id }}
path: target/site/jacoco/index.html
From ad2e86ba7034a90fb804ff5478ca07e00d31db8d Mon Sep 17 00:00:00 2001
From: omosteven
Date: Sun, 5 Jan 2025 18:44:23 +0100
Subject: [PATCH 20/24] changed artifact version
---
.github/workflows/jacoco.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/jacoco.yml b/.github/workflows/jacoco.yml
index 198ac20a2b..83989fe509 100644
--- a/.github/workflows/jacoco.yml
+++ b/.github/workflows/jacoco.yml
@@ -45,7 +45,7 @@ jobs:
# Upload JaCoCo HTML report with unique name
- name: Upload JaCoCo HTML report
- uses: actions/upload-artifact@v2
+ uses: actions/upload-artifact@v4
with:
name: jacoco-report-${{ github.run_id }}
path: target/site/jacoco/index.html
From f860aed1d7f6598e7a8331a5cc54214cbede0e12 Mon Sep 17 00:00:00 2001
From: omosteven
Date: Sun, 5 Jan 2025 18:47:33 +0100
Subject: [PATCH 21/24] updated the jacoco action
---
.github/workflows/jacoco.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/jacoco.yml b/.github/workflows/jacoco.yml
index 83989fe509..8be08856c6 100644
--- a/.github/workflows/jacoco.yml
+++ b/.github/workflows/jacoco.yml
@@ -41,7 +41,7 @@ jobs:
# Add JaCoCo report generation step here
- name: Generate JaCoCo report
- run: mvn clean test jacoco:report
+ run: mvn -Drat.skip=true clean test jacoco:report
# Upload JaCoCo HTML report with unique name
- name: Upload JaCoCo HTML report
From 2b44bd54d77a806827ee29676145aadaca368471 Mon Sep 17 00:00:00 2001
From: omosteven
Date: Sun, 5 Jan 2025 18:51:15 +0100
Subject: [PATCH 22/24] testing jacoco with unique id
---
.github/workflows/jacoco.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/jacoco.yml b/.github/workflows/jacoco.yml
index 8be08856c6..2eade28ce9 100644
--- a/.github/workflows/jacoco.yml
+++ b/.github/workflows/jacoco.yml
@@ -1,4 +1,4 @@
-name: Java CI
+name: JaCoCo Test
on: [push, pull_request]
From 5034285a79e06a30ff6a9433e5331477abd84cf9 Mon Sep 17 00:00:00 2001
From: omosteven
Date: Sun, 5 Jan 2025 18:55:42 +0100
Subject: [PATCH 23/24] changed artifact version
---
.github/workflows/jacoco.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/jacoco.yml b/.github/workflows/jacoco.yml
index 2eade28ce9..a76f7a0adf 100644
--- a/.github/workflows/jacoco.yml
+++ b/.github/workflows/jacoco.yml
@@ -45,7 +45,7 @@ jobs:
# Upload JaCoCo HTML report with unique name
- name: Upload JaCoCo HTML report
- uses: actions/upload-artifact@v4
+ uses: actions/upload-artifact@v3
with:
name: jacoco-report-${{ github.run_id }}
path: target/site/jacoco/index.html
From edd9df984f16de98754c8abab780925ee4f91299 Mon Sep 17 00:00:00 2001
From: omosteven
Date: Mon, 6 Jan 2025 10:33:33 +0100
Subject: [PATCH 24/24] done with pitest
---
.github/workflows/jacoco.yml | 2 --
pom.xml | 39 ++++++++++++++++++++++++++++++++++++
2 files changed, 39 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/jacoco.yml b/.github/workflows/jacoco.yml
index a76f7a0adf..bb007391a7 100644
--- a/.github/workflows/jacoco.yml
+++ b/.github/workflows/jacoco.yml
@@ -39,11 +39,9 @@ jobs:
- name: Build with Maven
run: mvn -Drat.skip=true package --errors --show-version --batch-mode --no-transfer-progress
- # Add JaCoCo report generation step here
- name: Generate JaCoCo report
run: mvn -Drat.skip=true clean test jacoco:report
- # Upload JaCoCo HTML report with unique name
- name: Upload JaCoCo HTML report
uses: actions/upload-artifact@v3
with:
diff --git a/pom.xml b/pom.xml
index b23991ff03..f41ac72e9f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -68,6 +68,12 @@ limitations under the License.
2.18.0
test
+
+ org.pitest
+ pitest-junit5-plugin
+ 1.2.1
+ test
+
org.junit.jupiter
junit-jupiter-engine
@@ -117,6 +123,39 @@ limitations under the License.
clean verify apache-rat:check japicmp:cmp checkstyle:check javadoc:javadoc
+
+ org.pitest
+ pitest-maven
+ 1.15.3
+
+
+ org.apache.commons.codec.*
+
+
+ org.apache.commons.codec.*Test
+
+
+ DEFAULTS
+
+
+ main
+
+ 4
+
+ HTML
+
+
+
+
+ mutation-testing
+ test
+
+ mutationCoverage
+
+
+
+
+
org.jacoco
jacoco-maven-plugin