javadoc fixes

This commit is contained in:
2021-02-22 16:19:44 -05:00
parent 196295f8ed
commit 6c82e6b1a8
12 changed files with 77 additions and 21 deletions

28
pom.xml
View File

@@ -8,10 +8,24 @@
<description>This project implements the javax.crypto API using java.nio instead of java.io.</description> <description>This project implements the javax.crypto API using java.nio instead of java.io.</description>
<properties> <properties>
<project.build.sourceEncoding>utf-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source> <maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target> <maven.compiler.target>1.7</maven.compiler.target>
</properties> </properties>
<organization>
<name>Inteligr8</name>
<url>https://www.inteligr8.com</url>
</organization>
<developers>
<developer>
<name>Brian Long</name>
<email>brian@inteligr8.com</email>
<url>https://twitter.com/brianmlong</url>
</developer>
</developers>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
@@ -38,13 +52,23 @@
</dependency> </dependency>
</dependencies> </dependencies>
<reporting> <build>
<plugins> <plugins>
<plugin> <plugin>
<artifactId>maven-javadoc-plugin</artifactId> <artifactId>maven-javadoc-plugin</artifactId>
<executions>
<execution>
<id>javadoc</id>
<phase>package</phase>
<goals><goal>jar</goal></goals>
<configuration>
<show>public</show>
</configuration>
</execution>
</executions>
</plugin> </plugin>
</plugins> </plugins>
</reporting> </build>
<distributionManagement> <distributionManagement>
<repository> <repository>

View File

@@ -16,7 +16,7 @@ import org.slf4j.LoggerFactory;
* *
* @author brian@inteligr8.com * @author brian@inteligr8.com
*/ */
public class AbstractCryptoByteChannel implements Channel { abstract class AbstractCryptoByteChannel implements Channel {
private final Logger logger = LoggerFactory.getLogger(AbstractCryptoByteChannel.class); private final Logger logger = LoggerFactory.getLogger(AbstractCryptoByteChannel.class);

View File

@@ -25,7 +25,7 @@ import javax.crypto.BadPaddingException;
import javax.crypto.IllegalBlockSizeException; import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException; import javax.crypto.NoSuchPaddingException;
public abstract class AbstractCryptoReadableByteChannel extends AbstractCryptoByteChannel implements ReadableByteChannel { abstract class AbstractCryptoReadableByteChannel extends AbstractCryptoByteChannel implements ReadableByteChannel {
protected final ReadableByteChannel rbchannel; protected final ReadableByteChannel rbchannel;

View File

@@ -26,7 +26,7 @@ import javax.crypto.BadPaddingException;
import javax.crypto.IllegalBlockSizeException; import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException; import javax.crypto.NoSuchPaddingException;
public abstract class AbstractCryptoWritableByteChannel extends AbstractCryptoByteChannel implements WritableByteChannel, Flushable { abstract class AbstractCryptoWritableByteChannel extends AbstractCryptoByteChannel implements WritableByteChannel, Flushable {
protected final WritableByteChannel wbchannel; protected final WritableByteChannel wbchannel;

View File

@@ -26,7 +26,7 @@ import org.slf4j.LoggerFactory;
* *
* @author brian@inteligr8.com * @author brian@inteligr8.com
*/ */
public class AbstractDigestByteChannel implements Channel { abstract class AbstractDigestByteChannel implements Channel {
private final Logger logger = LoggerFactory.getLogger(AbstractDigestByteChannel.class); private final Logger logger = LoggerFactory.getLogger(AbstractDigestByteChannel.class);

View File

@@ -145,8 +145,9 @@ public class CipherBuffer extends AbstractBuffer {
/** /**
* An accessor for the optional initialization vector. * An accessor for the optional initialization vector.
* *
* https://en.wikipedia.org/wiki/Initialization_vector
*
* @return A byte array of the IV with a length of the key or block size; or null * @return A byte array of the IV with a length of the key or block size; or null
* @see https://en.wikipedia.org/wiki/Initialization_vector
*/ */
public byte[] getInitializationVector() { public byte[] getInitializationVector() {
return this.cipher.getIV(); return this.cipher.getIV();
@@ -155,9 +156,10 @@ public class CipherBuffer extends AbstractBuffer {
/** /**
* A modifier for the optional initialization vector. * A modifier for the optional initialization vector.
* *
* https://en.wikipedia.org/wiki/Initialization_vector
*
* @param initializationVector A byte array of the IV with a length of the key or block size; or null to unset * @param initializationVector A byte array of the IV with a length of the key or block size; or null to unset
* @throws InvalidAlgorithmParameterException The specified algorithm does not support an IV or the specified length is incorrect * @throws InvalidAlgorithmParameterException The specified algorithm does not support an IV or the specified length is incorrect
* @see https://en.wikipedia.org/wiki/Initialization_vector
*/ */
public void setInitializationVector(byte[] initializationVector) throws InvalidAlgorithmParameterException { public void setInitializationVector(byte[] initializationVector) throws InvalidAlgorithmParameterException {
try { try {

View File

@@ -106,7 +106,7 @@ public class HashingWritableByteChannel extends AbstractDigestByteChannel implem
* @param buffer A NIO buffer ready for reading * @param buffer A NIO buffer ready for reading
* @return The number of bytes written to the underlying channel; never negative * @return The number of bytes written to the underlying channel; never negative
* @throws IOException An I/O or hashing exception occurred * @throws IOException An I/O or hashing exception occurred
* @throws DigestException * @throws DigestException A hashing issue occurred
*/ */
protected int _write(ByteBuffer buffer) throws IOException, DigestException { protected int _write(ByteBuffer buffer) throws IOException, DigestException {
if (!this.isOpen()) if (!this.isOpen())
@@ -122,8 +122,7 @@ public class HashingWritableByteChannel extends AbstractDigestByteChannel implem
* *
* @return The number of bytes written to the underlying channel; never negative * @return The number of bytes written to the underlying channel; never negative
* @throws IOException An I/O or crypto exception occurred * @throws IOException An I/O or crypto exception occurred
* @throws IllegalBlockSizeException * @throws DigestException A hashing issue occurred
* @throws BadPaddingException
*/ */
protected int _flush() throws IOException, DigestException { protected int _flush() throws IOException, DigestException {
if (!this.isOpen()) if (!this.isOpen())

View File

@@ -44,7 +44,7 @@ public class IVEncryptingWritableByteChannel implements WritableByteChannel, Flu
private boolean wroteIV = false; private boolean wroteIV = false;
/** /**
* @param rbchannel A readable byte channel * @param wbchannel A writable byte channel
* @param key A JCA key * @param key A JCA key
* @param transformation A JCE transformation in the pattern 'algorithm/cipher_mode/padding' * @param transformation A JCE transformation in the pattern 'algorithm/cipher_mode/padding'
* @throws NoSuchAlgorithmException The algorithm is not supported by the JCA provider * @throws NoSuchAlgorithmException The algorithm is not supported by the JCA provider
@@ -57,19 +57,50 @@ public class IVEncryptingWritableByteChannel implements WritableByteChannel, Flu
this.wbchannel = wbchannel; this.wbchannel = wbchannel;
this.ewbchannel = new EncryptingWritableByteChannel(wbchannel, new EncryptingCipherParameters(key, transformation, IVSource.Generated)); this.ewbchannel = new EncryptingWritableByteChannel(wbchannel, new EncryptingCipherParameters(key, transformation, IVSource.Generated));
} }
/**
* @param wbchannel A writable byte channel
* @param key A JCA key
* @param transformation A JCE transformation in the pattern 'algorithm/cipher_mode/padding'
* @param iv A byte array of the initialization vector
* @throws NoSuchAlgorithmException The algorithm is not supported by the JCA provider
* @throws NoSuchPaddingException The padding is not supported by the JCA provider and cipher mode
* @throws InvalidKeyException The key is not compatible with the specified transformation
* @throws InvalidAlgorithmParameterException The algorithm does not support IV or requires an IV
*/
public IVEncryptingWritableByteChannel(WritableByteChannel wbchannel, Key key, String transformation, byte[] iv) public IVEncryptingWritableByteChannel(WritableByteChannel wbchannel, Key key, String transformation, byte[] iv)
throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException { throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException {
this.wbchannel = wbchannel; this.wbchannel = wbchannel;
this.ewbchannel = new EncryptingWritableByteChannel(wbchannel, new EncryptingCipherParameters(key, transformation, iv)); this.ewbchannel = new EncryptingWritableByteChannel(wbchannel, new EncryptingCipherParameters(key, transformation, iv));
} }
/**
* @param wbchannel A writable byte channel
* @param key A JCA key
* @param transformation A JCE transformation in the pattern 'algorithm/cipher_mode/padding'
* @param provider A JCA provider
* @throws NoSuchAlgorithmException The algorithm is not supported by the JCA provider
* @throws NoSuchPaddingException The padding is not supported by the JCA provider and cipher mode
* @throws InvalidKeyException The key is not compatible with the specified transformation
* @throws InvalidAlgorithmParameterException The algorithm does not support IV or requires an IV
*/
public IVEncryptingWritableByteChannel(WritableByteChannel wbchannel, Key key, String transformation, Provider provider) public IVEncryptingWritableByteChannel(WritableByteChannel wbchannel, Key key, String transformation, Provider provider)
throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException { throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException {
this.wbchannel = wbchannel; this.wbchannel = wbchannel;
this.ewbchannel = new EncryptingWritableByteChannel(wbchannel, new EncryptingCipherParameters(key, transformation, IVSource.Generated, provider)); this.ewbchannel = new EncryptingWritableByteChannel(wbchannel, new EncryptingCipherParameters(key, transformation, IVSource.Generated, provider));
} }
/**
* @param wbchannel A writable byte channel
* @param key A JCA key
* @param transformation A JCE transformation in the pattern 'algorithm/cipher_mode/padding'
* @param iv A byte array of the initialization vector
* @param provider A JCA provider
* @throws NoSuchAlgorithmException The algorithm is not supported by the JCA provider
* @throws NoSuchPaddingException The padding is not supported by the JCA provider and cipher mode
* @throws InvalidKeyException The key is not compatible with the specified transformation
* @throws InvalidAlgorithmParameterException The algorithm does not support IV or requires an IV
*/
public IVEncryptingWritableByteChannel(WritableByteChannel wbchannel, Key key, String transformation, byte[] iv, Provider provider) public IVEncryptingWritableByteChannel(WritableByteChannel wbchannel, Key key, String transformation, byte[] iv, Provider provider)
throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException { throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException {
this.wbchannel = wbchannel; this.wbchannel = wbchannel;
@@ -129,7 +160,7 @@ public class IVEncryptingWritableByteChannel implements WritableByteChannel, Flu
* @see EncryptingWritableByteChannel#write(ByteBuffer) * @see EncryptingWritableByteChannel#write(ByteBuffer)
*/ */
@Override @Override
public int write(ByteBuffer src) throws IOException { public int write(ByteBuffer buffer) throws IOException {
int bytes = 0; int bytes = 0;
if (!this.wroteIV) { if (!this.wroteIV) {
ByteBuffer iv = ByteBuffer.wrap(this.ewbchannel.getCipher().getInitializationVector()); ByteBuffer iv = ByteBuffer.wrap(this.ewbchannel.getCipher().getInitializationVector());
@@ -137,7 +168,7 @@ public class IVEncryptingWritableByteChannel implements WritableByteChannel, Flu
this.wroteIV = true; this.wroteIV = true;
} }
bytes += this.ewbchannel.write(src); bytes += this.ewbchannel.write(buffer);
return bytes; return bytes;
} }

View File

@@ -8,7 +8,7 @@ import java.security.NoSuchAlgorithmException;
import javax.crypto.KeyGenerator; import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey; import javax.crypto.SecretKey;
public abstract class AbstractCipherUnitTest { abstract class AbstractCipherUnitTest {
public abstract String getDefaultAlgorithm(); public abstract String getDefaultAlgorithm();
public abstract int getDefaultKeySize(); public abstract int getDefaultKeySize();

View File

@@ -10,7 +10,7 @@ import org.apache.commons.codec.binary.Hex;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
public abstract class AbstractCryptoByteChannelUnitTest { abstract class AbstractCryptoByteChannelUnitTest {
private final Charset charset = Charset.forName("utf-8"); private final Charset charset = Charset.forName("utf-8");

View File

@@ -12,7 +12,7 @@ import org.apache.commons.codec.binary.Hex;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
public abstract class AbstractDigestUnitTest { abstract class AbstractDigestUnitTest {
public abstract String getDefaultAlgorithm(); public abstract String getDefaultAlgorithm();

View File

@@ -7,7 +7,7 @@ import java.nio.charset.Charset;
import org.junit.Test; import org.junit.Test;
public abstract class AbstractHashingByteChannelUnitTest { abstract class AbstractHashingByteChannelUnitTest {
private final Charset charset = Charset.forName("utf-8"); private final Charset charset = Charset.forName("utf-8");