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/jacoco.yml b/.github/workflows/jacoco.yml
new file mode 100644
index 0000000000..bb007391a7
--- /dev/null
+++ b/.github/workflows/jacoco.yml
@@ -0,0 +1,49 @@
+name: JaCoCo Test
+
+on: [push, pull_request]
+
+permissions:
+ contents: read
+
+jobs:
+ 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:
+ - uses: actions/checkout@v2
+ with:
+ persist-credentials: false
+
+ - 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@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
+
+ - name: Generate JaCoCo report
+ run: mvn -Drat.skip=true clean test jacoco:report
+
+ - name: Upload JaCoCo HTML report
+ uses: actions/upload-artifact@v3
+ with:
+ name: jacoco-report-${{ github.run_id }}
+ path: target/site/jacoco/index.html
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..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,64 @@ 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
+ 0.8.7
+
+
+
+ prepare-agent
+ report
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+ 3.3.0
+
+
+
+
+
+
+
+
org.apache.maven.plugins
maven-scm-publish-plugin
@@ -136,7 +200,7 @@ limitations under the License.
true
NOTICE.txt,LICENSE.txt,**/pom.properties,**/sha512.properties
-
+
@@ -149,6 +213,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
diff --git a/src/main/java/org/apache/commons/codec/CharEncoding.java b/src/main/java/org/apache/commons/codec/CharEncoding.java
index 98ff8a82c6..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.
*
@@ -119,12 +118,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
}
diff --git a/src/main/java/org/apache/commons/codec/Charsets.java b/src/main/java/org/apache/commons/codec/Charsets.java
index 5103b6a5cc..3202d4298f 100644
--- a/src/main/java/org/apache/commons/codec/Charsets.java
+++ b/src/main/java/org/apache/commons/codec/Charsets.java
@@ -61,79 +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
- */
- @Deprecated
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
- */
- @Deprecated
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
- */
- @Deprecated
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
- */
- @Deprecated
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
- */
- @Deprecated
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
- */
- @Deprecated
public static final Charset UTF_8 = StandardCharsets.UTF_8;
/**
@@ -160,12 +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.
- */
- @Deprecated
public Charsets() {
// empty
}
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/Base32.java b/src/main/java/org/apache/commons/codec/binary/Base32.java
index c771b40fef..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());
}
}
@@ -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/binary/Base64.java b/src/main/java/org/apache/commons/codec/binary/Base64.java
index b406c62f43..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());
}
/**
@@ -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);
}
@@ -678,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();
@@ -706,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 f2c11c907a..9e44867763 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,11 +376,7 @@ 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
+ 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 c64b6e53a6..4e165e3eab 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
*/
@@ -151,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/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..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);
}
@@ -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/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 {
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/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 67abe9bb9d..f52df51aab 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
}
/**
@@ -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
}
/**
@@ -330,16 +330,8 @@ 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 getSha1Digest();
+ return getSha256Digest();
}
/**
@@ -361,7 +353,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 +365,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 +376,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 +387,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 +399,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 +410,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
}
/**
@@ -428,7 +420,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 +432,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
}
/**
@@ -450,7 +442,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 +452,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 +464,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,45 +474,19 @@ 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
}
- /**
- * 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);
+ 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);
+ 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);
+ return sha1(data); // NOSONAR: sha1 is acceptable here
}
/**
@@ -531,7 +497,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 +509,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);
}
/**
@@ -553,7 +519,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 +530,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 +542,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 +553,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
}
/**
@@ -1202,42 +1168,14 @@ 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);
+ 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);
+ 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);
+ return sha1Hex(data); // NOSONAR: sha1Hex is acceptable here
}
/**
@@ -1284,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
@@ -1371,12 +1308,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 bf07556404..87aa786675 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 {
@@ -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
}
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 24856133de..e7f55e1ef1 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;
// ************
@@ -100,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];
@@ -110,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
@@ -274,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;
@@ -284,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
@@ -303,12 +288,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 +397,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 +430,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);
@@ -563,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
@@ -635,9 +612,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 +635,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 +658,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 +678,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;
@@ -730,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];
@@ -740,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;
@@ -869,10 +843,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);
@@ -927,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;
@@ -937,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;
@@ -967,10 +944,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 +975,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 +1006,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.
@@ -1063,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
@@ -1112,10 +1092,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 +1132,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 +1174,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/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
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
}
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;
}
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/DigestUtilsTest.java b/src/test/java/org/apache/commons/codec/digest/DigestUtilsTest.java
index a2ac153edb..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("a9993e364706816aba3e25717850c26c9cd0d89d", DigestUtils.sha1Hex("abc"));
-
- assertEquals("a9993e364706816aba3e25717850c26c9cd0d89d", DigestUtils.sha1Hex(getBytesUtf8("abc")));
-
- assertEquals("84983e441c3bd26ebaae4aa1f95129e5e54670f1", 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 {
@@ -341,7 +278,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"));
@@ -492,19 +429,19 @@ 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("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)));
}
@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!'";
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 = " ";