You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2020/04/10 21:36:27 UTC

[commons-crypto] branch master updated (2eed995 -> b453b61)

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-crypto.git.


    from 2eed995  Update dependencies.
     new 9067ae9  Use final.
     new 9d5cc36  Add missing @Override.
     new b89f043  Remove unused imports.
     new 438eb1b  Organize imports.
     new 3bb0604  Remove redundant modifiers.
     new b453b61  Site reports.

The 6 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 pom.xml                                            |  56 +++-
 .../java/org/apache/commons/crypto/Crypto.java     |  12 +-
 .../apache/commons/crypto/NativeCodeLoader.java    |  38 +--
 .../apache/commons/crypto/OpenSslInfoNative.java   |   2 +
 .../java/org/apache/commons/crypto/OsInfo.java     |  20 +-
 .../apache/commons/crypto/cipher/CryptoCipher.java |   5 +-
 .../commons/crypto/cipher/CryptoCipherFactory.java |  18 +-
 .../apache/commons/crypto/cipher/JceCipher.java    |  20 +-
 .../org/apache/commons/crypto/cipher/OpenSsl.java  |  53 ++--
 .../commons/crypto/cipher/OpenSslCipher.java       |  26 +-
 .../commons/crypto/cipher/OpenSslCommonMode.java   |  23 +-
 .../crypto/cipher/OpenSslEvpCtrlValues.java        |   2 +-
 .../crypto/cipher/OpenSslFeedbackCipher.java       |  11 +-
 .../crypto/cipher/OpenSslGaloisCounterMode.java    |  46 ++--
 .../commons/crypto/jna/OpenSsl10XNativeJna.java    |   4 +-
 .../commons/crypto/jna/OpenSsl11XNativeJna.java    |   4 +-
 .../org/apache/commons/crypto/jna/OpenSslJna.java  |   2 +-
 .../commons/crypto/jna/OpenSslJnaCipher.java       |  72 ++---
 .../commons/crypto/jna/OpenSslJnaCryptoRandom.java |  30 +--
 .../commons/crypto/jna/OpenSslNativeJna.java       |  38 +--
 .../commons/crypto/random/CryptoRandomFactory.java |  18 +-
 .../commons/crypto/random/JavaCryptoRandom.java    |   6 +-
 .../commons/crypto/random/OpenSslCryptoRandom.java |  16 +-
 .../commons/crypto/random/OsCryptoRandom.java      |  16 +-
 .../commons/crypto/stream/CryptoInputStream.java   |  79 +++---
 .../commons/crypto/stream/CryptoOutputStream.java  |  43 +--
 .../crypto/stream/CtrCryptoInputStream.java        |  89 ++++---
 .../crypto/stream/CtrCryptoOutputStream.java       |  63 ++---
 .../crypto/stream/PositionedCryptoInputStream.java |  65 ++---
 .../commons/crypto/stream/input/ChannelInput.java  |  14 +-
 .../commons/crypto/stream/input/StreamInput.java   |  10 +-
 .../crypto/stream/output/ChannelOutput.java        |   4 +-
 .../commons/crypto/stream/output/StreamOutput.java |   4 +-
 .../org/apache/commons/crypto/utils/IoUtils.java   |  16 +-
 .../commons/crypto/utils/ReflectionUtils.java      |  18 +-
 .../org/apache/commons/crypto/utils/Utils.java     |  34 +--
 .../checkstyle/checkstyle-suppressions.xml         |  21 +-
 src/site/resources/pmd/pmd-ruleset.xml             |  89 +++++++
 .../resources/spotbugs/spotbugs-exclude-filter.xml |  29 +-
 .../java/org/apache/commons/crypto/CryptoTest.java |   4 +-
 .../commons/crypto/NativeCodeLoaderTest.java       |   2 +-
 .../commons/crypto/cipher/AbstractCipherTest.java  |  86 +++---
 .../crypto/cipher/CryptoCipherFactoryTest.java     |  12 +-
 .../commons/crypto/cipher/GcmCipherTest.java       | 296 ++++++++++-----------
 .../commons/crypto/cipher/JceCipherTest.java       |   2 +-
 .../commons/crypto/cipher/OpenSslCipherTest.java   |  25 +-
 .../org/apache/commons/crypto/cipher/TestData.java |   2 +-
 .../crypto/examples/CipherByteArrayExample.java    |  20 +-
 .../crypto/examples/CipherByteBufferExample.java   |  14 +-
 .../commons/crypto/examples/RandomExample.java     |   8 +-
 .../commons/crypto/examples/StreamExample.java     |  14 +-
 .../crypto/jna/AbstractCipherJnaStreamTest.java    |   2 +-
 .../commons/crypto/jna/OpenSslJnaCipherTest.java   |   1 -
 .../crypto/jna/OpenSslJnaCryptoRandomTest.java     |   9 +-
 .../commons/crypto/random/AbstractRandom.java      |   2 +-
 .../commons/crypto/random/AbstractRandomTest.java  |  10 +-
 .../crypto/random/CryptoRandomFactoryTest.java     |  26 +-
 .../apache/commons/crypto/random/DummyRandom.java  |   2 +-
 .../commons/crypto/random/FailingRandom.java       |   4 +-
 .../crypto/random/JavaCryptoRandomTest.java        |   8 +-
 .../crypto/random/OpenSslCryptoRandomTest.java     |   8 +-
 .../commons/crypto/random/OsCryptoRandomTest.java  |  13 +-
 .../crypto/stream/AbstractCipherStreamTest.java    | 107 ++++----
 .../commons/crypto/stream/CtrCryptoStreamTest.java |   8 +-
 .../stream/PositionedCryptoInputStreamTest.java    | 155 +++++------
 .../org/apache/commons/crypto/utils/EnumTest.java  |   4 +-
 66 files changed, 1053 insertions(+), 907 deletions(-)
 copy clirr-excludes.xml => src/site/resources/checkstyle/checkstyle-suppressions.xml (68%)
 create mode 100644 src/site/resources/pmd/pmd-ruleset.xml
 copy clirr-excludes.xml => src/site/resources/spotbugs/spotbugs-exclude-filter.xml (60%)


[commons-crypto] 01/06: Use final.

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-crypto.git

commit 9067ae9e554605821b84b343cceabd1b7840b7d3
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Apr 10 15:34:56 2020 -0400

    Use final.
---
 .../java/org/apache/commons/crypto/Crypto.java     |  12 +-
 .../apache/commons/crypto/NativeCodeLoader.java    |  38 +--
 .../java/org/apache/commons/crypto/OsInfo.java     |  20 +-
 .../apache/commons/crypto/cipher/CryptoCipher.java |   4 +-
 .../commons/crypto/cipher/CryptoCipherFactory.java |  18 +-
 .../apache/commons/crypto/cipher/JceCipher.java    |  20 +-
 .../org/apache/commons/crypto/cipher/OpenSsl.java  |  48 ++--
 .../commons/crypto/cipher/OpenSslCipher.java       |  26 +-
 .../commons/crypto/cipher/OpenSslCommonMode.java   |  16 +-
 .../crypto/cipher/OpenSslEvpCtrlValues.java        |   2 +-
 .../crypto/cipher/OpenSslFeedbackCipher.java       |   2 +-
 .../crypto/cipher/OpenSslGaloisCounterMode.java    |  34 +--
 .../commons/crypto/jna/OpenSsl10XNativeJna.java    |   4 +-
 .../commons/crypto/jna/OpenSsl11XNativeJna.java    |   4 +-
 .../org/apache/commons/crypto/jna/OpenSslJna.java  |   2 +-
 .../commons/crypto/jna/OpenSslJnaCipher.java       |  68 ++---
 .../commons/crypto/jna/OpenSslJnaCryptoRandom.java |  30 +--
 .../commons/crypto/jna/OpenSslNativeJna.java       |  38 +--
 .../commons/crypto/random/CryptoRandomFactory.java |  18 +-
 .../commons/crypto/random/JavaCryptoRandom.java    |   6 +-
 .../commons/crypto/random/OpenSslCryptoRandom.java |  16 +-
 .../commons/crypto/random/OsCryptoRandom.java      |  16 +-
 .../commons/crypto/stream/CryptoInputStream.java   |  78 +++---
 .../commons/crypto/stream/CryptoOutputStream.java  |  42 +--
 .../crypto/stream/CtrCryptoInputStream.java        |  88 +++----
 .../crypto/stream/CtrCryptoOutputStream.java       |  62 ++---
 .../crypto/stream/PositionedCryptoInputStream.java |  64 ++---
 .../commons/crypto/stream/input/ChannelInput.java  |  14 +-
 .../commons/crypto/stream/input/StreamInput.java   |  10 +-
 .../crypto/stream/output/ChannelOutput.java        |   4 +-
 .../commons/crypto/stream/output/StreamOutput.java |   4 +-
 .../org/apache/commons/crypto/utils/IoUtils.java   |  16 +-
 .../commons/crypto/utils/ReflectionUtils.java      |  18 +-
 .../org/apache/commons/crypto/utils/Utils.java     |  34 +--
 .../java/org/apache/commons/crypto/CryptoTest.java |   4 +-
 .../commons/crypto/NativeCodeLoaderTest.java       |   2 +-
 .../commons/crypto/cipher/AbstractCipherTest.java  |  86 +++----
 .../crypto/cipher/CryptoCipherFactoryTest.java     |  12 +-
 .../commons/crypto/cipher/GcmCipherTest.java       | 286 ++++++++++-----------
 .../commons/crypto/cipher/JceCipherTest.java       |   2 +-
 .../commons/crypto/cipher/OpenSslCipherTest.java   |  24 +-
 .../org/apache/commons/crypto/cipher/TestData.java |   2 +-
 .../crypto/examples/CipherByteArrayExample.java    |  20 +-
 .../crypto/examples/CipherByteBufferExample.java   |  14 +-
 .../commons/crypto/examples/RandomExample.java     |   8 +-
 .../commons/crypto/examples/StreamExample.java     |  14 +-
 .../crypto/jna/AbstractCipherJnaStreamTest.java    |   2 +-
 .../crypto/jna/OpenSslJnaCryptoRandomTest.java     |   4 +-
 .../commons/crypto/random/AbstractRandom.java      |   2 +-
 .../commons/crypto/random/AbstractRandomTest.java  |  10 +-
 .../crypto/random/CryptoRandomFactoryTest.java     |  26 +-
 .../apache/commons/crypto/random/DummyRandom.java  |   2 +-
 .../commons/crypto/random/FailingRandom.java       |   4 +-
 .../crypto/random/JavaCryptoRandomTest.java        |   4 +-
 .../crypto/random/OpenSslCryptoRandomTest.java     |   4 +-
 .../commons/crypto/random/OsCryptoRandomTest.java  |   8 +-
 .../crypto/stream/AbstractCipherStreamTest.java    | 106 ++++----
 .../commons/crypto/stream/CtrCryptoStreamTest.java |   8 +-
 .../stream/PositionedCryptoInputStreamTest.java    | 130 +++++-----
 .../org/apache/commons/crypto/utils/EnumTest.java  |   4 +-
 60 files changed, 832 insertions(+), 832 deletions(-)

diff --git a/src/main/java/org/apache/commons/crypto/Crypto.java b/src/main/java/org/apache/commons/crypto/Crypto.java
index bbaf7c8..dd5cbba 100644
--- a/src/main/java/org/apache/commons/crypto/Crypto.java
+++ b/src/main/java/org/apache/commons/crypto/Crypto.java
@@ -62,13 +62,13 @@ public final class Crypto {
          * @return Properties contains project version.
          */
         private static Properties getComponentProperties() {
-            URL url = Crypto.class.getResource("/org/apache/commons/crypto/component.properties");
+            final URL url = Crypto.class.getResource("/org/apache/commons/crypto/component.properties");
             if (url != null) {
-                Properties versionData = new Properties();
+                final Properties versionData = new Properties();
                 try (InputStream openStream = url.openStream()) {
                     versionData.load(openStream);
                     return versionData;
-                } catch (IOException e) {  // NOPMD
+                } catch (final IOException e) {  // NOPMD
                 }
             }
             return new Properties(); // make sure field is not null
@@ -126,7 +126,7 @@ public final class Crypto {
      * @param args don't use the args
      * @throws Exception if getCryptoRandom or getCryptoCipher get error.
      */
-    public static void main(String args[]) throws Exception {
+    public static void main(final String args[]) throws Exception {
         System.out.println(getComponentName() + " " + getComponentVersion());
         if (isNativeCodeLoaded()) {
             System.out.println("Native code loaded OK " + OpenSslInfoNative.NativeVersion());
@@ -135,13 +135,13 @@ public final class Crypto {
             System.out.println("OpenSSL library loaded OK, version: 0x" + Long.toHexString(OpenSslInfoNative.OpenSSL()));
             System.out.println("OpenSSL library info " + OpenSslInfoNative.OpenSSLVersion(0));
             {
-                Properties props = new Properties();
+                final Properties props = new Properties();
                 props.setProperty(CryptoRandomFactory.CLASSES_KEY, CryptoRandomFactory.RandomProvider.OPENSSL.getClassName());
                 CryptoRandomFactory.getCryptoRandom(props);
                 System.out.println("Random instance created OK");
             }
             {
-                Properties props = new Properties();
+                final Properties props = new Properties();
                 props.setProperty(CryptoCipherFactory.CLASSES_KEY, CryptoCipherFactory.CipherProvider.OPENSSL.getClassName());
                 CryptoCipherFactory.getCryptoCipher("AES/CTR/NoPadding", props);
                 System.out.println("Cipher instance created OK");
diff --git a/src/main/java/org/apache/commons/crypto/NativeCodeLoader.java b/src/main/java/org/apache/commons/crypto/NativeCodeLoader.java
index e957762..e65d6ba 100644
--- a/src/main/java/org/apache/commons/crypto/NativeCodeLoader.java
+++ b/src/main/java/org/apache/commons/crypto/NativeCodeLoader.java
@@ -59,7 +59,7 @@ final class NativeCodeLoader {
      */
     static Throwable loadLibrary() {
         try {
-            File nativeLibFile = findNativeLibrary();
+            final File nativeLibFile = findNativeLibrary();
             if (nativeLibFile != null) {
                 // Load extracted or specified native library.
                 System.load(nativeLibFile.getAbsolutePath());
@@ -68,9 +68,9 @@ final class NativeCodeLoader {
                 System.loadLibrary("commons-crypto");
             }
             return null; // OK
-        } catch (Exception t) {
+        } catch (final Exception t) {
             return t;
-        } catch (UnsatisfiedLinkError t) {
+        } catch (final UnsatisfiedLinkError t) {
             return t;
         }
     }
@@ -93,7 +93,7 @@ final class NativeCodeLoader {
             nativeLibraryName = System.mapLibraryName("commons-crypto");
         }
         if (nativeLibraryPath != null) {
-            File nativeLib = new File(nativeLibraryPath, nativeLibraryName);
+            final File nativeLib = new File(nativeLibraryPath, nativeLibraryName);
             if (nativeLib.exists()) {
                 return nativeLib;
             }
@@ -105,7 +105,7 @@ final class NativeCodeLoader {
         boolean hasNativeLib = hasResource(nativeLibraryPath + "/"
                 + nativeLibraryName);
         if (!hasNativeLib) {
-            String altName = "libcommons-crypto.jnilib";
+            final String altName = "libcommons-crypto.jnilib";
             if (OsInfo.getOSName().equals("Mac") && hasResource(nativeLibraryPath + "/" + altName)) {
                 // Fix for openjdk7 for Mac
                 nativeLibraryName = altName;
@@ -114,7 +114,7 @@ final class NativeCodeLoader {
         }
 
         if (!hasNativeLib) {
-            String errorMessage = String.format(
+            final String errorMessage = String.format(
                     "no native library is found for os.name=%s and os.arch=%s",
                     OsInfo.getOSName(), OsInfo.getArchName());
             throw new RuntimeException(errorMessage);
@@ -122,7 +122,7 @@ final class NativeCodeLoader {
 
         // Temporary folder for the native lib. Use the value of
         // commons-crypto.tempdir or java.io.tmpdir
-        String tempFolder = new File(props.getProperty(Crypto.LIB_TEMPDIR_KEY,
+        final String tempFolder = new File(props.getProperty(Crypto.LIB_TEMPDIR_KEY,
         System.getProperty("java.io.tmpdir"))).getAbsolutePath();
 
         // Extract and load a native library inside the jar file
@@ -139,27 +139,27 @@ final class NativeCodeLoader {
      *        commons-crypto.tempdir or java.io.tmpdir.
      * @return the library file.
      */
-    private static File extractLibraryFile(String libFolderForCurrentOS,
-            String libraryFileName, String targetFolder) {
-        String nativeLibraryFilePath = libFolderForCurrentOS + "/"
+    private static File extractLibraryFile(final String libFolderForCurrentOS,
+            final String libraryFileName, final String targetFolder) {
+        final String nativeLibraryFilePath = libFolderForCurrentOS + "/"
                 + libraryFileName;
 
         // Attach UUID to the native library file to ensure multiple class
         // loaders
         // can read the libcommons-crypto multiple times.
-        String uuid = UUID.randomUUID().toString();
-        String extractedLibFileName = String.format("commons-crypto-%s-%s",
+        final String uuid = UUID.randomUUID().toString();
+        final String extractedLibFileName = String.format("commons-crypto-%s-%s",
                 uuid, libraryFileName);
-        File extractedLibFile = new File(targetFolder, extractedLibFileName);
+        final File extractedLibFile = new File(targetFolder, extractedLibFileName);
 
         InputStream reader = null;
         try {
             // Extract a native library file into the target directory
             reader = NativeCodeLoader.class
                     .getResourceAsStream(nativeLibraryFilePath);
-            FileOutputStream writer = new FileOutputStream(extractedLibFile);
+            final FileOutputStream writer = new FileOutputStream(extractedLibFile);
             try {
-                byte[] buffer = new byte[8192];
+                final byte[] buffer = new byte[8192];
                 int bytesRead;
                 while ((bytesRead = reader.read(buffer)) != -1) {
                     writer.write(buffer, 0, bytesRead);
@@ -206,7 +206,7 @@ final class NativeCodeLoader {
             }
 
             return extractedLibFile;
-        } catch (IOException e) {
+        } catch (final IOException e) {
             return null;
         } finally {
             IoUtils.cleanup(reader);
@@ -232,13 +232,13 @@ final class NativeCodeLoader {
 
         int ch = in1.read();
         while (ch != -1) {
-            int ch2 = in2.read();
+            final int ch2 = in2.read();
             if (ch != ch2) {
                 return false;
             }
             ch = in1.read();
         }
-        int ch2 = in2.read();
+        final int ch2 = in2.read();
         return ch2 == -1;
     }
 
@@ -248,7 +248,7 @@ final class NativeCodeLoader {
      * @param path the path.
      * @return the boolean.
      */
-    private static boolean hasResource(String path) {
+    private static boolean hasResource(final String path) {
         return NativeCodeLoader.class.getResource(path) != null;
     }
 
diff --git a/src/main/java/org/apache/commons/crypto/OsInfo.java b/src/main/java/org/apache/commons/crypto/OsInfo.java
index 4c2e20f..0517da8 100644
--- a/src/main/java/org/apache/commons/crypto/OsInfo.java
+++ b/src/main/java/org/apache/commons/crypto/OsInfo.java
@@ -114,7 +114,7 @@ final class OsInfo {
      *
      * @param args the argv.
      */
-    public static void main(String[] args) {
+    public static void main(final String[] args) {
         if (args.length >= 1) {
             if ("--os".equals(args[0])) {
                 System.out.print(getOSName());
@@ -153,30 +153,30 @@ final class OsInfo {
      */
     static String getArchName() {
         // if running Linux on ARM, need to determine ABI of JVM
-        String osArch = System.getProperty("os.arch");
+        final String osArch = System.getProperty("os.arch");
         if (osArch.startsWith("arm")
                 && System.getProperty("os.name").contains("Linux")) {
-            String javaHome = System.getProperty("java.home");
+            final String javaHome = System.getProperty("java.home");
             try {
                 // determine if first JVM found uses ARM hard-float ABI
-                String[] cmdarray = {
+                final String[] cmdarray = {
                         "/bin/sh",
                         "-c",
                         "find '"
                                 + javaHome
                                 + "' -name 'libjvm.so' | head -1 | xargs readelf -A | "
                                 + "grep 'Tag_ABI_VFP_args: VFP registers'" };
-                int exitCode = Runtime.getRuntime().exec(cmdarray).waitFor();
+                final int exitCode = Runtime.getRuntime().exec(cmdarray).waitFor();
                 if (exitCode == 0) {
                     return "armhf";
                 }
-            } catch (IOException e) { //NOPMD
+            } catch (final IOException e) { //NOPMD
                 // ignored: fall back to "arm" arch (soft-float ABI)
-            } catch (InterruptedException e) { //NOPMD
+            } catch (final InterruptedException e) { //NOPMD
                 // ignored: fall back to "arm" arch (soft-float ABI)
             }
         } else {
-            String lc = osArch.toLowerCase(Locale.US);
+            final String lc = osArch.toLowerCase(Locale.US);
             if (archMapping.containsKey(lc)) {
                 return archMapping.get(lc);
             }
@@ -190,7 +190,7 @@ final class OsInfo {
      * @param osName the OS name.
      * @return the folder name.
      */
-    private static String translateOSNameToFolderName(String osName) {
+    private static String translateOSNameToFolderName(final String osName) {
         if (osName.contains("Windows")) {
             return "Windows";
         } else if (osName.contains("Mac")) {
@@ -212,7 +212,7 @@ final class OsInfo {
      * @param archName the architecture name.
      * @return the folder name.
      */
-    private static String translateArchNameToFolderName(String archName) {
+    private static String translateArchNameToFolderName(final String archName) {
         return archName.replaceAll("\\W", "");
     }
 }
diff --git a/src/main/java/org/apache/commons/crypto/cipher/CryptoCipher.java b/src/main/java/org/apache/commons/crypto/cipher/CryptoCipher.java
index ea1edfd..5c5db9b 100644
--- a/src/main/java/org/apache/commons/crypto/cipher/CryptoCipher.java
+++ b/src/main/java/org/apache/commons/crypto/cipher/CryptoCipher.java
@@ -177,7 +177,7 @@ public interface CryptoCipher extends Closeable {
      * has not been overridden by an implementation
      *
      */
-    default void updateAAD(byte[] aad)
+    default void updateAAD(final byte[] aad)
             throws IllegalArgumentException, IllegalStateException, UnsupportedOperationException {
       throw new UnsupportedOperationException();
     }
@@ -205,7 +205,7 @@ public interface CryptoCipher extends Closeable {
      * has not been overridden by an implementation
      *
      */
-    default void updateAAD(ByteBuffer aad)
+    default void updateAAD(final ByteBuffer aad)
             throws IllegalArgumentException, IllegalStateException, UnsupportedOperationException {
       throw new UnsupportedOperationException();
     }
diff --git a/src/main/java/org/apache/commons/crypto/cipher/CryptoCipherFactory.java b/src/main/java/org/apache/commons/crypto/cipher/CryptoCipherFactory.java
index c9fe49a..6e19f75 100644
--- a/src/main/java/org/apache/commons/crypto/cipher/CryptoCipherFactory.java
+++ b/src/main/java/org/apache/commons/crypto/cipher/CryptoCipherFactory.java
@@ -89,7 +89,7 @@ public class CryptoCipherFactory {
          * The private constructor.
          * @param klass the Class of CryptoCipher
          */
-        private CipherProvider(Class<? extends CryptoCipher> klass) {
+        private CipherProvider(final Class<? extends CryptoCipher> klass) {
             this.klass = klass;
             this.className = klass.getName();
         }
@@ -143,8 +143,8 @@ public class CryptoCipherFactory {
      * @throws GeneralSecurityException if cipher initialize failed
      * @throws IllegalArgumentException if no classname(s) were provided
      */
-    public static CryptoCipher getCryptoCipher(String transformation,
-                                           Properties props) throws GeneralSecurityException {
+    public static CryptoCipher getCryptoCipher(final String transformation,
+                                           final Properties props) throws GeneralSecurityException {
 
         final List<String> names = Utils.splitClassNames(getCipherClassString(props), ",");
         if (names.size() == 0) {
@@ -153,16 +153,16 @@ public class CryptoCipherFactory {
         CryptoCipher cipher = null;
         Exception lastException = null;
 
-        StringBuilder errorMessage = new StringBuilder("CryptoCipher ");
-        for (String klass : names) {
+        final StringBuilder errorMessage = new StringBuilder("CryptoCipher ");
+        for (final String klass : names) {
             try {
-                Class<?> cls = ReflectionUtils.getClassByName(klass);
+                final Class<?> cls = ReflectionUtils.getClassByName(klass);
                 cipher = ReflectionUtils.newInstance(cls.asSubclass
                         (CryptoCipher.class), props, transformation);
                 if (cipher != null) {
                     break;
                 }
-            } catch (Exception e) {
+            } catch (final Exception e) {
                 lastException = e;
                 errorMessage.append("{" + klass + "}");
             }
@@ -187,7 +187,7 @@ public class CryptoCipherFactory {
      * @return CryptoCipher the cipher object (defaults to OpenSslCipher if available, else JceCipher)
      * @throws GeneralSecurityException if JCE cipher initialize failed
      */
-    public static CryptoCipher getCryptoCipher(String transformation)
+    public static CryptoCipher getCryptoCipher(final String transformation)
             throws GeneralSecurityException {
         return getCryptoCipher(transformation, new Properties());
     }
@@ -199,7 +199,7 @@ public class CryptoCipherFactory {
      *        properties.
      * @return the cipher class based on the props.
      */
-    private static String getCipherClassString(Properties props) {
+    private static String getCipherClassString(final Properties props) {
         String cipherClassString = props.getProperty(CryptoCipherFactory.CLASSES_KEY, CLASSES_DEFAULT);
         if (cipherClassString.isEmpty()) { // TODO does it make sense to treat the empty string as the default?
             cipherClassString = CLASSES_DEFAULT;
diff --git a/src/main/java/org/apache/commons/crypto/cipher/JceCipher.java b/src/main/java/org/apache/commons/crypto/cipher/JceCipher.java
index a2980d9..822e2ff 100644
--- a/src/main/java/org/apache/commons/crypto/cipher/JceCipher.java
+++ b/src/main/java/org/apache/commons/crypto/cipher/JceCipher.java
@@ -46,7 +46,7 @@ class JceCipher implements CryptoCipher {
      */
     // N.B. this class is not public/protected so does not appear in the main Javadoc
     // Please ensure that property use is documented in the enum CryptoRandomFactory.RandomProvider
-    public JceCipher(Properties props, String transformation)
+    public JceCipher(final Properties props, final String transformation)
             throws GeneralSecurityException {
         final String provider = props.getProperty(CryptoCipherFactory.JCE_PROVIDER_KEY);
         if (provider == null || provider.isEmpty()) {
@@ -95,7 +95,7 @@ class JceCipher implements CryptoCipher {
      *         configured jurisdiction policy files).
      */
     @Override
-    public void init(int mode, Key key, AlgorithmParameterSpec params)
+    public void init(final int mode, final Key key, final AlgorithmParameterSpec params)
             throws InvalidKeyException, InvalidAlgorithmParameterException {
         Objects.requireNonNull(key, "key");
         Objects.requireNonNull(params, "params");
@@ -115,7 +115,7 @@ class JceCipher implements CryptoCipher {
      *         buffer
      */
     @Override
-    public int update(ByteBuffer inBuffer, ByteBuffer outBuffer)
+    public int update(final ByteBuffer inBuffer, final ByteBuffer outBuffer)
             throws ShortBufferException {
         return cipher.update(inBuffer, outBuffer);
     }
@@ -134,8 +134,8 @@ class JceCipher implements CryptoCipher {
      *         byte array
      */
     @Override
-    public int update(byte[] input, int inputOffset, int inputLen,
-            byte[] output, int outputOffset) throws ShortBufferException {
+    public int update(final byte[] input, final int inputOffset, final int inputLen,
+            final byte[] output, final int outputOffset) throws ShortBufferException {
         return cipher
                 .update(input, inputOffset, inputLen, output, outputOffset);
     }
@@ -160,7 +160,7 @@ class JceCipher implements CryptoCipher {
      *         hold the result
      */
     @Override
-    public int doFinal(ByteBuffer inBuffer, ByteBuffer outBuffer)
+    public int doFinal(final ByteBuffer inBuffer, final ByteBuffer outBuffer)
             throws ShortBufferException, IllegalBlockSizeException,
             BadPaddingException {
         return cipher.doFinal(inBuffer, outBuffer);
@@ -188,8 +188,8 @@ class JceCipher implements CryptoCipher {
      *         to process the input data provided.
      */
     @Override
-    public int doFinal(byte[] input, int inputOffset, int inputLen,
-            byte[] output, int outputOffset) throws ShortBufferException,
+    public int doFinal(final byte[] input, final int inputOffset, final int inputLen,
+            final byte[] output, final int outputOffset) throws ShortBufferException,
             IllegalBlockSizeException, BadPaddingException {
         return cipher.doFinal(input, inputOffset, inputLen, output,
                 outputOffset);
@@ -219,7 +219,7 @@ class JceCipher implements CryptoCipher {
      * support such operation
      */
     @Override
-    public void updateAAD(byte[] aad) {
+    public void updateAAD(final byte[] aad) {
         cipher.updateAAD(aad);
     }
 
@@ -246,7 +246,7 @@ class JceCipher implements CryptoCipher {
      * support such operation
      */
     @Override
-    public void updateAAD(ByteBuffer aad) {
+    public void updateAAD(final ByteBuffer aad) {
         cipher.updateAAD(aad);
     }
 
diff --git a/src/main/java/org/apache/commons/crypto/cipher/OpenSsl.java b/src/main/java/org/apache/commons/crypto/cipher/OpenSsl.java
index 31e053b..38bad73 100644
--- a/src/main/java/org/apache/commons/crypto/cipher/OpenSsl.java
+++ b/src/main/java/org/apache/commons/crypto/cipher/OpenSsl.java
@@ -54,11 +54,11 @@ final class OpenSsl {
          * @return the Algorithm mode.
          * @throws NoSuchAlgorithmException if the algorithm is not available.
          */
-        static int get(String algorithm, String mode)
+        static int get(final String algorithm, final String mode)
                 throws NoSuchAlgorithmException {
             try {
                 return AlgorithmMode.valueOf(algorithm + "_" + mode).ordinal();
-            } catch (Exception e) {
+            } catch (final Exception e) {
                 throw new NoSuchAlgorithmException(
                         "Doesn't support algorithm: " + algorithm
                                 + " and mode: " + mode);
@@ -76,10 +76,10 @@ final class OpenSsl {
          * @return the value of Padding.
          * @throws NoSuchPaddingException if the padding is not available.
          */
-        static int get(String padding) throws NoSuchPaddingException {
+        static int get(final String padding) throws NoSuchPaddingException {
             try {
                 return Padding.valueOf(padding).ordinal();
-            } catch (Exception e) {
+            } catch (final Exception e) {
                 throw new NoSuchPaddingException("Doesn't support padding: "
                         + padding);
             }
@@ -96,9 +96,9 @@ final class OpenSsl {
             } else {
                 loadingFailure = Crypto.getLoadingError();
             }
-        } catch (Exception t) {
+        } catch (final Exception t) {
             loadingFailure = t;
-        } catch (UnsatisfiedLinkError t) {
+        } catch (final UnsatisfiedLinkError t) {
             loadingFailure = t;
         } finally {
             loadingFailureReason = loadingFailure;
@@ -121,7 +121,7 @@ final class OpenSsl {
      * @param algorithm the algorithm.
      * @param padding the padding.
      */
-    private OpenSsl(long context, int algorithm, int padding) {
+    private OpenSsl(final long context, final int algorithm, final int padding) {
         if (algorithm == AlgorithmMode.AES_GCM.ordinal()) {
             opensslBlockCipher = new OpenSslGaloisCounterMode(context, algorithm, padding);
         } else {
@@ -143,16 +143,16 @@ final class OpenSsl {
      *         padding scheme that is not available.
      * @throws IllegalStateException if native code cannot be initialised
      */
-    public static OpenSsl getInstance(String transformation)
+    public static OpenSsl getInstance(final String transformation)
             throws NoSuchAlgorithmException, NoSuchPaddingException {
         if (loadingFailureReason != null) {
             throw new IllegalStateException(loadingFailureReason);
         }
-        Transform transform = tokenizeTransformation(transformation);
-        int algorithmMode = AlgorithmMode.get(transform.algorithm,
+        final Transform transform = tokenizeTransformation(transformation);
+        final int algorithmMode = AlgorithmMode.get(transform.algorithm,
                 transform.mode);
-        int padding = Padding.get(transform.padding);
-        long context = OpenSslNative.initContext(algorithmMode, padding);
+        final int padding = Padding.get(transform.padding);
+        final long context = OpenSslNative.initContext(algorithmMode, padding);
         return new OpenSsl(context, algorithmMode, padding);
     }
 
@@ -169,7 +169,7 @@ final class OpenSsl {
          * @param mode the mode.
          * @param padding the padding.
          */
-        public Transform(String algorithm, String mode, String padding) {
+        public Transform(final String algorithm, final String mode, final String padding) {
             this.algorithm = algorithm;
             this.mode = mode;
             this.padding = padding;
@@ -183,7 +183,7 @@ final class OpenSsl {
      * @return the {@link Transform} instance.
      * @throws NoSuchAlgorithmException if the transformation is null.
      */
-    private static Transform tokenizeTransformation(String transformation)
+    private static Transform tokenizeTransformation(final String transformation)
             throws NoSuchAlgorithmException {
         if (transformation == null) {
             throw new NoSuchAlgorithmException("No transformation given.");
@@ -194,9 +194,9 @@ final class OpenSsl {
          * algorithm (e.g., AES) index 1: mode (e.g., CTR) index 2: padding
          * (e.g., NoPadding)
          */
-        String[] parts = new String[3];
+        final String[] parts = new String[3];
         int count = 0;
-        StringTokenizer parser = new StringTokenizer(transformation, "/");
+        final StringTokenizer parser = new StringTokenizer(transformation, "/");
         while (parser.hasMoreTokens() && count < 3) {
             parts[count++] = parser.nextToken().trim();
         }
@@ -215,7 +215,7 @@ final class OpenSsl {
      * @param params the algorithm parameters
      * @throws InvalidAlgorithmParameterException if IV length is wrong
      */
-    public void init(int mode, byte[] key, AlgorithmParameterSpec params)
+    public void init(final int mode, final byte[] key, final AlgorithmParameterSpec params)
             throws InvalidAlgorithmParameterException {
         opensslBlockCipher.init(mode, key, params);
     }
@@ -248,7 +248,7 @@ final class OpenSsl {
      * @throws ShortBufferException if there is insufficient space in the output
      *         buffer
      */
-    public int update(ByteBuffer input, ByteBuffer output)
+    public int update(final ByteBuffer input, final ByteBuffer output)
             throws ShortBufferException {
         Utils.checkArgument(input.isDirect() && output.isDirect(),
                 "Direct buffers are required.");
@@ -268,8 +268,8 @@ final class OpenSsl {
      * @throws ShortBufferException if there is insufficient space in the output
      *         byte array
      */
-    public int update(byte[] input, int inputOffset, int inputLen,
-            byte[] output, int outputOffset) throws ShortBufferException {
+    public int update(final byte[] input, final int inputOffset, final int inputLen,
+            final byte[] output, final int outputOffset) throws ShortBufferException {
         return opensslBlockCipher.update(input, inputOffset, inputLen, output, outputOffset);
     }
 
@@ -294,8 +294,8 @@ final class OpenSsl {
      *         multiple of block size; or if this encryption algorithm is unable
      *         to process the input data provided.
      */
-    public int doFinal(byte[] input, int inputOffset, int inputLen,
-                       byte[] output, int outputOffset)
+    public int doFinal(final byte[] input, final int inputOffset, final int inputLen,
+                       final byte[] output, final int outputOffset)
             throws ShortBufferException, IllegalBlockSizeException,
             BadPaddingException{
         return opensslBlockCipher.doFinal(input, inputOffset, inputLen, output, outputOffset);
@@ -341,7 +341,7 @@ final class OpenSsl {
      *         (un)padding has been requested, but the decrypted data is not
      *         bounded by the appropriate padding bytes
      */
-    public int doFinal(ByteBuffer input, ByteBuffer output) throws ShortBufferException,
+    public int doFinal(final ByteBuffer input, final ByteBuffer output) throws ShortBufferException,
             IllegalBlockSizeException, BadPaddingException {
         Utils.checkArgument(output.isDirect(), "Direct buffer is required.");
 
@@ -362,7 +362,7 @@ final class OpenSsl {
      * @param aad the buffer containing the Additional Authentication Data
      *
      */
-    public void updateAAD(byte[] aad) {
+    public void updateAAD(final byte[] aad) {
         this.opensslBlockCipher.updateAAD(aad);
     }
 
diff --git a/src/main/java/org/apache/commons/crypto/cipher/OpenSslCipher.java b/src/main/java/org/apache/commons/crypto/cipher/OpenSslCipher.java
index a149f70..124113b 100644
--- a/src/main/java/org/apache/commons/crypto/cipher/OpenSslCipher.java
+++ b/src/main/java/org/apache/commons/crypto/cipher/OpenSslCipher.java
@@ -50,11 +50,11 @@ class OpenSslCipher implements CryptoCipher {
      */
     // N.B. this class is not public/protected so does not appear in the main Javadoc
     // Please ensure that property use is documented in the enum CryptoRandomFactory.RandomProvider
-    public OpenSslCipher(Properties props, String transformation) // NOPMD
+    public OpenSslCipher(final Properties props, final String transformation) // NOPMD
             throws GeneralSecurityException {
         this.transformation = transformation;
 
-        Throwable loadingFailureReason = OpenSsl.getLoadingFailureReason();
+        final Throwable loadingFailureReason = OpenSsl.getLoadingFailureReason();
         if (loadingFailureReason != null) {
             throw new RuntimeException(loadingFailureReason);
         }
@@ -97,7 +97,7 @@ class OpenSslCipher implements CryptoCipher {
      * @throws InvalidAlgorithmParameterException if IV length is wrong
      */
     @Override
-    public void init(int mode, Key key, AlgorithmParameterSpec params)
+    public void init(final int mode, final Key key, final AlgorithmParameterSpec params)
             throws InvalidKeyException, InvalidAlgorithmParameterException {
         Objects.requireNonNull(key, "key");
         Objects.requireNonNull(params, "params");
@@ -121,7 +121,7 @@ class OpenSslCipher implements CryptoCipher {
      *         buffer
      */
     @Override
-    public int update(ByteBuffer inBuffer, ByteBuffer outBuffer)
+    public int update(final ByteBuffer inBuffer, final ByteBuffer outBuffer)
             throws ShortBufferException {
         return openSslEngine.update(inBuffer, outBuffer);
     }
@@ -140,8 +140,8 @@ class OpenSslCipher implements CryptoCipher {
      *         byte array
      */
     @Override
-    public int update(byte[] input, int inputOffset, int inputLen,
-            byte[] output, int outputOffset) throws ShortBufferException {
+    public int update(final byte[] input, final int inputOffset, final int inputLen,
+            final byte[] output, final int outputOffset) throws ShortBufferException {
         return openSslEngine
                 .update(input, inputOffset, inputLen, output, outputOffset);
     }
@@ -166,7 +166,7 @@ class OpenSslCipher implements CryptoCipher {
      *         hold the result
      */
     @Override
-    public int doFinal(ByteBuffer inBuffer, ByteBuffer outBuffer)
+    public int doFinal(final ByteBuffer inBuffer, final ByteBuffer outBuffer)
             throws ShortBufferException, IllegalBlockSizeException,
             BadPaddingException {
         return openSslEngine.doFinal(inBuffer, outBuffer);
@@ -194,8 +194,8 @@ class OpenSslCipher implements CryptoCipher {
      *         to process the input data provided.
      */
     @Override
-    public int doFinal(byte[] input, int inputOffset, int inputLen,
-            byte[] output, int outputOffset) throws ShortBufferException,
+    public int doFinal(final byte[] input, final int inputOffset, final int inputLen,
+            final byte[] output, final int outputOffset) throws ShortBufferException,
             IllegalBlockSizeException, BadPaddingException {
         return openSslEngine.doFinal(input, inputOffset, inputLen, output,outputOffset);
     }
@@ -224,7 +224,7 @@ class OpenSslCipher implements CryptoCipher {
      * doesn't support this operation.
      */
     @Override
-    public void updateAAD(byte[] aad) throws IllegalArgumentException,
+    public void updateAAD(final byte[] aad) throws IllegalArgumentException,
             IllegalStateException, UnsupportedOperationException {
         if (aad == null) {
             throw new IllegalArgumentException("aad buffer is null");
@@ -262,7 +262,7 @@ class OpenSslCipher implements CryptoCipher {
      * doesn't support this operation.
      */
     @Override
-    public void updateAAD(ByteBuffer aad) throws IllegalArgumentException,
+    public void updateAAD(final ByteBuffer aad) throws IllegalArgumentException,
             IllegalStateException, UnsupportedOperationException {
         if (aad == null) {
             throw new IllegalArgumentException("aad buffer is null");
@@ -271,11 +271,11 @@ class OpenSslCipher implements CryptoCipher {
             throw new IllegalStateException("Cipher not initialized");
         }
 
-        int aadLen = aad.limit() - aad.position();
+        final int aadLen = aad.limit() - aad.position();
         if (aadLen == 0) {
             return;
         }
-        byte[] aadBytes = new byte[aadLen];
+        final byte[] aadBytes = new byte[aadLen];
         aad.get(aadBytes);
         openSslEngine.updateAAD(aadBytes);
     }
diff --git a/src/main/java/org/apache/commons/crypto/cipher/OpenSslCommonMode.java b/src/main/java/org/apache/commons/crypto/cipher/OpenSslCommonMode.java
index 91475fc..bb9be56 100644
--- a/src/main/java/org/apache/commons/crypto/cipher/OpenSslCommonMode.java
+++ b/src/main/java/org/apache/commons/crypto/cipher/OpenSslCommonMode.java
@@ -32,12 +32,12 @@ import java.security.spec.AlgorithmParameterSpec;
  */
 class OpenSslCommonMode extends OpenSslFeedbackCipher {
 
-    OpenSslCommonMode(long context, int algorithmMode, int padding) {
+    OpenSslCommonMode(final long context, final int algorithmMode, final int padding) {
         super(context, algorithmMode, padding);
     }
 
     @Override
-    public void init(int mode, byte[] key, AlgorithmParameterSpec params)
+    public void init(final int mode, final byte[] key, final AlgorithmParameterSpec params)
             throws InvalidAlgorithmParameterException {
         this.cipherMode = mode;
         byte[] iv;
@@ -51,10 +51,10 @@ class OpenSslCommonMode extends OpenSslFeedbackCipher {
     }
 
     @Override
-    public int update(ByteBuffer input, ByteBuffer output) throws ShortBufferException {
+    public int update(final ByteBuffer input, final ByteBuffer output) throws ShortBufferException {
         checkState();
 
-        int len = OpenSslNative.update(context, input, input.position(),
+        final int len = OpenSslNative.update(context, input, input.position(),
                 input.remaining(), output, output.position(),
                 output.remaining());
         input.position(input.limit());
@@ -64,7 +64,7 @@ class OpenSslCommonMode extends OpenSslFeedbackCipher {
     }
 
     @Override
-    public int update(byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset)
+    public int update(final byte[] input, final int inputOffset, final int inputLen, final byte[] output, final int outputOffset)
             throws ShortBufferException {
         checkState();
 
@@ -73,7 +73,7 @@ class OpenSslCommonMode extends OpenSslFeedbackCipher {
     }
 
     @Override
-    public int doFinal(byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset)
+    public int doFinal(final byte[] input, final int inputOffset, final int inputLen, final byte[] output, final int outputOffset)
             throws ShortBufferException, IllegalBlockSizeException, BadPaddingException {
         checkState();
 
@@ -87,7 +87,7 @@ class OpenSslCommonMode extends OpenSslFeedbackCipher {
     }
 
     @Override
-    public int doFinal(ByteBuffer input, ByteBuffer output)
+    public int doFinal(final ByteBuffer input, final ByteBuffer output)
             throws ShortBufferException, IllegalBlockSizeException, BadPaddingException {
         checkState();
 
@@ -109,7 +109,7 @@ class OpenSslCommonMode extends OpenSslFeedbackCipher {
     }
 
     @Override
-    public void updateAAD(byte[] aad) {
+    public void updateAAD(final byte[] aad) {
         throw new UnsupportedOperationException(
                 "The underlying Cipher implementation "
                         + "does not support this method");
diff --git a/src/main/java/org/apache/commons/crypto/cipher/OpenSslEvpCtrlValues.java b/src/main/java/org/apache/commons/crypto/cipher/OpenSslEvpCtrlValues.java
index f826af9..b0315e4 100644
--- a/src/main/java/org/apache/commons/crypto/cipher/OpenSslEvpCtrlValues.java
+++ b/src/main/java/org/apache/commons/crypto/cipher/OpenSslEvpCtrlValues.java
@@ -42,7 +42,7 @@ enum OpenSslEvpCtrlValues {
 
     private final int value;
 
-    OpenSslEvpCtrlValues(int value) {
+    OpenSslEvpCtrlValues(final int value) {
         this.value = value;
     }
 
diff --git a/src/main/java/org/apache/commons/crypto/cipher/OpenSslFeedbackCipher.java b/src/main/java/org/apache/commons/crypto/cipher/OpenSslFeedbackCipher.java
index 67f8058..7d504ae 100644
--- a/src/main/java/org/apache/commons/crypto/cipher/OpenSslFeedbackCipher.java
+++ b/src/main/java/org/apache/commons/crypto/cipher/OpenSslFeedbackCipher.java
@@ -37,7 +37,7 @@ abstract class OpenSslFeedbackCipher {
 
     protected int cipherMode = OpenSsl.DECRYPT_MODE;
 
-    OpenSslFeedbackCipher(long context, int algorithmMode, int padding) {
+    OpenSslFeedbackCipher(final long context, final int algorithmMode, final int padding) {
         this.context = context;
         this.algorithmMode = algorithmMode;
         this.padding = padding;
diff --git a/src/main/java/org/apache/commons/crypto/cipher/OpenSslGaloisCounterMode.java b/src/main/java/org/apache/commons/crypto/cipher/OpenSslGaloisCounterMode.java
index 991c475..f8d321d 100644
--- a/src/main/java/org/apache/commons/crypto/cipher/OpenSslGaloisCounterMode.java
+++ b/src/main/java/org/apache/commons/crypto/cipher/OpenSslGaloisCounterMode.java
@@ -46,12 +46,12 @@ class OpenSslGaloisCounterMode extends OpenSslFeedbackCipher {
     // buffer for storing input in decryption, not used for encryption
     private ByteArrayOutputStream inBuffer = null;
 
-    public OpenSslGaloisCounterMode(long context, int algorithmMode, int padding) {
+    public OpenSslGaloisCounterMode(final long context, final int algorithmMode, final int padding) {
         super(context, algorithmMode, padding);
     }
 
     @Override
-    public void init(int mode, byte[] key, AlgorithmParameterSpec params)
+    public void init(final int mode, final byte[] key, final AlgorithmParameterSpec params)
             throws InvalidAlgorithmParameterException {
 
         if (aadBuffer == null) {
@@ -63,7 +63,7 @@ class OpenSslGaloisCounterMode extends OpenSslFeedbackCipher {
         this.cipherMode = mode;
         byte[] iv;
         if (params instanceof GCMParameterSpec) {
-            GCMParameterSpec gcmParam = (GCMParameterSpec) params;
+            final GCMParameterSpec gcmParam = (GCMParameterSpec) params;
             iv = gcmParam.getIV();
             this.tagBitLen = gcmParam.getTLen();
         } else {
@@ -79,7 +79,7 @@ class OpenSslGaloisCounterMode extends OpenSslFeedbackCipher {
     }
 
     @Override
-    public int update(ByteBuffer input, ByteBuffer output) throws ShortBufferException {
+    public int update(final ByteBuffer input, final ByteBuffer output) throws ShortBufferException {
         checkState();
 
         processAAD();
@@ -89,8 +89,8 @@ class OpenSslGaloisCounterMode extends OpenSslFeedbackCipher {
             // store internally until doFinal(decrypt) is called because
             // spec mentioned that only return recovered data after tag
             // is successfully verified
-            int inputLen = input.remaining();
-            byte[] inputBuf = new byte[inputLen];
+            final int inputLen = input.remaining();
+            final byte[] inputBuf = new byte[inputLen];
             input.get(inputBuf, 0, inputLen);
             inBuffer.write(inputBuf, 0, inputLen);
             return 0;
@@ -106,7 +106,7 @@ class OpenSslGaloisCounterMode extends OpenSslFeedbackCipher {
     }
 
     @Override
-    public int update(byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset)
+    public int update(final byte[] input, final int inputOffset, final int inputLen, final byte[] output, final int outputOffset)
             throws ShortBufferException {
         checkState();
 
@@ -125,7 +125,7 @@ class OpenSslGaloisCounterMode extends OpenSslFeedbackCipher {
     }
 
     @Override
-    public int doFinal(byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset)
+    public int doFinal(final byte[] input, final int inputOffset, final int inputLen, final byte[] output, final int outputOffset)
             throws ShortBufferException, IllegalBlockSizeException, BadPaddingException {
         checkState();
 
@@ -152,12 +152,12 @@ class OpenSslGaloisCounterMode extends OpenSslFeedbackCipher {
                 throw new AEADBadTagException("Input too short - need tag");
             }
 
-            int inputDataLen = inputLenFinal - getTagLen();
+            final int inputDataLen = inputLenFinal - getTagLen();
             len = OpenSslNative.updateByteArray(context, inputFinal, inputOffsetFinal,
                     inputDataLen, output, outputOffset, output.length - outputOffset);
 
             // set tag to EVP_Cipher for integrity verification in doFinal
-            ByteBuffer tag = ByteBuffer.allocate(getTagLen());
+            final ByteBuffer tag = ByteBuffer.allocate(getTagLen());
             tag.put(input, input.length - getTagLen(), getTagLen());
             tag.flip();
             evpCipherCtxCtrl(context, OpenSslEvpCtrlValues.AEAD_SET_TAG.getValue(), getTagLen(), tag);
@@ -182,7 +182,7 @@ class OpenSslGaloisCounterMode extends OpenSslFeedbackCipher {
     }
 
     @Override
-    public int doFinal(ByteBuffer input, ByteBuffer output)
+    public int doFinal(final ByteBuffer input, final ByteBuffer output)
             throws ShortBufferException, IllegalBlockSizeException, BadPaddingException {
         checkState();
 
@@ -191,15 +191,15 @@ class OpenSslGaloisCounterMode extends OpenSslFeedbackCipher {
         int totalLen = 0;
         int len;
         if (this.cipherMode == OpenSsl.DECRYPT_MODE) {
-            ByteBuffer tag = ByteBuffer.allocate(getTagLen());
+            final ByteBuffer tag = ByteBuffer.allocate(getTagLen());
 
             // if GCM-DECRYPT, we have to handle the buffered input
             // and the retrieve the trailing tag from input
             if (inBuffer != null && inBuffer.size() > 0) {
-                byte[] inputBytes = new byte[input.remaining()];
+                final byte[] inputBytes = new byte[input.remaining()];
                 input.get(inputBytes, 0, inputBytes.length);
                 inBuffer.write(inputBytes, 0, inputBytes.length);
-                byte[] inputFinal = inBuffer.toByteArray();
+                final byte[] inputFinal = inBuffer.toByteArray();
                 inBuffer.reset();
 
                 if (inputFinal.length < getTagLen()) {
@@ -267,7 +267,7 @@ class OpenSslGaloisCounterMode extends OpenSslFeedbackCipher {
     }
 
     @Override
-    public void updateAAD(byte[] aad) {
+    public void updateAAD(final byte[] aad) {
         // must be called after initialized.
         if (aadBuffer != null) {
             aadBuffer.write(aad, 0, aad.length);
@@ -296,7 +296,7 @@ class OpenSslGaloisCounterMode extends OpenSslFeedbackCipher {
      * it may set/get any native char or long type to the data buffer(ptr).
      * Here we use ByteBuffer and set nativeOrder to handle the endianness.
      */
-    private void evpCipherCtxCtrl(long context, int type, int arg, ByteBuffer bb) {
+    private void evpCipherCtxCtrl(final long context, final int type, final int arg, final ByteBuffer bb) {
         checkState();
 
         try {
@@ -306,7 +306,7 @@ class OpenSslGaloisCounterMode extends OpenSslFeedbackCipher {
             } else {
                 OpenSslNative.ctrl(context, type, arg, null);
             }
-        } catch (Exception e) {
+        } catch (final Exception e) {
             System.out.println(e.getMessage());
         }
     }
diff --git a/src/main/java/org/apache/commons/crypto/jna/OpenSsl10XNativeJna.java b/src/main/java/org/apache/commons/crypto/jna/OpenSsl10XNativeJna.java
index 190caa1..f281c40 100644
--- a/src/main/java/org/apache/commons/crypto/jna/OpenSsl10XNativeJna.java
+++ b/src/main/java/org/apache/commons/crypto/jna/OpenSsl10XNativeJna.java
@@ -36,9 +36,9 @@ class OpenSsl10XNativeJna {
         try {
             Native.register("crypto");
             ok = true;
-        } catch (Exception e) {
+        } catch (final Exception e) {
             thrown = e;
-        } catch (UnsatisfiedLinkError e) {
+        } catch (final UnsatisfiedLinkError e) {
             thrown = e;
         } finally {
             INIT_OK = ok;
diff --git a/src/main/java/org/apache/commons/crypto/jna/OpenSsl11XNativeJna.java b/src/main/java/org/apache/commons/crypto/jna/OpenSsl11XNativeJna.java
index f07b2d4..5879655 100644
--- a/src/main/java/org/apache/commons/crypto/jna/OpenSsl11XNativeJna.java
+++ b/src/main/java/org/apache/commons/crypto/jna/OpenSsl11XNativeJna.java
@@ -36,9 +36,9 @@ class OpenSsl11XNativeJna {
         try {
             Native.register("crypto");
             ok = true;
-        } catch (Exception e) {
+        } catch (final Exception e) {
             thrown = e;
-        } catch (UnsatisfiedLinkError e) {
+        } catch (final UnsatisfiedLinkError e) {
             thrown = e;
         } finally {
             INIT_OK = ok;
diff --git a/src/main/java/org/apache/commons/crypto/jna/OpenSslJna.java b/src/main/java/org/apache/commons/crypto/jna/OpenSslJna.java
index 061f864..04fedaf 100644
--- a/src/main/java/org/apache/commons/crypto/jna/OpenSslJna.java
+++ b/src/main/java/org/apache/commons/crypto/jna/OpenSslJna.java
@@ -60,7 +60,7 @@ public final class OpenSslJna {
      * @return A pointer to a constant string describing the version of the
      * OpenSSL library or giving information about the library build.
      */
-    static String OpenSSLVersion(int type) {
+    static String OpenSSLVersion(final int type) {
          return OpenSslNativeJna.OpenSSLVersion(type);
     }
 }
diff --git a/src/main/java/org/apache/commons/crypto/jna/OpenSslJnaCipher.java b/src/main/java/org/apache/commons/crypto/jna/OpenSslJnaCipher.java
index 4204745..0cea292 100644
--- a/src/main/java/org/apache/commons/crypto/jna/OpenSslJnaCipher.java
+++ b/src/main/java/org/apache/commons/crypto/jna/OpenSslJnaCipher.java
@@ -59,13 +59,13 @@ class OpenSslJnaCipher implements CryptoCipher {
      * @param transformation transformation for OpenSSL cipher
      * @throws GeneralSecurityException if OpenSSL cipher initialize failed
      */
-    public OpenSslJnaCipher(Properties props, String transformation) // NOPMD
+    public OpenSslJnaCipher(final Properties props, final String transformation) // NOPMD
             throws GeneralSecurityException {
         if (!OpenSslJna.isEnabled()) {
             throw new GeneralSecurityException("Could not enable JNA access", OpenSslJna.initialisationError());
         }
         this.transformation = transformation;
-        Transform transform = tokenizeTransformation(transformation);
+        final Transform transform = tokenizeTransformation(transformation);
         algMode = AlgorithmMode.get(transform.algorithm, transform.mode);
 
         if(algMode != AlgorithmMode.AES_CBC && algMode != AlgorithmMode.AES_CTR) {
@@ -87,7 +87,7 @@ class OpenSslJnaCipher implements CryptoCipher {
      * @throws InvalidAlgorithmParameterException if IV length is wrong
      */
     @Override
-    public void init(int mode, Key key, AlgorithmParameterSpec params)
+    public void init(final int mode, final Key key, final AlgorithmParameterSpec params)
             throws InvalidKeyException, InvalidAlgorithmParameterException {
         Objects.requireNonNull(key, "key");
         Objects.requireNonNull(params, "params");
@@ -123,7 +123,7 @@ class OpenSslJnaCipher implements CryptoCipher {
             }
         }
 
-        int retVal = OpenSslNativeJna.EVP_CipherInit_ex(context, algo, null, key.getEncoded(), iv, cipherMode);
+        final int retVal = OpenSslNativeJna.EVP_CipherInit_ex(context, algo, null, key.getEncoded(), iv, cipherMode);
         throwOnError(retVal);
         OpenSslNativeJna.EVP_CIPHER_CTX_set_padding(context, padding);
     }
@@ -139,12 +139,12 @@ class OpenSslJnaCipher implements CryptoCipher {
      *         buffer
      */
     @Override
-    public int update(ByteBuffer inBuffer, ByteBuffer outBuffer)
+    public int update(final ByteBuffer inBuffer, final ByteBuffer outBuffer)
             throws ShortBufferException {
-        int[] outlen = new int[1];
-        int retVal = OpenSslNativeJna.EVP_CipherUpdate(context, outBuffer, outlen, inBuffer, inBuffer.remaining());
+        final int[] outlen = new int[1];
+        final int retVal = OpenSslNativeJna.EVP_CipherUpdate(context, outBuffer, outlen, inBuffer, inBuffer.remaining());
         throwOnError(retVal);
-        int len = outlen[0];
+        final int len = outlen[0];
         inBuffer.position(inBuffer.limit());
         outBuffer.position(outBuffer.position() + len);
         return len;
@@ -164,10 +164,10 @@ class OpenSslJnaCipher implements CryptoCipher {
      *         byte array
      */
     @Override
-    public int update(byte[] input, int inputOffset, int inputLen,
-            byte[] output, int outputOffset) throws ShortBufferException {
-        ByteBuffer outputBuf = ByteBuffer.wrap(output, outputOffset, output.length - outputOffset);
-        ByteBuffer inputBuf = ByteBuffer.wrap(input, inputOffset, inputLen);
+    public int update(final byte[] input, final int inputOffset, final int inputLen,
+            final byte[] output, final int outputOffset) throws ShortBufferException {
+        final ByteBuffer outputBuf = ByteBuffer.wrap(output, outputOffset, output.length - outputOffset);
+        final ByteBuffer inputBuf = ByteBuffer.wrap(input, inputOffset, inputLen);
         return update(inputBuf, outputBuf);
     }
     /**
@@ -190,14 +190,14 @@ class OpenSslJnaCipher implements CryptoCipher {
      *         hold the result
      */
     @Override
-    public int doFinal(ByteBuffer inBuffer, ByteBuffer outBuffer)
+    public int doFinal(final ByteBuffer inBuffer, final ByteBuffer outBuffer)
             throws ShortBufferException, IllegalBlockSizeException,
             BadPaddingException {
-        int uptLen = update(inBuffer, outBuffer);
-        int[] outlen = new int[1];
-        int retVal = OpenSslNativeJna.EVP_CipherFinal_ex(context, outBuffer, outlen);
+        final int uptLen = update(inBuffer, outBuffer);
+        final int[] outlen = new int[1];
+        final int retVal = OpenSslNativeJna.EVP_CipherFinal_ex(context, outBuffer, outlen);
         throwOnError(retVal);
-        int len = uptLen + outlen[0];
+        final int len = uptLen + outlen[0];
         outBuffer.position(outBuffer.position() + outlen[0]);
         return len;
     }
@@ -224,11 +224,11 @@ class OpenSslJnaCipher implements CryptoCipher {
      *         to process the input data provided.
      */
     @Override
-    public int doFinal(byte[] input, int inputOffset, int inputLen,
-            byte[] output, int outputOffset) throws ShortBufferException,
+    public int doFinal(final byte[] input, final int inputOffset, final int inputLen,
+            final byte[] output, final int outputOffset) throws ShortBufferException,
             IllegalBlockSizeException, BadPaddingException {
-        ByteBuffer outputBuf = ByteBuffer.wrap(output, outputOffset, output.length-outputOffset);
-        ByteBuffer inputBuf = ByteBuffer.wrap(input, inputOffset, inputLen);
+        final ByteBuffer outputBuf = ByteBuffer.wrap(output, outputOffset, output.length-outputOffset);
+        final ByteBuffer inputBuf = ByteBuffer.wrap(input, inputOffset, inputLen);
         return doFinal(inputBuf, outputBuf);
     }
 
@@ -257,7 +257,7 @@ class OpenSslJnaCipher implements CryptoCipher {
      * doesn't support this operation.
      */
     @Override
-    public void updateAAD(byte[] aad) throws IllegalArgumentException,
+    public void updateAAD(final byte[] aad) throws IllegalArgumentException,
             IllegalStateException, UnsupportedOperationException {
         //TODO: implement GCM mode using Jna
         throw new UnsupportedOperationException("This is unsupported in Jna Cipher");
@@ -286,7 +286,7 @@ class OpenSslJnaCipher implements CryptoCipher {
      * doesn't support this operation.
      */
     @Override
-    public void updateAAD(ByteBuffer aad) throws IllegalArgumentException,
+    public void updateAAD(final ByteBuffer aad) throws IllegalArgumentException,
             IllegalStateException, UnsupportedOperationException {
         //TODO: implement GCM mode using Jna
         throw new UnsupportedOperationException("This is unsupported in Jna Cipher");
@@ -311,10 +311,10 @@ class OpenSslJnaCipher implements CryptoCipher {
     /**
      * @param retVal the result value of error.
      */
-    private void throwOnError(int retVal) {
+    private void throwOnError(final int retVal) {
         if (retVal != 1) {
-            NativeLong err = OpenSslNativeJna.ERR_peek_error();
-            String errdesc = OpenSslNativeJna.ERR_error_string(err, null);
+            final NativeLong err = OpenSslNativeJna.ERR_peek_error();
+            final String errdesc = OpenSslNativeJna.ERR_error_string(err, null);
 
             if (context != null) {
                 OpenSslNativeJna.EVP_CIPHER_CTX_cleanup(context);
@@ -336,7 +336,7 @@ class OpenSslJnaCipher implements CryptoCipher {
          * @param mode the mode name
          * @param padding the padding name
          */
-        public Transform(String algorithm, String mode, String padding) {
+        public Transform(final String algorithm, final String mode, final String padding) {
             this.algorithm = algorithm;
             this.mode = mode;
             this.padding = padding;
@@ -349,7 +349,7 @@ class OpenSslJnaCipher implements CryptoCipher {
      * @return the Transform
      * @throws NoSuchAlgorithmException if the algorithm is not supported
      */
-    private static Transform tokenizeTransformation(String transformation)
+    private static Transform tokenizeTransformation(final String transformation)
             throws NoSuchAlgorithmException {
         if (transformation == null) {
             throw new NoSuchAlgorithmException("No transformation given.");
@@ -360,9 +360,9 @@ class OpenSslJnaCipher implements CryptoCipher {
          * algorithm (e.g., AES) index 1: mode (e.g., CTR) index 2: padding
          * (e.g., NoPadding)
          */
-        String[] parts = new String[3];
+        final String[] parts = new String[3];
         int count = 0;
-        StringTokenizer parser = new StringTokenizer(transformation, "/");
+        final StringTokenizer parser = new StringTokenizer(transformation, "/");
         while (parser.hasMoreTokens() && count < 3) {
             parts[count++] = parser.nextToken().trim();
         }
@@ -386,10 +386,10 @@ class OpenSslJnaCipher implements CryptoCipher {
          * @return the AlgorithmMode instance
          * @throws NoSuchAlgorithmException if the algorithm is not support
          */
-        static AlgorithmMode get(String algorithm, String mode) throws NoSuchAlgorithmException {
+        static AlgorithmMode get(final String algorithm, final String mode) throws NoSuchAlgorithmException {
             try {
                 return AlgorithmMode.valueOf(algorithm + "_" + mode);
-            } catch (Exception e) {
+            } catch (final Exception e) {
                 throw new NoSuchAlgorithmException("Doesn't support algorithm: " + algorithm + " and mode: " + mode);
             }
         }
@@ -408,10 +408,10 @@ class OpenSslJnaCipher implements CryptoCipher {
          * @return the AlgorithmMode instance
          * @throws NoSuchPaddingException if the algorithm is not support
          */
-        static int get(String padding) throws NoSuchPaddingException {
+        static int get(final String padding) throws NoSuchPaddingException {
             try {
                 return Padding.valueOf(padding).ordinal();
-            } catch (Exception e) {
+            } catch (final Exception e) {
                 throw new NoSuchPaddingException("Doesn't support padding: " + padding);
             }
         }
diff --git a/src/main/java/org/apache/commons/crypto/jna/OpenSslJnaCryptoRandom.java b/src/main/java/org/apache/commons/crypto/jna/OpenSslJnaCryptoRandom.java
index 117d5dc..483cb51 100644
--- a/src/main/java/org/apache/commons/crypto/jna/OpenSslJnaCryptoRandom.java
+++ b/src/main/java/org/apache/commons/crypto/jna/OpenSslJnaCryptoRandom.java
@@ -57,7 +57,7 @@ class OpenSslJnaCryptoRandom extends Random implements CryptoRandom {
      * @param props the configuration properties (not used)
      * @throws GeneralSecurityException  if could not enable JNA access
      */
-    public OpenSslJnaCryptoRandom(Properties props) //NOPMD
+    public OpenSslJnaCryptoRandom(final Properties props) //NOPMD
             throws GeneralSecurityException {
         if (!OpenSslJna.isEnabled()) {
             throw new GeneralSecurityException("Could not enable JNA access", OpenSslJna.initialisationError());
@@ -67,19 +67,19 @@ class OpenSslJnaCryptoRandom extends Random implements CryptoRandom {
         try {
             OpenSslNativeJna.ENGINE_load_rdrand();
             rdrandEngine = OpenSslNativeJna.ENGINE_by_id("rdrand");
-            int ENGINE_METHOD_RAND = 0x0008;
+            final int ENGINE_METHOD_RAND = 0x0008;
             if(rdrandEngine != null) {
-                int rc = OpenSslNativeJna.ENGINE_init(rdrandEngine);
+                final int rc = OpenSslNativeJna.ENGINE_init(rdrandEngine);
 
                 if(rc != 0) {
-                    int rc2 = OpenSslNativeJna.ENGINE_set_default(rdrandEngine, ENGINE_METHOD_RAND);
+                    final int rc2 = OpenSslNativeJna.ENGINE_set_default(rdrandEngine, ENGINE_METHOD_RAND);
                     if(rc2 != 0) {
                         rdrandLoaded = true;
                     }
                 }
             }
 
-        } catch (Exception e) {
+        } catch (final Exception e) {
             throw new NoSuchAlgorithmException();
         }
 
@@ -96,7 +96,7 @@ class OpenSslJnaCryptoRandom extends Random implements CryptoRandom {
      * @param bytes the array to be filled in with random bytes.
      */
     @Override
-    public void nextBytes(byte[] bytes) {
+    public void nextBytes(final byte[] bytes) {
 
         synchronized (OpenSslJnaCryptoRandom.class) {
             //this method is synchronized for now
@@ -107,8 +107,8 @@ class OpenSslJnaCryptoRandom extends Random implements CryptoRandom {
                 throw new RuntimeException("rdrand should be used but default is detected");
             }
 
-            ByteBuffer buf = ByteBuffer.allocateDirect(bytes.length);
-            int retVal = OpenSslNativeJna.RAND_bytes(buf, bytes.length);
+            final ByteBuffer buf = ByteBuffer.allocateDirect(bytes.length);
+            final int retVal = OpenSslNativeJna.RAND_bytes(buf, bytes.length);
             throwOnError(retVal);
             buf.rewind();
             buf.get(bytes,0, bytes.length);
@@ -122,7 +122,7 @@ class OpenSslJnaCryptoRandom extends Random implements CryptoRandom {
      * @param seed the initial seed.
      */
     @Override
-    public void setSeed(long seed) {
+    public void setSeed(final long seed) {
         // Self-seeding.
     }
 
@@ -137,10 +137,10 @@ class OpenSslJnaCryptoRandom extends Random implements CryptoRandom {
      *         random bits (right justified, with leading zeros).
      */
     @Override
-    final protected int next(int numBits) {
+    final protected int next(final int numBits) {
         Utils.checkArgument(numBits >= 0 && numBits <= 32);
-        int numBytes = (numBits + 7) / 8;
-        byte b[] = new byte[numBytes];
+        final int numBytes = (numBits + 7) / 8;
+        final byte b[] = new byte[numBytes];
         int next = 0;
 
         nextBytes(b);
@@ -188,10 +188,10 @@ class OpenSslJnaCryptoRandom extends Random implements CryptoRandom {
     /**
      * @param retVal the result value of error.
      */
-    private void throwOnError(int retVal) {
+    private void throwOnError(final int retVal) {
         if (retVal != 1) {
-            NativeLong err = OpenSslNativeJna.ERR_peek_error();
-            String errdesc = OpenSslNativeJna.ERR_error_string(err, null);
+            final NativeLong err = OpenSslNativeJna.ERR_peek_error();
+            final String errdesc = OpenSslNativeJna.ERR_error_string(err, null);
             close();
             throw new RuntimeException("return code " + retVal + " from OpenSSL. Err code is " + err + ": " + errdesc);
         }
diff --git a/src/main/java/org/apache/commons/crypto/jna/OpenSslNativeJna.java b/src/main/java/org/apache/commons/crypto/jna/OpenSslNativeJna.java
index 26507d7..4680580 100644
--- a/src/main/java/org/apache/commons/crypto/jna/OpenSslNativeJna.java
+++ b/src/main/java/org/apache/commons/crypto/jna/OpenSslNativeJna.java
@@ -41,11 +41,11 @@ class OpenSslNativeJna {
     public static final long VERSION_1_1_X = 0x10100000;
 
     static {
-        NativeLibrary crypto = NativeLibrary.getInstance("crypto");
+        final NativeLibrary crypto = NativeLibrary.getInstance("crypto");
         Function version = null;
         try {
             version = crypto.getFunction("SSLeay");
-        } catch (UnsatisfiedLinkError e) {
+        } catch (final UnsatisfiedLinkError e) {
             // Swallow the Error.
         }
 
@@ -70,7 +70,7 @@ class OpenSslNativeJna {
         }
     }
 
-    public static PointerByReference ENGINE_by_id(String string) {
+    public static PointerByReference ENGINE_by_id(final String string) {
         if (VERSION == VERSION_1_1_X) {
             return OpenSsl11XNativeJna.ENGINE_by_id(string);
         } else {
@@ -78,7 +78,7 @@ class OpenSslNativeJna {
         }
     }
 
-    public static void ENGINE_finish(PointerByReference rdrandEngine) {
+    public static void ENGINE_finish(final PointerByReference rdrandEngine) {
         if (VERSION == VERSION_1_1_X) {
             OpenSsl11XNativeJna.ENGINE_finish(rdrandEngine);
         } else {
@@ -86,7 +86,7 @@ class OpenSslNativeJna {
         }
     }
 
-    public static void ENGINE_free(PointerByReference rdrandEngine) {
+    public static void ENGINE_free(final PointerByReference rdrandEngine) {
         if (VERSION == VERSION_1_1_X) {
             OpenSsl11XNativeJna.ENGINE_free(rdrandEngine);
         } else {
@@ -94,7 +94,7 @@ class OpenSslNativeJna {
         }
     }
 
-    public static int ENGINE_init(PointerByReference rdrandEngine) {
+    public static int ENGINE_init(final PointerByReference rdrandEngine) {
         if (VERSION == VERSION_1_1_X) {
             return OpenSsl11XNativeJna.ENGINE_init(rdrandEngine);
         } else {
@@ -102,7 +102,7 @@ class OpenSslNativeJna {
         }
     }
 
-    public static int ENGINE_set_default(PointerByReference rdrandEngine, int eNGINE_METHOD_RAND) {
+    public static int ENGINE_set_default(final PointerByReference rdrandEngine, final int eNGINE_METHOD_RAND) {
         if (VERSION == VERSION_1_1_X) {
             return OpenSsl11XNativeJna.ENGINE_set_default(rdrandEngine, eNGINE_METHOD_RAND);
         } else {
@@ -110,7 +110,7 @@ class OpenSslNativeJna {
         }
     }
 
-    public static String ERR_error_string(NativeLong err, Object object) {
+    public static String ERR_error_string(final NativeLong err, final Object object) {
         if (VERSION == VERSION_1_1_X) {
             return OpenSsl11XNativeJna.ERR_error_string(err, null);
         } else {
@@ -174,7 +174,7 @@ class OpenSslNativeJna {
         }
     }
 
-    public static void EVP_CIPHER_CTX_free(PointerByReference context) {
+    public static void EVP_CIPHER_CTX_free(final PointerByReference context) {
         if (VERSION == VERSION_1_1_X) {
             OpenSsl11XNativeJna.EVP_CIPHER_CTX_free(context);
         } else {
@@ -190,7 +190,7 @@ class OpenSslNativeJna {
         }
     }
 
-    public static void EVP_CIPHER_CTX_set_padding(PointerByReference context, int padding) {
+    public static void EVP_CIPHER_CTX_set_padding(final PointerByReference context, final int padding) {
         if (VERSION == VERSION_1_1_X) {
             OpenSsl11XNativeJna.EVP_CIPHER_CTX_set_padding(context, padding);
         } else {
@@ -198,8 +198,8 @@ class OpenSslNativeJna {
         }
     }
 
-    public static int EVP_CipherFinal_ex(PointerByReference context, ByteBuffer outBuffer,
-            int[] outlen) {
+    public static int EVP_CipherFinal_ex(final PointerByReference context, final ByteBuffer outBuffer,
+            final int[] outlen) {
         if (VERSION == VERSION_1_1_X) {
             return OpenSsl11XNativeJna.EVP_CipherFinal_ex(context, outBuffer, outlen);
         } else {
@@ -207,8 +207,8 @@ class OpenSslNativeJna {
         }
     }
 
-    public static int EVP_CipherInit_ex(PointerByReference context, PointerByReference algo,
-            Object object, byte[] encoded, byte[] iv, int cipherMode) {
+    public static int EVP_CipherInit_ex(final PointerByReference context, final PointerByReference algo,
+            final Object object, final byte[] encoded, final byte[] iv, final int cipherMode) {
         if (VERSION == VERSION_1_1_X) {
             return OpenSsl11XNativeJna.EVP_CipherInit_ex(context, algo, null, encoded, iv,
                     cipherMode);
@@ -218,8 +218,8 @@ class OpenSslNativeJna {
         }
     }
 
-    public static int EVP_CipherUpdate(PointerByReference context, ByteBuffer outBuffer,
-            int[] outlen, ByteBuffer inBuffer, int remaining) {
+    public static int EVP_CipherUpdate(final PointerByReference context, final ByteBuffer outBuffer,
+            final int[] outlen, final ByteBuffer inBuffer, final int remaining) {
         if (VERSION == VERSION_1_1_X) {
             return OpenSsl11XNativeJna.EVP_CipherUpdate(context, outBuffer, outlen, inBuffer,
                     remaining);
@@ -229,7 +229,7 @@ class OpenSslNativeJna {
         }
     }
 
-    public static int RAND_bytes(ByteBuffer buf, int length) {
+    public static int RAND_bytes(final ByteBuffer buf, final int length) {
         if (VERSION == VERSION_1_1_X) {
             return OpenSsl11XNativeJna.RAND_bytes(buf, length);
         } else {
@@ -253,7 +253,7 @@ class OpenSslNativeJna {
         }
     }
 
-    public static String OpenSSLVersion(int i) {
+    public static String OpenSSLVersion(final int i) {
         if (VERSION == VERSION_1_1_X) {
             return OpenSsl11XNativeJna.OpenSSL_version(i);
         } else {
@@ -277,7 +277,7 @@ class OpenSslNativeJna {
         }
     }
 
-    public static void EVP_CIPHER_CTX_cleanup(PointerByReference context) {
+    public static void EVP_CIPHER_CTX_cleanup(final PointerByReference context) {
         if (VERSION == VERSION_1_1_X) {
             return;
         } else {
diff --git a/src/main/java/org/apache/commons/crypto/random/CryptoRandomFactory.java b/src/main/java/org/apache/commons/crypto/random/CryptoRandomFactory.java
index 5e814ac..4b13755 100644
--- a/src/main/java/org/apache/commons/crypto/random/CryptoRandomFactory.java
+++ b/src/main/java/org/apache/commons/crypto/random/CryptoRandomFactory.java
@@ -120,7 +120,7 @@ public class CryptoRandomFactory {
          * The private constructor.
          * @param klass the Class of CryptoRandom
          */
-        private RandomProvider(Class<? extends CryptoRandom> klass) {
+        private RandomProvider(final Class<? extends CryptoRandom> klass) {
             this.klass = klass;
             this.className = klass.getName();
         }
@@ -166,7 +166,7 @@ public class CryptoRandomFactory {
      * @throws GeneralSecurityException if cannot create the {@link CryptoRandom} class
      */
     public static CryptoRandom getCryptoRandom() throws GeneralSecurityException {
-        Properties properties = new Properties();
+        final Properties properties = new Properties();
         return getCryptoRandom(properties);
     }
 
@@ -183,29 +183,29 @@ public class CryptoRandomFactory {
      * @throws GeneralSecurityException if cannot create the {@link CryptoRandom} class
      * @throws IllegalArgumentException if no classname(s) are provided
      */
-    public static CryptoRandom getCryptoRandom(Properties props)
+    public static CryptoRandom getCryptoRandom(final Properties props)
             throws GeneralSecurityException {
         final List<String> names = Utils.splitClassNames(getRandomClassString(props), ",");
         if (names.size() == 0) {
             throw new IllegalArgumentException("No classname(s) provided");
         }
-        StringBuilder errorMessage = new StringBuilder();
+        final StringBuilder errorMessage = new StringBuilder();
         CryptoRandom random = null;
         Exception lastException = null;
-        for (String klassName : names) {
+        for (final String klassName : names) {
             try {
                 final Class<?> klass = ReflectionUtils.getClassByName(klassName);
                 random = (CryptoRandom) ReflectionUtils.newInstance(klass, props);
                 if (random != null) {
                     break;
                 }
-            } catch (ClassCastException e) {
+            } catch (final ClassCastException e) {
                 lastException = e;
                 errorMessage.append("Class: [" + klassName + "] is not a CryptoRandom.");
-            } catch (ClassNotFoundException e) {
+            } catch (final ClassNotFoundException e) {
                 lastException = e;
                 errorMessage.append("CryptoRandom: [" + klassName + "] not found.");
-            } catch (Exception e) {
+            } catch (final Exception e) {
                 lastException = e;
                 errorMessage.append("CryptoRandom: [" + klassName + "] failed with " + e.getMessage());
             }
@@ -224,7 +224,7 @@ public class CryptoRandomFactory {
      *        properties.
      * @return the CryptoRandom class based on the props.
      */
-    private static String getRandomClassString(Properties props) {
+    private static String getRandomClassString(final Properties props) {
         String randomClassString = props.getProperty(CryptoRandomFactory.CLASSES_KEY, CLASSES_DEFAULT);
         if (randomClassString.isEmpty()) { // TODO does it make sense to treat the empty string as the default?
             randomClassString = CLASSES_DEFAULT;
diff --git a/src/main/java/org/apache/commons/crypto/random/JavaCryptoRandom.java b/src/main/java/org/apache/commons/crypto/random/JavaCryptoRandom.java
index 1921bdb..b4e0844 100644
--- a/src/main/java/org/apache/commons/crypto/random/JavaCryptoRandom.java
+++ b/src/main/java/org/apache/commons/crypto/random/JavaCryptoRandom.java
@@ -41,14 +41,14 @@ class JavaCryptoRandom extends Random implements CryptoRandom {
      */
     // N.B. this class is not public/protected so does not appear in the main Javadoc
     // Please ensure that property use is documented in the enum CryptoRandomFactory.RandomProvider
-    public JavaCryptoRandom(Properties properties) {
+    public JavaCryptoRandom(final Properties properties) {
       try {
         instance = SecureRandom
                 .getInstance(properties
                         .getProperty(
                                 CryptoRandomFactory.JAVA_ALGORITHM_KEY,
                                 CryptoRandomFactory.JAVA_ALGORITHM_DEFAULT));
-      } catch (NoSuchAlgorithmException e) {
+      } catch (final NoSuchAlgorithmException e) {
         instance = new SecureRandom();
       }
     }
@@ -70,7 +70,7 @@ class JavaCryptoRandom extends Random implements CryptoRandom {
      * @param bytes the array to be filled in with random bytes.
      */
     @Override
-    public void nextBytes(byte[] bytes) {
+    public void nextBytes(final byte[] bytes) {
         instance.nextBytes(bytes);
     }
 }
diff --git a/src/main/java/org/apache/commons/crypto/random/OpenSslCryptoRandom.java b/src/main/java/org/apache/commons/crypto/random/OpenSslCryptoRandom.java
index 37cf79c..b59017c 100644
--- a/src/main/java/org/apache/commons/crypto/random/OpenSslCryptoRandom.java
+++ b/src/main/java/org/apache/commons/crypto/random/OpenSslCryptoRandom.java
@@ -55,9 +55,9 @@ class OpenSslCryptoRandom extends Random implements CryptoRandom {
             try {
                 OpenSslCryptoRandomNative.initSR();
                 opensslLoaded = true;
-            } catch (Exception t) {
+            } catch (final Exception t) {
                 except = t;
-            } catch (UnsatisfiedLinkError t) {
+            } catch (final UnsatisfiedLinkError t) {
                 except = t;
             }
         }
@@ -82,7 +82,7 @@ class OpenSslCryptoRandom extends Random implements CryptoRandom {
      */
     // N.B. this class is not public/protected so does not appear in the main Javadoc
     // Please ensure that property use is documented in the enum CryptoRandomFactory.RandomProvider
-    public OpenSslCryptoRandom(Properties props) throws GeneralSecurityException { // NOPMD
+    public OpenSslCryptoRandom(final Properties props) throws GeneralSecurityException { // NOPMD
         if (!nativeEnabled) {
             if (initException != null) {
                 throw new GeneralSecurityException("Native library could not be initialised", initException);
@@ -101,7 +101,7 @@ class OpenSslCryptoRandom extends Random implements CryptoRandom {
      * @param bytes the array to be filled in with random bytes.
      */
     @Override
-    public void nextBytes(byte[] bytes) {
+    public void nextBytes(final byte[] bytes) {
         // Constructor ensures that native is enabled here
         if (!OpenSslCryptoRandomNative.nextRandBytes(bytes)) {
             // Assume it's a problem with the argument, rather than an internal issue
@@ -116,7 +116,7 @@ class OpenSslCryptoRandom extends Random implements CryptoRandom {
      * @param seed the initial seed.
      */
     @Override
-    public void setSeed(long seed) {
+    public void setSeed(final long seed) {
         // Self-seeding.
     }
 
@@ -131,10 +131,10 @@ class OpenSslCryptoRandom extends Random implements CryptoRandom {
      *         random bits (right justified, with leading zeros).
      */
     @Override
-    final protected int next(int numBits) {
+    final protected int next(final int numBits) {
         Utils.checkArgument(numBits >= 0 && numBits <= 32);
-        int numBytes = (numBits + 7) / 8;
-        byte b[] = new byte[numBytes];
+        final int numBytes = (numBits + 7) / 8;
+        final byte b[] = new byte[numBytes];
         int next = 0;
 
         nextBytes(b);
diff --git a/src/main/java/org/apache/commons/crypto/random/OsCryptoRandom.java b/src/main/java/org/apache/commons/crypto/random/OsCryptoRandom.java
index 1d40bd2..2ca0eef 100644
--- a/src/main/java/org/apache/commons/crypto/random/OsCryptoRandom.java
+++ b/src/main/java/org/apache/commons/crypto/random/OsCryptoRandom.java
@@ -46,11 +46,11 @@ class OsCryptoRandom extends Random implements CryptoRandom {
      *
      * @param min the length.
      */
-    private void fillReservoir(int min) {
+    private void fillReservoir(final int min) {
         if (pos >= reservoir.length - min) {
             try {
                 IoUtils.readFully(stream, reservoir, 0, reservoir.length);
-            } catch (IOException e) {
+            } catch (final IOException e) {
                 throw new RuntimeException("failed to fill reservoir", e);
             }
             pos = 0;
@@ -67,21 +67,21 @@ class OsCryptoRandom extends Random implements CryptoRandom {
      */
     // N.B. this class is not public/protected so does not appear in the main Javadoc
     // Please ensure that property use is documented in the enum CryptoRandomFactory.RandomProvider
-    public OsCryptoRandom(Properties props) {
-        File randomDevFile = new File(
+    public OsCryptoRandom(final Properties props) {
+        final File randomDevFile = new File(
                 props.getProperty(CryptoRandomFactory.DEVICE_FILE_PATH_KEY,
                                   CryptoRandomFactory.DEVICE_FILE_PATH_DEFAULT));
 
         try {
             close();
             this.stream = new FileInputStream(randomDevFile);
-        } catch (IOException e) {
+        } catch (final IOException e) {
             throw new RuntimeException(e);
         }
 
         try {
             fillReservoir(0);
-        } catch (RuntimeException e) {
+        } catch (final RuntimeException e) {
             close();
             throw e;
         }
@@ -95,7 +95,7 @@ class OsCryptoRandom extends Random implements CryptoRandom {
      * @param bytes the array to be filled in with random bytes.
      */
     @Override
-    synchronized public void nextBytes(byte[] bytes) {
+    synchronized public void nextBytes(final byte[] bytes) {
         int off = 0;
         int n = 0;
         while (off < bytes.length) {
@@ -116,7 +116,7 @@ class OsCryptoRandom extends Random implements CryptoRandom {
      *         sequence.
      */
     @Override
-    synchronized protected int next(int nbits) {
+    synchronized protected int next(final int nbits) {
         fillReservoir(4);
         int n = 0;
         for (int i = 0; i < 4; i++) {
diff --git a/src/main/java/org/apache/commons/crypto/stream/CryptoInputStream.java b/src/main/java/org/apache/commons/crypto/stream/CryptoInputStream.java
index dba3903..fe2951e 100644
--- a/src/main/java/org/apache/commons/crypto/stream/CryptoInputStream.java
+++ b/src/main/java/org/apache/commons/crypto/stream/CryptoInputStream.java
@@ -115,9 +115,9 @@ public class CryptoInputStream extends InputStream implements
      * @param params the algorithm parameters.
      * @throws IOException if an I/O error occurs.
      */
-    public CryptoInputStream(String transformation,
-            Properties props, InputStream in, Key key,
-            AlgorithmParameterSpec params) throws IOException {
+    public CryptoInputStream(final String transformation,
+            final Properties props, final InputStream in, final Key key,
+            final AlgorithmParameterSpec params) throws IOException {
         this(in, Utils.getCipherInstance(transformation, props),
                 CryptoInputStream.getBufferSize(props), key, params);
     }
@@ -136,9 +136,9 @@ public class CryptoInputStream extends InputStream implements
      * @param params the algorithm parameters.
      * @throws IOException if an I/O error occurs.
      */
-    public CryptoInputStream(String transformation,
-            Properties props, ReadableByteChannel in, Key key,
-            AlgorithmParameterSpec params) throws IOException {
+    public CryptoInputStream(final String transformation,
+            final Properties props, final ReadableByteChannel in, final Key key,
+            final AlgorithmParameterSpec params) throws IOException {
         this(in, Utils.getCipherInstance(transformation, props), CryptoInputStream
                 .getBufferSize(props), key, params);
     }
@@ -153,8 +153,8 @@ public class CryptoInputStream extends InputStream implements
      * @param params the algorithm parameters.
      * @throws IOException if an I/O error occurs.
      */
-    protected CryptoInputStream(InputStream in, CryptoCipher cipher,
-            int bufferSize, Key key, AlgorithmParameterSpec params)
+    protected CryptoInputStream(final InputStream in, final CryptoCipher cipher,
+            final int bufferSize, final Key key, final AlgorithmParameterSpec params)
             throws IOException {
         this(new StreamInput(in, bufferSize), cipher, bufferSize, key, params);
     }
@@ -169,8 +169,8 @@ public class CryptoInputStream extends InputStream implements
      * @param params the algorithm parameters.
      * @throws IOException if an I/O error occurs.
      */
-    protected CryptoInputStream(ReadableByteChannel in, CryptoCipher cipher,
-            int bufferSize, Key key, AlgorithmParameterSpec params)
+    protected CryptoInputStream(final ReadableByteChannel in, final CryptoCipher cipher,
+            final int bufferSize, final Key key, final AlgorithmParameterSpec params)
             throws IOException {
         this(new ChannelInput(in), cipher, bufferSize, key, params);
     }
@@ -185,8 +185,8 @@ public class CryptoInputStream extends InputStream implements
      * @param params the algorithm parameters.
      * @throws IOException if an I/O error occurs.
      */
-    protected CryptoInputStream(Input input, CryptoCipher cipher, int bufferSize,
-            Key key, AlgorithmParameterSpec params) throws IOException {
+    protected CryptoInputStream(final Input input, final CryptoCipher cipher, final int bufferSize,
+            final Key key, final AlgorithmParameterSpec params) throws IOException {
         this.input = input;
         this.cipher = cipher;
         this.bufferSize = CryptoInputStream.checkBufferSize(cipher, bufferSize);
@@ -238,7 +238,7 @@ public class CryptoInputStream extends InputStream implements
      * @throws IOException if an I/O error occurs.
      */
     @Override
-    public int read(byte[] array, int off, int len) throws IOException {
+    public int read(final byte[] array, final int off, final int len) throws IOException {
         checkStream();
         Objects.requireNonNull(array, "array");
         if (off < 0 || len < 0 || len > array.length - off) {
@@ -247,10 +247,10 @@ public class CryptoInputStream extends InputStream implements
             return 0;
         }
 
-        int remaining = outBuffer.remaining();
+        final int remaining = outBuffer.remaining();
         if (remaining > 0) {
             // Satisfy the read with the existing data
-            int n = Math.min(len, remaining);
+            final int n = Math.min(len, remaining);
             outBuffer.get(array, off, n);
             return n;
         }
@@ -264,7 +264,7 @@ public class CryptoInputStream extends InputStream implements
             return nd;
         }
 
-        int n = Math.min(len, outBuffer.remaining());
+        final int n = Math.min(len, outBuffer.remaining());
         outBuffer.get(array, off, n);
         return n;
     }
@@ -278,7 +278,7 @@ public class CryptoInputStream extends InputStream implements
      * @throws IOException if an I/O error occurs.
      */
     @Override
-    public long skip(long n) throws IOException {
+    public long skip(final long n) throws IOException {
         Utils.checkArgument(n >= 0, "Negative skip length.");
         checkStream();
 
@@ -292,7 +292,7 @@ public class CryptoInputStream extends InputStream implements
         while (remaining > 0) {
             if (remaining <= outBuffer.remaining()) {
                 // Skip in the remaining buffer
-                int pos = outBuffer.position() + (int) remaining;
+                final int pos = outBuffer.position() + (int) remaining;
                 outBuffer.position(pos);
 
                 remaining = 0;
@@ -359,7 +359,7 @@ public class CryptoInputStream extends InputStream implements
      *        mark position becomes invalid.
      */
     @Override
-    public void mark(int readlimit) {
+    public void mark(final int readlimit) {
     }
 
     /**
@@ -405,7 +405,7 @@ public class CryptoInputStream extends InputStream implements
      * @throws IOException if an I/O error occurs.
      */
     @Override
-    public int read(ByteBuffer dst) throws IOException {
+    public int read(final ByteBuffer dst) throws IOException {
         checkStream();
         int remaining = outBuffer.remaining();
         if (remaining <= 0) {
@@ -488,9 +488,9 @@ public class CryptoInputStream extends InputStream implements
     protected void initCipher() throws IOException {
         try {
             cipher.init(Cipher.DECRYPT_MODE, key, params);
-        } catch (InvalidKeyException e) {
+        } catch (final InvalidKeyException e) {
             throw new IOException(e);
-        } catch (InvalidAlgorithmParameterException e) {
+        } catch (final InvalidAlgorithmParameterException e) {
             throw new IOException(e);
         }
     }
@@ -510,13 +510,13 @@ public class CryptoInputStream extends InputStream implements
             return -1;
         }
 
-        int n = input.read(inBuffer);
+        final int n = input.read(inBuffer);
         if (n < 0) {
             // The stream is end, finalize the cipher stream
             decryptFinal();
 
             // Satisfy the read with the remaining
-            int remaining = outBuffer.remaining();
+            final int remaining = outBuffer.remaining();
             if (remaining > 0) {
                 return remaining;
             }
@@ -546,7 +546,7 @@ public class CryptoInputStream extends InputStream implements
 
         try {
             cipher.update(inBuffer, outBuffer);
-        } catch (ShortBufferException e) {
+        } catch (final ShortBufferException e) {
             throw new IOException(e);
         }
 
@@ -568,11 +568,11 @@ public class CryptoInputStream extends InputStream implements
         try {
             cipher.doFinal(inBuffer, outBuffer);
             finalDone = true;
-        } catch (ShortBufferException e) {
+        } catch (final ShortBufferException e) {
             throw new IOException(e);
-        } catch (IllegalBlockSizeException e) {
+        } catch (final IllegalBlockSizeException e) {
             throw new IOException(e);
-        } catch (BadPaddingException e) {
+        } catch (final BadPaddingException e) {
             throw new IOException(e);
         }
 
@@ -603,26 +603,26 @@ public class CryptoInputStream extends InputStream implements
      *
      * @param buffer the bytebuffer to be freed.
      */
-    static void freeDirectBuffer(ByteBuffer buffer) {
+    static void freeDirectBuffer(final ByteBuffer buffer) {
         try {
             /* Using reflection to implement sun.nio.ch.DirectBuffer.cleaner()
             .clean(); */
             final String SUN_CLASS = "sun.nio.ch.DirectBuffer";
-            Class<?>[] interfaces = buffer.getClass().getInterfaces();
+            final Class<?>[] interfaces = buffer.getClass().getInterfaces();
 
-            for (Class<?> clazz : interfaces) {
+            for (final Class<?> clazz : interfaces) {
                 if (clazz.getName().equals(SUN_CLASS)) {
                     final Object[] NO_PARAM = new Object[0];
                     /* DirectBuffer#cleaner() */
-                    Method getCleaner = Class.forName(SUN_CLASS).getMethod("cleaner");
-                    Object cleaner = getCleaner.invoke(buffer, NO_PARAM);
+                    final Method getCleaner = Class.forName(SUN_CLASS).getMethod("cleaner");
+                    final Object cleaner = getCleaner.invoke(buffer, NO_PARAM);
                     /* Cleaner#clean() */
-                    Method cleanMethod = Class.forName("sun.misc.Cleaner").getMethod("clean");
+                    final Method cleanMethod = Class.forName("sun.misc.Cleaner").getMethod("clean");
                     cleanMethod.invoke(cleaner, NO_PARAM);
                     return;
                 }
             }
-        } catch (ReflectiveOperationException e) { // NOPMD
+        } catch (final ReflectiveOperationException e) { // NOPMD
             // Ignore the Reflection exception.
         }
     }
@@ -634,8 +634,8 @@ public class CryptoInputStream extends InputStream implements
      *        properties.
      * @return the buffer size.
      * */
-    static int getBufferSize(Properties props) {
-        String bufferSizeStr = props.getProperty(CryptoInputStream.STREAM_BUFFER_SIZE_KEY);
+    static int getBufferSize(final Properties props) {
+        final String bufferSizeStr = props.getProperty(CryptoInputStream.STREAM_BUFFER_SIZE_KEY);
         if (bufferSizeStr == null || bufferSizeStr.isEmpty()) {
             return CryptoInputStream.STREAM_BUFFER_SIZE_DEFAULT;
         }
@@ -648,7 +648,7 @@ public class CryptoInputStream extends InputStream implements
      * @param cipher the {@link CryptoCipher} instance.
      * @throws IOException if an I/O error occurs.
      */
-    static void checkStreamCipher(CryptoCipher cipher)
+    static void checkStreamCipher(final CryptoCipher cipher)
             throws IOException {
         if (!cipher.getAlgorithm().equals("AES/CTR/NoPadding")) {
             throw new IOException("AES/CTR/NoPadding is required");
@@ -662,7 +662,7 @@ public class CryptoInputStream extends InputStream implements
      * @param bufferSize the buffer size.
      * @return the remaining buffer size.
      */
-    static int checkBufferSize(CryptoCipher cipher, int bufferSize) {
+    static int checkBufferSize(final CryptoCipher cipher, final int bufferSize) {
         Utils.checkArgument(bufferSize >= CryptoInputStream.MIN_BUFFER_SIZE,
                 "Minimum value of buffer size is " + CryptoInputStream.MIN_BUFFER_SIZE + ".");
         return bufferSize - bufferSize
diff --git a/src/main/java/org/apache/commons/crypto/stream/CryptoOutputStream.java b/src/main/java/org/apache/commons/crypto/stream/CryptoOutputStream.java
index 273637c..47c2207 100644
--- a/src/main/java/org/apache/commons/crypto/stream/CryptoOutputStream.java
+++ b/src/main/java/org/apache/commons/crypto/stream/CryptoOutputStream.java
@@ -99,9 +99,9 @@ public class CryptoOutputStream extends OutputStream implements
      * @throws IOException if an I/O error occurs.
      */
 
-    public CryptoOutputStream(String transformation,
-            Properties props, OutputStream out, Key key,
-            AlgorithmParameterSpec params) throws IOException {
+    public CryptoOutputStream(final String transformation,
+            final Properties props, final OutputStream out, final Key key,
+            final AlgorithmParameterSpec params) throws IOException {
         this(out, Utils.getCipherInstance(transformation, props),
                 CryptoInputStream.getBufferSize(props), key, params);
 
@@ -121,9 +121,9 @@ public class CryptoOutputStream extends OutputStream implements
      * @param params the algorithm parameters.
      * @throws IOException if an I/O error occurs.
      */
-    public CryptoOutputStream(String transformation,
-            Properties props, WritableByteChannel out, Key key,
-            AlgorithmParameterSpec params) throws IOException {
+    public CryptoOutputStream(final String transformation,
+            final Properties props, final WritableByteChannel out, final Key key,
+            final AlgorithmParameterSpec params) throws IOException {
         this(out, Utils.getCipherInstance(transformation, props), CryptoInputStream
                 .getBufferSize(props), key, params);
 
@@ -139,8 +139,8 @@ public class CryptoOutputStream extends OutputStream implements
      * @param params the algorithm parameters.
      * @throws IOException if an I/O error occurs.
      */
-    protected CryptoOutputStream(OutputStream out, CryptoCipher cipher,
-            int bufferSize, Key key, AlgorithmParameterSpec params)
+    protected CryptoOutputStream(final OutputStream out, final CryptoCipher cipher,
+            final int bufferSize, final Key key, final AlgorithmParameterSpec params)
             throws IOException {
         this(new StreamOutput(out, bufferSize), cipher, bufferSize, key, params);
     }
@@ -155,8 +155,8 @@ public class CryptoOutputStream extends OutputStream implements
      * @param params the algorithm parameters.
      * @throws IOException if an I/O error occurs.
      */
-    protected CryptoOutputStream(WritableByteChannel channel, CryptoCipher cipher,
-            int bufferSize, Key key, AlgorithmParameterSpec params)
+    protected CryptoOutputStream(final WritableByteChannel channel, final CryptoCipher cipher,
+            final int bufferSize, final Key key, final AlgorithmParameterSpec params)
             throws IOException {
         this(new ChannelOutput(channel), cipher, bufferSize, key, params);
     }
@@ -171,8 +171,8 @@ public class CryptoOutputStream extends OutputStream implements
      * @param params the algorithm parameters.
      * @throws IOException if an I/O error occurs.
      */
-    protected CryptoOutputStream(Output output, CryptoCipher cipher,
-            int bufferSize, Key key, AlgorithmParameterSpec params)
+    protected CryptoOutputStream(final Output output, final CryptoCipher cipher,
+            final int bufferSize, final Key key, final AlgorithmParameterSpec params)
             throws IOException {
 
         this.output = output;
@@ -203,7 +203,7 @@ public class CryptoOutputStream extends OutputStream implements
      * @throws IOException if an I/O error occurs.
      */
     @Override
-    public void write(int b) throws IOException {
+    public void write(final int b) throws IOException {
         oneByteBuf[0] = (byte) (b & 0xff);
         write(oneByteBuf, 0, oneByteBuf.length);
     }
@@ -220,7 +220,7 @@ public class CryptoOutputStream extends OutputStream implements
      * @throws IOException if an I/O error occurs.
      */
     @Override
-    public void write(byte[] array, int off, int len) throws IOException {
+    public void write(final byte[] array, int off, int len) throws IOException {
         checkStream();
         Objects.requireNonNull(array, "array");
         if (off < 0 || len < 0 || off > array.length || len > array.length - off) {
@@ -300,7 +300,7 @@ public class CryptoOutputStream extends OutputStream implements
      * @throws IOException if an I/O error occurs.
      */
     @Override
-    public int write(ByteBuffer src) throws IOException {
+    public int write(final ByteBuffer src) throws IOException {
         checkStream();
         final int len = src.remaining();
         int remaining = len;
@@ -336,9 +336,9 @@ public class CryptoOutputStream extends OutputStream implements
     protected void initCipher() throws IOException {
         try {
             cipher.init(Cipher.ENCRYPT_MODE, key, params);
-        } catch (InvalidKeyException e) {
+        } catch (final InvalidKeyException e) {
             throw new IOException(e);
-        } catch (InvalidAlgorithmParameterException e) {
+        } catch (final InvalidAlgorithmParameterException e) {
             throw new IOException(e);
         }
     }
@@ -356,7 +356,7 @@ public class CryptoOutputStream extends OutputStream implements
 
         try {
             cipher.update(inBuffer, outBuffer);
-        } catch (ShortBufferException e) {
+        } catch (final ShortBufferException e) {
             throw new IOException(e);
         }
 
@@ -380,11 +380,11 @@ public class CryptoOutputStream extends OutputStream implements
 
         try {
             cipher.doFinal(inBuffer, outBuffer);
-        } catch (ShortBufferException e) {
+        } catch (final ShortBufferException e) {
             throw new IOException(e);
-        } catch (IllegalBlockSizeException e) {
+        } catch (final IllegalBlockSizeException e) {
             throw new IOException(e);
-        } catch (BadPaddingException e) {
+        } catch (final BadPaddingException e) {
             throw new IOException(e);
         }
 
diff --git a/src/main/java/org/apache/commons/crypto/stream/CtrCryptoInputStream.java b/src/main/java/org/apache/commons/crypto/stream/CtrCryptoInputStream.java
index ce40c23..5b1f4ba 100644
--- a/src/main/java/org/apache/commons/crypto/stream/CtrCryptoInputStream.java
+++ b/src/main/java/org/apache/commons/crypto/stream/CtrCryptoInputStream.java
@@ -66,7 +66,7 @@ public class CtrCryptoInputStream extends CryptoInputStream {
     /**
      * Initialization vector for the cipher.
      */
-    private byte[] iv;
+    private final byte[] iv;
 
     /**
      * Padding = pos%(algorithm blocksize); Padding is put into
@@ -90,8 +90,8 @@ public class CtrCryptoInputStream extends CryptoInputStream {
      * @param iv Initialization vector for the cipher.
      * @throws IOException if an I/O error occurs.
      */
-    public CtrCryptoInputStream(Properties props, InputStream in, byte[] key,
-            byte[] iv) throws IOException {
+    public CtrCryptoInputStream(final Properties props, final InputStream in, final byte[] key,
+            final byte[] iv) throws IOException {
         this(props, in, key, iv, 0);
     }
 
@@ -105,8 +105,8 @@ public class CtrCryptoInputStream extends CryptoInputStream {
      * @param iv Initialization vector for the cipher.
      * @throws IOException if an I/O error occurs.
      */
-    public CtrCryptoInputStream(Properties props, ReadableByteChannel in,
-            byte[] key, byte[] iv) throws IOException {
+    public CtrCryptoInputStream(final Properties props, final ReadableByteChannel in,
+            final byte[] key, final byte[] iv) throws IOException {
         this(props, in, key, iv, 0);
     }
 
@@ -120,8 +120,8 @@ public class CtrCryptoInputStream extends CryptoInputStream {
      * @param iv Initialization vector for the cipher.
      * @throws IOException if an I/O error occurs.
      */
-    protected CtrCryptoInputStream(InputStream in, CryptoCipher cipher,
-            int bufferSize, byte[] key, byte[] iv) throws IOException {
+    protected CtrCryptoInputStream(final InputStream in, final CryptoCipher cipher,
+            final int bufferSize, final byte[] key, final byte[] iv) throws IOException {
         this(in, cipher, bufferSize, key, iv, 0);
     }
 
@@ -135,8 +135,8 @@ public class CtrCryptoInputStream extends CryptoInputStream {
      * @param iv Initialization vector for the cipher.
      * @throws IOException if an I/O error occurs.
      */
-    protected CtrCryptoInputStream(ReadableByteChannel in, CryptoCipher cipher,
-            int bufferSize, byte[] key, byte[] iv) throws IOException {
+    protected CtrCryptoInputStream(final ReadableByteChannel in, final CryptoCipher cipher,
+            final int bufferSize, final byte[] key, final byte[] iv) throws IOException {
         this(in, cipher, bufferSize, key, iv, 0);
     }
 
@@ -150,8 +150,8 @@ public class CtrCryptoInputStream extends CryptoInputStream {
      * @param iv Initialization vector for the cipher.
      * @throws IOException if an I/O error occurs.
      */
-    protected CtrCryptoInputStream(Input input, CryptoCipher cipher,
-            int bufferSize, byte[] key, byte[] iv) throws IOException {
+    protected CtrCryptoInputStream(final Input input, final CryptoCipher cipher,
+            final int bufferSize, final byte[] key, final byte[] iv) throws IOException {
         this(input, cipher, bufferSize, key, iv, 0);
     }
 
@@ -166,8 +166,8 @@ public class CtrCryptoInputStream extends CryptoInputStream {
      * @param streamOffset the start offset in the stream.
      * @throws IOException if an I/O error occurs.
      */
-    public CtrCryptoInputStream(Properties props, InputStream in, byte[] key,
-            byte[] iv, long streamOffset) throws IOException {
+    public CtrCryptoInputStream(final Properties props, final InputStream in, final byte[] key,
+            final byte[] iv, final long streamOffset) throws IOException {
         this(in, Utils.getCipherInstance(
                 "AES/CTR/NoPadding", props),
                 CryptoInputStream.getBufferSize(props), key, iv, streamOffset);
@@ -184,8 +184,8 @@ public class CtrCryptoInputStream extends CryptoInputStream {
      * @param streamOffset the start offset in the stream.
      * @throws IOException if an I/O error occurs.
      */
-    public CtrCryptoInputStream(Properties props, ReadableByteChannel in,
-            byte[] key, byte[] iv, long streamOffset) throws IOException {
+    public CtrCryptoInputStream(final Properties props, final ReadableByteChannel in,
+            final byte[] key, final byte[] iv, final long streamOffset) throws IOException {
         this(in, Utils.getCipherInstance(
                 "AES/CTR/NoPadding", props),
                 CryptoInputStream.getBufferSize(props), key, iv, streamOffset);
@@ -202,8 +202,8 @@ public class CtrCryptoInputStream extends CryptoInputStream {
      * @param streamOffset the start offset in the stream.
      * @throws IOException if an I/O error occurs.
      */
-    protected CtrCryptoInputStream(InputStream in, CryptoCipher cipher,
-            int bufferSize, byte[] key, byte[] iv, long streamOffset)
+    protected CtrCryptoInputStream(final InputStream in, final CryptoCipher cipher,
+            final int bufferSize, final byte[] key, final byte[] iv, final long streamOffset)
             throws IOException {
         this(new StreamInput(in, bufferSize), cipher, bufferSize, key, iv,
                 streamOffset);
@@ -220,8 +220,8 @@ public class CtrCryptoInputStream extends CryptoInputStream {
      * @param streamOffset the start offset in the stream.
      * @throws IOException if an I/O error occurs.
      */
-    protected CtrCryptoInputStream(ReadableByteChannel in, CryptoCipher cipher,
-            int bufferSize, byte[] key, byte[] iv, long streamOffset)
+    protected CtrCryptoInputStream(final ReadableByteChannel in, final CryptoCipher cipher,
+            final int bufferSize, final byte[] key, final byte[] iv, final long streamOffset)
             throws IOException {
         this(new ChannelInput(in), cipher, bufferSize, key, iv, streamOffset);
     }
@@ -237,8 +237,8 @@ public class CtrCryptoInputStream extends CryptoInputStream {
      * @param streamOffset the start offset in the stream.
      * @throws IOException if an I/O error occurs.
      */
-    protected CtrCryptoInputStream(Input input, CryptoCipher cipher,
-            int bufferSize, byte[] key, byte[] iv, long streamOffset)
+    protected CtrCryptoInputStream(final Input input, final CryptoCipher cipher,
+            final int bufferSize, final byte[] key, final byte[] iv, final long streamOffset)
             throws IOException {
         super(input, cipher, bufferSize, new SecretKeySpec(key, "AES"),
                 new IvParameterSpec(iv));
@@ -267,7 +267,7 @@ public class CtrCryptoInputStream extends CryptoInputStream {
         if (n == 0) {
             return 0;
         } else if (n <= outBuffer.remaining()) {
-            int pos = outBuffer.position() + (int) n;
+            final int pos = outBuffer.position() + (int) n;
             outBuffer.position(pos);
             return n;
         } else {
@@ -282,7 +282,7 @@ public class CtrCryptoInputStream extends CryptoInputStream {
             if (skipped < 0) {
                 skipped = 0;
             }
-            long pos = streamOffset + skipped;
+            final long pos = streamOffset + skipped;
             skipped += outBuffer.remaining();
             resetStreamOffset(pos);
             return skipped;
@@ -299,7 +299,7 @@ public class CtrCryptoInputStream extends CryptoInputStream {
      * @throws IOException if an I/O error occurs.
      */
     @Override
-    public int read(ByteBuffer buf) throws IOException {
+    public int read(final ByteBuffer buf) throws IOException {
         checkStream();
         int unread = outBuffer.remaining();
         if (unread <= 0) { // Fill the unread decrypted data buffer firstly
@@ -342,7 +342,7 @@ public class CtrCryptoInputStream extends CryptoInputStream {
      * @param position the given position in the data.
      * @throws IOException if an I/O error occurs.
      */
-    public void seek(long position) throws IOException {
+    public void seek(final long position) throws IOException {
         Utils.checkArgument(position >= 0, "Cannot seek to negative offset.");
         checkStream();
         /*
@@ -350,7 +350,7 @@ public class CtrCryptoInputStream extends CryptoInputStream {
          * and decrypted in outBuffer, we just need to re-position outBuffer.
          */
         if (position >= getStreamPosition() && position <= getStreamOffset()) {
-            int forward = (int) (position - getStreamPosition());
+            final int forward = (int) (position - getStreamPosition());
             if (forward > 0) {
                 outBuffer.position(outBuffer.position() + forward);
             }
@@ -374,7 +374,7 @@ public class CtrCryptoInputStream extends CryptoInputStream {
      *
      * @param streamOffset the stream offset.
      */
-    protected void setStreamOffset(long streamOffset) {
+    protected void setStreamOffset(final long streamOffset) {
         this.streamOffset = streamOffset;
     }
 
@@ -396,7 +396,7 @@ public class CtrCryptoInputStream extends CryptoInputStream {
      */
     @Override
     protected int decryptMore() throws IOException {
-        int n = input.read(inBuffer);
+        final int n = input.read(inBuffer);
         if (n <= 0) {
             return n;
         }
@@ -447,7 +447,7 @@ public class CtrCryptoInputStream extends CryptoInputStream {
      * @param buf The buffer into which bytes are to be transferred.
      * @throws IOException if an I/O error occurs.
      */
-    protected void decryptInPlace(ByteBuffer buf) throws IOException {
+    protected void decryptInPlace(final ByteBuffer buf) throws IOException {
         Utils.checkState(inBuffer.position() >= padding);
         Utils.checkState(buf.isDirect());
         Utils.checkState(buf.remaining() >= inBuffer.position());
@@ -472,7 +472,7 @@ public class CtrCryptoInputStream extends CryptoInputStream {
      * @param len the maximum number of decrypted data bytes to read.
      * @throws IOException if an I/O error occurs.
      */
-    protected void decrypt(ByteBuffer buf, int offset, int len)
+    protected void decrypt(final ByteBuffer buf, final int offset, final int len)
             throws IOException {
         final int pos = buf.position();
         final int limit = buf.limit();
@@ -503,7 +503,7 @@ public class CtrCryptoInputStream extends CryptoInputStream {
      * @return the byte.
      * @throws IOException if an I/O error occurs.
      */
-    protected byte postDecryption(long position) throws IOException {
+    protected byte postDecryption(final long position) throws IOException {
         byte padding = 0;
         if (cipherReset) {
             /*
@@ -534,7 +534,7 @@ public class CtrCryptoInputStream extends CryptoInputStream {
      * @param position the given position in the data.
      * @return the counter for input stream position.
      */
-    protected long getCounter(long position) {
+    protected long getCounter(final long position) {
         return position / cipher.getBlockSize();
     }
 
@@ -544,7 +544,7 @@ public class CtrCryptoInputStream extends CryptoInputStream {
      * @param position the given position in the data.
      * @return the padding for input stream position.
      */
-    protected byte getPadding(long position) {
+    protected byte getPadding(final long position) {
         return (byte) (position % cipher.getBlockSize());
     }
 
@@ -564,14 +564,14 @@ public class CtrCryptoInputStream extends CryptoInputStream {
      * @param position the given position in the data.
      * @throws IOException if an I/O error occurs.
      */
-    protected void resetCipher(long position) throws IOException {
+    protected void resetCipher(final long position) throws IOException {
         final long counter = getCounter(position);
         CtrCryptoInputStream.calculateIV(initIV, counter, iv);
         try {
             cipher.init(Cipher.DECRYPT_MODE, key, new IvParameterSpec(iv));
-        } catch (InvalidKeyException e) {
+        } catch (final InvalidKeyException e) {
             throw new IOException(e);
-        } catch (InvalidAlgorithmParameterException e) {
+        } catch (final InvalidAlgorithmParameterException e) {
             throw new IOException(e);
         }
         cipherReset = false;
@@ -584,7 +584,7 @@ public class CtrCryptoInputStream extends CryptoInputStream {
      * @param offset the offset of the stream.
      * @throws IOException if an I/O error occurs.
      */
-    protected void resetStreamOffset(long offset) throws IOException {
+    protected void resetStreamOffset(final long offset) throws IOException {
         streamOffset = offset;
         inBuffer.clear();
         outBuffer.clear();
@@ -600,10 +600,10 @@ public class CtrCryptoInputStream extends CryptoInputStream {
      * @param out the output ByteBuffer.
      * @throws IOException if an I/O error occurs.
      */
-    protected void decryptBuffer(ByteBuffer out) throws IOException {
-        int inputSize = inBuffer.remaining();
+    protected void decryptBuffer(final ByteBuffer out) throws IOException {
+        final int inputSize = inBuffer.remaining();
         try {
-            int n = cipher.update(inBuffer, out);
+            final int n = cipher.update(inBuffer, out);
             if (n < inputSize) {
                 /**
                  * Typically code will not get here. CryptoCipher#update will
@@ -613,11 +613,11 @@ public class CtrCryptoInputStream extends CryptoInputStream {
                 cipher.doFinal(inBuffer, out);
                 cipherReset = true;
             }
-        } catch (ShortBufferException e) {
+        } catch (final ShortBufferException e) {
             throw new IOException(e);
-        } catch (IllegalBlockSizeException e) {
+        } catch (final IllegalBlockSizeException e) {
             throw new IOException(e);
-        } catch (BadPaddingException e) {
+        } catch (final BadPaddingException e) {
             throw new IOException(e);
         }
     }
@@ -645,7 +645,7 @@ public class CtrCryptoInputStream extends CryptoInputStream {
      * @param counter counter for input stream position
      * @param IV the IV for input stream position
      */
-    static void calculateIV(byte[] initIV, long counter, byte[] IV) {
+    static void calculateIV(final byte[] initIV, long counter, final byte[] IV) {
         Utils.checkArgument(initIV.length == CryptoCipherFactory.AES_BLOCK_SIZE);
         Utils.checkArgument(IV.length == CryptoCipherFactory.AES_BLOCK_SIZE);
 
diff --git a/src/main/java/org/apache/commons/crypto/stream/CtrCryptoOutputStream.java b/src/main/java/org/apache/commons/crypto/stream/CtrCryptoOutputStream.java
index ff5089d..fbc27e5 100644
--- a/src/main/java/org/apache/commons/crypto/stream/CtrCryptoOutputStream.java
+++ b/src/main/java/org/apache/commons/crypto/stream/CtrCryptoOutputStream.java
@@ -70,7 +70,7 @@ public class CtrCryptoOutputStream extends CryptoOutputStream {
     /**
      * Initialization vector for the cipher.
      */
-    private byte[] iv;
+    private final byte[] iv;
 
     /**
      * Padding = pos%(algorithm blocksize); Padding is put into
@@ -94,8 +94,8 @@ public class CtrCryptoOutputStream extends CryptoOutputStream {
      * @param iv Initialization vector for the cipher.
      * @throws IOException if an I/O error occurs.
      */
-    public CtrCryptoOutputStream(Properties props, OutputStream out,
-            byte[] key, byte[] iv) throws IOException {
+    public CtrCryptoOutputStream(final Properties props, final OutputStream out,
+            final byte[] key, final byte[] iv) throws IOException {
         this(props, out, key, iv, 0);
     }
 
@@ -109,8 +109,8 @@ public class CtrCryptoOutputStream extends CryptoOutputStream {
      * @param iv Initialization vector for the cipher.
      * @throws IOException if an I/O error occurs.
      */
-    public CtrCryptoOutputStream(Properties props, WritableByteChannel out,
-            byte[] key, byte[] iv) throws IOException {
+    public CtrCryptoOutputStream(final Properties props, final WritableByteChannel out,
+            final byte[] key, final byte[] iv) throws IOException {
         this(props, out, key, iv, 0);
     }
 
@@ -124,8 +124,8 @@ public class CtrCryptoOutputStream extends CryptoOutputStream {
      * @param iv Initialization vector for the cipher.
      * @throws IOException if an I/O error occurs.
      */
-    protected CtrCryptoOutputStream(OutputStream out, CryptoCipher cipher,
-            int bufferSize, byte[] key, byte[] iv) throws IOException {
+    protected CtrCryptoOutputStream(final OutputStream out, final CryptoCipher cipher,
+            final int bufferSize, final byte[] key, final byte[] iv) throws IOException {
         this(out, cipher, bufferSize, key, iv, 0);
     }
 
@@ -139,8 +139,8 @@ public class CtrCryptoOutputStream extends CryptoOutputStream {
      * @param iv Initialization vector for the cipher.
      * @throws IOException if an I/O error occurs.
      */
-    protected CtrCryptoOutputStream(WritableByteChannel channel,
-            CryptoCipher cipher, int bufferSize, byte[] key, byte[] iv)
+    protected CtrCryptoOutputStream(final WritableByteChannel channel,
+            final CryptoCipher cipher, final int bufferSize, final byte[] key, final byte[] iv)
             throws IOException {
         this(channel, cipher, bufferSize, key, iv, 0);
     }
@@ -155,8 +155,8 @@ public class CtrCryptoOutputStream extends CryptoOutputStream {
      * @param iv Initialization vector for the cipher.
      * @throws IOException if an I/O error occurs.
      */
-    protected CtrCryptoOutputStream(Output output, CryptoCipher cipher,
-            int bufferSize, byte[] key, byte[] iv) throws IOException {
+    protected CtrCryptoOutputStream(final Output output, final CryptoCipher cipher,
+            final int bufferSize, final byte[] key, final byte[] iv) throws IOException {
         this(output, cipher, bufferSize, key, iv, 0);
     }
 
@@ -171,8 +171,8 @@ public class CtrCryptoOutputStream extends CryptoOutputStream {
      * @param streamOffset the start offset in the data.
      * @throws IOException if an I/O error occurs.
      */
-    public CtrCryptoOutputStream(Properties props, OutputStream out,
-            byte[] key, byte[] iv, long streamOffset) throws IOException {
+    public CtrCryptoOutputStream(final Properties props, final OutputStream out,
+            final byte[] key, final byte[] iv, final long streamOffset) throws IOException {
         this(out, Utils.getCipherInstance(
                 "AES/CTR/NoPadding", props),
                 CryptoInputStream.getBufferSize(props), key, iv, streamOffset);
@@ -189,8 +189,8 @@ public class CtrCryptoOutputStream extends CryptoOutputStream {
      * @param streamOffset the start offset in the data.
      * @throws IOException if an I/O error occurs.
      */
-    public CtrCryptoOutputStream(Properties props, WritableByteChannel out,
-            byte[] key, byte[] iv, long streamOffset) throws IOException {
+    public CtrCryptoOutputStream(final Properties props, final WritableByteChannel out,
+            final byte[] key, final byte[] iv, final long streamOffset) throws IOException {
         this(out, Utils.getCipherInstance(
                 "AES/CTR/NoPadding", props),
                 CryptoInputStream.getBufferSize(props), key, iv, streamOffset);
@@ -207,8 +207,8 @@ public class CtrCryptoOutputStream extends CryptoOutputStream {
      * @param streamOffset the start offset in the data.
      * @throws IOException if an I/O error occurs.
      */
-    protected CtrCryptoOutputStream(OutputStream out, CryptoCipher cipher,
-            int bufferSize, byte[] key, byte[] iv, long streamOffset)
+    protected CtrCryptoOutputStream(final OutputStream out, final CryptoCipher cipher,
+            final int bufferSize, final byte[] key, final byte[] iv, final long streamOffset)
             throws IOException {
         this(new StreamOutput(out, bufferSize), cipher, bufferSize, key, iv,
                 streamOffset);
@@ -225,9 +225,9 @@ public class CtrCryptoOutputStream extends CryptoOutputStream {
      * @param streamOffset the start offset in the data.
      * @throws IOException if an I/O error occurs.
      */
-    protected CtrCryptoOutputStream(WritableByteChannel channel,
-            CryptoCipher cipher, int bufferSize, byte[] key, byte[] iv,
-            long streamOffset) throws IOException {
+    protected CtrCryptoOutputStream(final WritableByteChannel channel,
+            final CryptoCipher cipher, final int bufferSize, final byte[] key, final byte[] iv,
+            final long streamOffset) throws IOException {
         this(new ChannelOutput(channel), cipher, bufferSize, key, iv,
                 streamOffset);
     }
@@ -243,8 +243,8 @@ public class CtrCryptoOutputStream extends CryptoOutputStream {
      * @param streamOffset the start offset in the data.
      * @throws IOException if an I/O error occurs.
      */
-    protected CtrCryptoOutputStream(Output output, CryptoCipher cipher,
-            int bufferSize, byte[] key, byte[] iv, long streamOffset)
+    protected CtrCryptoOutputStream(final Output output, final CryptoCipher cipher,
+            final int bufferSize, final byte[] key, final byte[] iv, final long streamOffset)
             throws IOException {
         super(output, cipher, bufferSize, new SecretKeySpec(key, "AES"),
                 new IvParameterSpec(iv));
@@ -334,9 +334,9 @@ public class CtrCryptoOutputStream extends CryptoOutputStream {
         CtrCryptoInputStream.calculateIV(initIV, counter, iv);
         try {
             cipher.init(Cipher.ENCRYPT_MODE, key, new IvParameterSpec(iv));
-        } catch (InvalidKeyException e) {
+        } catch (final InvalidKeyException e) {
             throw new IOException(e);
-        } catch (InvalidAlgorithmParameterException e) {
+        } catch (final InvalidAlgorithmParameterException e) {
             throw new IOException(e);
         }
         cipherReset = false;
@@ -348,10 +348,10 @@ public class CtrCryptoOutputStream extends CryptoOutputStream {
      * @param out the output ByteBuffer.
      * @throws IOException if an I/O error occurs.
      */
-    private void encryptBuffer(ByteBuffer out) throws IOException {
-        int inputSize = inBuffer.remaining();
+    private void encryptBuffer(final ByteBuffer out) throws IOException {
+        final int inputSize = inBuffer.remaining();
         try {
-            int n = cipher.update(inBuffer, out);
+            final int n = cipher.update(inBuffer, out);
             if (n < inputSize) {
                 /**
                  * Typically code will not get here. CryptoCipher#update will
@@ -361,11 +361,11 @@ public class CtrCryptoOutputStream extends CryptoOutputStream {
                 cipher.doFinal(inBuffer, out);
                 cipherReset = true;
             }
-        } catch (ShortBufferException e) {
+        } catch (final ShortBufferException e) {
             throw new IOException(e);
-        } catch (BadPaddingException e) {
+        } catch (final BadPaddingException e) {
             throw new IOException(e);
-        } catch (IllegalBlockSizeException e) {
+        } catch (final IllegalBlockSizeException e) {
             throw new IOException(e);
         }
     }
@@ -384,7 +384,7 @@ public class CtrCryptoOutputStream extends CryptoOutputStream {
      *
      * @param streamOffset the underlying stream offset
      */
-    protected void setStreamOffset(long streamOffset) {
+    protected void setStreamOffset(final long streamOffset) {
         this.streamOffset = streamOffset;
     }
 }
diff --git a/src/main/java/org/apache/commons/crypto/stream/PositionedCryptoInputStream.java b/src/main/java/org/apache/commons/crypto/stream/PositionedCryptoInputStream.java
index 172db49..45749f3 100644
--- a/src/main/java/org/apache/commons/crypto/stream/PositionedCryptoInputStream.java
+++ b/src/main/java/org/apache/commons/crypto/stream/PositionedCryptoInputStream.java
@@ -70,8 +70,8 @@ public class PositionedCryptoInputStream extends CtrCryptoInputStream {
      * @param streamOffset the start offset in the data.
      * @throws IOException if an I/O error occurs.
      */
-    public PositionedCryptoInputStream(Properties props, Input in, byte[] key,
-            byte[] iv, long streamOffset) throws IOException {
+    public PositionedCryptoInputStream(final Properties props, final Input in, final byte[] key,
+            final byte[] iv, final long streamOffset) throws IOException {
         this(props, in, Utils.getCipherInstance("AES/CTR/NoPadding", props),
                 CryptoInputStream.getBufferSize(props), key, iv, streamOffset);
     }
@@ -88,8 +88,8 @@ public class PositionedCryptoInputStream extends CtrCryptoInputStream {
      * @param streamOffset the start offset in the data.
      * @throws IOException if an I/O error occurs.
      */
-    protected PositionedCryptoInputStream(Properties props, Input input, CryptoCipher cipher,
-            int bufferSize, byte[] key, byte[] iv, long streamOffset)
+    protected PositionedCryptoInputStream(final Properties props, final Input input, final CryptoCipher cipher,
+            final int bufferSize, final byte[] key, final byte[] iv, final long streamOffset)
             throws IOException {
         super(input, cipher, bufferSize, key, iv, streamOffset);
         this.props = props;
@@ -108,7 +108,7 @@ public class PositionedCryptoInputStream extends CtrCryptoInputStream {
      * @return int the total number of decrypted data bytes read into the
      *         buffer.
      */
-    public int read(long position, byte[] buffer, int offset, int length)
+    public int read(final long position, final byte[] buffer, final int offset, final int length)
             throws IOException {
         checkStream();
         final int n = input.read(position, buffer, offset, length);
@@ -130,7 +130,7 @@ public class PositionedCryptoInputStream extends CtrCryptoInputStream {
      * @param position the offset from the start of the stream.
      * @throws IOException if an I/O error occurs.
      */
-    public void readFully(long position, byte[] buffer, int offset, int length)
+    public void readFully(final long position, final byte[] buffer, final int offset, final int length)
             throws IOException {
         checkStream();
         IoUtils.readFully(input, position, buffer, offset, length);
@@ -149,7 +149,7 @@ public class PositionedCryptoInputStream extends CtrCryptoInputStream {
      * @param buffer the buffer into which the data is read.
      * @throws IOException if an I/O error occurs.
      */
-    public void readFully(long position, byte[] buffer) throws IOException {
+    public void readFully(final long position, final byte[] buffer) throws IOException {
         readFully(position, buffer, 0, buffer.length);
     }
 
@@ -163,21 +163,21 @@ public class PositionedCryptoInputStream extends CtrCryptoInputStream {
      * @param length the maximum number of bytes to read.
      * @throws IOException if an I/O error occurs.
      */
-    protected void decrypt(long position, byte[] buffer, int offset, int length)
+    protected void decrypt(final long position, final byte[] buffer, final int offset, final int length)
             throws IOException {
-        ByteBuffer inByteBuffer = getBuffer();
-        ByteBuffer outByteBuffer = getBuffer();
+        final ByteBuffer inByteBuffer = getBuffer();
+        final ByteBuffer outByteBuffer = getBuffer();
         CipherState state = null;
         try {
             state = getCipherState();
-            byte[] iv = getInitIV().clone();
+            final byte[] iv = getInitIV().clone();
             resetCipher(state, position, iv);
             byte padding = getPadding(position);
             inByteBuffer.position(padding); // Set proper position for input data.
 
             int n = 0;
             while (n < length) {
-                int toDecrypt = Math.min(length - n, inByteBuffer.remaining());
+                final int toDecrypt = Math.min(length - n, inByteBuffer.remaining());
                 inByteBuffer.put(buffer, offset + n, toDecrypt);
 
                 // Do decryption
@@ -205,8 +205,8 @@ public class PositionedCryptoInputStream extends CtrCryptoInputStream {
      * @param padding the padding.
      * @throws IOException if an I/O error occurs.
      */
-    private void decrypt(CipherState state, ByteBuffer inByteBuffer,
-            ByteBuffer outByteBuffer, byte padding) throws IOException {
+    private void decrypt(final CipherState state, final ByteBuffer inByteBuffer,
+            final ByteBuffer outByteBuffer, final byte padding) throws IOException {
         Utils.checkState(inByteBuffer.position() >= padding);
         if (inByteBuffer.position() == padding) {
             // There is no real data in inBuffer.
@@ -234,11 +234,11 @@ public class PositionedCryptoInputStream extends CtrCryptoInputStream {
      * @param outByteBuffer the output buffer.
      * @throws IOException if an I/O error occurs.
      */
-    private void decryptBuffer(CipherState state, ByteBuffer inByteBuffer,
-            ByteBuffer outByteBuffer) throws IOException {
-        int inputSize = inByteBuffer.remaining();
+    private void decryptBuffer(final CipherState state, final ByteBuffer inByteBuffer,
+            final ByteBuffer outByteBuffer) throws IOException {
+        final int inputSize = inByteBuffer.remaining();
         try {
-            int n = state.getCryptoCipher().update(inByteBuffer, outByteBuffer);
+            final int n = state.getCryptoCipher().update(inByteBuffer, outByteBuffer);
             if (n < inputSize) {
                 /**
                  * Typically code will not get here. CryptoCipher#update will
@@ -248,11 +248,11 @@ public class PositionedCryptoInputStream extends CtrCryptoInputStream {
                 state.getCryptoCipher().doFinal(inByteBuffer, outByteBuffer);
                 state.reset(true);
             }
-        } catch (ShortBufferException e) {
+        } catch (final ShortBufferException e) {
             throw new IOException(e);
-        } catch (IllegalBlockSizeException e) {
+        } catch (final IllegalBlockSizeException e) {
             throw new IOException(e);
-        } catch (BadPaddingException e) {
+        } catch (final BadPaddingException e) {
             throw new IOException(e);
         }
     }
@@ -268,8 +268,8 @@ public class PositionedCryptoInputStream extends CtrCryptoInputStream {
      * @return the padding.
      * @throws IOException if an I/O error occurs.
      */
-    private byte postDecryption(CipherState state, ByteBuffer inByteBuffer,
-            long position, byte[] iv) throws IOException {
+    private byte postDecryption(final CipherState state, final ByteBuffer inByteBuffer,
+            final long position, final byte[] iv) throws IOException {
         byte padding = 0;
         if (state.isReset()) {
             /*
@@ -293,16 +293,16 @@ public class PositionedCryptoInputStream extends CtrCryptoInputStream {
      * @param iv the iv.
      * @throws IOException if an I/O error occurs.
      */
-    private void resetCipher(CipherState state, long position, byte[] iv)
+    private void resetCipher(final CipherState state, final long position, final byte[] iv)
             throws IOException {
         final long counter = getCounter(position);
         CtrCryptoInputStream.calculateIV(getInitIV(), counter, iv);
         try {
             state.getCryptoCipher().init(Cipher.DECRYPT_MODE, key,
                     new IvParameterSpec(iv));
-        } catch (InvalidKeyException e) {
+        } catch (final InvalidKeyException e) {
             throw new IOException(e);
-        } catch (InvalidAlgorithmParameterException e) {
+        } catch (final InvalidAlgorithmParameterException e) {
             throw new IOException(e);
         }
         state.reset(false);
@@ -320,7 +320,7 @@ public class PositionedCryptoInputStream extends CtrCryptoInputStream {
             CryptoCipher cryptoCipher;
             try {
                 cryptoCipher = CryptoCipherFactory.getCryptoCipher("AES/CTR/NoPadding", props);
-            } catch (GeneralSecurityException e) {
+            } catch (final GeneralSecurityException e) {
                 throw new IOException(e);
             }
             state = new CipherState(cryptoCipher);
@@ -334,7 +334,7 @@ public class PositionedCryptoInputStream extends CtrCryptoInputStream {
      *
      * @param state the CipherState instance.
      */
-    private void returnCipherState(CipherState state) {
+    private void returnCipherState(final CipherState state) {
         if (state != null) {
             cipherPool.add(state);
         }
@@ -359,7 +359,7 @@ public class PositionedCryptoInputStream extends CtrCryptoInputStream {
      *
      * @param buf the buffer.
      */
-    private void returnBuffer(ByteBuffer buf) {
+    private void returnBuffer(final ByteBuffer buf) {
         if (buf != null) {
             buf.clear();
             bufferPool.add(buf);
@@ -391,7 +391,7 @@ public class PositionedCryptoInputStream extends CtrCryptoInputStream {
     }
 
     private class CipherState {
-        private CryptoCipher cryptoCipher;
+        private final CryptoCipher cryptoCipher;
         private boolean reset;
 
         /**
@@ -399,7 +399,7 @@ public class PositionedCryptoInputStream extends CtrCryptoInputStream {
          *
          * @param cipher the CryptoCipher instance.
          */
-        public CipherState(CryptoCipher cipher) {
+        public CipherState(final CryptoCipher cipher) {
             this.cryptoCipher = cipher;
             this.reset = false;
         }
@@ -427,7 +427,7 @@ public class PositionedCryptoInputStream extends CtrCryptoInputStream {
          *
          * @param reset the reset.
          */
-        public void reset(boolean reset) {
+        public void reset(final boolean reset) {
             this.reset = reset;
         }
     }
diff --git a/src/main/java/org/apache/commons/crypto/stream/input/ChannelInput.java b/src/main/java/org/apache/commons/crypto/stream/input/ChannelInput.java
index ce4c9da..4cfd1fd 100644
--- a/src/main/java/org/apache/commons/crypto/stream/input/ChannelInput.java
+++ b/src/main/java/org/apache/commons/crypto/stream/input/ChannelInput.java
@@ -38,7 +38,7 @@ public class ChannelInput implements Input {
      *
      * @param channel the ReadableByteChannel object.
      */
-    public ChannelInput(ReadableByteChannel channel) {
+    public ChannelInput(final ReadableByteChannel channel) {
         this.channel = channel;
     }
 
@@ -54,7 +54,7 @@ public class ChannelInput implements Input {
      * @throws IOException if an I/O error occurs.
      */
     @Override
-    public int read(ByteBuffer dst) throws IOException {
+    public int read(final ByteBuffer dst) throws IOException {
         return channel.read(dst);
     }
 
@@ -68,7 +68,7 @@ public class ChannelInput implements Input {
      * @throws IOException if an I/O error occurs.
      */
     @Override
-    public long skip(long n) throws IOException {
+    public long skip(final long n) throws IOException {
         long remaining = n;
         int nr;
 
@@ -76,8 +76,8 @@ public class ChannelInput implements Input {
             return 0;
         }
 
-        int size = (int) Math.min(SKIP_BUFFER_SIZE, remaining);
-        ByteBuffer skipBuffer = getSkipBuf();
+        final int size = (int) Math.min(SKIP_BUFFER_SIZE, remaining);
+        final ByteBuffer skipBuffer = getSkipBuf();
         while (remaining > 0) {
             skipBuffer.clear();
             skipBuffer.limit((int) Math.min(size, remaining));
@@ -127,7 +127,7 @@ public class ChannelInput implements Input {
      * @throws IOException if an I/O error occurs.
      */
     @Override
-    public int read(long position, byte[] buffer, int offset, int length)
+    public int read(final long position, final byte[] buffer, final int offset, final int length)
             throws IOException {
         throw new UnsupportedOperationException(
                 "Positioned read is not supported by this implementation");
@@ -143,7 +143,7 @@ public class ChannelInput implements Input {
      * @throws IOException if an I/O error occurs.
      */
     @Override
-    public void seek(long position) throws IOException {
+    public void seek(final long position) throws IOException {
         throw new UnsupportedOperationException(
                 "Seek is not supported by this implementation");
     }
diff --git a/src/main/java/org/apache/commons/crypto/stream/input/StreamInput.java b/src/main/java/org/apache/commons/crypto/stream/input/StreamInput.java
index f9f6610..bc20edd 100644
--- a/src/main/java/org/apache/commons/crypto/stream/input/StreamInput.java
+++ b/src/main/java/org/apache/commons/crypto/stream/input/StreamInput.java
@@ -36,7 +36,7 @@ public class StreamInput implements Input {
      * @param inputStream the inputstream object.
      * @param bufferSize the buffersize.
      */
-    public StreamInput(InputStream inputStream, int bufferSize) {
+    public StreamInput(final InputStream inputStream, final int bufferSize) {
         this.in = inputStream;
         this.bufferSize = bufferSize;
         buf = new byte[bufferSize];
@@ -55,7 +55,7 @@ public class StreamInput implements Input {
      * @throws IOException if an I/O error occurs.
      */
     @Override
-    public int read(ByteBuffer dst) throws IOException {
+    public int read(final ByteBuffer dst) throws IOException {
         int remaining = dst.remaining();
         int read = 0;
         while (remaining > 0) {
@@ -84,7 +84,7 @@ public class StreamInput implements Input {
      * @throws IOException if an I/O error occurs.
      */
     @Override
-    public long skip(long n) throws IOException {
+    public long skip(final long n) throws IOException {
         return in.skip(n);
     }
 
@@ -124,7 +124,7 @@ public class StreamInput implements Input {
      * @throws IOException if an I/O error occurs.
      */
     @Override
-    public int read(long position, byte[] buffer, int offset, int length)
+    public int read(final long position, final byte[] buffer, final int offset, final int length)
             throws IOException {
         throw new UnsupportedOperationException(
                 "Positioned read is not supported by this implementation");
@@ -140,7 +140,7 @@ public class StreamInput implements Input {
      * @throws IOException if an I/O error occurs.
      */
     @Override
-    public void seek(long position) throws IOException {
+    public void seek(final long position) throws IOException {
         throw new UnsupportedOperationException(
                 "Seek is not supported by this implementation");
     }
diff --git a/src/main/java/org/apache/commons/crypto/stream/output/ChannelOutput.java b/src/main/java/org/apache/commons/crypto/stream/output/ChannelOutput.java
index 41abc77..ca41ea5 100644
--- a/src/main/java/org/apache/commons/crypto/stream/output/ChannelOutput.java
+++ b/src/main/java/org/apache/commons/crypto/stream/output/ChannelOutput.java
@@ -36,7 +36,7 @@ public class ChannelOutput implements Output {
      *
      * @param channel the WritableByteChannel object.
      */
-    public ChannelOutput(WritableByteChannel channel) {
+    public ChannelOutput(final WritableByteChannel channel) {
         this.channel = channel;
     }
 
@@ -51,7 +51,7 @@ public class ChannelOutput implements Output {
      * @throws IOException if an I/O error occurs.
      */
     @Override
-    public int write(ByteBuffer src) throws IOException {
+    public int write(final ByteBuffer src) throws IOException {
         return channel.write(src);
     }
 
diff --git a/src/main/java/org/apache/commons/crypto/stream/output/StreamOutput.java b/src/main/java/org/apache/commons/crypto/stream/output/StreamOutput.java
index 616f06e..57af1f8 100644
--- a/src/main/java/org/apache/commons/crypto/stream/output/StreamOutput.java
+++ b/src/main/java/org/apache/commons/crypto/stream/output/StreamOutput.java
@@ -38,7 +38,7 @@ public class StreamOutput implements Output {
      * @param out the OutputStream object.
      * @param bufferSize the buffersize.
      */
-    public StreamOutput(OutputStream out, int bufferSize) {
+    public StreamOutput(final OutputStream out, final int bufferSize) {
         this.out = out;
         this.bufferSize = bufferSize;
         buf = new byte[bufferSize];
@@ -55,7 +55,7 @@ public class StreamOutput implements Output {
      * @throws IOException if an I/O error occurs.
      */
     @Override
-    public int write(ByteBuffer src) throws IOException {
+    public int write(final ByteBuffer src) throws IOException {
         final int len = src.remaining();
 
         int remaining = len;
diff --git a/src/main/java/org/apache/commons/crypto/utils/IoUtils.java b/src/main/java/org/apache/commons/crypto/utils/IoUtils.java
index 3ad5477..13a3dd0 100644
--- a/src/main/java/org/apache/commons/crypto/utils/IoUtils.java
+++ b/src/main/java/org/apache/commons/crypto/utils/IoUtils.java
@@ -42,11 +42,11 @@ public final class IoUtils {
      * @param len the maximum number of bytes to read.
      * @throws IOException if an I/O error occurs.
      */
-    public static void readFully(InputStream in, byte buf[], int off, int len)
+    public static void readFully(final InputStream in, final byte buf[], int off, final int len)
             throws IOException {
         int toRead = len;
         while (toRead > 0) {
-            int ret = in.read(buf, off, toRead);
+            final int ret = in.read(buf, off, toRead);
             if (ret < 0) {
                 throw new IOException("Premature EOF from inputStream");
             }
@@ -66,11 +66,11 @@ public final class IoUtils {
      * @param offset the start offset in array buffer.
      * @throws IOException if an I/O error occurs.
      */
-    public static void readFully(Input in, long position, byte[] buffer,
-            int offset, int length) throws IOException {
+    public static void readFully(final Input in, final long position, final byte[] buffer,
+            final int offset, final int length) throws IOException {
         int nread = 0;
         while (nread < length) {
-            int nbytes = in.read(position + nread, buffer, offset + nread,
+            final int nbytes = in.read(position + nread, buffer, offset + nread,
                     length - nread);
             if (nbytes < 0) {
                 throw new IOException(
@@ -86,12 +86,12 @@ public final class IoUtils {
      *
      * @param closeables the objects to close.
      */
-    public static void cleanup(java.io.Closeable... closeables) {
-        for (java.io.Closeable c : closeables) {
+    public static void cleanup(final java.io.Closeable... closeables) {
+        for (final java.io.Closeable c : closeables) {
             if (c != null) {
                 try {
                     c.close();
-                } catch (IOException e) { // NOPMD
+                } catch (final IOException e) { // NOPMD
                 }
             }
         }
diff --git a/src/main/java/org/apache/commons/crypto/utils/ReflectionUtils.java b/src/main/java/org/apache/commons/crypto/utils/ReflectionUtils.java
index 52cb745..969ceff 100644
--- a/src/main/java/org/apache/commons/crypto/utils/ReflectionUtils.java
+++ b/src/main/java/org/apache/commons/crypto/utils/ReflectionUtils.java
@@ -35,7 +35,7 @@ public final class ReflectionUtils {
     private static final ClassLoader CLASSLOADER;
 
     static {
-        ClassLoader threadClassLoader = Thread.currentThread()
+        final ClassLoader threadClassLoader = Thread.currentThread()
                 .getContextClassLoader();
         CLASSLOADER = (threadClassLoader != null) ? threadClassLoader
                 : CryptoCipher.class.getClassLoader();
@@ -71,14 +71,14 @@ public final class ReflectionUtils {
      * @return a new object created by calling the constructor this object
      *         represents.
      */
-    public static <T> T newInstance(Class<T> klass, Object... args) {
+    public static <T> T newInstance(final Class<T> klass, final Object... args) {
         try {
             Constructor<T> ctor;
 
             if (args.length == 0) {
                 ctor = klass.getDeclaredConstructor();
             } else {
-                Class<?>[] argClses = new Class[args.length];
+                final Class<?>[] argClses = new Class[args.length];
                 for (int i = 0; i < args.length; i++) {
                     argClses[i] = args[i].getClass();
                 }
@@ -86,7 +86,7 @@ public final class ReflectionUtils {
             }
             ctor.setAccessible(true);
             return ctor.newInstance(args);
-        } catch (Exception e) {
+        } catch (final Exception e) {
             throw new RuntimeException(e);
         }
     }
@@ -98,9 +98,9 @@ public final class ReflectionUtils {
      * @return the class object.
      * @throws ClassNotFoundException if the class is not found.
      */
-    public static Class<?> getClassByName(String name)
+    public static Class<?> getClassByName(final String name)
             throws ClassNotFoundException {
-        Class<?> ret = getClassByNameOrNull(name);
+        final Class<?> ret = getClassByNameOrNull(name);
         if (ret == null) {
             throw new ClassNotFoundException("Class " + name + " not found");
         }
@@ -115,7 +115,7 @@ public final class ReflectionUtils {
      * @param name the class name.
      * @return the class object, or null if it could not be found.
      */
-    private static Class<?> getClassByNameOrNull(String name) {
+    private static Class<?> getClassByNameOrNull(final String name) {
         Map<String, WeakReference<Class<?>>> map;
 
         synchronized (CACHE_CLASSES) {
@@ -128,7 +128,7 @@ public final class ReflectionUtils {
         }
 
         Class<?> clazz = null;
-        WeakReference<Class<?>> ref = map.get(name);
+        final WeakReference<Class<?>> ref = map.get(name);
         if (ref != null) {
             clazz = ref.get();
         }
@@ -136,7 +136,7 @@ public final class ReflectionUtils {
         if (clazz == null) {
             try {
                 clazz = Class.forName(name, true, CLASSLOADER);
-            } catch (ClassNotFoundException e) {
+            } catch (final ClassNotFoundException e) {
                 // Leave a marker that the class isn't found
                 map.put(name, new WeakReference<Class<?>>(
                         NEGATIVE_CACHE_SENTINEL));
diff --git a/src/main/java/org/apache/commons/crypto/utils/Utils.java b/src/main/java/org/apache/commons/crypto/utils/Utils.java
index 1106912..c8a11af 100644
--- a/src/main/java/org/apache/commons/crypto/utils/Utils.java
+++ b/src/main/java/org/apache/commons/crypto/utils/Utils.java
@@ -60,27 +60,27 @@ public final class Utils {
      */
     private static Properties createDefaultProperties() {
         // default to system
-        Properties defaultedProps = new Properties(System.getProperties());
+        final Properties defaultedProps = new Properties(System.getProperties());
         try {
-            InputStream is = Thread.currentThread().getContextClassLoader()
+            final InputStream is = Thread.currentThread().getContextClassLoader()
                     .getResourceAsStream(SYSTEM_PROPERTIES_FILE);
 
             if (is == null) {
                 return defaultedProps; // no configuration file is found
             }
             // Load property file
-            Properties fileProps = new Properties();
+            final Properties fileProps = new Properties();
             fileProps.load(is);
             is.close();
-            Enumeration<?> names = fileProps.propertyNames();
+            final Enumeration<?> names = fileProps.propertyNames();
             while (names.hasMoreElements()) {
-                String name = (String) names.nextElement();
+                final String name = (String) names.nextElement();
                 // ensure System properties override ones in the file so one can override the file on the command line
                 if (System.getProperty(name) == null) {
                     defaultedProps.setProperty(name, fileProps.getProperty(name));
                 }
             }
-        } catch (Exception ex) {
+        } catch (final Exception ex) {
             System.err.println("Could not load '"
                     + SYSTEM_PROPERTIES_FILE
                     + "' from classpath: " + ex.toString());
@@ -103,8 +103,8 @@ public final class Utils {
      * @param newProp  User-defined properties
      * @return User-defined properties with the default properties
      */
-    public static Properties getProperties(Properties newProp) {
-        Properties properties = new Properties(DefaultPropertiesHolder.DEFAULT_PROPERTIES);
+    public static Properties getProperties(final Properties newProp) {
+        final Properties properties = new Properties(DefaultPropertiesHolder.DEFAULT_PROPERTIES);
         properties.putAll(newProp);
         return properties;
      }
@@ -123,11 +123,11 @@ public final class Utils {
      * @throws IOException if an I/O error occurs.
      */
     public static CryptoCipher getCipherInstance(
-            String transformation, Properties props)
+            final String transformation, final Properties props)
             throws IOException {
         try {
             return CryptoCipherFactory.getCryptoCipher(transformation, props);
-        } catch (GeneralSecurityException e) {
+        } catch (final GeneralSecurityException e) {
             throw new IOException(e);
         }
     }
@@ -139,7 +139,7 @@ public final class Utils {
      * @param expression a boolean expression.
      * @throws IllegalArgumentException if expression is false.
      */
-    public static void checkArgument(boolean expression) {
+    public static void checkArgument(final boolean expression) {
         if (!expression) {
             throw new IllegalArgumentException();
         }
@@ -154,7 +154,7 @@ public final class Utils {
      *                     .valueOf(Object)</code>.
      * @throws IllegalArgumentException if expression is false.
      */
-    public static void checkArgument(boolean expression, Object errorMessage) {
+    public static void checkArgument(final boolean expression, final Object errorMessage) {
         if (!expression) {
             throw new IllegalArgumentException(String.valueOf(errorMessage));
         }
@@ -171,7 +171,7 @@ public final class Utils {
      * @deprecated Use {@link Objects#requireNonNull(Object)}.
      */
     @Deprecated
-    public static <T> T checkNotNull(T reference) {
+    public static <T> T checkNotNull(final T reference) {
         return Objects.requireNonNull(reference, "reference");
     }
 
@@ -182,7 +182,7 @@ public final class Utils {
      * @param expression a boolean expression.
      * @throws IllegalStateException if expression is false.
      */
-    public static void checkState(boolean expression) {
+    public static void checkState(final boolean expression) {
         checkState(expression, null);
     }
 
@@ -194,7 +194,7 @@ public final class Utils {
      * @param message Error message for the exception when the expression is false.
      * @throws IllegalStateException if expression is false.
      */
-    public static void checkState(boolean expression, String message) {
+    public static void checkState(final boolean expression, final String message) {
         if (!expression) {
             throw new IllegalStateException(message);
         }
@@ -209,8 +209,8 @@ public final class Utils {
      * @param separator a delimiter for the input string.
      * @return a list of class entries.
      */
-    public static List<String> splitClassNames(String clazzNames, String separator) {
-        List<String> res = new ArrayList<>();
+    public static List<String> splitClassNames(final String clazzNames, final String separator) {
+        final List<String> res = new ArrayList<>();
         if (clazzNames == null || clazzNames.isEmpty()) {
             return res;
         }
diff --git a/src/test/java/org/apache/commons/crypto/CryptoTest.java b/src/test/java/org/apache/commons/crypto/CryptoTest.java
index a6004ee..54ad0b1 100644
--- a/src/test/java/org/apache/commons/crypto/CryptoTest.java
+++ b/src/test/java/org/apache/commons/crypto/CryptoTest.java
@@ -26,7 +26,7 @@ public class CryptoTest {
     // This test may fail unless the code was built by Maven, as
     // it relies on the VERSION file being set up correctly
     public void testGetComponentVersion() {
-        String version = Crypto.getComponentVersion();
+        final String version = Crypto.getComponentVersion();
         Assert.assertNotNull("Should not be null",version);
         Assert.assertTrue(version,version.matches("^\\d+\\.\\d+.*"));
     }
@@ -35,7 +35,7 @@ public class CryptoTest {
     // This test may fail unless the code was built by Maven, as
     // it relies on the VERSION file being set up correctly
     public void testGetComponentName() {
-        String version = Crypto.getComponentName();
+        final String version = Crypto.getComponentName();
         Assert.assertNotNull("Should not be null",version);
         Assert.assertTrue(version,version.matches("^Apache Commons Crypto.*"));
     }
diff --git a/src/test/java/org/apache/commons/crypto/NativeCodeLoaderTest.java b/src/test/java/org/apache/commons/crypto/NativeCodeLoaderTest.java
index 94ff605..8709c4f 100644
--- a/src/test/java/org/apache/commons/crypto/NativeCodeLoaderTest.java
+++ b/src/test/java/org/apache/commons/crypto/NativeCodeLoaderTest.java
@@ -66,7 +66,7 @@ public class NativeCodeLoaderTest {
         final String nameKey = System.getProperty(Crypto.LIB_NAME_KEY);
         final String pathKey = System.getProperty(Crypto.LIB_PATH_KEY);
         // An empty file should cause UnsatisfiedLinkError
-        File empty = File.createTempFile("NativeCodeLoaderTest", "tmp");
+        final File empty = File.createTempFile("NativeCodeLoaderTest", "tmp");
         try {
             System.setProperty(Crypto.LIB_PATH_KEY, empty.getParent());
             System.setProperty(Crypto.LIB_NAME_KEY, empty.getName());
diff --git a/src/test/java/org/apache/commons/crypto/cipher/AbstractCipherTest.java b/src/test/java/org/apache/commons/crypto/cipher/AbstractCipherTest.java
index ce2d8f2..f14804a 100644
--- a/src/test/java/org/apache/commons/crypto/cipher/AbstractCipherTest.java
+++ b/src/test/java/org/apache/commons/crypto/cipher/AbstractCipherTest.java
@@ -71,14 +71,14 @@ public abstract class AbstractCipherTest {
     @Test
     public void closeTestNoInit() throws Exception {
         // This test deliberately does not use try with resources in order to control the sequence of operations exactly
-        CryptoCipher enc = getCipher(transformations[0]);
+        final CryptoCipher enc = getCipher(transformations[0]);
         enc.close();
     }
 
     @Test
     public void closeTestAfterInit() throws Exception {
         // This test deliberately does not use try with resources in order to control the sequence of operations exactly
-        CryptoCipher enc = getCipher(transformations[0]);
+        final CryptoCipher enc = getCipher(transformations[0]);
         enc.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(KEY, "AES"), new IvParameterSpec(IV));
         enc.close();
     }
@@ -86,7 +86,7 @@ public abstract class AbstractCipherTest {
     @Test
     public void reInitTest() throws Exception {
         // This test deliberately does not use try with resources in order to control the sequence of operations exactly
-        CryptoCipher enc = getCipher(transformations[0]);
+        final CryptoCipher enc = getCipher(transformations[0]);
         enc.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(KEY, "AES"), new IvParameterSpec(IV));
         enc.init(Cipher.DECRYPT_MODE, new SecretKeySpec(KEY, "AES"), new IvParameterSpec(IV));
         enc.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(KEY, "AES"), new IvParameterSpec(IV));
@@ -96,7 +96,7 @@ public abstract class AbstractCipherTest {
     @Test
     public void reInitAfterClose() throws Exception {
         // This test deliberately does not use try with resources in order to control the sequence of operations exactly
-        CryptoCipher enc = getCipher(transformations[0]);
+        final CryptoCipher enc = getCipher(transformations[0]);
         enc.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(KEY, "AES"), new IvParameterSpec(IV));
         enc.close();
         enc.init(Cipher.DECRYPT_MODE, new SecretKeySpec(KEY, "AES"), new IvParameterSpec(IV));
@@ -106,7 +106,7 @@ public abstract class AbstractCipherTest {
     @Test
     public void closeTestRepeat() throws Exception {
         // This test deliberately does not use try with resources in order to control the sequence of operations exactly
-        CryptoCipher enc = getCipher(transformations[0]);
+        final CryptoCipher enc = getCipher(transformations[0]);
         enc.close();
         enc.close(); // repeat the close
         enc.close();
@@ -114,24 +114,24 @@ public abstract class AbstractCipherTest {
 
     @Test
     public void cryptoTest() throws Exception {
-        for (String tran : transformations) {
+        for (final String tran : transformations) {
             /** uses the small data set in {@link TestData} */
             cipherTests = TestData.getTestData(tran);
             assertNotNull(tran, cipherTests);
             for (int i = 0; i != cipherTests.length; i += 5) {
-                byte[] key = DatatypeConverter
+                final byte[] key = DatatypeConverter
                         .parseHexBinary(cipherTests[i + 1]);
-                byte[] iv = DatatypeConverter
+                final byte[] iv = DatatypeConverter
                         .parseHexBinary(cipherTests[i + 2]);
 
-                byte[] inputBytes = DatatypeConverter
+                final byte[] inputBytes = DatatypeConverter
                         .parseHexBinary(cipherTests[i + 3]);
-                byte[] outputBytes = DatatypeConverter
+                final byte[] outputBytes = DatatypeConverter
                         .parseHexBinary(cipherTests[i + 4]);
 
-                ByteBuffer inputBuffer = ByteBuffer
+                final ByteBuffer inputBuffer = ByteBuffer
                         .allocateDirect(inputBytes.length);
-                ByteBuffer outputBuffer = ByteBuffer
+                final ByteBuffer outputBuffer = ByteBuffer
                         .allocateDirect(outputBytes.length);
                 inputBuffer.put(inputBytes);
                 inputBuffer.flip();
@@ -147,17 +147,17 @@ public abstract class AbstractCipherTest {
         }
     }
 
-    private void byteBufferTest(String transformation,
-            byte[] key, byte[] iv, ByteBuffer input, ByteBuffer output)
+    private void byteBufferTest(final String transformation,
+            final byte[] key, final byte[] iv, final ByteBuffer input, final ByteBuffer output)
             throws Exception {
-        ByteBuffer decResult = ByteBuffer.allocateDirect(BYTEBUFFER_SIZE);
-        ByteBuffer encResult = ByteBuffer.allocateDirect(BYTEBUFFER_SIZE);
+        final ByteBuffer decResult = ByteBuffer.allocateDirect(BYTEBUFFER_SIZE);
+        final ByteBuffer encResult = ByteBuffer.allocateDirect(BYTEBUFFER_SIZE);
 
-        CryptoCipher enc = getCipher(transformation);
+        final CryptoCipher enc = getCipher(transformation);
         enc.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(key, "AES"),
                 new IvParameterSpec(iv));
 
-        CryptoCipher dec = getCipher(transformation);
+        final CryptoCipher dec = getCipher(transformation);
         dec.init(Cipher.DECRYPT_MODE, new SecretKeySpec(key, "AES"),
                 new IvParameterSpec(iv));
 
@@ -168,9 +168,9 @@ public abstract class AbstractCipherTest {
         input.flip();
         encResult.flip();
         if (!output.equals(encResult)) {
-            byte[] b = new byte[output.remaining()];
+            final byte[] b = new byte[output.remaining()];
             output.get(b);
-            byte[] c = new byte[encResult.remaining()];
+            final byte[] c = new byte[encResult.remaining()];
             encResult.get(c);
             Assert.fail("AES failed encryption - expected "
                     + new String(DatatypeConverter.printHexBinary(b)) + " got "
@@ -184,8 +184,8 @@ public abstract class AbstractCipherTest {
         decResult.flip();
 
         if (!input.equals(decResult)) {
-            byte[] inArray = new byte[input.remaining()];
-            byte[] decResultArray = new byte[decResult.remaining()];
+            final byte[] inArray = new byte[input.remaining()];
+            final byte[] decResultArray = new byte[decResult.remaining()];
             input.get(inArray);
             decResult.get(decResultArray);
             Assert.fail();
@@ -193,46 +193,46 @@ public abstract class AbstractCipherTest {
     }
 
     /** test byte array whose data is planned in {@link TestData} */
-    private void byteArrayTest(String transformation, byte[] key,
-            byte[] iv, byte[] input, byte[] output)
+    private void byteArrayTest(final String transformation, final byte[] key,
+            final byte[] iv, final byte[] input, final byte[] output)
             throws Exception {
         resetCipher(transformation, key, iv);
-        int blockSize = enc.getBlockSize();
+        final int blockSize = enc.getBlockSize();
 
         byte[] temp = new byte[input.length + blockSize];
-        int n = enc.doFinal(input, 0, input.length, temp, 0);
-        byte[] cipherText = new byte[n];
+        final int n = enc.doFinal(input, 0, input.length, temp, 0);
+        final byte[] cipherText = new byte[n];
         System.arraycopy(temp, 0, cipherText, 0, n);
         Assert.assertArrayEquals("byte array encryption error.", output,
                 cipherText);
 
         temp = new byte[cipherText.length + blockSize];
-        int m = dec.doFinal(cipherText, 0, cipherText.length, temp, 0);
-        byte[] plainText = new byte[m];
+        final int m = dec.doFinal(cipherText, 0, cipherText.length, temp, 0);
+        final byte[] plainText = new byte[m];
         System.arraycopy(temp, 0, plainText, 0, m);
         Assert.assertArrayEquals("byte array decryption error.", input,
                 plainText);
     }
 
     /** test byte array whose data is randomly generated */
-    private void byteArrayTest(String transformation, byte[] key,
-            byte[] iv) throws Exception {
-        int blockSize = enc.getBlockSize();
+    private void byteArrayTest(final String transformation, final byte[] key,
+            final byte[] iv) throws Exception {
+        final int blockSize = enc.getBlockSize();
 
         // AES_CBC_NOPADDING only accepts data whose size is the multiple of
         // block size
-        int[] dataLenList = transformation.equals("AES/CBC/NoPadding") ? new int[] { 10 * 1024 }
+        final int[] dataLenList = transformation.equals("AES/CBC/NoPadding") ? new int[] { 10 * 1024 }
                 : new int[] { 10 * 1024, 10 * 1024 - 3 };
-        for (int dataLen : dataLenList) {
-            byte[] plainText = new byte[dataLen];
-            Random random = new SecureRandom();
+        for (final int dataLen : dataLenList) {
+            final byte[] plainText = new byte[dataLen];
+            final Random random = new SecureRandom();
             random.nextBytes(plainText);
-            byte[] cipherText = new byte[dataLen + blockSize];
+            final byte[] cipherText = new byte[dataLen + blockSize];
 
             // check update method with inputs whose sizes are the multiple of
             // block size or not
-            int[] bufferLenList = new int[] { 2 * 1024 - 128, 2 * 1024 - 125 };
-            for (int bufferLen : bufferLenList) {
+            final int[] bufferLenList = new int[] { 2 * 1024 - 128, 2 * 1024 - 125 };
+            for (final int bufferLen : bufferLenList) {
                 resetCipher(transformation, key, iv);
 
                 int offset = 0;
@@ -248,7 +248,7 @@ public abstract class AbstractCipherTest {
 
                 offset = 0;
                 // decrypt (update + doFinal) the data
-                byte[] realPlainText = new byte[cipherPos + blockSize];
+                final byte[] realPlainText = new byte[cipherPos + blockSize];
                 int plainPos = 0;
                 for (int i = 0; i < cipherPos / bufferLen; i++) {
                     plainPos += dec.update(cipherText, offset, bufferLen,
@@ -263,7 +263,7 @@ public abstract class AbstractCipherTest {
                         "random byte array length changes after transformation",
                         dataLen, plainPos);
 
-                byte[] shrinkPlainText = new byte[plainPos];
+                final byte[] shrinkPlainText = new byte[plainPos];
                 System.arraycopy(realPlainText, 0, shrinkPlainText, 0, plainPos);
                 Assert.assertArrayEquals(
                         "random byte array contents changes after transformation",
@@ -272,7 +272,7 @@ public abstract class AbstractCipherTest {
         }
     }
 
-    private void resetCipher(String transformation, byte[] key, byte[] iv) throws Exception {
+    private void resetCipher(final String transformation, final byte[] key, final byte[] iv) throws Exception {
         enc = getCipher(transformation);
         dec = getCipher(transformation);
 
@@ -283,7 +283,7 @@ public abstract class AbstractCipherTest {
                 new IvParameterSpec(iv));
     }
 
-    private CryptoCipher getCipher(String transformation) throws Exception {
+    private CryptoCipher getCipher(final String transformation) throws Exception {
         return (CryptoCipher) ReflectionUtils.newInstance(
                 ReflectionUtils.getClassByName(cipherClass), props,
                 transformation);
diff --git a/src/test/java/org/apache/commons/crypto/cipher/CryptoCipherFactoryTest.java b/src/test/java/org/apache/commons/crypto/cipher/CryptoCipherFactoryTest.java
index f47e7e0..a5b0ff0 100644
--- a/src/test/java/org/apache/commons/crypto/cipher/CryptoCipherFactoryTest.java
+++ b/src/test/java/org/apache/commons/crypto/cipher/CryptoCipherFactoryTest.java
@@ -26,7 +26,7 @@ import org.junit.Test;
 public class CryptoCipherFactoryTest {
     @Test
     public void testDefaultCipher() throws GeneralSecurityException {
-        CryptoCipher defaultCipher = CryptoCipherFactory
+        final CryptoCipher defaultCipher = CryptoCipherFactory
                 .getCryptoCipher("AES/CBC/NoPadding");
         final String name = defaultCipher.getClass().getName();
         if (OpenSsl.getLoadingFailureReason() == null) {
@@ -38,9 +38,9 @@ public class CryptoCipherFactoryTest {
 
     @Test
     public void testEmptyCipher() throws GeneralSecurityException {
-        Properties properties = new Properties();
+        final Properties properties = new Properties();
         properties.setProperty(CryptoCipherFactory.CLASSES_KEY, ""); // TODO should this really mean use the default?
-        CryptoCipher defaultCipher = CryptoCipherFactory.getCryptoCipher(
+        final CryptoCipher defaultCipher = CryptoCipherFactory.getCryptoCipher(
                 "AES/CBC/NoPadding", properties);
         final String name = defaultCipher.getClass().getName();
         if (OpenSsl.getLoadingFailureReason() == null) {
@@ -52,7 +52,7 @@ public class CryptoCipherFactoryTest {
 
     @Test(expected = GeneralSecurityException.class)
     public void testInvalidCipher() throws GeneralSecurityException {
-        Properties properties = new Properties();
+        final Properties properties = new Properties();
         properties.setProperty(CryptoCipherFactory.CLASSES_KEY,
                 "InvalidCipherName");
         CryptoCipherFactory.getCryptoCipher("AES/CBC/NoPadding", properties);
@@ -60,13 +60,13 @@ public class CryptoCipherFactoryTest {
 
     @Test(expected = GeneralSecurityException.class)
     public void testInvalidTransformation() throws GeneralSecurityException {
-      Properties properties = new Properties();
+      final Properties properties = new Properties();
       CryptoCipherFactory.getCryptoCipher("AES/Invalid/NoPadding", properties);
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testNoCipher() throws Exception {
-        Properties properties = new Properties();
+        final Properties properties = new Properties();
         // An empty string currently means use the default
         // However the splitter drops empty fields
         properties.setProperty(CryptoCipherFactory.CLASSES_KEY, ",");
diff --git a/src/test/java/org/apache/commons/crypto/cipher/GcmCipherTest.java b/src/test/java/org/apache/commons/crypto/cipher/GcmCipherTest.java
index 7e75dda..cdfc5eb 100644
--- a/src/test/java/org/apache/commons/crypto/cipher/GcmCipherTest.java
+++ b/src/test/java/org/apache/commons/crypto/cipher/GcmCipherTest.java
@@ -69,13 +69,13 @@ public class GcmCipherTest {
         // iv length:           12 bytes
         // aad length:          0 bytes
 
-        String kHex = "00000000000000000000000000000000";
-        String pHex = "00000000000000000000000000000000";
-        String ivHex = "000000000000000000000000";
-        String aadHex = "";
+        final String kHex = "00000000000000000000000000000000";
+        final String pHex = "00000000000000000000000000000000";
+        final String ivHex = "000000000000000000000000";
+        final String aadHex = "";
 
-        String cHex = "0388dace60b6a392f328c2b971b2fe78";
-        String tHex = "ab6e47d42cec13bdf53a67b21257bddf";
+        final String cHex = "0388dace60b6a392f328c2b971b2fe78";
+        final String tHex = "ab6e47d42cec13bdf53a67b21257bddf";
 
         testGcmEncryption(kHex, pHex, ivHex, aadHex, cHex, tHex);
         testGcmDecryption(kHex, pHex, ivHex, aadHex, cHex, tHex);
@@ -91,20 +91,20 @@ public class GcmCipherTest {
         // iv length:           12 bytes
         // aad length:          20 bytes
 
-        String kHex = "feffe9928665731c6d6a8f9467308308";
-        String pHex = "d9313225f88406e5a55909c5aff5269a"
+        final String kHex = "feffe9928665731c6d6a8f9467308308";
+        final String pHex = "d9313225f88406e5a55909c5aff5269a"
                 + "86a7a9531534f7da2e4c303d8a318a72"
                 + "1c3c0c95956809532fcf0e2449a6b525"
                 + "b16aedf5aa0de657ba637b39";
-        String ivHex = "cafebabefacedbaddecaf888";
-        String aadHex = "feedfacedeadbeeffeedfacedeadbeef"
+        final String ivHex = "cafebabefacedbaddecaf888";
+        final String aadHex = "feedfacedeadbeeffeedfacedeadbeef"
                 + "abaddad2";
 
-        String cHex = "42831ec2217774244b7221b784d0d49c"
+        final String cHex = "42831ec2217774244b7221b784d0d49c"
                 + "e3aa212f2c02a4e035c17e2329aca12e"
                 + "21d514b25466931c7d8f6a5aac84aa05"
                 + "1ba30b396a0aac973d58e091";
-        String tHex = "5bc94fbc3221a5db94fae95ae7121a47";
+        final String tHex = "5bc94fbc3221a5db94fae95ae7121a47";
 
         testGcmEncryption(kHex, pHex, ivHex, aadHex, cHex, tHex);
         testGcmDecryption(kHex, pHex, ivHex, aadHex, cHex, tHex);
@@ -120,24 +120,24 @@ public class GcmCipherTest {
         // iv length:           8 bytes
         // aad length:          20 bytes
 
-        String kHex = "feffe9928665731c6d6a8f9467308308";
+        final String kHex = "feffe9928665731c6d6a8f9467308308";
 
-        String pHex = "d9313225f88406e5a55909c5aff5269a"
+        final String pHex = "d9313225f88406e5a55909c5aff5269a"
                 + "86a7a9531534f7da2e4c303d8a318a72"
                 + "1c3c0c95956809532fcf0e2449a6b525"
                 + "b16aedf5aa0de657ba637b39";
 
-        String ivHex ="cafebabefacedbad"; // 64bits < 96bits
+        final String ivHex ="cafebabefacedbad"; // 64bits < 96bits
 
-        String aadHex="feedfacedeadbeeffeedfacedeadbeef"
+        final String aadHex="feedfacedeadbeeffeedfacedeadbeef"
                 + "abaddad2";
 
-        String cHex = "61353b4c2806934a777ff51fa22a4755"
+        final String cHex = "61353b4c2806934a777ff51fa22a4755"
                 + "699b2a714fcdc6f83766e5f97b6c7423"
                 + "73806900e49f24b22b097544d4896b42"
                 + "4989b5e1ebac0f07c23f4598";
 
-        String tHex = "3612d2e79e3b0785561be14aaca2fccb";
+        final String tHex = "3612d2e79e3b0785561be14aaca2fccb";
 
         testGcmEncryption(kHex, pHex, ivHex, aadHex, cHex, tHex);
         testGcmDecryption(kHex, pHex, ivHex, aadHex, cHex, tHex);
@@ -153,27 +153,27 @@ public class GcmCipherTest {
         // iv length:           60 bytes
         // aad length:          20 bytes
 
-        String kHex = "feffe9928665731c6d6a8f9467308308";
+        final String kHex = "feffe9928665731c6d6a8f9467308308";
 
-        String pHex = "d9313225f88406e5a55909c5aff5269a"
+        final String pHex = "d9313225f88406e5a55909c5aff5269a"
                 + "86a7a9531534f7da2e4c303d8a318a72"
                 + "1c3c0c95956809532fcf0e2449a6b525"
                 + "b16aedf5aa0de657ba637b39";
 
-        String ivHex ="9313225df88406e555909c5aff5269aa"
+        final String ivHex ="9313225df88406e555909c5aff5269aa"
                 + "6a7a9538534f7da1e4c303d2a318a728"
                 + "c3c0c95156809539fcf0e2429a6b5254"
                 + "16aedbf5a0de6a57a637b39b"; // > 96bits
 
-        String aadHex="feedfacedeadbeeffeedfacedeadbeef"
+        final String aadHex="feedfacedeadbeeffeedfacedeadbeef"
                 + "abaddad2";
 
-        String cHex = "8ce24998625615b603a033aca13fb894"
+        final String cHex = "8ce24998625615b603a033aca13fb894"
                 + "be9112a5c3a211a8ba262a3cca7e2ca7"
                 + "01e4a9a4fba43c90ccdcb281d48c7c6f"
                 + "d62875d2aca417034c34aee5";
 
-        String tHex = "619cc5aefffe0bfa462af43c1699d050";
+        final String tHex = "619cc5aefffe0bfa462af43c1699d050";
 
         testGcmEncryption(kHex, pHex, ivHex, aadHex, cHex, tHex);
         testGcmDecryption(kHex, pHex, ivHex, aadHex, cHex, tHex);
@@ -196,31 +196,31 @@ public class GcmCipherTest {
     @Test(expected = AEADBadTagException.class)
     public void testGcmTamperedData() throws Exception {
 
-        Random r = new Random();
-        int textLength = r.nextInt(1024*1024);
-        int ivLength = r.nextInt(60);
-        int keyLength = 16;
-        int tagLength = 128;  // bits
-        int aadLength = r.nextInt(128);
+        final Random r = new Random();
+        final int textLength = r.nextInt(1024*1024);
+        final int ivLength = r.nextInt(60);
+        final int keyLength = 16;
+        final int tagLength = 128;  // bits
+        final int aadLength = r.nextInt(128);
 
-        byte[] keyBytes = new byte[keyLength];
-        byte[] plainBytes = new byte[textLength];
-        byte[] ivBytes = new byte[ivLength];
-        byte[] aadBytes = new byte[aadLength];
+        final byte[] keyBytes = new byte[keyLength];
+        final byte[] plainBytes = new byte[textLength];
+        final byte[] ivBytes = new byte[ivLength];
+        final byte[] aadBytes = new byte[aadLength];
 
         r.nextBytes(keyBytes);
         r.nextBytes(plainBytes);
         r.nextBytes(ivBytes);
         r.nextBytes(aadBytes);
 
-        byte[] encOutput = new byte[plainBytes.length + (tagLength >> 3)];
-        byte[] decOutput = new byte[plainBytes.length];
+        final byte[] encOutput = new byte[plainBytes.length + (tagLength >> 3)];
+        final byte[] decOutput = new byte[plainBytes.length];
 
         {
-            CryptoCipher c = Utils.getCipherInstance(transformation, props);
-            Key key = new SecretKeySpec(keyBytes, "AES");
+            final CryptoCipher c = Utils.getCipherInstance(transformation, props);
+            final Key key = new SecretKeySpec(keyBytes, "AES");
 
-            GCMParameterSpec iv = new GCMParameterSpec(tagLength, ivBytes);
+            final GCMParameterSpec iv = new GCMParameterSpec(tagLength, ivBytes);
             c.init(Cipher.ENCRYPT_MODE, key, iv);
             c.updateAAD(aadBytes);
             c.doFinal(plainBytes, 0, plainBytes.length, encOutput, 0);
@@ -231,16 +231,16 @@ public class GcmCipherTest {
         encOutput[0] = (byte)(encOutput[0] + 1);
 
         try {
-            CryptoCipher c = Utils.getCipherInstance(transformation, props);
-            Key key = new SecretKeySpec(keyBytes, "AES");
+            final CryptoCipher c = Utils.getCipherInstance(transformation, props);
+            final Key key = new SecretKeySpec(keyBytes, "AES");
 
-            GCMParameterSpec iv = new GCMParameterSpec(tagLength, ivBytes);
+            final GCMParameterSpec iv = new GCMParameterSpec(tagLength, ivBytes);
             c.init(Cipher.DECRYPT_MODE, key, iv);
             c.updateAAD(aadBytes);
             c.doFinal(encOutput, 0, encOutput.length, decOutput, 0);
             c.close();
         }
-        catch (AEADBadTagException ex) {
+        catch (final AEADBadTagException ex) {
             Assert.assertTrue("Tag mismatch!".equals(ex.getMessage()));
             throw ex;
         }
@@ -251,16 +251,16 @@ public class GcmCipherTest {
         // for GMAC,  aad is the input data,
         // tag is the digest message
 
-        Random r = new Random();
-        byte[] keyBytes = new byte[32];
-        byte[] input = new byte[0];  // no input for GMAC
-        byte[] ivBytes = new byte[16];
+        final Random r = new Random();
+        final byte[] keyBytes = new byte[32];
+        final byte[] input = new byte[0];  // no input for GMAC
+        final byte[] ivBytes = new byte[16];
 
-        byte[] tag_orig = new byte[16]; // JDK's tag
-        byte[] tag = new byte[16];
+        final byte[] tag_orig = new byte[16]; // JDK's tag
+        final byte[] tag = new byte[16];
 
         // aad is the data to be hashed
-        byte[] aad = new byte[r.nextInt() % 1000 + 1000 ];
+        final byte[] aad = new byte[r.nextInt() % 1000 + 1000 ];
 
         r.nextBytes(keyBytes);
         r.nextBytes(input);
@@ -268,18 +268,18 @@ public class GcmCipherTest {
         r.nextBytes(aad);
 
         {
-            Cipher c = Cipher.getInstance(transformation);
-            Key key = new SecretKeySpec(keyBytes, "AES");
-            GCMParameterSpec iv = new GCMParameterSpec(128, ivBytes);
+            final Cipher c = Cipher.getInstance(transformation);
+            final Key key = new SecretKeySpec(keyBytes, "AES");
+            final GCMParameterSpec iv = new GCMParameterSpec(128, ivBytes);
             c.init(Cipher.ENCRYPT_MODE, key, iv);
             c.updateAAD(aad);
             c.doFinal(input, 0, input.length, tag_orig, 0);
         }
 
         {
-            CryptoCipher c = Utils.getCipherInstance(transformation, props);
-            Key key = new SecretKeySpec(keyBytes, "AES");
-            GCMParameterSpec iv = new GCMParameterSpec(128, ivBytes);
+            final CryptoCipher c = Utils.getCipherInstance(transformation, props);
+            final Key key = new SecretKeySpec(keyBytes, "AES");
+            final GCMParameterSpec iv = new GCMParameterSpec(128, ivBytes);
             c.init(Cipher.ENCRYPT_MODE, key, iv);
             c.updateAAD(aad);
             c.doFinal(input, 0, input.length, tag, 0);
@@ -292,9 +292,9 @@ public class GcmCipherTest {
         // like JDK's decrypt mode. The plaintext+tag is the input for decrypt mode
         // let's verify the add & tag now
         {
-            CryptoCipher c = Utils.getCipherInstance(transformation, props);
-            Key key = new SecretKeySpec(keyBytes, "AES");
-            GCMParameterSpec iv = new GCMParameterSpec(128, ivBytes);
+            final CryptoCipher c = Utils.getCipherInstance(transformation, props);
+            final Key key = new SecretKeySpec(keyBytes, "AES");
+            final GCMParameterSpec iv = new GCMParameterSpec(128, ivBytes);
             c.init(Cipher.DECRYPT_MODE, key, iv);
             c.updateAAD(aad);
             c.doFinal(tag, 0, tag.length, input, 0);
@@ -304,14 +304,14 @@ public class GcmCipherTest {
 
     @Test(expected = AEADBadTagException.class)
     public void testGMacTamperedData() throws Exception {
-        Random r = new Random();
-        byte[] keyBytes = new byte[32];
-        byte[] input = new byte[0];
-        byte[] ivBytes = new byte[16];
+        final Random r = new Random();
+        final byte[] keyBytes = new byte[32];
+        final byte[] input = new byte[0];
+        final byte[] ivBytes = new byte[16];
 
-        byte[] tag = new byte[16];
+        final byte[] tag = new byte[16];
 
-        byte[] aad = new byte[r.nextInt() % 1000 + 1000 ];
+        final byte[] aad = new byte[r.nextInt() % 1000 + 1000 ];
 
         r.nextBytes(keyBytes);
         r.nextBytes(input);
@@ -319,9 +319,9 @@ public class GcmCipherTest {
         r.nextBytes(aad);
 
         {
-            CryptoCipher c = Utils.getCipherInstance(transformation, props);
-            Key key = new SecretKeySpec(keyBytes, "AES");
-            GCMParameterSpec iv = new GCMParameterSpec(128, ivBytes);
+            final CryptoCipher c = Utils.getCipherInstance(transformation, props);
+            final Key key = new SecretKeySpec(keyBytes, "AES");
+            final GCMParameterSpec iv = new GCMParameterSpec(128, ivBytes);
             c.init(Cipher.ENCRYPT_MODE, key, iv);
             c.updateAAD(aad);
             c.doFinal(input, 0, input.length, tag, 0);
@@ -330,9 +330,9 @@ public class GcmCipherTest {
 
         try {
             // like JDK's decrypt mode. The plaintext+tag is the input for decrypt mode
-            CryptoCipher c = Utils.getCipherInstance(transformation, props);
-            Key key = new SecretKeySpec(keyBytes, "AES");
-            GCMParameterSpec iv = new GCMParameterSpec(128, ivBytes);
+            final CryptoCipher c = Utils.getCipherInstance(transformation, props);
+            final Key key = new SecretKeySpec(keyBytes, "AES");
+            final GCMParameterSpec iv = new GCMParameterSpec(128, ivBytes);
             c.init(Cipher.DECRYPT_MODE, key, iv);
 
             // if the origin data is tampered
@@ -343,28 +343,28 @@ public class GcmCipherTest {
             c.close();
 
         }
-        catch (AEADBadTagException ex) {
+        catch (final AEADBadTagException ex) {
             Assert.assertTrue("Tag mismatch!".equals(ex.getMessage()));
             throw ex;
         }
     }
 
-    private void testGcmEncryption(String kHex, String pHex, String ivHex, String aadHex,
-                                   String cHex, String tHex) throws Exception {
+    private void testGcmEncryption(final String kHex, final String pHex, final String ivHex, final String aadHex,
+                                   final String cHex, final String tHex) throws Exception {
 
-        byte[] keyBytes = DatatypeConverter.parseHexBinary(kHex);
-        byte[] input = DatatypeConverter.parseHexBinary(pHex);
-        byte[] ivBytes = DatatypeConverter.parseHexBinary(ivHex);
-        byte[] aad = DatatypeConverter.parseHexBinary(aadHex);
-        byte[] expectedOutput = DatatypeConverter.parseHexBinary(cHex+tHex);
+        final byte[] keyBytes = DatatypeConverter.parseHexBinary(kHex);
+        final byte[] input = DatatypeConverter.parseHexBinary(pHex);
+        final byte[] ivBytes = DatatypeConverter.parseHexBinary(ivHex);
+        final byte[] aad = DatatypeConverter.parseHexBinary(aadHex);
+        final byte[] expectedOutput = DatatypeConverter.parseHexBinary(cHex+tHex);
 
-        byte[] output = new byte[expectedOutput.length];
+        final byte[] output = new byte[expectedOutput.length];
 
-        CryptoCipher c = Utils.getCipherInstance(transformation, props);
+        final CryptoCipher c = Utils.getCipherInstance(transformation, props);
 
-        Key key = new SecretKeySpec(keyBytes, "AES");
+        final Key key = new SecretKeySpec(keyBytes, "AES");
 
-        GCMParameterSpec iv = new GCMParameterSpec(128, ivBytes);
+        final GCMParameterSpec iv = new GCMParameterSpec(128, ivBytes);
         c.init(Cipher.ENCRYPT_MODE, key, iv);
         c.updateAAD(aad);
 
@@ -374,28 +374,28 @@ public class GcmCipherTest {
         c.close();
     }
 
-    private void testGcmArbitraryLengthUpdate(String kHex, String pHex, String ivHex, String aadHex,
-                                              String cHex, String tHex) throws Exception {
+    private void testGcmArbitraryLengthUpdate(final String kHex, final String pHex, final String ivHex, final String aadHex,
+                                              final String cHex, final String tHex) throws Exception {
 
-        byte[] keyBytes = DatatypeConverter.parseHexBinary(kHex);
-        byte[] input = DatatypeConverter.parseHexBinary(pHex);
-        byte[] ivBytes = DatatypeConverter.parseHexBinary(ivHex);
-        byte[] aad = DatatypeConverter.parseHexBinary(aadHex);
-        byte[] expectedOutput = DatatypeConverter.parseHexBinary(cHex+tHex);
+        final byte[] keyBytes = DatatypeConverter.parseHexBinary(kHex);
+        final byte[] input = DatatypeConverter.parseHexBinary(pHex);
+        final byte[] ivBytes = DatatypeConverter.parseHexBinary(ivHex);
+        final byte[] aad = DatatypeConverter.parseHexBinary(aadHex);
+        final byte[] expectedOutput = DatatypeConverter.parseHexBinary(cHex+tHex);
 
-        byte[] encOutput = new byte[expectedOutput.length];
-        byte[] decOutput = new byte[input.length];
+        final byte[] encOutput = new byte[expectedOutput.length];
+        final byte[] decOutput = new byte[input.length];
 
-        Random r = new Random();
+        final Random r = new Random();
 
-        CryptoCipher enc = Utils.getCipherInstance(transformation, props);
-        Key key = new SecretKeySpec(keyBytes, "AES");
-        GCMParameterSpec iv = new GCMParameterSpec(128, ivBytes);
+        final CryptoCipher enc = Utils.getCipherInstance(transformation, props);
+        final Key key = new SecretKeySpec(keyBytes, "AES");
+        final GCMParameterSpec iv = new GCMParameterSpec(128, ivBytes);
         enc.init(Cipher.ENCRYPT_MODE, key, iv);
         if (aad.length > 0) {
-            int len1 = r.nextInt(aad.length) ;
-            byte[] aad1 = Arrays.copyOfRange(aad, 0, len1);
-            byte[] aad2 = Arrays.copyOfRange(aad, len1, aad.length);
+            final int len1 = r.nextInt(aad.length) ;
+            final byte[] aad1 = Arrays.copyOfRange(aad, 0, len1);
+            final byte[] aad2 = Arrays.copyOfRange(aad, len1, aad.length);
             enc.updateAAD(aad1);
             enc.updateAAD(aad2);
         }
@@ -410,17 +410,17 @@ public class GcmCipherTest {
         enc.close();
 
         // Decryption
-        CryptoCipher dec = Utils.getCipherInstance(transformation, props);
+        final CryptoCipher dec = Utils.getCipherInstance(transformation, props);
         dec.init(Cipher.DECRYPT_MODE, new SecretKeySpec(keyBytes, "AES"),
                 new GCMParameterSpec(128, ivBytes));
         if (aad.length > 0) {
-            int len1 = r.nextInt(aad.length) ;
-            byte[] aad1 = Arrays.copyOfRange(aad, 0, len1);
-            byte[] aad2 = Arrays.copyOfRange(aad, len1, aad.length);
+            final int len1 = r.nextInt(aad.length) ;
+            final byte[] aad1 = Arrays.copyOfRange(aad, 0, len1);
+            final byte[] aad2 = Arrays.copyOfRange(aad, len1, aad.length);
             dec.updateAAD(aad1);
             dec.updateAAD(aad2);
         }
-        byte[] decInput = encOutput;
+        final byte[] decInput = encOutput;
         partLen = r.nextInt(input.length);
         len = dec.update(decInput, 0, partLen, decOutput, 0);
         Assert.assertTrue(len == 0);
@@ -431,24 +431,24 @@ public class GcmCipherTest {
         dec.close();
     }
 
-    private void testGcmDecryption(String kHex, String pHex, String ivHex, String aadHex,
-                                   String cHex, String tHex) throws Exception {
+    private void testGcmDecryption(final String kHex, final String pHex, final String ivHex, final String aadHex,
+                                   final String cHex, final String tHex) throws Exception {
 
-        byte[] keyBytes = DatatypeConverter.parseHexBinary(kHex);
-        byte[] plainBytes = DatatypeConverter.parseHexBinary(pHex);
-        byte[] ivBytes = DatatypeConverter.parseHexBinary(ivHex);
+        final byte[] keyBytes = DatatypeConverter.parseHexBinary(kHex);
+        final byte[] plainBytes = DatatypeConverter.parseHexBinary(pHex);
+        final byte[] ivBytes = DatatypeConverter.parseHexBinary(ivHex);
 
-        byte[] aad = DatatypeConverter.parseHexBinary(aadHex);
-        byte[] cipherBytes = DatatypeConverter.parseHexBinary(cHex+tHex);
+        final byte[] aad = DatatypeConverter.parseHexBinary(aadHex);
+        final byte[] cipherBytes = DatatypeConverter.parseHexBinary(cHex+tHex);
 
-        byte[] input = cipherBytes;
-        byte[] output = new byte[plainBytes.length];
+        final byte[] input = cipherBytes;
+        final byte[] output = new byte[plainBytes.length];
 
-        CryptoCipher c = Utils.getCipherInstance(transformation, props);
+        final CryptoCipher c = Utils.getCipherInstance(transformation, props);
 
-        Key key = new SecretKeySpec(keyBytes, "AES");
+        final Key key = new SecretKeySpec(keyBytes, "AES");
 
-        GCMParameterSpec iv = new GCMParameterSpec(128, ivBytes);
+        final GCMParameterSpec iv = new GCMParameterSpec(128, ivBytes);
         c.init(Cipher.DECRYPT_MODE, key, iv);
         c.updateAAD(aad);
         c.doFinal(input, 0, input.length, output, 0);
@@ -457,24 +457,24 @@ public class GcmCipherTest {
         c.close();
     }
 
-    private void testGcmReturnDataAfterTagVerified(String kHex, String pHex, String ivHex, String aadHex,
-                                                   String cHex, String tHex) throws Exception {
+    private void testGcmReturnDataAfterTagVerified(final String kHex, final String pHex, final String ivHex, final String aadHex,
+                                                   final String cHex, final String tHex) throws Exception {
 
-        byte[] keyBytes = DatatypeConverter.parseHexBinary(kHex);
-        byte[] plainBytes = DatatypeConverter.parseHexBinary(pHex);
-        byte[] ivBytes = DatatypeConverter.parseHexBinary(ivHex);
+        final byte[] keyBytes = DatatypeConverter.parseHexBinary(kHex);
+        final byte[] plainBytes = DatatypeConverter.parseHexBinary(pHex);
+        final byte[] ivBytes = DatatypeConverter.parseHexBinary(ivHex);
 
-        byte[] aad = DatatypeConverter.parseHexBinary(aadHex);
-        byte[] cipherBytes = DatatypeConverter.parseHexBinary(cHex+tHex);
+        final byte[] aad = DatatypeConverter.parseHexBinary(aadHex);
+        final byte[] cipherBytes = DatatypeConverter.parseHexBinary(cHex+tHex);
 
-        byte[] input = cipherBytes;
-        byte[] output = new byte[plainBytes.length];
+        final byte[] input = cipherBytes;
+        final byte[] output = new byte[plainBytes.length];
 
-        CryptoCipher c = Utils.getCipherInstance(transformation, props);
+        final CryptoCipher c = Utils.getCipherInstance(transformation, props);
 
-        Key key = new SecretKeySpec(keyBytes, "AES");
+        final Key key = new SecretKeySpec(keyBytes, "AES");
 
-        GCMParameterSpec iv = new GCMParameterSpec(128, ivBytes);
+        final GCMParameterSpec iv = new GCMParameterSpec(128, ivBytes);
         c.init(Cipher.DECRYPT_MODE, key, iv);
         c.updateAAD(aad);
 
@@ -488,19 +488,19 @@ public class GcmCipherTest {
         c.close();
     }
 
-    private void testGcmByteBuffer(String kHex, String pHex, String ivHex, String aadHex,
-                                   String cHex, String tHex) throws Exception {
+    private void testGcmByteBuffer(final String kHex, final String pHex, final String ivHex, final String aadHex,
+                                   final String cHex, final String tHex) throws Exception {
 
-        byte[] keyBytes = DatatypeConverter.parseHexBinary(kHex);
-        byte[] plainText = DatatypeConverter.parseHexBinary(pHex);
-        byte[] ivBytes = DatatypeConverter.parseHexBinary(ivHex);
-        byte[] aad = DatatypeConverter.parseHexBinary(aadHex);
-        byte[] cipherText = DatatypeConverter.parseHexBinary(cHex+tHex);
+        final byte[] keyBytes = DatatypeConverter.parseHexBinary(kHex);
+        final byte[] plainText = DatatypeConverter.parseHexBinary(pHex);
+        final byte[] ivBytes = DatatypeConverter.parseHexBinary(ivHex);
+        final byte[] aad = DatatypeConverter.parseHexBinary(aadHex);
+        final byte[] cipherText = DatatypeConverter.parseHexBinary(cHex+tHex);
 
-        byte[] encOutput = new byte[cipherText.length];
-        byte[] decOutput = new byte[plainText.length];
+        final byte[] encOutput = new byte[cipherText.length];
+        final byte[] decOutput = new byte[plainText.length];
 
-        ByteBuffer bfAAD = ByteBuffer.allocateDirect(aad.length);
+        final ByteBuffer bfAAD = ByteBuffer.allocateDirect(aad.length);
         bfAAD.put(aad);
 
         ByteBuffer bfPlainText;
@@ -509,9 +509,9 @@ public class GcmCipherTest {
         bfCipherText = ByteBuffer.allocateDirect(encOutput.length);
 
         // Encryption -------------------
-        CryptoCipher c = Utils.getCipherInstance(transformation, props);
-        Key key = new SecretKeySpec(keyBytes, "AES");
-        GCMParameterSpec iv = new GCMParameterSpec(128, ivBytes);
+        final CryptoCipher c = Utils.getCipherInstance(transformation, props);
+        final Key key = new SecretKeySpec(keyBytes, "AES");
+        final GCMParameterSpec iv = new GCMParameterSpec(128, ivBytes);
         c.init(Cipher.ENCRYPT_MODE, key, iv);
 
         bfAAD.flip();
@@ -529,7 +529,7 @@ public class GcmCipherTest {
         c.close();
 
         // Decryption -------------------
-        CryptoCipher dec = Utils.getCipherInstance(transformation, props);
+        final CryptoCipher dec = Utils.getCipherInstance(transformation, props);
         dec.init(Cipher.DECRYPT_MODE, new SecretKeySpec(keyBytes, "AES"),
                 new GCMParameterSpec(128, ivBytes));
         bfAAD.flip();
@@ -547,7 +547,7 @@ public class GcmCipherTest {
 
     private void initTestData() {
 
-        int casesNumber = 4;
+        final int casesNumber = 4;
 
         kHex = new String[casesNumber];
         pHex = new String[casesNumber];
diff --git a/src/test/java/org/apache/commons/crypto/cipher/JceCipherTest.java b/src/test/java/org/apache/commons/crypto/cipher/JceCipherTest.java
index 33eca8b..d5d481e 100644
--- a/src/test/java/org/apache/commons/crypto/cipher/JceCipherTest.java
+++ b/src/test/java/org/apache/commons/crypto/cipher/JceCipherTest.java
@@ -40,7 +40,7 @@ public class JceCipherTest extends AbstractCipherTest {
 
     @BeforeClass
     public static void checkJceUnlimitedStrength() throws NoSuchAlgorithmException {
-        int maxKeyLen = Cipher.getMaxAllowedKeyLength("AES");
+        final int maxKeyLen = Cipher.getMaxAllowedKeyLength("AES");
         Assert.assertTrue(String.format(
                 "Testing requires support for an AES key length of %d, but " +
                 "the detected maximum key length is %d.  This may indicate " +
diff --git a/src/test/java/org/apache/commons/crypto/cipher/OpenSslCipherTest.java b/src/test/java/org/apache/commons/crypto/cipher/OpenSslCipherTest.java
index 98fc325..b77a698 100644
--- a/src/test/java/org/apache/commons/crypto/cipher/OpenSslCipherTest.java
+++ b/src/test/java/org/apache/commons/crypto/cipher/OpenSslCipherTest.java
@@ -59,7 +59,7 @@ public class OpenSslCipherTest extends AbstractCipherTest {
     @Test(timeout = 120000)
     public void testUpdateArguments() throws Exception {
         Assume.assumeTrue(OpenSsl.getLoadingFailureReason() == null);
-        OpenSsl cipher = OpenSsl
+        final OpenSsl cipher = OpenSsl
                 .getInstance("AES/CTR/NoPadding");
         Assert.assertNotNull(cipher);
 
@@ -72,7 +72,7 @@ public class OpenSslCipherTest extends AbstractCipherTest {
         try {
             cipher.update(input, output);
             Assert.fail("Should have failed to accept non-direct buffers.");
-        } catch (IllegalArgumentException e) {
+        } catch (final IllegalArgumentException e) {
             Assert.assertTrue(e.getMessage().contains(
                     "Direct buffers are required"));
         }
@@ -83,7 +83,7 @@ public class OpenSslCipherTest extends AbstractCipherTest {
         try {
             cipher.update(input, output);
             Assert.fail("Failed to check for output buffer size.");
-        } catch (ShortBufferException e) {
+        } catch (final ShortBufferException e) {
             Assert.assertTrue(e.getMessage().contains(
                     "Output buffer is not sufficient"));
         }
@@ -92,20 +92,20 @@ public class OpenSslCipherTest extends AbstractCipherTest {
     @Test(timeout = 120000)
     public void testDoFinalArguments() throws Exception {
         Assume.assumeTrue(OpenSsl.getLoadingFailureReason() == null);
-        OpenSsl cipher = OpenSsl
+        final OpenSsl cipher = OpenSsl
                 .getInstance("AES/CTR/NoPadding");
         Assert.assertNotNull(cipher);
 
         cipher.init(OpenSsl.ENCRYPT_MODE, KEY, new IvParameterSpec(IV));
 
         // Require direct buffer
-        ByteBuffer input = ByteBuffer.allocate(1024);
-        ByteBuffer output = ByteBuffer.allocate(1024);
+        final ByteBuffer input = ByteBuffer.allocate(1024);
+        final ByteBuffer output = ByteBuffer.allocate(1024);
 
         try {
             cipher.doFinal(input, output);
             Assert.fail("Should have failed to accept non-direct buffers.");
-        } catch (IllegalArgumentException e) {
+        } catch (final IllegalArgumentException e) {
             Assert.assertTrue(e.getMessage().contains(
                     "Direct buffer is required"));
         }
@@ -114,7 +114,7 @@ public class OpenSslCipherTest extends AbstractCipherTest {
     @Test(expected = InvalidKeyException.class, timeout = 120000)
     public void testInvalidKey() throws Exception {
         Assume.assumeTrue(OpenSsl.getLoadingFailureReason() == null);
-        OpenSsl cipher = OpenSsl
+        final OpenSsl cipher = OpenSsl
                 .getInstance("AES/CTR/NoPadding");
         Assert.assertNotNull(cipher);
 
@@ -126,7 +126,7 @@ public class OpenSslCipherTest extends AbstractCipherTest {
     @Test(expected = InvalidAlgorithmParameterException.class, timeout = 120000)
     public void testInvalidIV() throws Exception {
         Assume.assumeTrue(OpenSsl.getLoadingFailureReason() == null);
-        OpenSsl cipher = OpenSsl
+        final OpenSsl cipher = OpenSsl
                 .getInstance("AES/CTR/NoPadding");
         Assert.assertNotNull(cipher);
 
@@ -141,7 +141,7 @@ public class OpenSslCipherTest extends AbstractCipherTest {
             try {
                 cipher.update(dummyBuffer(), dummyBuffer());
                 Assert.fail("Should have thrown exception.");
-            } catch (IllegalStateException ise) {
+            } catch (final IllegalStateException ise) {
                 // expected;
             }
 
@@ -153,7 +153,7 @@ public class OpenSslCipherTest extends AbstractCipherTest {
                 cipher.init(OpenSsl.ENCRYPT_MODE, new SecretKeySpec(new byte[1], "AES"),
                     new IvParameterSpec(IV));
                 Assert.fail("Should have thrown exception.");
-            } catch (InvalidKeyException ike) {
+            } catch (final InvalidKeyException ike) {
                 // expected;
             }
 
@@ -165,7 +165,7 @@ public class OpenSslCipherTest extends AbstractCipherTest {
             try {
                 cipher.update(dummyBuffer(), dummyBuffer());
                 Assert.fail("Should have thrown exception.");
-            } catch (IllegalStateException ise) {
+            } catch (final IllegalStateException ise) {
                 // expected;
             }
 
diff --git a/src/test/java/org/apache/commons/crypto/cipher/TestData.java b/src/test/java/org/apache/commons/crypto/cipher/TestData.java
index 3c73ea8..966f15f 100644
--- a/src/test/java/org/apache/commons/crypto/cipher/TestData.java
+++ b/src/test/java/org/apache/commons/crypto/cipher/TestData.java
@@ -144,7 +144,7 @@ public class TestData {
         testData.put("AES/CTR/NoPadding", cipherCTRTests);
     }
 
-    public static String[] getTestData(String transformation) {
+    public static String[] getTestData(final String transformation) {
         return testData.get(transformation);
     }
 }
diff --git a/src/test/java/org/apache/commons/crypto/examples/CipherByteArrayExample.java b/src/test/java/org/apache/commons/crypto/examples/CipherByteArrayExample.java
index 61f13ad..3e78e24 100644
--- a/src/test/java/org/apache/commons/crypto/examples/CipherByteArrayExample.java
+++ b/src/test/java/org/apache/commons/crypto/examples/CipherByteArrayExample.java
@@ -35,31 +35,31 @@ import org.apache.commons.crypto.utils.Utils;
  */
 public class CipherByteArrayExample {
 
-    public static void main(String[] args) throws Exception {
+    public static void main(final String[] args) throws Exception {
 
         final SecretKeySpec key = new SecretKeySpec(getUTF8Bytes("1234567890123456"),"AES");
         final IvParameterSpec iv = new IvParameterSpec(getUTF8Bytes("1234567890123456"));
 
-        Properties properties = new Properties();
+        final Properties properties = new Properties();
         properties.setProperty(CryptoCipherFactory.CLASSES_KEY, CipherProvider.OPENSSL.getClassName());
         //Creates a CryptoCipher instance with the transformation and properties.
         final String transform = "AES/CBC/PKCS5Padding";
-        CryptoCipher encipher = Utils.getCipherInstance(transform, properties);
+        final CryptoCipher encipher = Utils.getCipherInstance(transform, properties);
         System.out.println("Cipher:  " + encipher.getClass().getCanonicalName());
 
         final String sampleInput = "hello world!";
         System.out.println("input:  " + sampleInput);
 
-        byte[] input = getUTF8Bytes(sampleInput);
-        byte[] output = new byte[32];
+        final byte[] input = getUTF8Bytes(sampleInput);
+        final byte[] output = new byte[32];
 
         //Initializes the cipher with ENCRYPT_MODE, key and iv.
         encipher.init(Cipher.ENCRYPT_MODE, key, iv);
         //Continues a multiple-part encryption/decryption operation for byte array.
-        int updateBytes = encipher.update(input, 0, input.length, output, 0);
+        final int updateBytes = encipher.update(input, 0, input.length, output, 0);
         System.out.println(updateBytes);
         //We must call doFinal at the end of encryption/decryption.
-        int finalBytes = encipher.doFinal(input, 0, 0, output, updateBytes);
+        final int finalBytes = encipher.doFinal(input, 0, 0, output, updateBytes);
         System.out.println(finalBytes);
         //Closes the cipher.
         encipher.close();
@@ -68,11 +68,11 @@ public class CipherByteArrayExample {
 
         // Now reverse the process using a different implementation with the same settings
         properties.setProperty(CryptoCipherFactory.CLASSES_KEY, CipherProvider.JCE.getClassName());
-        CryptoCipher decipher = Utils.getCipherInstance(transform, properties);
+        final CryptoCipher decipher = Utils.getCipherInstance(transform, properties);
         System.out.println("Cipher:  " + encipher.getClass().getCanonicalName());
 
         decipher.init(Cipher.DECRYPT_MODE, key, iv);
-        byte [] decoded = new byte[32];
+        final byte [] decoded = new byte[32];
         decipher.doFinal(output, 0, updateBytes + finalBytes, decoded, 0);
 
         System.out.println("output: " + new String(decoded, StandardCharsets.UTF_8));
@@ -84,7 +84,7 @@ public class CipherByteArrayExample {
      * @param input the input string
      * @return UTF8 bytes
      */
-    private static byte[] getUTF8Bytes(String input) {
+    private static byte[] getUTF8Bytes(final String input) {
         return input.getBytes(StandardCharsets.UTF_8);
     }
 
diff --git a/src/test/java/org/apache/commons/crypto/examples/CipherByteBufferExample.java b/src/test/java/org/apache/commons/crypto/examples/CipherByteBufferExample.java
index 9a0f010..7023b2d 100644
--- a/src/test/java/org/apache/commons/crypto/examples/CipherByteBufferExample.java
+++ b/src/test/java/org/apache/commons/crypto/examples/CipherByteBufferExample.java
@@ -34,10 +34,10 @@ import org.apache.commons.crypto.utils.Utils;
  */
 public class CipherByteBufferExample {
 
-    public static void main(String[] args) throws Exception {
+    public static void main(final String[] args) throws Exception {
         final SecretKeySpec key = new SecretKeySpec(getUTF8Bytes("1234567890123456"), "AES");
         final IvParameterSpec iv = new IvParameterSpec(getUTF8Bytes("1234567890123456"));
-        Properties properties = new Properties();
+        final Properties properties = new Properties();
         //Creates a CryptoCipher instance with the transformation and properties.
         final String transform = "AES/CBC/PKCS5Padding";
         final ByteBuffer outBuffer;
@@ -46,7 +46,7 @@ public class CipherByteBufferExample {
         final int finalBytes;
         try (CryptoCipher encipher = Utils.getCipherInstance(transform, properties)) {
 
-            ByteBuffer inBuffer = ByteBuffer.allocateDirect(bufferSize);
+            final ByteBuffer inBuffer = ByteBuffer.allocateDirect(bufferSize);
             outBuffer = ByteBuffer.allocateDirect(bufferSize);
             inBuffer.put(getUTF8Bytes("hello world!"));
 
@@ -66,14 +66,14 @@ public class CipherByteBufferExample {
         }
 
         outBuffer.flip(); // ready for use as decrypt
-        byte [] encoded = new byte[updateBytes + finalBytes];
+        final byte [] encoded = new byte[updateBytes + finalBytes];
         outBuffer.duplicate().get(encoded);
         System.out.println(Arrays.toString(encoded));
 
         // Now reverse the process
         try (CryptoCipher decipher = Utils.getCipherInstance(transform, properties)) {
             decipher.init(Cipher.DECRYPT_MODE, key, iv);
-            ByteBuffer decoded = ByteBuffer.allocateDirect(bufferSize);
+            final ByteBuffer decoded = ByteBuffer.allocateDirect(bufferSize);
             decipher.update(outBuffer, decoded);
             decipher.doFinal(outBuffer, decoded);
             decoded.flip(); // ready for use
@@ -87,7 +87,7 @@ public class CipherByteBufferExample {
      * @param input the input string
      * @return UTF8 bytes
      */
-    private static byte[] getUTF8Bytes(String input) {
+    private static byte[] getUTF8Bytes(final String input) {
         return input.getBytes(StandardCharsets.UTF_8);
     }
 
@@ -97,7 +97,7 @@ public class CipherByteBufferExample {
      * @param buffer input byte buffer
      * @return the converted string
      */
-    private static String asString(ByteBuffer buffer) {
+    private static String asString(final ByteBuffer buffer) {
         final ByteBuffer copy = buffer.duplicate();
         final byte[] bytes = new byte[copy.remaining()];
         copy.get(bytes);
diff --git a/src/test/java/org/apache/commons/crypto/examples/RandomExample.java b/src/test/java/org/apache/commons/crypto/examples/RandomExample.java
index 5505ee5..ccdf320 100644
--- a/src/test/java/org/apache/commons/crypto/examples/RandomExample.java
+++ b/src/test/java/org/apache/commons/crypto/examples/RandomExample.java
@@ -30,12 +30,12 @@ import org.apache.commons.crypto.random.CryptoRandomFactory;
  */
 public class RandomExample {
 
-    public static void main(String []args) throws GeneralSecurityException, IOException {
+    public static void main(final String []args) throws GeneralSecurityException, IOException {
         // Constructs a byte array to store random data.
-        byte[] key = new byte[16];
-        byte[] iv = new byte[32];
+        final byte[] key = new byte[16];
+        final byte[] iv = new byte[32];
 
-        Properties properties = new Properties();
+        final Properties properties = new Properties();
         properties.put(CryptoRandomFactory.CLASSES_KEY,
             CryptoRandomFactory.RandomProvider.OPENSSL.getClassName());
 
diff --git a/src/test/java/org/apache/commons/crypto/examples/StreamExample.java b/src/test/java/org/apache/commons/crypto/examples/StreamExample.java
index 372475a..fe22c43 100644
--- a/src/test/java/org/apache/commons/crypto/examples/StreamExample.java
+++ b/src/test/java/org/apache/commons/crypto/examples/StreamExample.java
@@ -36,16 +36,16 @@ import org.apache.commons.crypto.stream.CryptoOutputStream;
  */
 public class StreamExample {
 
-    public static void main(String []args) throws IOException {
+    public static void main(final String []args) throws IOException {
         final SecretKeySpec key = new SecretKeySpec(getUTF8Bytes("1234567890123456"),"AES");
         final IvParameterSpec iv = new IvParameterSpec(getUTF8Bytes("1234567890123456"));
-        Properties properties = new Properties();
+        final Properties properties = new Properties();
         final String transform = "AES/CBC/PKCS5Padding";
 
-        String input = "hello world!";
+        final String input = "hello world!";
         //Encryption with CryptoOutputStream.
 
-        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+        final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
 
         try (CryptoOutputStream cos = new CryptoOutputStream(transform, properties, outputStream, key, iv)) {
             cos.write(getUTF8Bytes(input));
@@ -56,10 +56,10 @@ public class StreamExample {
         System.out.println("Encrypted: "+Arrays.toString(outputStream.toByteArray()));
 
         // Decryption with CryptoInputStream.
-        InputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
+        final InputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
 
         try (CryptoInputStream cis = new CryptoInputStream(transform, properties, inputStream, key, iv)) {
-            byte[] decryptedData = new byte[1024];
+            final byte[] decryptedData = new byte[1024];
             int decryptedLen = 0;
             int i;
             while ((i = cis.read(decryptedData, decryptedLen, decryptedData.length - decryptedLen)) > -1) {
@@ -75,7 +75,7 @@ public class StreamExample {
      * @param input the input string
      * @return UTF8 bytes
      */
-    private static byte[] getUTF8Bytes(String input) {
+    private static byte[] getUTF8Bytes(final String input) {
         return input.getBytes(StandardCharsets.UTF_8);
     }
 
diff --git a/src/test/java/org/apache/commons/crypto/jna/AbstractCipherJnaStreamTest.java b/src/test/java/org/apache/commons/crypto/jna/AbstractCipherJnaStreamTest.java
index 5770a3f..b7ab60f 100644
--- a/src/test/java/org/apache/commons/crypto/jna/AbstractCipherJnaStreamTest.java
+++ b/src/test/java/org/apache/commons/crypto/jna/AbstractCipherJnaStreamTest.java
@@ -56,7 +56,7 @@ public abstract class AbstractCipherJnaStreamTest extends AbstractCipherStreamTe
     @Override
     @Test(timeout = 120000)
     public void testByteBufferWrite() throws Exception {
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
         doByteBufferWrite(CIPHER_OPENSSL_JNA, baos, false);
 
         doByteBufferWrite(CIPHER_OPENSSL_JNA, baos, true);
diff --git a/src/test/java/org/apache/commons/crypto/jna/OpenSslJnaCryptoRandomTest.java b/src/test/java/org/apache/commons/crypto/jna/OpenSslJnaCryptoRandomTest.java
index 7c8bb3d..fe23c99 100644
--- a/src/test/java/org/apache/commons/crypto/jna/OpenSslJnaCryptoRandomTest.java
+++ b/src/test/java/org/apache/commons/crypto/jna/OpenSslJnaCryptoRandomTest.java
@@ -38,11 +38,11 @@ public class OpenSslJnaCryptoRandomTest extends AbstractRandomTest {
 
     @Override
     public CryptoRandom getCryptoRandom() throws GeneralSecurityException {
-        Properties props = new Properties();
+        final Properties props = new Properties();
         props.setProperty(
                 CryptoRandomFactory.CLASSES_KEY,
                 OpenSslJnaCryptoRandom.class.getName());
-        CryptoRandom random = CryptoRandomFactory.getCryptoRandom(props);
+        final CryptoRandom random = CryptoRandomFactory.getCryptoRandom(props);
         assertTrue(
                 "The CryptoRandom should be: " + OpenSslJnaCryptoRandom.class.getName(),
                 random instanceof OpenSslJnaCryptoRandom);
diff --git a/src/test/java/org/apache/commons/crypto/random/AbstractRandom.java b/src/test/java/org/apache/commons/crypto/random/AbstractRandom.java
index 313f6c8..da1ac04 100644
--- a/src/test/java/org/apache/commons/crypto/random/AbstractRandom.java
+++ b/src/test/java/org/apache/commons/crypto/random/AbstractRandom.java
@@ -25,7 +25,7 @@ import java.util.Properties;
 abstract class AbstractRandom implements CryptoRandom {
 
     // Should fail to instantiate, as it is an abstract class
-    AbstractRandom(Properties props) {
+    AbstractRandom(final Properties props) {
 
     }
 }
diff --git a/src/test/java/org/apache/commons/crypto/random/AbstractRandomTest.java b/src/test/java/org/apache/commons/crypto/random/AbstractRandomTest.java
index 920b7df..786aaec 100644
--- a/src/test/java/org/apache/commons/crypto/random/AbstractRandomTest.java
+++ b/src/test/java/org/apache/commons/crypto/random/AbstractRandomTest.java
@@ -51,7 +51,7 @@ public abstract class AbstractRandomTest {
             final List<Thread> threads = new ArrayList<>(threadCount);
 
             for (int i = 0; i < threadCount; i++) {
-                Thread t = new Thread(() -> {
+                final Thread t = new Thread(() -> {
                     checkRandomBytes(random, 10);
                     checkRandomBytes(random, 1000);
                     checkRandomBytes(random, 100000);
@@ -60,7 +60,7 @@ public abstract class AbstractRandomTest {
                 threads.add(t);
             }
 
-            for (Thread t : threads) {
+            for (final Thread t : threads) {
                 if (!t.getState().equals(State.NEW)) {
                     t.join();
                 }
@@ -73,9 +73,9 @@ public abstract class AbstractRandomTest {
      * Test will timeout if secure random implementation always returns a
      * constant value.
      */
-    private void checkRandomBytes(CryptoRandom random, int len) {
-        byte[] bytes = new byte[len];
-        byte[] bytes1 = new byte[len];
+    private void checkRandomBytes(final CryptoRandom random, final int len) {
+        final byte[] bytes = new byte[len];
+        final byte[] bytes1 = new byte[len];
         random.nextBytes(bytes);
         random.nextBytes(bytes1);
 
diff --git a/src/test/java/org/apache/commons/crypto/random/CryptoRandomFactoryTest.java b/src/test/java/org/apache/commons/crypto/random/CryptoRandomFactoryTest.java
index f4f1397..e6747cb 100644
--- a/src/test/java/org/apache/commons/crypto/random/CryptoRandomFactoryTest.java
+++ b/src/test/java/org/apache/commons/crypto/random/CryptoRandomFactoryTest.java
@@ -42,8 +42,8 @@ public class CryptoRandomFactoryTest {
 
     @Test
     public void testDefaultRandom() throws GeneralSecurityException {
-        Properties props = new Properties();
-        CryptoRandom random = CryptoRandomFactory.getCryptoRandom(props);
+        final Properties props = new Properties();
+        final CryptoRandom random = CryptoRandomFactory.getCryptoRandom(props);
         final String name = random.getClass().getName();
         if (OpenSslCryptoRandom.isNativeCodeEnabled()) {
             Assert.assertEquals(OpenSslCryptoRandom.class.getName(), name);
@@ -56,11 +56,11 @@ public class CryptoRandomFactoryTest {
     public void testGetOSRandom() throws GeneralSecurityException {
         // Windows does not have a /dev/random device
         Assume.assumeTrue(!System.getProperty("os.name").contains("Windows"));
-        Properties props = new Properties();
+        final Properties props = new Properties();
         props.setProperty(
             CryptoRandomFactory.CLASSES_KEY,
             CryptoRandomFactory.RandomProvider.OS.getClassName());
-        CryptoRandom random = CryptoRandomFactory.getCryptoRandom(props);
+        final CryptoRandom random = CryptoRandomFactory.getCryptoRandom(props);
 
         Assert.assertEquals(OsCryptoRandom.class.getName(), random.getClass()
             .getName());
@@ -68,11 +68,11 @@ public class CryptoRandomFactoryTest {
 
     @Test
     public void testFullClassName() throws GeneralSecurityException {
-        Properties props = new Properties();
+        final Properties props = new Properties();
         props.setProperty(
             CryptoRandomFactory.CLASSES_KEY,
             JavaCryptoRandom.class.getName());
-        CryptoRandom random = CryptoRandomFactory.getCryptoRandom(props);
+        final CryptoRandom random = CryptoRandomFactory.getCryptoRandom(props);
 
         Assert.assertEquals(JavaCryptoRandom.class.getName(), random.getClass()
             .getName());
@@ -80,7 +80,7 @@ public class CryptoRandomFactoryTest {
 
     @Test(expected = GeneralSecurityException.class)
     public void testInvalidRandom() throws GeneralSecurityException {
-        Properties properties = new Properties();
+        final Properties properties = new Properties();
         properties.setProperty(
             CryptoRandomFactory.CLASSES_KEY,
             "InvalidCipherName");
@@ -89,12 +89,12 @@ public class CryptoRandomFactoryTest {
 
     @Test
     public void testAbstractRandom() {
-        Properties props = new Properties();
+        final Properties props = new Properties();
         props.setProperty(CryptoRandomFactory.CLASSES_KEY, AbstractRandom.class.getName());
         try {
             CryptoRandomFactory.getCryptoRandom(props);
             Assert.fail("Expected GeneralSecurityException");
-        } catch (GeneralSecurityException e) {
+        } catch (final GeneralSecurityException e) {
             final String message = e.getMessage();
             Assert.assertTrue(message, message.contains("InstantiationException"));
         }
@@ -103,12 +103,12 @@ public class CryptoRandomFactoryTest {
 
     @Test
     public void testDummmyRandom() {
-        Properties props = new Properties();
+        final Properties props = new Properties();
         props.setProperty(CryptoRandomFactory.CLASSES_KEY, DummyRandom.class.getName());
         try {
             CryptoRandomFactory.getCryptoRandom(props);
             Assert.fail("Expected GeneralSecurityException");
-        } catch (GeneralSecurityException e) {
+        } catch (final GeneralSecurityException e) {
             final String message = e.getMessage();
             Assert.assertTrue(message, message.contains("NoSuchMethodException"));
         }
@@ -125,12 +125,12 @@ public class CryptoRandomFactoryTest {
 
     @Test
     public void testFailingRandom() {
-        Properties props = new Properties();
+        final Properties props = new Properties();
         props.setProperty(CryptoRandomFactory.CLASSES_KEY, FailingRandom.class.getName());
         try {
             CryptoRandomFactory.getCryptoRandom(props);
             Assert.fail("Expected GeneralSecurityException");
-        } catch (GeneralSecurityException e) {
+        } catch (final GeneralSecurityException e) {
             Throwable cause = e.getCause();
             Assert.assertEquals(RuntimeException.class, cause.getClass());
             cause = cause.getCause();
diff --git a/src/test/java/org/apache/commons/crypto/random/DummyRandom.java b/src/test/java/org/apache/commons/crypto/random/DummyRandom.java
index 3e1f07d..399b03b 100644
--- a/src/test/java/org/apache/commons/crypto/random/DummyRandom.java
+++ b/src/test/java/org/apache/commons/crypto/random/DummyRandom.java
@@ -31,7 +31,7 @@ class DummyRandom implements CryptoRandom {
     }
 
     @Override
-    public void nextBytes(byte[] bytes) {
+    public void nextBytes(final byte[] bytes) {
     }
 
 }
diff --git a/src/test/java/org/apache/commons/crypto/random/FailingRandom.java b/src/test/java/org/apache/commons/crypto/random/FailingRandom.java
index 14e3935..e362076 100644
--- a/src/test/java/org/apache/commons/crypto/random/FailingRandom.java
+++ b/src/test/java/org/apache/commons/crypto/random/FailingRandom.java
@@ -23,7 +23,7 @@ import java.util.Properties;
 class FailingRandom implements CryptoRandom {
 
     // Should fail with NoSuchMethodException
-    FailingRandom(Properties props) {
+    FailingRandom(final Properties props) {
         NoSuchMethod();
     }
 
@@ -32,7 +32,7 @@ class FailingRandom implements CryptoRandom {
     }
 
     @Override
-    public void nextBytes(byte[] bytes) {
+    public void nextBytes(final byte[] bytes) {
     }
 
     public static native void NoSuchMethod();
diff --git a/src/test/java/org/apache/commons/crypto/random/JavaCryptoRandomTest.java b/src/test/java/org/apache/commons/crypto/random/JavaCryptoRandomTest.java
index 708c6bb..19afa0e 100644
--- a/src/test/java/org/apache/commons/crypto/random/JavaCryptoRandomTest.java
+++ b/src/test/java/org/apache/commons/crypto/random/JavaCryptoRandomTest.java
@@ -26,11 +26,11 @@ public class JavaCryptoRandomTest extends AbstractRandomTest {
 
     @Override
     public CryptoRandom getCryptoRandom() throws GeneralSecurityException {
-        Properties props = new Properties();
+        final Properties props = new Properties();
         props.setProperty(
                 CryptoRandomFactory.CLASSES_KEY,
                 JavaCryptoRandom.class.getName());
-        CryptoRandom random = CryptoRandomFactory.getCryptoRandom(props);
+        final CryptoRandom random = CryptoRandomFactory.getCryptoRandom(props);
         assertTrue(
                 "The CryptoRandom should be: " + JavaCryptoRandom.class.getName(),
                 random instanceof JavaCryptoRandom);
diff --git a/src/test/java/org/apache/commons/crypto/random/OpenSslCryptoRandomTest.java b/src/test/java/org/apache/commons/crypto/random/OpenSslCryptoRandomTest.java
index a2a9aa7..78fa226 100644
--- a/src/test/java/org/apache/commons/crypto/random/OpenSslCryptoRandomTest.java
+++ b/src/test/java/org/apache/commons/crypto/random/OpenSslCryptoRandomTest.java
@@ -30,11 +30,11 @@ public class OpenSslCryptoRandomTest extends AbstractRandomTest {
     @Override
     public CryptoRandom getCryptoRandom() throws GeneralSecurityException {
         Assume.assumeTrue(Crypto.isNativeCodeLoaded());
-        Properties props = new Properties();
+        final Properties props = new Properties();
         props.setProperty(
                 CryptoRandomFactory.CLASSES_KEY,
                 OpenSslCryptoRandom.class.getName());
-        CryptoRandom random = CryptoRandomFactory.getCryptoRandom(props);
+        final CryptoRandom random = CryptoRandomFactory.getCryptoRandom(props);
         assertTrue(
                 "The CryptoRandom should be: " + OpenSslCryptoRandom.class.getName(),
                 random instanceof OpenSslCryptoRandom);
diff --git a/src/test/java/org/apache/commons/crypto/random/OsCryptoRandomTest.java b/src/test/java/org/apache/commons/crypto/random/OsCryptoRandomTest.java
index 57f0e08..16f1ee1 100644
--- a/src/test/java/org/apache/commons/crypto/random/OsCryptoRandomTest.java
+++ b/src/test/java/org/apache/commons/crypto/random/OsCryptoRandomTest.java
@@ -34,11 +34,11 @@ public class OsCryptoRandomTest extends AbstractRandomTest {
     public CryptoRandom getCryptoRandom() throws GeneralSecurityException {
         // Windows does not have a /dev/random device
         Assume.assumeTrue(!System.getProperty("os.name").contains("Windows"));
-        Properties props = new Properties();
+        final Properties props = new Properties();
         props.setProperty(
                 CryptoRandomFactory.CLASSES_KEY,
                 OsCryptoRandom.class.getName());
-        CryptoRandom random = CryptoRandomFactory.getCryptoRandom(props);
+        final CryptoRandom random = CryptoRandomFactory.getCryptoRandom(props);
         assertTrue(
                 "The CryptoRandom should be: " + OsCryptoRandom.class.getName(),
                 random instanceof OsCryptoRandom);
@@ -47,14 +47,14 @@ public class OsCryptoRandomTest extends AbstractRandomTest {
 
     @Test
     public void testInvalidRandom() {
-        Properties props = new Properties();
+        final Properties props = new Properties();
         props.setProperty(CryptoRandomFactory.CLASSES_KEY, OsCryptoRandom.class.getName());
         // Invalid device
         props.setProperty(CryptoRandomFactory.DEVICE_FILE_PATH_KEY, "");
         try {
             CryptoRandomFactory.getCryptoRandom(props);
             fail("Expected GeneralSecurityException");
-        } catch (GeneralSecurityException e) {
+        } catch (final GeneralSecurityException e) {
             Throwable cause;
             cause = e.getCause();
             Assert.assertEquals(RuntimeException.class, cause.getClass());
diff --git a/src/test/java/org/apache/commons/crypto/stream/AbstractCipherStreamTest.java b/src/test/java/org/apache/commons/crypto/stream/AbstractCipherStreamTest.java
index 4b0be67..5a3bbbf 100644
--- a/src/test/java/org/apache/commons/crypto/stream/AbstractCipherStreamTest.java
+++ b/src/test/java/org/apache/commons/crypto/stream/AbstractCipherStreamTest.java
@@ -44,9 +44,9 @@ import org.junit.Test;
 public abstract class AbstractCipherStreamTest {
 
     private final int dataLen = 20000;
-    private byte[] data = new byte[dataLen];
+    private final byte[] data = new byte[dataLen];
     private byte[] encData;
-    private Properties props = new Properties();
+    private final Properties props = new Properties();
     protected byte[] key = new byte[16];
     protected byte[] iv = new byte[16];
     protected int count = 10000;
@@ -59,7 +59,7 @@ public abstract class AbstractCipherStreamTest {
 
     @Before
     public void before() throws IOException {
-        Random random = new SecureRandom();
+        final Random random = new SecureRandom();
         random.nextBytes(data);
         random.nextBytes(key);
         random.nextBytes(iv);
@@ -90,7 +90,7 @@ public abstract class AbstractCipherStreamTest {
     /** Test byte buffer write. */
     @Test(timeout = 120000)
     public void testByteBufferWrite() throws Exception {
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
         doByteBufferWrite(AbstractCipherTest.JCE_CIPHER_CLASSNAME, baos, false);
         doByteBufferWrite(AbstractCipherTest.OPENSSL_CIPHER_CLASSNAME, baos, false);
 
@@ -98,7 +98,7 @@ public abstract class AbstractCipherStreamTest {
         doByteBufferWrite(AbstractCipherTest.OPENSSL_CIPHER_CLASSNAME, baos, true);
     }
 
-    protected void doSkipTest(String cipherClass, boolean withChannel)
+    protected void doSkipTest(final String cipherClass, final boolean withChannel)
             throws IOException {
         if (AbstractCipherTest.OPENSSL_CIPHER_CLASSNAME.equals(cipherClass)) {
             if (!Crypto.isNativeCodeLoaded()) {
@@ -108,23 +108,23 @@ public abstract class AbstractCipherStreamTest {
         try (InputStream in = getCryptoInputStream(
                 new ByteArrayInputStream(encData), getCipher(cipherClass),
                 defaultBufferSize, iv, withChannel)) {
-            byte[] result = new byte[dataLen];
-            int n1 = readAll(in, result, 0, dataLen / 3);
+            final byte[] result = new byte[dataLen];
+            final int n1 = readAll(in, result, 0, dataLen / 3);
 
             long skipped = in.skip(dataLen / 3);
-            int n2 = readAll(in, result, 0, dataLen);
+            final int n2 = readAll(in, result, 0, dataLen);
 
             Assert.assertEquals(dataLen, n1 + skipped + n2);
-            byte[] readData = new byte[n2];
+            final byte[] readData = new byte[n2];
             System.arraycopy(result, 0, readData, 0, n2);
-            byte[] expectedData = new byte[n2];
+            final byte[] expectedData = new byte[n2];
             System.arraycopy(data, dataLen - n2, expectedData, 0, n2);
             Assert.assertArrayEquals(readData, expectedData);
 
             try {
                 skipped = in.skip(-3);
                 Assert.fail("Skip Negative length should fail.");
-            } catch (IllegalArgumentException e) {
+            } catch (final IllegalArgumentException e) {
                 Assert.assertTrue(e.getMessage().contains("Negative skip length"));
             }
 
@@ -134,7 +134,7 @@ public abstract class AbstractCipherStreamTest {
         }
     }
 
-    protected void doByteBufferRead(String cipherClass, boolean withChannel)
+    protected void doByteBufferRead(final String cipherClass, final boolean withChannel)
             throws Exception {
         if (AbstractCipherTest.OPENSSL_CIPHER_CLASSNAME.equals(cipherClass)) {
             if (!Crypto.isNativeCodeLoaded()) {
@@ -199,30 +199,30 @@ public abstract class AbstractCipherStreamTest {
         in.close();
     }
 
-    protected void doByteBufferWrite(String cipherClass,
-            ByteArrayOutputStream baos, boolean withChannel) throws Exception {
+    protected void doByteBufferWrite(final String cipherClass,
+            final ByteArrayOutputStream baos, final boolean withChannel) throws Exception {
         if (AbstractCipherTest.OPENSSL_CIPHER_CLASSNAME.equals(cipherClass)) {
             if (!Crypto.isNativeCodeLoaded()) {
                 return; // Skip this test if no JNI
             }
         }
         baos.reset();
-        CryptoOutputStream out = getCryptoOutputStream(baos,
+        final CryptoOutputStream out = getCryptoOutputStream(baos,
                 getCipher(cipherClass), defaultBufferSize, iv, withChannel);
         ByteBuffer buf = ByteBuffer.allocateDirect(dataLen / 2);
         buf.put(data, 0, dataLen / 2);
         buf.flip();
-        int n1 = out.write(buf);
+        final int n1 = out.write(buf);
 
         buf.clear();
         buf.put(data, n1, dataLen / 3);
         buf.flip();
-        int n2 = out.write(buf);
+        final int n2 = out.write(buf);
 
         buf.clear();
         buf.put(data, n1 + n2, dataLen - n1 - n2);
         buf.flip();
-        int n3 = out.write(buf);
+        final int n3 = out.write(buf);
 
         Assert.assertEquals(dataLen, n1 + n2 + n3);
 
@@ -236,16 +236,16 @@ public abstract class AbstractCipherStreamTest {
         }
     }
 
-    private void byteBufferReadCheck(InputStream in, ByteBuffer buf, int bufPos)
+    private void byteBufferReadCheck(final InputStream in, final ByteBuffer buf, final int bufPos)
             throws Exception {
         buf.position(bufPos);
-        int n = ((ReadableByteChannel) in).read(buf);
+        final int n = ((ReadableByteChannel) in).read(buf);
         Assert.assertEquals(bufPos + n, buf.position());
-        byte[] readData = new byte[n];
+        final byte[] readData = new byte[n];
         buf.rewind();
         buf.position(bufPos);
         buf.get(readData);
-        byte[] expectedData = new byte[n];
+        final byte[] expectedData = new byte[n];
         System.arraycopy(data, 0, expectedData, 0, n);
         Assert.assertArrayEquals(readData, expectedData);
     }
@@ -256,11 +256,11 @@ public abstract class AbstractCipherStreamTest {
             cipher = (CryptoCipher) ReflectionUtils.newInstance(
                     ReflectionUtils.getClassByName(AbstractCipherTest.JCE_CIPHER_CLASSNAME), props,
                     transformation);
-        } catch (ClassNotFoundException cnfe) {
+        } catch (final ClassNotFoundException cnfe) {
             throw new IOException("Illegal crypto cipher!");
         }
 
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
         try (OutputStream out = new CryptoOutputStream(baos, cipher,
                 defaultBufferSize, new SecretKeySpec(key, "AES"),
                 new IvParameterSpec(iv))) {
@@ -270,8 +270,8 @@ public abstract class AbstractCipherStreamTest {
         encData = baos.toByteArray();
     }
 
-    protected CryptoInputStream getCryptoInputStream(ByteArrayInputStream bais,
-            CryptoCipher cipher, int bufferSize, byte[] iv, boolean withChannel)
+    protected CryptoInputStream getCryptoInputStream(final ByteArrayInputStream bais,
+            final CryptoCipher cipher, final int bufferSize, final byte[] iv, final boolean withChannel)
             throws IOException {
         if (withChannel) {
             return new CryptoInputStream(Channels.newChannel(bais), cipher,
@@ -283,8 +283,8 @@ public abstract class AbstractCipherStreamTest {
     }
 
     protected CryptoOutputStream getCryptoOutputStream(
-            ByteArrayOutputStream baos, CryptoCipher cipher, int bufferSize,
-            byte[] iv, boolean withChannel) throws IOException {
+            final ByteArrayOutputStream baos, final CryptoCipher cipher, final int bufferSize,
+            final byte[] iv, final boolean withChannel) throws IOException {
         if (withChannel) {
             return new CryptoOutputStream(Channels.newChannel(baos), cipher,
                     bufferSize, new SecretKeySpec(key, "AES"),
@@ -294,7 +294,7 @@ public abstract class AbstractCipherStreamTest {
                 new SecretKeySpec(key, "AES"), new IvParameterSpec(iv));
     }
 
-    private int readAll(InputStream in, byte[] b, int offset, int len)
+    private int readAll(final InputStream in, final byte[] b, final int offset, final int len)
             throws IOException {
         int n = 0;
         int total = 0;
@@ -309,12 +309,12 @@ public abstract class AbstractCipherStreamTest {
         return total;
     }
 
-    protected CryptoCipher getCipher(String cipherClass) throws IOException {
+    protected CryptoCipher getCipher(final String cipherClass) throws IOException {
         try {
             return (CryptoCipher) ReflectionUtils.newInstance(
                     ReflectionUtils.getClassByName(cipherClass), props,
                     transformation);
-        } catch (ClassNotFoundException cnfe) {
+        } catch (final ClassNotFoundException cnfe) {
             throw new IOException("Illegal crypto cipher!");
         }
     }
@@ -337,15 +337,15 @@ public abstract class AbstractCipherStreamTest {
         doReadWriteTest(count, AbstractCipherTest.OPENSSL_CIPHER_CLASSNAME, AbstractCipherTest.JCE_CIPHER_CLASSNAME, iv);
     }
 
-    protected void doReadWriteTest(int count, String encCipherClass,
-            String decCipherClass, byte[] iv) throws IOException {
+    protected void doReadWriteTest(final int count, final String encCipherClass,
+            final String decCipherClass, final byte[] iv) throws IOException {
         doReadWriteTestForInputStream(count, encCipherClass, decCipherClass, iv);
         doReadWriteTestForReadableByteChannel(count, encCipherClass,
                 decCipherClass, iv);
     }
 
-    private void doReadWriteTestForInputStream(int count,
-            String encCipherClass, String decCipherClass, byte[] iv)
+    private void doReadWriteTestForInputStream(final int count,
+            final String encCipherClass, final String decCipherClass, final byte[] iv)
             throws IOException {
         if (AbstractCipherTest.OPENSSL_CIPHER_CLASSNAME.equals(encCipherClass)
                 ||
@@ -355,16 +355,16 @@ public abstract class AbstractCipherStreamTest {
             }
         }
         // Created a cipher object of type encCipherClass;
-        CryptoCipher encCipher = getCipher(encCipherClass);
+        final CryptoCipher encCipher = getCipher(encCipherClass);
 
         // Generate data
-        SecureRandom random = new SecureRandom();
-        byte[] originalData = new byte[count];
-        byte[] decryptedData = new byte[count];
+        final SecureRandom random = new SecureRandom();
+        final byte[] originalData = new byte[count];
+        final byte[] decryptedData = new byte[count];
         random.nextBytes(originalData);
 
         // Encrypt data
-        ByteArrayOutputStream encryptedData = new ByteArrayOutputStream();
+        final ByteArrayOutputStream encryptedData = new ByteArrayOutputStream();
         try (CryptoOutputStream out = getCryptoOutputStream(encryptedData,
                 encCipher, defaultBufferSize, iv, false)) {
             out.write(originalData, 0, originalData.length);
@@ -372,7 +372,7 @@ public abstract class AbstractCipherStreamTest {
         }
 
         // Created a cipher object of type decCipherClass;
-        CryptoCipher decCipher = getCipher(decCipherClass);
+        final CryptoCipher decCipher = getCipher(decCipherClass);
 
         // Decrypt data
         CryptoInputStream in = getCryptoInputStream(new ByteArrayInputStream(
@@ -383,7 +383,7 @@ public abstract class AbstractCipherStreamTest {
         int remainingToRead = count;
         int offset = 0;
         while (remainingToRead > 0) {
-            int n = in.read(decryptedData, offset, decryptedData.length
+            final int n = in.read(decryptedData, offset, decryptedData.length
                     - offset);
             if (n >= 0) {
                 remainingToRead -= n;
@@ -400,7 +400,7 @@ public abstract class AbstractCipherStreamTest {
                 decCipher, defaultBufferSize, iv, false);
 
         // Check
-        DataInputStream originalIn = new DataInputStream(
+        final DataInputStream originalIn = new DataInputStream(
                 new BufferedInputStream(new ByteArrayInputStream(originalData)));
         int expected;
         do {
@@ -412,8 +412,8 @@ public abstract class AbstractCipherStreamTest {
         // Completed checking records;
     }
 
-    private void doReadWriteTestForReadableByteChannel(int count,
-            String encCipherClass, String decCipherClass, byte[] iv)
+    private void doReadWriteTestForReadableByteChannel(final int count,
+            final String encCipherClass, final String decCipherClass, final byte[] iv)
             throws IOException {
         if (AbstractCipherTest.OPENSSL_CIPHER_CLASSNAME.equals(encCipherClass)
                 ||
@@ -423,16 +423,16 @@ public abstract class AbstractCipherStreamTest {
             }
         }
         // Creates a cipher object of type encCipherClass;
-        CryptoCipher encCipher = getCipher(encCipherClass);
+        final CryptoCipher encCipher = getCipher(encCipherClass);
 
         // Generate data
-        SecureRandom random = new SecureRandom();
-        byte[] originalData = new byte[count];
-        byte[] decryptedData = new byte[count];
+        final SecureRandom random = new SecureRandom();
+        final byte[] originalData = new byte[count];
+        final byte[] decryptedData = new byte[count];
         random.nextBytes(originalData);
 
         // Encrypt data
-        ByteArrayOutputStream encryptedData = new ByteArrayOutputStream();
+        final ByteArrayOutputStream encryptedData = new ByteArrayOutputStream();
         try (CryptoOutputStream out = getCryptoOutputStream(encryptedData,
                 encCipher, defaultBufferSize, iv, true)) {
             out.write(originalData, 0, originalData.length);
@@ -440,7 +440,7 @@ public abstract class AbstractCipherStreamTest {
         }
 
         // Creates a cipher object of type decCipherClass
-        CryptoCipher decCipher = getCipher(decCipherClass);
+        final CryptoCipher decCipher = getCipher(decCipherClass);
 
         // Decrypt data
         CryptoInputStream in = getCryptoInputStream(new ByteArrayInputStream(
@@ -451,7 +451,7 @@ public abstract class AbstractCipherStreamTest {
         int remainingToRead = count;
         int offset = 0;
         while (remainingToRead > 0) {
-            int n = in.read(decryptedData, offset, decryptedData.length
+            final int n = in.read(decryptedData, offset, decryptedData.length
                     - offset);
             if (n >= 0) {
                 remainingToRead -= n;
@@ -468,7 +468,7 @@ public abstract class AbstractCipherStreamTest {
                 decCipher, defaultBufferSize, iv, true);
 
         // Check
-        DataInputStream originalIn = new DataInputStream(
+        final DataInputStream originalIn = new DataInputStream(
                 new BufferedInputStream(new ByteArrayInputStream(originalData)));
         int expected;
         do {
diff --git a/src/test/java/org/apache/commons/crypto/stream/CtrCryptoStreamTest.java b/src/test/java/org/apache/commons/crypto/stream/CtrCryptoStreamTest.java
index 7b9c12b..a2ee57d 100644
--- a/src/test/java/org/apache/commons/crypto/stream/CtrCryptoStreamTest.java
+++ b/src/test/java/org/apache/commons/crypto/stream/CtrCryptoStreamTest.java
@@ -33,8 +33,8 @@ public class CtrCryptoStreamTest extends AbstractCipherStreamTest {
 
     @Override
     protected CtrCryptoInputStream getCryptoInputStream(
-            ByteArrayInputStream bais, CryptoCipher cipher, int bufferSize,
-            byte[] iv, boolean withChannel) throws IOException {
+            final ByteArrayInputStream bais, final CryptoCipher cipher, final int bufferSize,
+            final byte[] iv, final boolean withChannel) throws IOException {
         if (withChannel) {
             return new CtrCryptoInputStream(Channels.newChannel(bais), cipher,
                     bufferSize, key, iv);
@@ -44,8 +44,8 @@ public class CtrCryptoStreamTest extends AbstractCipherStreamTest {
 
     @Override
     protected CtrCryptoOutputStream getCryptoOutputStream(
-            ByteArrayOutputStream baos, CryptoCipher cipher, int bufferSize,
-            byte[] iv, boolean withChannel) throws IOException {
+            final ByteArrayOutputStream baos, final CryptoCipher cipher, final int bufferSize,
+            final byte[] iv, final boolean withChannel) throws IOException {
         if (withChannel) {
             return new CtrCryptoOutputStream(Channels.newChannel(baos), cipher,
                     bufferSize, key, iv);
diff --git a/src/test/java/org/apache/commons/crypto/stream/PositionedCryptoInputStreamTest.java b/src/test/java/org/apache/commons/crypto/stream/PositionedCryptoInputStreamTest.java
index c8d27ac..9931b63 100644
--- a/src/test/java/org/apache/commons/crypto/stream/PositionedCryptoInputStreamTest.java
+++ b/src/test/java/org/apache/commons/crypto/stream/PositionedCryptoInputStreamTest.java
@@ -43,23 +43,23 @@ import java.util.Random;
 public class PositionedCryptoInputStreamTest {
 
     private final int dataLen = 20000;
-    private byte[] testData = new byte[dataLen];
+    private final byte[] testData = new byte[dataLen];
     private byte[] encData;
-    private Properties props = new Properties();
-    private byte[] key = new byte[16];
-    private byte[] iv = new byte[16];
-    private int bufferSize = 2048;
-    private int bufferSizeLess = bufferSize - 1;
-    private int bufferSizeMore = bufferSize + 1;
-    private int length = 1024;
-    private int lengthLess = length - 1;
-    private int lengthMore = length + 1;
-
-    private String transformation = "AES/CTR/NoPadding";
+    private final Properties props = new Properties();
+    private final byte[] key = new byte[16];
+    private final byte[] iv = new byte[16];
+    private final int bufferSize = 2048;
+    private final int bufferSizeLess = bufferSize - 1;
+    private final int bufferSizeMore = bufferSize + 1;
+    private final int length = 1024;
+    private final int lengthLess = length - 1;
+    private final int lengthMore = length + 1;
+
+    private final String transformation = "AES/CTR/NoPadding";
 
     @Before
     public void before() throws IOException {
-        Random random = new SecureRandom();
+        final Random random = new SecureRandom();
         random.nextBytes(testData);
         random.nextBytes(key);
         random.nextBytes(iv);
@@ -72,13 +72,13 @@ public class PositionedCryptoInputStreamTest {
             cipher = (CryptoCipher) ReflectionUtils.newInstance(
                     ReflectionUtils.getClassByName(AbstractCipherTest.JCE_CIPHER_CLASSNAME), props,
                     transformation);
-        } catch (ClassNotFoundException cnfe) {
+        } catch (final ClassNotFoundException cnfe) {
             throw new IOException("Illegal crypto cipher!");
         }
 
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
         // encryption data
-        OutputStream out = new CryptoOutputStream(baos, cipher, bufferSize,
+        final OutputStream out = new CryptoOutputStream(baos, cipher, bufferSize,
                 new SecretKeySpec(key, "AES"), new IvParameterSpec(iv));
         out.write(testData);
         out.flush();
@@ -87,7 +87,7 @@ public class PositionedCryptoInputStreamTest {
     }
 
     private PositionedCryptoInputStream getCryptoInputStream(
-            CryptoCipher cipher, int bufferSize) throws IOException {
+            final CryptoCipher cipher, final int bufferSize) throws IOException {
         return new PositionedCryptoInputStream(props, new PositionedInputForTest(
                 Arrays.copyOf(encData, encData.length)), cipher, bufferSize,
                 key, iv, 0);
@@ -104,7 +104,7 @@ public class PositionedCryptoInputStreamTest {
         testCipher(AbstractCipherTest.OPENSSL_CIPHER_CLASSNAME);
     }
 
-    protected void testCipher(String cipherClass) throws Exception {
+    protected void testCipher(final String cipherClass) throws Exception {
         doPositionedReadTests(cipherClass);
         doReadFullyTests(cipherClass);
         doSeekTests(cipherClass);
@@ -113,17 +113,17 @@ public class PositionedCryptoInputStreamTest {
 
     // when there are multiple positioned read actions and one read action,
     // they will not interfere each other.
-    private void doMultipleReadTest(String cipherClass) throws Exception {
+    private void doMultipleReadTest(final String cipherClass) throws Exception {
         try (PositionedCryptoInputStream in = getCryptoInputStream(getCipher(cipherClass), bufferSize)) {
             int position = 0;
             while (in.available() > 0) {
-                ByteBuffer buf = ByteBuffer.allocate(length);
-                byte[] bytes1 = new byte[length];
-                byte[] bytes2 = new byte[lengthLess];
+                final ByteBuffer buf = ByteBuffer.allocate(length);
+                final byte[] bytes1 = new byte[length];
+                final byte[] bytes2 = new byte[lengthLess];
                 // do the read and position read
-                int pn1 = in.read(position, bytes1, 0, length);
-                int n = in.read(buf);
-                int pn2 = in.read(position, bytes2, 0, lengthLess);
+                final int pn1 = in.read(position, bytes1, 0, length);
+                final int n = in.read(buf);
+                final int pn2 = in.read(position, bytes2, 0, lengthLess);
 
                 // verify the result
                 if (pn1 > 0) {
@@ -144,7 +144,7 @@ public class PositionedCryptoInputStreamTest {
         }
     }
 
-    private void doPositionedReadTests(String cipherClass) throws Exception {
+    private void doPositionedReadTests(final String cipherClass) throws Exception {
         // test with different bufferSize when position = 0
         testPositionedReadLoop(cipherClass, 0, length, bufferSize, dataLen);
         testPositionedReadLoop(cipherClass, 0, length, bufferSizeLess, dataLen);
@@ -161,7 +161,7 @@ public class PositionedCryptoInputStreamTest {
         testPositionedReadNone(cipherClass, dataLen, length, bufferSize);
     }
 
-    private void doReadFullyTests(String cipherClass) throws Exception {
+    private void doReadFullyTests(final String cipherClass) throws Exception {
         // test with different bufferSize when position = 0
         testReadFullyLoop(cipherClass, 0, length, bufferSize, dataLen);
         testReadFullyLoop(cipherClass, 0, length, bufferSizeLess, dataLen);
@@ -177,7 +177,7 @@ public class PositionedCryptoInputStreamTest {
                 bufferSize);
     }
 
-    private void doSeekTests(String cipherClass) throws Exception {
+    private void doSeekTests(final String cipherClass) throws Exception {
         // test with different length when position = 0
         testSeekLoop(cipherClass, 0, length, bufferSize);
         testSeekLoop(cipherClass, 0, lengthLess, bufferSize);
@@ -188,13 +188,13 @@ public class PositionedCryptoInputStreamTest {
         testSeekFailed(cipherClass, -1, bufferSize);
     }
 
-    private void testSeekLoop(String cipherClass, int position, int length,
-            int bufferSize) throws Exception {
+    private void testSeekLoop(final String cipherClass, int position, final int length,
+            final int bufferSize) throws Exception {
         try (PositionedCryptoInputStream in = getCryptoInputStream(getCipher(cipherClass), bufferSize)) {
             while (in.available() > 0) {
                 in.seek(position);
-                ByteBuffer buf = ByteBuffer.allocate(length);
-                int n = in.read(buf);
+                final ByteBuffer buf = ByteBuffer.allocate(length);
+                final int n = in.read(buf);
                 if (n > 0) {
                     compareByteArray(testData, position, buf.array(), n);
                     position += n;
@@ -206,25 +206,25 @@ public class PositionedCryptoInputStreamTest {
     }
 
     // test for the out of index position, eg, -1.
-    private void testSeekFailed(String cipherClass, int position, int bufferSize)
+    private void testSeekFailed(final String cipherClass, final int position, final int bufferSize)
             throws Exception {
-        PositionedCryptoInputStream in = getCryptoInputStream(
+        final PositionedCryptoInputStream in = getCryptoInputStream(
                 getCipher(cipherClass), bufferSize);
         try {
             in.seek(position);
             Assert.fail("Excepted exception for cannot seek to negative offset.");
-        } catch (IllegalArgumentException iae) {
+        } catch (final IllegalArgumentException iae) {
         }
         in.close();
     }
 
-    private void testPositionedReadLoop(String cipherClass, int position,
-            int length, int bufferSize, int total) throws Exception {
+    private void testPositionedReadLoop(final String cipherClass, int position,
+            final int length, final int bufferSize, final int total) throws Exception {
         try (PositionedCryptoInputStream in = getCryptoInputStream(getCipher(cipherClass), bufferSize)) {
             // do the position read until the end of data
             while (position < total) {
-                byte[] bytes = new byte[length];
-                int n = in.read(position, bytes, 0, length);
+                final byte[] bytes = new byte[length];
+                final int n = in.read(position, bytes, 0, length);
                 if (n >= 0) {
                     compareByteArray(testData, position, bytes, n);
                     position += n;
@@ -236,23 +236,23 @@ public class PositionedCryptoInputStreamTest {
     }
 
     // test for the out of index position, eg, -1.
-    private void testPositionedReadNone(String cipherClass, int position,
-            int length, int bufferSize) throws Exception {
+    private void testPositionedReadNone(final String cipherClass, final int position,
+            final int length, final int bufferSize) throws Exception {
         try (PositionedCryptoInputStream in = getCryptoInputStream(getCipher(cipherClass), bufferSize)) {
-            byte[] bytes = new byte[length];
-            int n = in.read(position, bytes, 0, length);
+            final byte[] bytes = new byte[length];
+            final int n = in.read(position, bytes, 0, length);
             Assert.assertEquals(n, -1);
         }
     }
 
-    private void testReadFullyLoop(String cipherClass, int position,
-            int length, int bufferSize, int total) throws Exception {
+    private void testReadFullyLoop(final String cipherClass, int position,
+            final int length, final int bufferSize, final int total) throws Exception {
         try (PositionedCryptoInputStream in = getCryptoInputStream(
                 getCipher(cipherClass), bufferSize)) {
 
             // do the position read full until remain < length
             while (position + length <= total) {
-                byte[] bytes = new byte[length];
+                final byte[] bytes = new byte[length];
                 in.readFully(position, bytes, 0, length);
                 compareByteArray(testData, position, bytes, length);
                 position += length;
@@ -262,25 +262,25 @@ public class PositionedCryptoInputStreamTest {
     }
 
     // test for the End of file reached before reading fully
-    private void testReadFullyFailed(String cipherClass, int position,
-            int length, int bufferSize) throws Exception {
-        PositionedCryptoInputStream in = getCryptoInputStream(
+    private void testReadFullyFailed(final String cipherClass, final int position,
+            final int length, final int bufferSize) throws Exception {
+        final PositionedCryptoInputStream in = getCryptoInputStream(
                 getCipher(cipherClass), bufferSize);
-        byte[] bytes = new byte[length];
+        final byte[] bytes = new byte[length];
         try {
             in.readFully(position, bytes, 0, length);
             Assert.fail("Expected IOException.");
-        } catch (IOException ioe) {
+        } catch (final IOException ioe) {
             // excepted exception
         }
         in.close();
     }
 
     // compare the data from pos with length and data2 from 0 with length
-    private void compareByteArray(byte[] data1, int pos, byte[] data2,
-            int length) {
-        byte[] expectedData = new byte[length];
-        byte[] realData = new byte[length];
+    private void compareByteArray(final byte[] data1, final int pos, final byte[] data2,
+            final int length) {
+        final byte[] expectedData = new byte[length];
+        final byte[] realData = new byte[length];
         // get the expected data with the position and length
         System.arraycopy(data1, pos, expectedData, 0, length);
         // get the real data
@@ -288,12 +288,12 @@ public class PositionedCryptoInputStreamTest {
         Assert.assertArrayEquals(expectedData, realData);
     }
 
-    private CryptoCipher getCipher(String cipherClass) throws IOException {
+    private CryptoCipher getCipher(final String cipherClass) throws IOException {
         try {
             return (CryptoCipher) ReflectionUtils.newInstance(
                     ReflectionUtils.getClassByName(cipherClass), props,
                     transformation);
-        } catch (ClassNotFoundException cnfe) {
+        } catch (final ClassNotFoundException cnfe) {
             throw new IOException("Illegal crypto cipher!");
         }
     }
@@ -304,20 +304,20 @@ public class PositionedCryptoInputStreamTest {
         long pos;
         long count;
 
-        public PositionedInputForTest(byte[] data) {
+        public PositionedInputForTest(final byte[] data) {
             this.data = data;
             this.pos = 0;
             this.count = data.length;
         }
 
         @Override
-        public int read(ByteBuffer dst) throws IOException {
-            int remaining = (int) (count - pos);
+        public int read(final ByteBuffer dst) throws IOException {
+            final int remaining = (int) (count - pos);
             if (remaining <= 0) {
                 return -1;
             }
 
-            int length = Math.min(dst.remaining(), remaining);
+            final int length = Math.min(dst.remaining(), remaining);
             dst.put(data, (int) pos, length);
             pos += length;
             return length;
@@ -329,7 +329,7 @@ public class PositionedCryptoInputStreamTest {
                 return 0;
             }
 
-            long remaining = count - pos;
+            final long remaining = count - pos;
             if (remaining < n) {
                 n = remaining;
             }
@@ -339,7 +339,7 @@ public class PositionedCryptoInputStreamTest {
         }
 
         @Override
-        public int read(long position, byte[] buffer, int offset, int length)
+        public int read(final long position, final byte[] buffer, final int offset, int length)
                 throws IOException {
             Objects.requireNonNull(buffer, "buffer");
             if (offset < 0 || length < 0
@@ -351,7 +351,7 @@ public class PositionedCryptoInputStreamTest {
                 return -1;
             }
 
-            long avail = count - position;
+            final long avail = count - position;
             if (length > avail) {
                 length = (int) avail;
             }
@@ -363,7 +363,7 @@ public class PositionedCryptoInputStreamTest {
         }
 
         @Override
-        public void seek(long position) throws IOException {
+        public void seek(final long position) throws IOException {
             if (pos < 0) {
                 throw new IOException("Negative seek offset");
             } else if (position >= 0 && position < count) {
diff --git a/src/test/java/org/apache/commons/crypto/utils/EnumTest.java b/src/test/java/org/apache/commons/crypto/utils/EnumTest.java
index 72a5f61..a98c93e 100644
--- a/src/test/java/org/apache/commons/crypto/utils/EnumTest.java
+++ b/src/test/java/org/apache/commons/crypto/utils/EnumTest.java
@@ -30,14 +30,14 @@ public class EnumTest {
 
     @Test
     public void testRandom() throws Exception {
-        for(RandomProvider value : CryptoRandomFactory.RandomProvider.values()) {
+        for(final RandomProvider value : CryptoRandomFactory.RandomProvider.values()) {
             ReflectionUtils.getClassByName(value.getClassName());
         }
     }
 
     @Test
     public void testCipher() throws Exception {
-        for(CipherProvider value : CryptoCipherFactory.CipherProvider.values()) {
+        for(final CipherProvider value : CryptoCipherFactory.CipherProvider.values()) {
             ReflectionUtils.getClassByName(value.getClassName());
         }
     }


[commons-crypto] 02/06: Add missing @Override.

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-crypto.git

commit 9d5cc361c60736eae3554d5306bcf80759b1bfa8
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Apr 10 15:35:38 2020 -0400

    Add missing @Override.
---
 .../java/org/apache/commons/crypto/cipher/OpenSslGaloisCounterMode.java  | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/main/java/org/apache/commons/crypto/cipher/OpenSslGaloisCounterMode.java b/src/main/java/org/apache/commons/crypto/cipher/OpenSslGaloisCounterMode.java
index f8d321d..87ed5a1 100644
--- a/src/main/java/org/apache/commons/crypto/cipher/OpenSslGaloisCounterMode.java
+++ b/src/main/java/org/apache/commons/crypto/cipher/OpenSslGaloisCounterMode.java
@@ -261,6 +261,7 @@ class OpenSslGaloisCounterMode extends OpenSslFeedbackCipher {
         return totalLen;
     }
 
+    @Override
     public void clean() {
         super.clean();
         aadBuffer = null;


[commons-crypto] 05/06: Remove redundant modifiers.

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-crypto.git

commit 3bb06044710118b18f07ee9a56f5a91e6e11af29
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Apr 10 15:38:44 2020 -0400

    Remove redundant modifiers.
---
 src/main/java/org/apache/commons/crypto/cipher/OpenSsl.java       | 4 ++--
 src/main/java/org/apache/commons/crypto/jna/OpenSslJnaCipher.java | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/apache/commons/crypto/cipher/OpenSsl.java b/src/main/java/org/apache/commons/crypto/cipher/OpenSsl.java
index 6cb5a3d..eb4c592 100644
--- a/src/main/java/org/apache/commons/crypto/cipher/OpenSsl.java
+++ b/src/main/java/org/apache/commons/crypto/cipher/OpenSsl.java
@@ -44,7 +44,7 @@ final class OpenSsl {
     private final OpenSslFeedbackCipher opensslBlockCipher;
 
     /** Currently only support AES/CTR/NoPadding. */
-    private static enum AlgorithmMode {
+    private enum AlgorithmMode {
         AES_CTR, AES_CBC, AES_GCM;
 
         /**
@@ -67,7 +67,7 @@ final class OpenSsl {
         }
     }
 
-    private static enum Padding {
+    private enum Padding {
         NoPadding, PKCS5Padding;
 
         /**
diff --git a/src/main/java/org/apache/commons/crypto/jna/OpenSslJnaCipher.java b/src/main/java/org/apache/commons/crypto/jna/OpenSslJnaCipher.java
index 0cea292..bc63d11 100644
--- a/src/main/java/org/apache/commons/crypto/jna/OpenSslJnaCipher.java
+++ b/src/main/java/org/apache/commons/crypto/jna/OpenSslJnaCipher.java
@@ -376,7 +376,7 @@ class OpenSslJnaCipher implements CryptoCipher {
     /**
      * AlgorithmMode of JNA.  Currently only support AES/CTR/NoPadding.
      */
-    private static enum AlgorithmMode {
+    private enum AlgorithmMode {
         AES_CTR, AES_CBC;
 
         /**
@@ -398,7 +398,7 @@ class OpenSslJnaCipher implements CryptoCipher {
     /**
      * Padding of JNA.
      */
-    private static enum Padding {
+    private enum Padding {
         NoPadding, PKCS5Padding;
 
         /**


[commons-crypto] 04/06: Organize imports.

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-crypto.git

commit 438eb1b2f838418e739e4470c1978012e7c6308d
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Apr 10 15:37:35 2020 -0400

    Organize imports.
---
 .../apache/commons/crypto/OpenSslInfoNative.java   |  2 ++
 .../apache/commons/crypto/cipher/CryptoCipher.java |  1 +
 .../org/apache/commons/crypto/cipher/OpenSsl.java  |  1 +
 .../commons/crypto/cipher/OpenSslCommonMode.java   |  7 +++---
 .../crypto/cipher/OpenSslFeedbackCipher.java       |  9 ++++----
 .../crypto/cipher/OpenSslGaloisCounterMode.java    | 11 +++++-----
 .../commons/crypto/stream/CryptoInputStream.java   |  1 +
 .../commons/crypto/stream/CryptoOutputStream.java  |  1 +
 .../crypto/stream/CtrCryptoInputStream.java        |  1 +
 .../crypto/stream/CtrCryptoOutputStream.java       |  1 +
 .../crypto/stream/PositionedCryptoInputStream.java |  1 +
 .../commons/crypto/cipher/GcmCipherTest.java       | 10 ++++-----
 .../commons/crypto/cipher/OpenSslCipherTest.java   |  1 +
 .../crypto/jna/OpenSslJnaCryptoRandomTest.java     |  4 ++--
 .../crypto/random/JavaCryptoRandomTest.java        |  4 ++--
 .../crypto/random/OpenSslCryptoRandomTest.java     |  4 ++--
 .../commons/crypto/random/OsCryptoRandomTest.java  |  5 +++--
 .../crypto/stream/AbstractCipherStreamTest.java    |  1 +
 .../stream/PositionedCryptoInputStreamTest.java    | 25 +++++++++++-----------
 19 files changed, 53 insertions(+), 37 deletions(-)

diff --git a/src/main/java/org/apache/commons/crypto/OpenSslInfoNative.java b/src/main/java/org/apache/commons/crypto/OpenSslInfoNative.java
index b72640d..0b3d188 100644
--- a/src/main/java/org/apache/commons/crypto/OpenSslInfoNative.java
+++ b/src/main/java/org/apache/commons/crypto/OpenSslInfoNative.java
@@ -17,6 +17,8 @@
  */
 package org.apache.commons.crypto;
 
+import org.apache.commons.crypto.random.CryptoRandom;
+
 /**
  * JNI interface of {@link CryptoRandom} implementation for OpenSSL.
  * The native method in this class is defined in
diff --git a/src/main/java/org/apache/commons/crypto/cipher/CryptoCipher.java b/src/main/java/org/apache/commons/crypto/cipher/CryptoCipher.java
index 5c5db9b..667ad65 100644
--- a/src/main/java/org/apache/commons/crypto/cipher/CryptoCipher.java
+++ b/src/main/java/org/apache/commons/crypto/cipher/CryptoCipher.java
@@ -23,6 +23,7 @@ import java.security.InvalidAlgorithmParameterException;
 import java.security.InvalidKeyException;
 import java.security.Key;
 import java.security.spec.AlgorithmParameterSpec;
+
 import javax.crypto.BadPaddingException;
 import javax.crypto.IllegalBlockSizeException;
 import javax.crypto.ShortBufferException;
diff --git a/src/main/java/org/apache/commons/crypto/cipher/OpenSsl.java b/src/main/java/org/apache/commons/crypto/cipher/OpenSsl.java
index 38bad73..6cb5a3d 100644
--- a/src/main/java/org/apache/commons/crypto/cipher/OpenSsl.java
+++ b/src/main/java/org/apache/commons/crypto/cipher/OpenSsl.java
@@ -22,6 +22,7 @@ import java.security.InvalidAlgorithmParameterException;
 import java.security.NoSuchAlgorithmException;
 import java.security.spec.AlgorithmParameterSpec;
 import java.util.StringTokenizer;
+
 import javax.crypto.BadPaddingException;
 import javax.crypto.IllegalBlockSizeException;
 import javax.crypto.NoSuchPaddingException;
diff --git a/src/main/java/org/apache/commons/crypto/cipher/OpenSslCommonMode.java b/src/main/java/org/apache/commons/crypto/cipher/OpenSslCommonMode.java
index bb9be56..b9520fa 100644
--- a/src/main/java/org/apache/commons/crypto/cipher/OpenSslCommonMode.java
+++ b/src/main/java/org/apache/commons/crypto/cipher/OpenSslCommonMode.java
@@ -17,13 +17,14 @@
  */
 package org.apache.commons.crypto.cipher;
 
+import java.nio.ByteBuffer;
+import java.security.InvalidAlgorithmParameterException;
+import java.security.spec.AlgorithmParameterSpec;
+
 import javax.crypto.BadPaddingException;
 import javax.crypto.IllegalBlockSizeException;
 import javax.crypto.ShortBufferException;
 import javax.crypto.spec.IvParameterSpec;
-import java.nio.ByteBuffer;
-import java.security.InvalidAlgorithmParameterException;
-import java.security.spec.AlgorithmParameterSpec;
 
 /**
  * This class do the real work(Encryption/Decryption) for non-authenticated modes, such as CTR, CBC.
diff --git a/src/main/java/org/apache/commons/crypto/cipher/OpenSslFeedbackCipher.java b/src/main/java/org/apache/commons/crypto/cipher/OpenSslFeedbackCipher.java
index 7d504ae..41b7ba9 100644
--- a/src/main/java/org/apache/commons/crypto/cipher/OpenSslFeedbackCipher.java
+++ b/src/main/java/org/apache/commons/crypto/cipher/OpenSslFeedbackCipher.java
@@ -17,14 +17,15 @@
  */
 package org.apache.commons.crypto.cipher;
 
-import org.apache.commons.crypto.utils.Utils;
+import java.nio.ByteBuffer;
+import java.security.InvalidAlgorithmParameterException;
+import java.security.spec.AlgorithmParameterSpec;
 
 import javax.crypto.BadPaddingException;
 import javax.crypto.IllegalBlockSizeException;
 import javax.crypto.ShortBufferException;
-import java.nio.ByteBuffer;
-import java.security.InvalidAlgorithmParameterException;
-import java.security.spec.AlgorithmParameterSpec;
+
+import org.apache.commons.crypto.utils.Utils;
 
 /**
  * This class represents a block cipher in one of its modes.
diff --git a/src/main/java/org/apache/commons/crypto/cipher/OpenSslGaloisCounterMode.java b/src/main/java/org/apache/commons/crypto/cipher/OpenSslGaloisCounterMode.java
index 87ed5a1..29682c8 100644
--- a/src/main/java/org/apache/commons/crypto/cipher/OpenSslGaloisCounterMode.java
+++ b/src/main/java/org/apache/commons/crypto/cipher/OpenSslGaloisCounterMode.java
@@ -17,17 +17,18 @@
  */
 package org.apache.commons.crypto.cipher;
 
-import javax.crypto.AEADBadTagException;
-import javax.crypto.BadPaddingException;
-import javax.crypto.IllegalBlockSizeException;
-import javax.crypto.ShortBufferException;
-import javax.crypto.spec.GCMParameterSpec;
 import java.io.ByteArrayOutputStream;
 import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
 import java.security.InvalidAlgorithmParameterException;
 import java.security.spec.AlgorithmParameterSpec;
 
+import javax.crypto.AEADBadTagException;
+import javax.crypto.BadPaddingException;
+import javax.crypto.IllegalBlockSizeException;
+import javax.crypto.ShortBufferException;
+import javax.crypto.spec.GCMParameterSpec;
+
 /**
  * This class do the real work(Encryption/Decryption/Authentication) for the authenticated mode: GCM.
  *
diff --git a/src/main/java/org/apache/commons/crypto/stream/CryptoInputStream.java b/src/main/java/org/apache/commons/crypto/stream/CryptoInputStream.java
index fe2951e..66aa0c1 100644
--- a/src/main/java/org/apache/commons/crypto/stream/CryptoInputStream.java
+++ b/src/main/java/org/apache/commons/crypto/stream/CryptoInputStream.java
@@ -28,6 +28,7 @@ import java.security.Key;
 import java.security.spec.AlgorithmParameterSpec;
 import java.util.Objects;
 import java.util.Properties;
+
 import javax.crypto.BadPaddingException;
 import javax.crypto.Cipher;
 import javax.crypto.IllegalBlockSizeException;
diff --git a/src/main/java/org/apache/commons/crypto/stream/CryptoOutputStream.java b/src/main/java/org/apache/commons/crypto/stream/CryptoOutputStream.java
index 47c2207..e9228c4 100644
--- a/src/main/java/org/apache/commons/crypto/stream/CryptoOutputStream.java
+++ b/src/main/java/org/apache/commons/crypto/stream/CryptoOutputStream.java
@@ -28,6 +28,7 @@ import java.security.Key;
 import java.security.spec.AlgorithmParameterSpec;
 import java.util.Objects;
 import java.util.Properties;
+
 import javax.crypto.BadPaddingException;
 import javax.crypto.Cipher;
 import javax.crypto.IllegalBlockSizeException;
diff --git a/src/main/java/org/apache/commons/crypto/stream/CtrCryptoInputStream.java b/src/main/java/org/apache/commons/crypto/stream/CtrCryptoInputStream.java
index 5b1f4ba..d27837d 100644
--- a/src/main/java/org/apache/commons/crypto/stream/CtrCryptoInputStream.java
+++ b/src/main/java/org/apache/commons/crypto/stream/CtrCryptoInputStream.java
@@ -24,6 +24,7 @@ import java.nio.channels.ReadableByteChannel;
 import java.security.InvalidAlgorithmParameterException;
 import java.security.InvalidKeyException;
 import java.util.Properties;
+
 import javax.crypto.BadPaddingException;
 import javax.crypto.Cipher;
 import javax.crypto.IllegalBlockSizeException;
diff --git a/src/main/java/org/apache/commons/crypto/stream/CtrCryptoOutputStream.java b/src/main/java/org/apache/commons/crypto/stream/CtrCryptoOutputStream.java
index fbc27e5..3925c48 100644
--- a/src/main/java/org/apache/commons/crypto/stream/CtrCryptoOutputStream.java
+++ b/src/main/java/org/apache/commons/crypto/stream/CtrCryptoOutputStream.java
@@ -24,6 +24,7 @@ import java.nio.channels.WritableByteChannel;
 import java.security.InvalidAlgorithmParameterException;
 import java.security.InvalidKeyException;
 import java.util.Properties;
+
 import javax.crypto.BadPaddingException;
 import javax.crypto.Cipher;
 import javax.crypto.IllegalBlockSizeException;
diff --git a/src/main/java/org/apache/commons/crypto/stream/PositionedCryptoInputStream.java b/src/main/java/org/apache/commons/crypto/stream/PositionedCryptoInputStream.java
index 45749f3..72ff838 100644
--- a/src/main/java/org/apache/commons/crypto/stream/PositionedCryptoInputStream.java
+++ b/src/main/java/org/apache/commons/crypto/stream/PositionedCryptoInputStream.java
@@ -25,6 +25,7 @@ import java.security.InvalidKeyException;
 import java.util.Properties;
 import java.util.Queue;
 import java.util.concurrent.ConcurrentLinkedQueue;
+
 import javax.crypto.BadPaddingException;
 import javax.crypto.Cipher;
 import javax.crypto.IllegalBlockSizeException;
diff --git a/src/test/java/org/apache/commons/crypto/cipher/GcmCipherTest.java b/src/test/java/org/apache/commons/crypto/cipher/GcmCipherTest.java
index cdfc5eb..611587a 100644
--- a/src/test/java/org/apache/commons/crypto/cipher/GcmCipherTest.java
+++ b/src/test/java/org/apache/commons/crypto/cipher/GcmCipherTest.java
@@ -23,17 +23,17 @@ import java.util.Arrays;
 import java.util.Properties;
 import java.util.Random;
 
-import org.apache.commons.crypto.utils.Utils;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
 import javax.crypto.AEADBadTagException;
 import javax.crypto.Cipher;
 import javax.crypto.spec.GCMParameterSpec;
 import javax.crypto.spec.SecretKeySpec;
 import javax.xml.bind.DatatypeConverter;
 
+import org.apache.commons.crypto.utils.Utils;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
 public class GcmCipherTest {
 
     Properties props = null;
diff --git a/src/test/java/org/apache/commons/crypto/cipher/OpenSslCipherTest.java b/src/test/java/org/apache/commons/crypto/cipher/OpenSslCipherTest.java
index b77a698..7578206 100644
--- a/src/test/java/org/apache/commons/crypto/cipher/OpenSslCipherTest.java
+++ b/src/test/java/org/apache/commons/crypto/cipher/OpenSslCipherTest.java
@@ -23,6 +23,7 @@ import java.security.InvalidAlgorithmParameterException;
 import java.security.InvalidKeyException;
 import java.security.NoSuchAlgorithmException;
 import java.util.Properties;
+
 import javax.crypto.NoSuchPaddingException;
 import javax.crypto.ShortBufferException;
 import javax.crypto.spec.IvParameterSpec;
diff --git a/src/test/java/org/apache/commons/crypto/jna/OpenSslJnaCryptoRandomTest.java b/src/test/java/org/apache/commons/crypto/jna/OpenSslJnaCryptoRandomTest.java
index a7162df..0f1f6a9 100644
--- a/src/test/java/org/apache/commons/crypto/jna/OpenSslJnaCryptoRandomTest.java
+++ b/src/test/java/org/apache/commons/crypto/jna/OpenSslJnaCryptoRandomTest.java
@@ -17,6 +17,8 @@
  */
 package org.apache.commons.crypto.jna;
 
+import static org.junit.Assert.assertTrue;
+
 import java.security.GeneralSecurityException;
 import java.util.Properties;
 
@@ -26,8 +28,6 @@ import org.apache.commons.crypto.random.CryptoRandomFactory;
 import org.junit.Assume;
 import org.junit.Before;
 
-import static org.junit.Assert.assertTrue;
-
 public class OpenSslJnaCryptoRandomTest extends AbstractRandomTest {
 
     @Before
diff --git a/src/test/java/org/apache/commons/crypto/random/JavaCryptoRandomTest.java b/src/test/java/org/apache/commons/crypto/random/JavaCryptoRandomTest.java
index 19afa0e..1a03856 100644
--- a/src/test/java/org/apache/commons/crypto/random/JavaCryptoRandomTest.java
+++ b/src/test/java/org/apache/commons/crypto/random/JavaCryptoRandomTest.java
@@ -17,11 +17,11 @@
  */
 package org.apache.commons.crypto.random;
 
+import static org.junit.Assert.assertTrue;
+
 import java.security.GeneralSecurityException;
 import java.util.Properties;
 
-import static org.junit.Assert.assertTrue;
-
 public class JavaCryptoRandomTest extends AbstractRandomTest {
 
     @Override
diff --git a/src/test/java/org/apache/commons/crypto/random/OpenSslCryptoRandomTest.java b/src/test/java/org/apache/commons/crypto/random/OpenSslCryptoRandomTest.java
index 78fa226..14f300c 100644
--- a/src/test/java/org/apache/commons/crypto/random/OpenSslCryptoRandomTest.java
+++ b/src/test/java/org/apache/commons/crypto/random/OpenSslCryptoRandomTest.java
@@ -17,14 +17,14 @@
  */
 package org.apache.commons.crypto.random;
 
+import static org.junit.Assert.assertTrue;
+
 import java.security.GeneralSecurityException;
 import java.util.Properties;
 
 import org.apache.commons.crypto.Crypto;
 import org.junit.Assume;
 
-import static org.junit.Assert.assertTrue;
-
 public class OpenSslCryptoRandomTest extends AbstractRandomTest {
 
     @Override
diff --git a/src/test/java/org/apache/commons/crypto/random/OsCryptoRandomTest.java b/src/test/java/org/apache/commons/crypto/random/OsCryptoRandomTest.java
index 16f1ee1..3ae3ab9 100644
--- a/src/test/java/org/apache/commons/crypto/random/OsCryptoRandomTest.java
+++ b/src/test/java/org/apache/commons/crypto/random/OsCryptoRandomTest.java
@@ -17,6 +17,9 @@
  */
 package org.apache.commons.crypto.random;
 
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
 import java.io.FileNotFoundException;
 import java.lang.reflect.InvocationTargetException;
 import java.security.GeneralSecurityException;
@@ -25,8 +28,6 @@ import java.util.Properties;
 import org.junit.Assert;
 import org.junit.Assume;
 import org.junit.Test;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 
 public class OsCryptoRandomTest extends AbstractRandomTest {
 
diff --git a/src/test/java/org/apache/commons/crypto/stream/AbstractCipherStreamTest.java b/src/test/java/org/apache/commons/crypto/stream/AbstractCipherStreamTest.java
index 5a3bbbf..344fc0d 100644
--- a/src/test/java/org/apache/commons/crypto/stream/AbstractCipherStreamTest.java
+++ b/src/test/java/org/apache/commons/crypto/stream/AbstractCipherStreamTest.java
@@ -30,6 +30,7 @@ import java.nio.channels.ReadableByteChannel;
 import java.security.SecureRandom;
 import java.util.Properties;
 import java.util.Random;
+
 import javax.crypto.spec.IvParameterSpec;
 import javax.crypto.spec.SecretKeySpec;
 
diff --git a/src/test/java/org/apache/commons/crypto/stream/PositionedCryptoInputStreamTest.java b/src/test/java/org/apache/commons/crypto/stream/PositionedCryptoInputStreamTest.java
index 9931b63..52b9d2e 100644
--- a/src/test/java/org/apache/commons/crypto/stream/PositionedCryptoInputStreamTest.java
+++ b/src/test/java/org/apache/commons/crypto/stream/PositionedCryptoInputStreamTest.java
@@ -18,18 +18,6 @@
 
 package org.apache.commons.crypto.stream;
 
-import org.apache.commons.crypto.Crypto;
-import org.apache.commons.crypto.cipher.AbstractCipherTest;
-import org.apache.commons.crypto.cipher.CryptoCipher;
-import org.apache.commons.crypto.stream.input.Input;
-import org.apache.commons.crypto.utils.ReflectionUtils;
-import org.junit.Assert;
-import org.junit.Assume;
-import org.junit.Before;
-import org.junit.Test;
-
-import javax.crypto.spec.IvParameterSpec;
-import javax.crypto.spec.SecretKeySpec;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
@@ -40,6 +28,19 @@ import java.util.Objects;
 import java.util.Properties;
 import java.util.Random;
 
+import javax.crypto.spec.IvParameterSpec;
+import javax.crypto.spec.SecretKeySpec;
+
+import org.apache.commons.crypto.Crypto;
+import org.apache.commons.crypto.cipher.AbstractCipherTest;
+import org.apache.commons.crypto.cipher.CryptoCipher;
+import org.apache.commons.crypto.stream.input.Input;
+import org.apache.commons.crypto.utils.ReflectionUtils;
+import org.junit.Assert;
+import org.junit.Assume;
+import org.junit.Before;
+import org.junit.Test;
+
 public class PositionedCryptoInputStreamTest {
 
     private final int dataLen = 20000;


[commons-crypto] 03/06: Remove unused imports.

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-crypto.git

commit b89f0430c9ce1627597c157702bdba82a2c1e331
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Apr 10 15:36:10 2020 -0400

    Remove unused imports.
---
 src/test/java/org/apache/commons/crypto/jna/OpenSslJnaCipherTest.java    | 1 -
 .../java/org/apache/commons/crypto/jna/OpenSslJnaCryptoRandomTest.java   | 1 -
 2 files changed, 2 deletions(-)

diff --git a/src/test/java/org/apache/commons/crypto/jna/OpenSslJnaCipherTest.java b/src/test/java/org/apache/commons/crypto/jna/OpenSslJnaCipherTest.java
index 4b69ac9..d935e8b 100644
--- a/src/test/java/org/apache/commons/crypto/jna/OpenSslJnaCipherTest.java
+++ b/src/test/java/org/apache/commons/crypto/jna/OpenSslJnaCipherTest.java
@@ -19,7 +19,6 @@
 package org.apache.commons.crypto.jna;
 
 import org.apache.commons.crypto.cipher.OpenSslCipherTest;
-import org.apache.commons.crypto.jna.OpenSslJnaCipher;
 import org.junit.Assume;
 
 public class OpenSslJnaCipherTest extends OpenSslCipherTest {
diff --git a/src/test/java/org/apache/commons/crypto/jna/OpenSslJnaCryptoRandomTest.java b/src/test/java/org/apache/commons/crypto/jna/OpenSslJnaCryptoRandomTest.java
index fe23c99..a7162df 100644
--- a/src/test/java/org/apache/commons/crypto/jna/OpenSslJnaCryptoRandomTest.java
+++ b/src/test/java/org/apache/commons/crypto/jna/OpenSslJnaCryptoRandomTest.java
@@ -20,7 +20,6 @@ package org.apache.commons.crypto.jna;
 import java.security.GeneralSecurityException;
 import java.util.Properties;
 
-import org.apache.commons.crypto.jna.OpenSslJnaCryptoRandom;
 import org.apache.commons.crypto.random.AbstractRandomTest;
 import org.apache.commons.crypto.random.CryptoRandom;
 import org.apache.commons.crypto.random.CryptoRandomFactory;


[commons-crypto] 06/06: Site reports.

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-crypto.git

commit b453b61548b3cf28da837bdca05014fa4635cd15
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Apr 10 17:36:20 2020 -0400

    Site reports.
---
 pom.xml                                            | 56 ++++++++++++--
 .../checkstyle/checkstyle-suppressions.xml         | 23 ++++++
 src/site/resources/pmd/pmd-ruleset.xml             | 89 ++++++++++++++++++++++
 .../resources/spotbugs/spotbugs-exclude-filter.xml | 31 ++++++++
 4 files changed, 191 insertions(+), 8 deletions(-)

diff --git a/pom.xml b/pom.xml
index 5fdcf5b..e38ed4b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -473,6 +473,39 @@ The following provides more details on the included cryptographic software:
       </plugins>
     </pluginManagement>
     <plugins>
+      <!-- Allow checkstyle to be run interactively; keep in sync with report config below -->
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-checkstyle-plugin</artifactId>
+        <version>${checkstyle.version}</version>
+        <configuration>
+          <configLocation>${basedir}/checkstyle.xml</configLocation>
+          <enableRulesSummary>false</enableRulesSummary>
+          <suppressionsLocation>${basedir}/src/site/resources/checkstyle/checkstyle-suppressions.xml</suppressionsLocation>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>com.github.spotbugs</groupId>
+        <artifactId>spotbugs-maven-plugin</artifactId>
+        <version>${commons.spotbugs.version}</version>
+        <configuration>
+          <excludeFilterFile>${basedir}/src/site/resources/spotbugs/spotbugs-exclude-filter.xml</excludeFilterFile>
+        </configuration>
+      </plugin>
+      <!-- Allow pmd to be run interactively; keep in sync with report config below -->
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-pmd-plugin</artifactId>
+        <version>${commons.pmd.version}</version>
+        <configuration>
+          <targetJdk>${maven.compiler.target}</targetJdk>
+          <skipEmptyReport>false</skipEmptyReport>
+          <analysisCache>true</analysisCache>
+          <rulesets>
+            <ruleset>${basedir}/src/site/resources/pmd/pmd-ruleset.xml</ruleset>
+          </rulesets>
+        </configuration>
+      </plugin>    
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-jar-plugin</artifactId>
@@ -572,14 +605,17 @@ The following provides more details on the included cryptographic software:
   </build>
   <reporting>
     <plugins>
+      <!-- Keep in sync with build config above -->
       <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-checkstyle-plugin</artifactId>
-        <version>2.17</version>
+        <version>${checkstyle.version}</version>
         <configuration>
           <configLocation>${basedir}/checkstyle.xml</configLocation>
           <enableRulesSummary>false</enableRulesSummary>
-          <failsOnError>true</failsOnError>
+          <suppressionsLocation>${basedir}/src/site/resources/checkstyle/checkstyle-suppressions.xml</suppressionsLocation>
         </configuration>
+        <!-- We need to specify reportSets because 2.9.1 creates two reports -->
         <reportSets>
           <reportSet>
             <reports>
@@ -588,21 +624,25 @@ The following provides more details on the included cryptographic software:
           </reportSet>
         </reportSets>
       </plugin>
-      <!-- Requires setting 'export MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=128m" ' -->
       <plugin>
-        <groupId>org.codehaus.mojo</groupId>
-        <artifactId>findbugs-maven-plugin</artifactId>
-        <!-- Use version from parent pom as that is adjusted according to the Java version used to run Maven -->
-        <version>${commons.findbugs.version}</version>
+        <groupId>com.github.spotbugs</groupId>
+        <artifactId>spotbugs-maven-plugin</artifactId>
+        <version>${commons.spotbugs.version}</version>
         <configuration>
-          <excludeFilterFile>${basedir}/findbugs-exclude.xml</excludeFilterFile>
+          <excludeFilterFile>${basedir}/src/site/resources/spotbugs/spotbugs-exclude-filter.xml</excludeFilterFile>
         </configuration>
       </plugin>
       <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-pmd-plugin</artifactId>
         <version>${commons.pmd.version}</version>
         <configuration>
           <targetJdk>${maven.compiler.target}</targetJdk>
+          <skipEmptyReport>false</skipEmptyReport>
+          <analysisCache>true</analysisCache>
+          <rulesets>
+            <ruleset>${basedir}/src/site/resources/pmd/pmd-ruleset.xml</ruleset>
+          </rulesets>
         </configuration>
       </plugin>
       <plugin>
diff --git a/src/site/resources/checkstyle/checkstyle-suppressions.xml b/src/site/resources/checkstyle/checkstyle-suppressions.xml
new file mode 100644
index 0000000..d6b6e9c
--- /dev/null
+++ b/src/site/resources/checkstyle/checkstyle-suppressions.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0"?>
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+<!DOCTYPE suppressions PUBLIC
+    "-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
+    "https://checkstyle.org/dtds/suppressions_1_2.dtd">
+<suppressions>
+  <suppress checks="LineLength" files="[\\/]CSVParser\.java$" lines="508"/>
+</suppressions>
diff --git a/src/site/resources/pmd/pmd-ruleset.xml b/src/site/resources/pmd/pmd-ruleset.xml
new file mode 100644
index 0000000..8d52e45
--- /dev/null
+++ b/src/site/resources/pmd/pmd-ruleset.xml
@@ -0,0 +1,89 @@
+<?xml version="1.0"?>
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+<ruleset name="commons-rng-customized"
+    xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd">
+  <description>
+    This ruleset checks the code for discouraged programming constructs.
+  </description>
+
+  <!-- Default ruleset for maven-pmd-plugin -->
+  <rule ref="category/java/bestpractices.xml/AvoidUsingHardCodedIP"/>
+  <rule ref="category/java/bestpractices.xml/CheckResultSet"/>
+  <rule ref="category/java/bestpractices.xml/UnusedImports"/>
+  <rule ref="category/java/bestpractices.xml/UnusedFormalParameter"/>
+  <rule ref="category/java/bestpractices.xml/UnusedLocalVariable"/>
+  <rule ref="category/java/bestpractices.xml/UnusedPrivateField"/>
+  <rule ref="category/java/bestpractices.xml/UnusedPrivateMethod"/>
+  <rule ref="category/java/codestyle.xml/DontImportJavaLang"/>
+  <rule ref="category/java/codestyle.xml/DuplicateImports"/>
+  <rule ref="category/java/codestyle.xml/ExtendsObject"/>
+  <rule ref="category/java/codestyle.xml/ForLoopShouldBeWhileLoop"/>
+  <rule ref="category/java/codestyle.xml/TooManyStaticImports"/>
+  <rule ref="category/java/codestyle.xml/UnnecessaryFullyQualifiedName"/>
+  <rule ref="category/java/codestyle.xml/UnnecessaryModifier"/>
+  <rule ref="category/java/codestyle.xml/UnnecessaryReturn"/>
+  <rule ref="category/java/codestyle.xml/UselessParentheses"/>
+  <rule ref="category/java/codestyle.xml/UselessQualifiedThis"/>
+  <rule ref="category/java/design.xml/CollapsibleIfStatements"/>
+  <rule ref="category/java/design.xml/SimplifiedTernary"/>
+  <rule ref="category/java/design.xml/UselessOverridingMethod"/>
+  <rule ref="category/java/errorprone.xml/AvoidBranchingStatementAsLastInLoop"/>
+  <rule ref="category/java/errorprone.xml/AvoidDecimalLiteralsInBigDecimalConstructor"/>
+  <rule ref="category/java/errorprone.xml/AvoidMultipleUnaryOperators"/>
+  <rule ref="category/java/errorprone.xml/AvoidUsingOctalValues"/>
+  <rule ref="category/java/errorprone.xml/BrokenNullCheck"/>
+  <rule ref="category/java/errorprone.xml/CheckSkipResult"/>
+  <rule ref="category/java/errorprone.xml/ClassCastExceptionWithToArray"/>
+  <rule ref="category/java/errorprone.xml/DontUseFloatTypeForLoopIndices"/>
+  <rule ref="category/java/errorprone.xml/EmptyCatchBlock"/>
+  <rule ref="category/java/errorprone.xml/EmptyFinallyBlock"/>
+  <rule ref="category/java/errorprone.xml/EmptyIfStmt"/>
+  <rule ref="category/java/errorprone.xml/EmptyInitializer"/>
+  <rule ref="category/java/errorprone.xml/EmptyStatementBlock"/>
+  <rule ref="category/java/errorprone.xml/EmptyStatementNotInLoop"/>
+  <rule ref="category/java/errorprone.xml/EmptySwitchStatements"/>
+  <rule ref="category/java/errorprone.xml/EmptySynchronizedBlock"/>
+  <rule ref="category/java/errorprone.xml/EmptyTryBlock"/>
+  <rule ref="category/java/errorprone.xml/EmptyWhileStmt"/>
+  <rule ref="category/java/errorprone.xml/ImportFromSamePackage"/>
+  <rule ref="category/java/errorprone.xml/JumbledIncrementer"/>
+  <rule ref="category/java/errorprone.xml/MisplacedNullCheck"/>
+  <rule ref="category/java/errorprone.xml/OverrideBothEqualsAndHashcode"/>
+  <rule ref="category/java/errorprone.xml/ReturnFromFinallyBlock"/>
+  <rule ref="category/java/errorprone.xml/UnconditionalIfStatement"/>
+  <rule ref="category/java/errorprone.xml/UnnecessaryConversionTemporary"/>
+  <rule ref="category/java/errorprone.xml/UnusedNullCheckInEquals"/>
+  <rule ref="category/java/errorprone.xml/UselessOperationOnImmutable"/>
+  <rule ref="category/java/multithreading.xml/AvoidThreadGroup"/>
+  <rule ref="category/java/multithreading.xml/DontCallThreadRun"/>
+  <rule ref="category/java/multithreading.xml/DoubleCheckedLocking"/>
+  <rule ref="category/java/performance.xml/BigIntegerInstantiation"/>
+  <rule ref="category/java/performance.xml/BooleanInstantiation"/>
+
+  <!-- Rule customisations. -->
+
+  <rule ref="category/java/codestyle.xml/TooManyStaticImports">
+    <properties>
+      <property name="violationSuppressXPath"
+        value="//ClassOrInterfaceDeclaration[@Image='CSVFormat' or @Image='Lexer']"/>
+    </properties>
+  </rule>
+
+</ruleset>
diff --git a/src/site/resources/spotbugs/spotbugs-exclude-filter.xml b/src/site/resources/spotbugs/spotbugs-exclude-filter.xml
new file mode 100644
index 0000000..4af22bc
--- /dev/null
+++ b/src/site/resources/spotbugs/spotbugs-exclude-filter.xml
@@ -0,0 +1,31 @@
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+<FindBugsFilter
+        xmlns="https://github.com/spotbugs/filter/3.0.0"
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+        xsi:schemaLocation="https://github.com/spotbugs/filter/3.0.0 https://raw.githubusercontent.com/spotbugs/spotbugs/3.1.0/spotbugs/etc/findbugsfilter.xsd">
+
+
+  <Match>
+    <Class name="org.apache.commons.csv.CSVPrinter" />
+      <Method name="printComment" >
+          <!-- Deliberate switch statement fall-through -->
+      </Method>
+    <Bug code="SF" />
+  </Match>
+
+</FindBugsFilter>