diff options
Diffstat (limited to 'bcprov/src/main/java/org/bouncycastle/util')
25 files changed, 0 insertions, 1049 deletions
diff --git a/bcprov/src/main/java/org/bouncycastle/util/MemoableResetException.java b/bcprov/src/main/java/org/bouncycastle/util/MemoableResetException.java deleted file mode 100644 index 6552bd4..0000000 --- a/bcprov/src/main/java/org/bouncycastle/util/MemoableResetException.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.bouncycastle.util; - -/** - * Exception to be thrown on a failure to reset an object implementing Memoable. - * <p> - * The exception extends ClassCastException to enable users to have a single handling case, - * only introducing specific handling of this one if required. - * </p> - */ -public class MemoableResetException - extends ClassCastException -{ - /** - * Basic Constructor. - * - * @param msg message to be associated with this exception. - */ - public MemoableResetException(String msg) - { - super(msg); - } -} diff --git a/bcprov/src/main/java/org/bouncycastle/util/Shorts.java b/bcprov/src/main/java/org/bouncycastle/util/Shorts.java deleted file mode 100644 index 258e01e..0000000 --- a/bcprov/src/main/java/org/bouncycastle/util/Shorts.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.bouncycastle.util; - -public class Shorts -{ - public static Short valueOf(short value) - { - return Short.valueOf(value); - } -} diff --git a/bcprov/src/main/java/org/bouncycastle/util/StreamParser.java b/bcprov/src/main/java/org/bouncycastle/util/StreamParser.java deleted file mode 100644 index 13f2b16..0000000 --- a/bcprov/src/main/java/org/bouncycastle/util/StreamParser.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.bouncycastle.util; - -import java.util.Collection; - -public interface StreamParser -{ - Object read() throws StreamParsingException; - - Collection readAll() throws StreamParsingException; -} diff --git a/bcprov/src/main/java/org/bouncycastle/util/StreamParsingException.java b/bcprov/src/main/java/org/bouncycastle/util/StreamParsingException.java deleted file mode 100644 index 0a76378..0000000 --- a/bcprov/src/main/java/org/bouncycastle/util/StreamParsingException.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.bouncycastle.util; - -public class StreamParsingException - extends Exception -{ - Throwable _e; - - public StreamParsingException(String message, Throwable e) - { - super(message); - _e = e; - } - - public Throwable getCause() - { - return _e; - } -} diff --git a/bcprov/src/main/java/org/bouncycastle/util/Times.java b/bcprov/src/main/java/org/bouncycastle/util/Times.java deleted file mode 100644 index 617d00b..0000000 --- a/bcprov/src/main/java/org/bouncycastle/util/Times.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.bouncycastle.util; - -public final class Times -{ - public static long nanoTime() - { - return System.nanoTime(); - } -} diff --git a/bcprov/src/main/java/org/bouncycastle/util/encoders/BufferedDecoder.java b/bcprov/src/main/java/org/bouncycastle/util/encoders/BufferedDecoder.java deleted file mode 100644 index eea85b9..0000000 --- a/bcprov/src/main/java/org/bouncycastle/util/encoders/BufferedDecoder.java +++ /dev/null @@ -1,96 +0,0 @@ -package org.bouncycastle.util.encoders; - - -/** - * A buffering class to allow translation from one format to another to - * be done in discrete chunks. - */ -public class BufferedDecoder -{ - protected byte[] buf; - protected int bufOff; - - protected Translator translator; - - /** - * @param translator the translator to use. - * @param bufSize amount of input to buffer for each chunk. - */ - public BufferedDecoder( - Translator translator, - int bufSize) - { - this.translator = translator; - - if ((bufSize % translator.getEncodedBlockSize()) != 0) - { - throw new IllegalArgumentException("buffer size not multiple of input block size"); - } - - buf = new byte[bufSize]; - bufOff = 0; - } - - public int processByte( - byte in, - byte[] out, - int outOff) - { - int resultLen = 0; - - buf[bufOff++] = in; - - if (bufOff == buf.length) - { - resultLen = translator.decode(buf, 0, buf.length, out, outOff); - bufOff = 0; - } - - return resultLen; - } - - public int processBytes( - byte[] in, - int inOff, - int len, - byte[] out, - int outOff) - { - if (len < 0) - { - throw new IllegalArgumentException("Can't have a negative input length!"); - } - - int resultLen = 0; - int gapLen = buf.length - bufOff; - - if (len > gapLen) - { - System.arraycopy(in, inOff, buf, bufOff, gapLen); - - resultLen += translator.decode(buf, 0, buf.length, out, outOff); - - bufOff = 0; - - len -= gapLen; - inOff += gapLen; - outOff += resultLen; - - int chunkSize = len - (len % buf.length); - - resultLen += translator.decode(in, inOff, chunkSize, out, outOff); - - len -= chunkSize; - inOff += chunkSize; - } - - if (len != 0) - { - System.arraycopy(in, inOff, buf, bufOff, len); - - bufOff += len; - } - - return resultLen; - } -} diff --git a/bcprov/src/main/java/org/bouncycastle/util/encoders/BufferedEncoder.java b/bcprov/src/main/java/org/bouncycastle/util/encoders/BufferedEncoder.java deleted file mode 100644 index 60a098d..0000000 --- a/bcprov/src/main/java/org/bouncycastle/util/encoders/BufferedEncoder.java +++ /dev/null @@ -1,96 +0,0 @@ -package org.bouncycastle.util.encoders; - - -/** - * A buffering class to allow translation from one format to another to - * be done in discrete chunks. - */ -public class BufferedEncoder -{ - protected byte[] buf; - protected int bufOff; - - protected Translator translator; - - /** - * @param translator the translator to use. - * @param bufSize amount of input to buffer for each chunk. - */ - public BufferedEncoder( - Translator translator, - int bufSize) - { - this.translator = translator; - - if ((bufSize % translator.getEncodedBlockSize()) != 0) - { - throw new IllegalArgumentException("buffer size not multiple of input block size"); - } - - buf = new byte[bufSize]; - bufOff = 0; - } - - public int processByte( - byte in, - byte[] out, - int outOff) - { - int resultLen = 0; - - buf[bufOff++] = in; - - if (bufOff == buf.length) - { - resultLen = translator.encode(buf, 0, buf.length, out, outOff); - bufOff = 0; - } - - return resultLen; - } - - public int processBytes( - byte[] in, - int inOff, - int len, - byte[] out, - int outOff) - { - if (len < 0) - { - throw new IllegalArgumentException("Can't have a negative input length!"); - } - - int resultLen = 0; - int gapLen = buf.length - bufOff; - - if (len > gapLen) - { - System.arraycopy(in, inOff, buf, bufOff, gapLen); - - resultLen += translator.encode(buf, 0, buf.length, out, outOff); - - bufOff = 0; - - len -= gapLen; - inOff += gapLen; - outOff += resultLen; - - int chunkSize = len - (len % buf.length); - - resultLen += translator.encode(in, inOff, chunkSize, out, outOff); - - len -= chunkSize; - inOff += chunkSize; - } - - if (len != 0) - { - System.arraycopy(in, inOff, buf, bufOff, len); - - bufOff += len; - } - - return resultLen; - } -} diff --git a/bcprov/src/main/java/org/bouncycastle/util/encoders/HexTranslator.java b/bcprov/src/main/java/org/bouncycastle/util/encoders/HexTranslator.java deleted file mode 100644 index 3fff65a..0000000 --- a/bcprov/src/main/java/org/bouncycastle/util/encoders/HexTranslator.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.bouncycastle.util.encoders; - -/** - * Converters for going from hex to binary and back. Note: this class assumes ASCII processing. - */ -public class HexTranslator - implements Translator -{ - private static final byte[] hexTable = - { - (byte)'0', (byte)'1', (byte)'2', (byte)'3', (byte)'4', (byte)'5', (byte)'6', (byte)'7', - (byte)'8', (byte)'9', (byte)'a', (byte)'b', (byte)'c', (byte)'d', (byte)'e', (byte)'f' - }; - - /** - * size of the output block on encoding produced by getDecodedBlockSize() - * bytes. - */ - public int getEncodedBlockSize() - { - return 2; - } - - public int encode( - byte[] in, - int inOff, - int length, - byte[] out, - int outOff) - { - for (int i = 0, j = 0; i < length; i++, j += 2) - { - out[outOff + j] = hexTable[(in[inOff] >> 4) & 0x0f]; - out[outOff + j + 1] = hexTable[in[inOff] & 0x0f]; - - inOff++; - } - - return length * 2; - } - - /** - * size of the output block on decoding produced by getEncodedBlockSize() - * bytes. - */ - public int getDecodedBlockSize() - { - return 1; - } - - public int decode( - byte[] in, - int inOff, - int length, - byte[] out, - int outOff) - { - int halfLength = length / 2; - byte left, right; - for (int i = 0; i < halfLength; i++) - { - left = in[inOff + i * 2]; - right = in[inOff + i * 2 + 1]; - - if (left < (byte)'a') - { - out[outOff] = (byte)((left - '0') << 4); - } - else - { - out[outOff] = (byte)((left - 'a' + 10) << 4); - } - if (right < (byte)'a') - { - out[outOff] += (byte)(right - '0'); - } - else - { - out[outOff] += (byte)(right - 'a' + 10); - } - - outOff++; - } - - return halfLength; - } -} diff --git a/bcprov/src/main/java/org/bouncycastle/util/encoders/Translator.java b/bcprov/src/main/java/org/bouncycastle/util/encoders/Translator.java deleted file mode 100644 index 96381bc..0000000 --- a/bcprov/src/main/java/org/bouncycastle/util/encoders/Translator.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.bouncycastle.util.encoders; - -/** - * General interface for an translator. - */ -public interface Translator -{ - /** - * size of the output block on encoding produced by getDecodedBlockSize() - * bytes. - */ - public int getEncodedBlockSize(); - - public int encode(byte[] in, int inOff, int length, byte[] out, int outOff); - - /** - * size of the output block on decoding produced by getEncodedBlockSize() - * bytes. - */ - public int getDecodedBlockSize(); - - public int decode(byte[] in, int inOff, int length, byte[] out, int outOff); -} diff --git a/bcprov/src/main/java/org/bouncycastle/util/encoders/UrlBase64.java b/bcprov/src/main/java/org/bouncycastle/util/encoders/UrlBase64.java deleted file mode 100644 index 3b83e95..0000000 --- a/bcprov/src/main/java/org/bouncycastle/util/encoders/UrlBase64.java +++ /dev/null @@ -1,129 +0,0 @@ -package org.bouncycastle.util.encoders; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.OutputStream; - -/** - * Convert binary data to and from UrlBase64 encoding. This is identical to - * Base64 encoding, except that the padding character is "." and the other - * non-alphanumeric characters are "-" and "_" instead of "+" and "/". - * <p> - * The purpose of UrlBase64 encoding is to provide a compact encoding of binary - * data that is safe for use as an URL parameter. Base64 encoding does not - * produce encoded values that are safe for use in URLs, since "/" can be - * interpreted as a path delimiter; "+" is the encoded form of a space; and - * "=" is used to separate a name from the corresponding value in an URL - * parameter. - */ -public class UrlBase64 -{ - private static final Encoder encoder = new UrlBase64Encoder(); - - /** - * Encode the input data producing a URL safe base 64 encoded byte array. - * - * @return a byte array containing the URL safe base 64 encoded data. - */ - public static byte[] encode( - byte[] data) - { - ByteArrayOutputStream bOut = new ByteArrayOutputStream(); - - try - { - encoder.encode(data, 0, data.length, bOut); - } - catch (Exception e) - { - throw new EncoderException("exception encoding URL safe base64 data: " + e.getMessage(), e); - } - - return bOut.toByteArray(); - } - - /** - * Encode the byte data writing it to the given output stream. - * - * @return the number of bytes produced. - */ - public static int encode( - byte[] data, - OutputStream out) - throws IOException - { - return encoder.encode(data, 0, data.length, out); - } - - /** - * Decode the URL safe base 64 encoded input data - white space will be ignored. - * - * @return a byte array representing the decoded data. - */ - public static byte[] decode( - byte[] data) - { - ByteArrayOutputStream bOut = new ByteArrayOutputStream(); - - try - { - encoder.decode(data, 0, data.length, bOut); - } - catch (Exception e) - { - throw new DecoderException("exception decoding URL safe base64 string: " + e.getMessage(), e); - } - - return bOut.toByteArray(); - } - - /** - * decode the URL safe base 64 encoded byte data writing it to the given output stream, - * whitespace characters will be ignored. - * - * @return the number of bytes produced. - */ - public static int decode( - byte[] data, - OutputStream out) - throws IOException - { - return encoder.decode(data, 0, data.length, out); - } - - /** - * decode the URL safe base 64 encoded String data - whitespace will be ignored. - * - * @return a byte array representing the decoded data. - */ - public static byte[] decode( - String data) - { - ByteArrayOutputStream bOut = new ByteArrayOutputStream(); - - try - { - encoder.decode(data, bOut); - } - catch (Exception e) - { - throw new DecoderException("exception decoding URL safe base64 string: " + e.getMessage(), e); - } - - return bOut.toByteArray(); - } - - /** - * Decode the URL safe base 64 encoded String data writing it to the given output stream, - * whitespace characters will be ignored. - * - * @return the number of bytes produced. - */ - public static int decode( - String data, - OutputStream out) - throws IOException - { - return encoder.decode(data, out); - } -} diff --git a/bcprov/src/main/java/org/bouncycastle/util/encoders/UrlBase64Encoder.java b/bcprov/src/main/java/org/bouncycastle/util/encoders/UrlBase64Encoder.java deleted file mode 100644 index a5fff5e..0000000 --- a/bcprov/src/main/java/org/bouncycastle/util/encoders/UrlBase64Encoder.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.bouncycastle.util.encoders; - -/** - * Convert binary data to and from UrlBase64 encoding. This is identical to - * Base64 encoding, except that the padding character is "." and the other - * non-alphanumeric characters are "-" and "_" instead of "+" and "/". - * <p> - * The purpose of UrlBase64 encoding is to provide a compact encoding of binary - * data that is safe for use as an URL parameter. Base64 encoding does not - * produce encoded values that are safe for use in URLs, since "/" can be - * interpreted as a path delimiter; "+" is the encoded form of a space; and - * "=" is used to separate a name from the corresponding value in an URL - * parameter. - */ -public class UrlBase64Encoder extends Base64Encoder -{ - public UrlBase64Encoder() - { - encodingTable[encodingTable.length - 2] = (byte) '-'; - encodingTable[encodingTable.length - 1] = (byte) '_'; - padding = (byte) '.'; - // we must re-create the decoding table with the new encoded values. - initialiseDecodingTable(); - } -} diff --git a/bcprov/src/main/java/org/bouncycastle/util/encoders/package.html b/bcprov/src/main/java/org/bouncycastle/util/encoders/package.html deleted file mode 100644 index 3be222b..0000000 --- a/bcprov/src/main/java/org/bouncycastle/util/encoders/package.html +++ /dev/null @@ -1,5 +0,0 @@ -<html> -<body bgcolor="#ffffff"> -Classes for producing and reading Base64 and Hex strings. -</body> -</html> diff --git a/bcprov/src/main/java/org/bouncycastle/util/io/BufferingOutputStream.java b/bcprov/src/main/java/org/bouncycastle/util/io/BufferingOutputStream.java deleted file mode 100644 index 9d5fe14..0000000 --- a/bcprov/src/main/java/org/bouncycastle/util/io/BufferingOutputStream.java +++ /dev/null @@ -1,108 +0,0 @@ -package org.bouncycastle.util.io; - -import java.io.IOException; -import java.io.OutputStream; - -import org.bouncycastle.util.Arrays; - -/** - * An output stream that buffers data to be feed into an encapsulated output stream. - * <p> - * The stream zeroes out the internal buffer on each flush. - * </p> - */ -public class BufferingOutputStream - extends OutputStream -{ - private final OutputStream other; - private final byte[] buf; - - private int bufOff; - - /** - * Create a buffering stream with the default buffer size (4096). - * - * @param other output stream to be wrapped. - */ - public BufferingOutputStream(OutputStream other) - { - this.other = other; - this.buf = new byte[4096]; - } - - /** - * Create a buffering stream with a specified buffer size. - * - * @param other output stream to be wrapped. - * @param bufferSize size in bytes for internal buffer. - */ - public BufferingOutputStream(OutputStream other, int bufferSize) - { - this.other = other; - this.buf = new byte[bufferSize]; - } - - public void write(byte[] bytes, int offset, int len) - throws IOException - { - if (len < buf.length - bufOff) - { - System.arraycopy(bytes, offset, buf, bufOff, len); - bufOff += len; - } - else - { - int gap = buf.length - bufOff; - - System.arraycopy(bytes, offset, buf, bufOff, gap); - bufOff += gap; - - flush(); - - offset += gap; - len -= gap; - while (len >= buf.length) - { - other.write(bytes, offset, buf.length); - offset += buf.length; - len -= buf.length; - } - - if (len > 0) - { - System.arraycopy(bytes, offset, buf, bufOff, len); - bufOff += len; - } - } - } - - public void write(int b) - throws IOException - { - buf[bufOff++] = (byte)b; - if (bufOff == buf.length) - { - flush(); - } - } - - /** - * Flush the internal buffer to the encapsulated output stream. Zero the buffer contents when done. - * - * @throws IOException on error. - */ - public void flush() - throws IOException - { - other.write(buf, 0, bufOff); - bufOff = 0; - Arrays.fill(buf, (byte)0); - } - - public void close() - throws IOException - { - flush(); - other.close(); - } -} diff --git a/bcprov/src/main/java/org/bouncycastle/util/io/package.html b/bcprov/src/main/java/org/bouncycastle/util/io/package.html deleted file mode 100644 index e987cca..0000000 --- a/bcprov/src/main/java/org/bouncycastle/util/io/package.html +++ /dev/null @@ -1,5 +0,0 @@ -<html> -<body bgcolor="#ffffff"> -General purpose I/O helper classes and wrappers. -</body> -</html> diff --git a/bcprov/src/main/java/org/bouncycastle/util/io/pem/package.html b/bcprov/src/main/java/org/bouncycastle/util/io/pem/package.html deleted file mode 100644 index c5cc4a5..0000000 --- a/bcprov/src/main/java/org/bouncycastle/util/io/pem/package.html +++ /dev/null @@ -1,5 +0,0 @@ -<html> -<body bgcolor="#ffffff"> -Classes for reading and writing raw PEM objects. -</body> -</html> diff --git a/bcprov/src/main/java/org/bouncycastle/util/package.html b/bcprov/src/main/java/org/bouncycastle/util/package.html deleted file mode 100644 index c9247ea..0000000 --- a/bcprov/src/main/java/org/bouncycastle/util/package.html +++ /dev/null @@ -1,5 +0,0 @@ -<html> -<body bgcolor="#ffffff"> -General purpose utility classes used throughout the APIs. -</body> -</html> diff --git a/bcprov/src/main/java/org/bouncycastle/util/test/FixedSecureRandom.java b/bcprov/src/main/java/org/bouncycastle/util/test/FixedSecureRandom.java deleted file mode 100644 index 49bd730..0000000 --- a/bcprov/src/main/java/org/bouncycastle/util/test/FixedSecureRandom.java +++ /dev/null @@ -1,135 +0,0 @@ -package org.bouncycastle.util.test; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.security.SecureRandom; - -public class FixedSecureRandom - extends SecureRandom -{ - private byte[] _data; - - private int _index; - private int _intPad; - - public FixedSecureRandom(byte[] value) - { - this(false, new byte[][] { value }); - } - - public FixedSecureRandom( - byte[][] values) - { - this(false, values); - } - - /** - * Pad the data on integer boundaries. This is necessary for the classpath project's BigInteger - * implementation. - */ - public FixedSecureRandom( - boolean intPad, - byte[] value) - { - this(intPad, new byte[][] { value }); - } - - /** - * Pad the data on integer boundaries. This is necessary for the classpath project's BigInteger - * implementation. - */ - public FixedSecureRandom( - boolean intPad, - byte[][] values) - { - ByteArrayOutputStream bOut = new ByteArrayOutputStream(); - - for (int i = 0; i != values.length; i++) - { - try - { - bOut.write(values[i]); - } - catch (IOException e) - { - throw new IllegalArgumentException("can't save value array."); - } - } - - _data = bOut.toByteArray(); - - if (intPad) - { - _intPad = _data.length % 4; - } - } - - public void nextBytes(byte[] bytes) - { - System.arraycopy(_data, _index, bytes, 0, bytes.length); - - _index += bytes.length; - } - - // - // classpath's implementation of SecureRandom doesn't currently go back to nextBytes - // when next is called. We can't override next as it's a final method. - // - public int nextInt() - { - int val = 0; - - val |= nextValue() << 24; - val |= nextValue() << 16; - - if (_intPad == 2) - { - _intPad--; - } - else - { - val |= nextValue() << 8; - } - - if (_intPad == 1) - { - _intPad--; - } - else - { - val |= nextValue(); - } - - return val; - } - - // - // classpath's implementation of SecureRandom doesn't currently go back to nextBytes - // when next is called. We can't override next as it's a final method. - // - public long nextLong() - { - long val = 0; - - val |= (long)nextValue() << 56; - val |= (long)nextValue() << 48; - val |= (long)nextValue() << 40; - val |= (long)nextValue() << 32; - val |= (long)nextValue() << 24; - val |= (long)nextValue() << 16; - val |= (long)nextValue() << 8; - val |= (long)nextValue(); - - return val; - } - - public boolean isExhausted() - { - return _index == _data.length; - } - - private int nextValue() - { - return _data[_index++] & 0xff; - } -} diff --git a/bcprov/src/main/java/org/bouncycastle/util/test/NumberParsing.java b/bcprov/src/main/java/org/bouncycastle/util/test/NumberParsing.java deleted file mode 100644 index a060dd8..0000000 --- a/bcprov/src/main/java/org/bouncycastle/util/test/NumberParsing.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.bouncycastle.util.test; - -/** - * Parsing - */ -public final class NumberParsing -{ - private NumberParsing() - { - // Hide constructor - } - - public static long decodeLongFromHex(String longAsString) - { - if ((longAsString.charAt(1) == 'x') - || (longAsString.charAt(1) == 'X')) - { - return Long.parseLong(longAsString.substring(2), 16); - } - - return Long.parseLong(longAsString, 16); - } - - public static int decodeIntFromHex(String intAsString) - { - if ((intAsString.charAt(1) == 'x') - || (intAsString.charAt(1) == 'X')) - { - return Integer.parseInt(intAsString.substring(2), 16); - } - - return Integer.parseInt(intAsString, 16); - } -} diff --git a/bcprov/src/main/java/org/bouncycastle/util/test/SimpleTest.java b/bcprov/src/main/java/org/bouncycastle/util/test/SimpleTest.java deleted file mode 100644 index ef8ee61..0000000 --- a/bcprov/src/main/java/org/bouncycastle/util/test/SimpleTest.java +++ /dev/null @@ -1,84 +0,0 @@ -package org.bouncycastle.util.test; - -import java.io.PrintStream; - -import org.bouncycastle.util.Arrays; - -public abstract class SimpleTest - implements Test -{ - public abstract String getName(); - - private TestResult success() - { - return SimpleTestResult.successful(this, "Okay"); - } - - protected void fail( - String message) - { - throw new TestFailedException(SimpleTestResult.failed(this, message)); - } - - protected void fail( - String message, - Throwable throwable) - { - throw new TestFailedException(SimpleTestResult.failed(this, message, throwable)); - } - - protected void fail( - String message, - Object expected, - Object found) - { - throw new TestFailedException(SimpleTestResult.failed(this, message, expected, found)); - } - - protected boolean areEqual( - byte[] a, - byte[] b) - { - return Arrays.areEqual(a, b); - } - - public TestResult perform() - { - try - { - performTest(); - - return success(); - } - catch (TestFailedException e) - { - return e.getResult(); - } - catch (Exception e) - { - return SimpleTestResult.failed(this, "Exception: " + e, e); - } - } - - protected static void runTest( - Test test) - { - runTest(test, System.out); - } - - protected static void runTest( - Test test, - PrintStream out) - { - TestResult result = test.perform(); - - out.println(result.toString()); - if (result.getException() != null) - { - result.getException().printStackTrace(out); - } - } - - public abstract void performTest() - throws Exception; -} diff --git a/bcprov/src/main/java/org/bouncycastle/util/test/SimpleTestResult.java b/bcprov/src/main/java/org/bouncycastle/util/test/SimpleTestResult.java deleted file mode 100644 index bd69fe8..0000000 --- a/bcprov/src/main/java/org/bouncycastle/util/test/SimpleTestResult.java +++ /dev/null @@ -1,80 +0,0 @@ -package org.bouncycastle.util.test; - -public class SimpleTestResult implements TestResult -{ - private static final String SEPARATOR = System.getProperty("line.separator"); - - private boolean success; - private String message; - private Throwable exception; - - public SimpleTestResult(boolean success, String message) - { - this.success = success; - this.message = message; - } - - public SimpleTestResult(boolean success, String message, Throwable exception) - { - this.success = success; - this.message = message; - this.exception = exception; - } - - public static TestResult successful( - Test test, - String message) - { - return new SimpleTestResult(true, test.getName() + ": " + message); - } - - public static TestResult failed( - Test test, - String message) - { - return new SimpleTestResult(false, test.getName() + ": " + message); - } - - public static TestResult failed( - Test test, - String message, - Throwable t) - { - return new SimpleTestResult(false, test.getName() + ": " + message, t); - } - - public static TestResult failed( - Test test, - String message, - Object expected, - Object found) - { - return failed(test, message + SEPARATOR + "Expected: " + expected + SEPARATOR + "Found : " + found); - } - - public static String failedMessage(String algorithm, String testName, String expected, - String actual) - { - StringBuffer sb = new StringBuffer(algorithm); - sb.append(" failing ").append(testName); - sb.append(SEPARATOR).append(" expected: ").append(expected); - sb.append(SEPARATOR).append(" got : ").append(actual); - - return sb.toString(); - } - - public boolean isSuccessful() - { - return success; - } - - public String toString() - { - return message; - } - - public Throwable getException() - { - return exception; - } -} diff --git a/bcprov/src/main/java/org/bouncycastle/util/test/Test.java b/bcprov/src/main/java/org/bouncycastle/util/test/Test.java deleted file mode 100644 index e631cd0..0000000 --- a/bcprov/src/main/java/org/bouncycastle/util/test/Test.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.bouncycastle.util.test; - -public interface Test -{ - String getName(); - - TestResult perform(); -} diff --git a/bcprov/src/main/java/org/bouncycastle/util/test/TestFailedException.java b/bcprov/src/main/java/org/bouncycastle/util/test/TestFailedException.java deleted file mode 100644 index 21e95d3..0000000 --- a/bcprov/src/main/java/org/bouncycastle/util/test/TestFailedException.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.bouncycastle.util.test; - -public class TestFailedException - extends RuntimeException -{ - private TestResult _result; - - public TestFailedException( - TestResult result) - { - _result = result; - } - - public TestResult getResult() - { - return _result; - } -} diff --git a/bcprov/src/main/java/org/bouncycastle/util/test/TestResult.java b/bcprov/src/main/java/org/bouncycastle/util/test/TestResult.java deleted file mode 100644 index 0a1885f..0000000 --- a/bcprov/src/main/java/org/bouncycastle/util/test/TestResult.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.bouncycastle.util.test; - -public interface TestResult -{ - public boolean isSuccessful(); - - public Throwable getException(); - - public String toString(); -} diff --git a/bcprov/src/main/java/org/bouncycastle/util/test/UncloseableOutputStream.java b/bcprov/src/main/java/org/bouncycastle/util/test/UncloseableOutputStream.java deleted file mode 100644 index 89073d7..0000000 --- a/bcprov/src/main/java/org/bouncycastle/util/test/UncloseableOutputStream.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.bouncycastle.util.test; - -import java.io.FilterOutputStream; -import java.io.IOException; -import java.io.OutputStream; - -public class UncloseableOutputStream extends FilterOutputStream -{ - public UncloseableOutputStream(OutputStream s) - { - super(s); - } - - public void close() - { - throw new RuntimeException("close() called on UncloseableOutputStream"); - } - - public void write(byte[] b, int off, int len) throws IOException - { - out.write(b, off, len); - } - } diff --git a/bcprov/src/main/java/org/bouncycastle/util/test/package.html b/bcprov/src/main/java/org/bouncycastle/util/test/package.html deleted file mode 100644 index e723fd1..0000000 --- a/bcprov/src/main/java/org/bouncycastle/util/test/package.html +++ /dev/null @@ -1,5 +0,0 @@ -<html> -<body bgcolor="#ffffff"> -Light weight test API. If you can use Junit! -</body> -</html> |