Repository: commons-crypto Updated Branches: refs/heads/master 720b1173d -> 4afa1ec81
CRYPTO-79: Fix the javadoc based on the checkstyle Project: http://git-wip-us.apache.org/repos/asf/commons-crypto/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-crypto/commit/4afa1ec8 Tree: http://git-wip-us.apache.org/repos/asf/commons-crypto/tree/4afa1ec8 Diff: http://git-wip-us.apache.org/repos/asf/commons-crypto/diff/4afa1ec8 Branch: refs/heads/master Commit: 4afa1ec81b6f51df8683144f79633a392dcb9264 Parents: 720b117 Author: JKSelf <ke.a....@intel.com> Authored: Thu Jun 16 14:17:01 2016 +0800 Committer: Sun Dapeng <s...@apache.org> Committed: Thu Jun 16 14:56:52 2016 +0800 ---------------------------------------------------------------------- .../crypto/cipher/CryptoCipherFactory.java | 10 ++- .../apache/commons/crypto/cipher/Openssl.java | 36 +++++++++ .../commons/crypto/cipher/OpensslNative.java | 3 + .../commons/crypto/conf/ConfigurationKeys.java | 3 + .../crypto/random/CryptoRandomFactory.java | 3 + .../random/OpensslCryptoRandomNative.java | 4 +- .../commons/crypto/random/OsCryptoRandom.java | 5 ++ .../crypto/stream/CTRCryptoInputStream.java | 5 ++ .../crypto/stream/CryptoOutputStream.java | 5 ++ .../stream/PositionedCryptoInputStream.java | 77 ++++++++++++++++++-- .../crypto/stream/input/ChannelInput.java | 5 ++ .../crypto/stream/output/StreamOutput.java | 5 ++ .../apache/commons/crypto/utils/IOUtils.java | 3 + .../commons/crypto/utils/NativeCodeLoader.java | 23 +++++- .../org/apache/commons/crypto/utils/OSInfo.java | 8 ++ .../commons/crypto/utils/ReflectionUtils.java | 3 + .../org/apache/commons/crypto/utils/Utils.java | 3 + 17 files changed, 192 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/4afa1ec8/src/main/java/org/apache/commons/crypto/cipher/CryptoCipherFactory.java ---------------------------------------------------------------------- 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 9b2e58e..9e59cff 100644 --- a/src/main/java/org/apache/commons/crypto/cipher/CryptoCipherFactory.java +++ b/src/main/java/org/apache/commons/crypto/cipher/CryptoCipherFactory.java @@ -36,6 +36,9 @@ public class CryptoCipherFactory { private final static Logger LOG = LoggerFactory .getLogger(CryptoCipherFactory.class); + /** + * The private Constructor of {@link CryptoCipherFactory}. + */ private CryptoCipherFactory() { } @@ -88,7 +91,12 @@ public class CryptoCipherFactory { return getInstance(transformation, new Properties()); } - // Return OpenSSLCipher if Properties is null or empty by default + /** + * Returns OpenSSLCipher if Properties is null or empty by default. + * + * @param props the configuration properties. + * @return the OpenSSLCipher instance. + */ private static List<Class<? extends CryptoCipher>> getCipherClasses( Properties props) { List<Class<? extends CryptoCipher>> result = new ArrayList<Class<? extends CryptoCipher>>(); http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/4afa1ec8/src/main/java/org/apache/commons/crypto/cipher/Openssl.java ---------------------------------------------------------------------- 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 de8856c..1d0e441 100644 --- a/src/main/java/org/apache/commons/crypto/cipher/Openssl.java +++ b/src/main/java/org/apache/commons/crypto/cipher/Openssl.java @@ -47,6 +47,14 @@ public final class Openssl { private static enum AlgorithmMode { AES_CTR, AES_CBC; + /** + * Gets the mode. + * + * @param algorithm the algorithm. + * @param mode the mode. + * @return the Algorithm mode. + * @throws NoSuchAlgorithmException if the algorithm is not available. + */ static int get(String algorithm, String mode) throws NoSuchAlgorithmException { try { @@ -62,6 +70,13 @@ public final class Openssl { private static enum Padding { NoPadding, PKCS5Padding; + /** + * Gets the Padding instance. + * + * @param padding the padding. + * @return the value of Padding. + * @throws NoSuchPaddingException if the padding is not available. + */ static int get(String padding) throws NoSuchPaddingException { try { return Padding.valueOf(padding).ordinal(); @@ -101,6 +116,13 @@ public final class Openssl { return loadingFailureReason; } + /** + * Constructs a {@Link Openssl} instance based on context, algorithm and padding. + * + * @param context the context. + * @param algorithm the algorithm. + * @param padding the padding. + */ private Openssl(long context, int algorithm, int padding) { this.context = context; this.algorithm = algorithm; @@ -136,6 +158,13 @@ public final class Openssl { final String mode; final String padding; + /** + * Constructs a {@Link Transform} based on the algorithm, mode and padding. + * + * @param algorithm the algorithm + * @param mode the mode. + * @param padding the padding. + */ public Transform(String algorithm, String mode, String padding) { this.algorithm = algorithm; this.mode = mode; @@ -143,6 +172,13 @@ public final class Openssl { } } + /** + * Gets the tokens of transformation. + * + * @param transformation the transformation. + * @return the {@Link Transform} instance. + * @throws NoSuchAlgorithmException if the transformation is null. + */ private static Transform tokenizeTransformation(String transformation) throws NoSuchAlgorithmException { if (transformation == null) { http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/4afa1ec8/src/main/java/org/apache/commons/crypto/cipher/OpensslNative.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/crypto/cipher/OpensslNative.java b/src/main/java/org/apache/commons/crypto/cipher/OpensslNative.java index 9993098..7b4f5a5 100644 --- a/src/main/java/org/apache/commons/crypto/cipher/OpensslNative.java +++ b/src/main/java/org/apache/commons/crypto/cipher/OpensslNative.java @@ -25,6 +25,9 @@ import java.nio.ByteBuffer; */ public class OpensslNative { + /** + * The private constructor of {@Link OpensslNative}. + */ private OpensslNative() { } http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/4afa1ec8/src/main/java/org/apache/commons/crypto/conf/ConfigurationKeys.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/crypto/conf/ConfigurationKeys.java b/src/main/java/org/apache/commons/crypto/conf/ConfigurationKeys.java index 30edb1b..04d89b2 100644 --- a/src/main/java/org/apache/commons/crypto/conf/ConfigurationKeys.java +++ b/src/main/java/org/apache/commons/crypto/conf/ConfigurationKeys.java @@ -130,6 +130,9 @@ public class ConfigurationKeys { public static final String COMMONS_CRYPTO_LIB_TEMPDIR_KEY = CONF_PREFIX + "lib.tempdir"; + /** + * The private constructor of {@Link ConfigurationKeys}. + */ private ConfigurationKeys() { } } http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/4afa1ec8/src/main/java/org/apache/commons/crypto/random/CryptoRandomFactory.java ---------------------------------------------------------------------- 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 b299353..eb536ef 100644 --- a/src/main/java/org/apache/commons/crypto/random/CryptoRandomFactory.java +++ b/src/main/java/org/apache/commons/crypto/random/CryptoRandomFactory.java @@ -35,6 +35,9 @@ public class CryptoRandomFactory { public final static Logger LOG = LoggerFactory .getLogger(CryptoRandomFactory.class); + /** + * The private constructor of {@Link CryptoRandomFactory}. + */ private CryptoRandomFactory() { } http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/4afa1ec8/src/main/java/org/apache/commons/crypto/random/OpensslCryptoRandomNative.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/crypto/random/OpensslCryptoRandomNative.java b/src/main/java/org/apache/commons/crypto/random/OpensslCryptoRandomNative.java index 65078c3..8301873 100644 --- a/src/main/java/org/apache/commons/crypto/random/OpensslCryptoRandomNative.java +++ b/src/main/java/org/apache/commons/crypto/random/OpensslCryptoRandomNative.java @@ -22,7 +22,9 @@ package org.apache.commons.crypto.random; * this class is defined in OpensslCryptoRandomNative.h(genereted by javah). */ public class OpensslCryptoRandomNative { - + /** + * The private constructor of {@Link OpensslCryptoRandomNative}. + */ private OpensslCryptoRandomNative() { } http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/4afa1ec8/src/main/java/org/apache/commons/crypto/random/OsCryptoRandom.java ---------------------------------------------------------------------- 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 eca62d2..2e6fd00 100644 --- a/src/main/java/org/apache/commons/crypto/random/OsCryptoRandom.java +++ b/src/main/java/org/apache/commons/crypto/random/OsCryptoRandom.java @@ -47,6 +47,11 @@ public class OsCryptoRandom extends Random implements CryptoRandom { private int pos = reservoir.length; + /** + * Fills the reservoir. + * + * @param min the length. + */ private void fillReservoir(int min) { if (pos >= reservoir.length - min) { try { http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/4afa1ec8/src/main/java/org/apache/commons/crypto/stream/CTRCryptoInputStream.java ---------------------------------------------------------------------- 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 f2df802..bfdd6fb 100644 --- a/src/main/java/org/apache/commons/crypto/stream/CTRCryptoInputStream.java +++ b/src/main/java/org/apache/commons/crypto/stream/CTRCryptoInputStream.java @@ -368,6 +368,11 @@ public class CTRCryptoInputStream extends CryptoInputStream { return streamOffset; } + /** + * Sets the offset of stream. + * + * @param streamOffset the stream offset. + */ protected void setStreamOffset(long streamOffset) { this.streamOffset = streamOffset; } http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/4afa1ec8/src/main/java/org/apache/commons/crypto/stream/CryptoOutputStream.java ---------------------------------------------------------------------- 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 2cce827..f5f9d97 100644 --- a/src/main/java/org/apache/commons/crypto/stream/CryptoOutputStream.java +++ b/src/main/java/org/apache/commons/crypto/stream/CryptoOutputStream.java @@ -384,6 +384,11 @@ public class CryptoOutputStream extends OutputStream implements output.write(outBuffer); } + /** + * Checks whether the stream is closed. + * + * @throws IOException if an I/O error occurs. + */ protected void checkStream() throws IOException { if (closed) { throw new IOException("Stream closed"); http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/4afa1ec8/src/main/java/org/apache/commons/crypto/stream/PositionedCryptoInputStream.java ---------------------------------------------------------------------- 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 a962215..c7399dd 100644 --- a/src/main/java/org/apache/commons/crypto/stream/PositionedCryptoInputStream.java +++ b/src/main/java/org/apache/commons/crypto/stream/PositionedCryptoInputStream.java @@ -192,7 +192,13 @@ public class PositionedCryptoInputStream extends CTRCryptoInputStream { /** * Does the decryption using inBuffer as input and outBuffer as output. Upon * return, inBuffer is cleared; the decrypted data starts at - * outBuffer.position() and ends at outBuffer.limit() + * outBuffer.position() and ends at outBuffer.limit(). + * + * @param state the CipherState instance. + * @param inBuffer the input buffer. + * @param outBuffer the output buffer. + * @param padding the padding. + * @throws IOException if an I/O error occurs. */ private void decrypt(CipherState state, ByteBuffer inBuffer, ByteBuffer outBuffer, byte padding) throws IOException { @@ -215,6 +221,14 @@ public class PositionedCryptoInputStream extends CTRCryptoInputStream { } } + /** + * Does the decryption using inBuffer as input and outBuffer as output. + * + * @param state the CipherState instance. + * @param inBuffer the input buffer. + * @param outBuffer the output buffer. + * @throws IOException if an I/O error occurs. + */ private void decryptBuffer(CipherState state, ByteBuffer inBuffer, ByteBuffer outBuffer) throws IOException { int inputSize = inBuffer.remaining(); @@ -241,6 +255,13 @@ public class PositionedCryptoInputStream extends CTRCryptoInputStream { /** * This method is executed immediately after decryption. Check whether * cipher should be updated and recalculate padding if needed. + * + * @param state the CipherState instance. + * @param inBuffer the input buffer. + * @param position the offset from the start of the stream. + * @param iv the iv. + * @return the padding. + * @throws IOException if an I/O error occurs. */ private byte postDecryption(CipherState state, ByteBuffer inBuffer, long position, byte[] iv) throws IOException { @@ -259,7 +280,14 @@ public class PositionedCryptoInputStream extends CTRCryptoInputStream { return padding; } - /** Calculate the counter and iv, reset the cipher. */ + /** + * Calculates the counter and iv, reset the cipher. + * + * @param state the CipherState instance. + * @param position the offset from the start of the stream. + * @param iv the iv. + * @throws IOException if an I/O error occurs. + */ private void resetCipher(CipherState state, long position, byte[] iv) throws IOException { final long counter = getCounter(position); @@ -275,7 +303,12 @@ public class PositionedCryptoInputStream extends CTRCryptoInputStream { state.reset(false); } - /** Get CryptoCipher from pool */ + /** + * Gets CryptoCipher from pool. + * + * @return the CipherState instance. + * @throws IOException if an I/O error occurs. + */ private CipherState getCipherState() throws IOException { CipherState state = cipherPool.poll(); if (state == null) { @@ -292,14 +325,22 @@ public class PositionedCryptoInputStream extends CTRCryptoInputStream { return state; } - /** Return CryptoCipher to pool */ + /** + * Returns CryptoCipher to pool. + * + * @param state the CipherState instance. + */ private void returnCipherState(CipherState state) { if (state != null) { cipherPool.add(state); } } - /** Get direct buffer from pool */ + /** + * Gets direct buffer from pool. + * + * @return the buffer. + */ private ByteBuffer getBuffer() { ByteBuffer buffer = bufferPool.poll(); if (buffer == null) { @@ -309,7 +350,11 @@ public class PositionedCryptoInputStream extends CTRCryptoInputStream { return buffer; } - /** Return direct buffer to pool */ + /** + * Returns direct buffer to pool. + * + * @param buf the buffer. + */ private void returnBuffer(ByteBuffer buf) { if (buf != null) { buf.clear(); @@ -345,19 +390,39 @@ public class PositionedCryptoInputStream extends CTRCryptoInputStream { private CryptoCipher cipher; private boolean reset; + /** + * The constructor of {@Link CipherState}. + * + * @param cipher the CryptoCipher instance. + */ public CipherState(CryptoCipher cipher) { this.cipher = cipher; this.reset = false; } + /** + * Gets the CryptoCipher instance. + * + * @return the cipher. + */ public CryptoCipher getCipher() { return cipher; } + /** + * Gets the reset. + * + * @return the value of reset. + */ public boolean isReset() { return reset; } + /** + * Sets the value of reset. + * + * @param reset the reset. + */ public void reset(boolean reset) { this.reset = reset; } http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/4afa1ec8/src/main/java/org/apache/commons/crypto/stream/input/ChannelInput.java ---------------------------------------------------------------------- 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 dbcba57..d85dba1 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 @@ -161,6 +161,11 @@ public class ChannelInput implements Input { channel.close(); } + /** + * Gets the skip buffer. + * + * @return the buffer. + */ private ByteBuffer getSkipBuf() { if (buf == null) { buf = ByteBuffer.allocate(SKIP_BUFFER_SIZE); http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/4afa1ec8/src/main/java/org/apache/commons/crypto/stream/output/StreamOutput.java ---------------------------------------------------------------------- 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 78c9bab..e76c11c 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 @@ -92,6 +92,11 @@ public class StreamOutput implements Output { out.close(); } + /** + * Gets the output stream. + * + * @return the output stream. + */ protected OutputStream getOut() { return out; } http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/4afa1ec8/src/main/java/org/apache/commons/crypto/utils/IOUtils.java ---------------------------------------------------------------------- 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 d414716..a766613 100644 --- a/src/main/java/org/apache/commons/crypto/utils/IOUtils.java +++ b/src/main/java/org/apache/commons/crypto/utils/IOUtils.java @@ -28,6 +28,9 @@ import org.apache.commons.logging.Log; */ public final class IOUtils { + /** + * Teh private constructor of {@Link IOUtils}. + */ private IOUtils() { } http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/4afa1ec8/src/main/java/org/apache/commons/crypto/utils/NativeCodeLoader.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/crypto/utils/NativeCodeLoader.java b/src/main/java/org/apache/commons/crypto/utils/NativeCodeLoader.java index 1813745..2068828 100644 --- a/src/main/java/org/apache/commons/crypto/utils/NativeCodeLoader.java +++ b/src/main/java/org/apache/commons/crypto/utils/NativeCodeLoader.java @@ -40,7 +40,9 @@ public final class NativeCodeLoader { private static final Log LOG = LogFactory.getLog(NativeCodeLoader.class); private final static boolean nativeCodeLoaded; - + /** + * The private constructor of {@Link NativeCodeLoader}. + */ private NativeCodeLoader() { } @@ -78,6 +80,11 @@ public final class NativeCodeLoader { } } + /** + * Finds the native library. + * + * @return the jar file. + */ static File findNativeLibrary() { // Try to load the library in commons-crypto.lib.path */ String nativeLibraryPath = Utils.getLibPath(); @@ -248,6 +255,14 @@ public final class NativeCodeLoader { return version; } + /** + * Checks whether in1 and in2 is equal. + * + * @param in1 the input1. + * @param in2 the input2. + * @return true if in1 and in2 is equal, else false. + * @throws IOException if an I/O error occurs. + */ private static boolean contentsEquals(InputStream in1, InputStream in2) throws IOException { if (!(in1 instanceof BufferedInputStream)) { @@ -269,6 +284,12 @@ public final class NativeCodeLoader { return ch2 == -1; } + /** + * Checks whether the given path has resource. + * + * @param path the path. + * @return the boolean. + */ private static boolean hasResource(String path) { return NativeCodeLoader.class.getResource(path) != null; } http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/4afa1ec8/src/main/java/org/apache/commons/crypto/utils/OSInfo.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/crypto/utils/OSInfo.java b/src/main/java/org/apache/commons/crypto/utils/OSInfo.java index 21f2fe3..f4c31fb 100644 --- a/src/main/java/org/apache/commons/crypto/utils/OSInfo.java +++ b/src/main/java/org/apache/commons/crypto/utils/OSInfo.java @@ -63,6 +63,9 @@ public class OSInfo { */ public static final String PPC64 = "ppc64"; + /** + * The private constructor of {@Link OSInfo}. + */ private OSInfo() { } @@ -104,6 +107,11 @@ public class OSInfo { archMapping.put("power_rs64", PPC64); } + /** + * The main method. + * + * @param args the argv. + */ public static void main(String[] args) { if (args.length >= 1) { if ("--os".equals(args[0])) { http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/4afa1ec8/src/main/java/org/apache/commons/crypto/utils/ReflectionUtils.java ---------------------------------------------------------------------- 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 81e0aa6..014e7b1 100644 --- a/src/main/java/org/apache/commons/crypto/utils/ReflectionUtils.java +++ b/src/main/java/org/apache/commons/crypto/utils/ReflectionUtils.java @@ -46,6 +46,9 @@ public final class ReflectionUtils { */ private static final Class<?> NEGATIVE_CACHE_SENTINEL = NegativeCacheSentinel.class; + /** + * The private constructor of {@Link ReflectionUtils}. + */ private ReflectionUtils() { } http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/4afa1ec8/src/main/java/org/apache/commons/crypto/utils/Utils.java ---------------------------------------------------------------------- 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 f3a82e9..a36f215 100644 --- a/src/main/java/org/apache/commons/crypto/utils/Utils.java +++ b/src/main/java/org/apache/commons/crypto/utils/Utils.java @@ -59,6 +59,9 @@ public final class Utils { private static final int AES_BLOCK_SIZE = CipherTransformation.AES_CTR_NOPADDING .getAlgorithmBlockSize(); + /** + * The private constructor of {@Link Utils}. + */ private Utils() { }