| | |
| | | /** |
| | | * An interface for encoding ASN.1 elements to a data source. |
| | | * <p> |
| | | * Methods for creating {@link ASN1Writer}s are provided in the |
| | | * {@link ASN1} class. |
| | | * Methods for creating {@link ASN1Writer}s are provided in the {@link ASN1} |
| | | * class. |
| | | */ |
| | | public interface ASN1Writer extends Closeable, Flushable |
| | | { |
| | | |
| | | /** |
| | | * Closes this ASN.1 writer, flushing it first. Closing a previously |
| | | * closed ASN.1 writer has no effect. Any unfinished sequences and/or |
| | | * sets will be ended. |
| | | * Closes this ASN.1 writer, flushing it first. Closing a previously closed |
| | | * ASN.1 writer has no effect. Any unfinished sequences and/or sets will be |
| | | * ended. |
| | | * |
| | | * @throws IOException |
| | | * If an error occurs while closing. |
| | |
| | | |
| | | /** |
| | | * Flushes this ASN.1 writer so that any buffered elements are written |
| | | * immediately to their intended destination. Then, if that |
| | | * destination is another byte stream, flush it. Thus one {@code |
| | | * flush()} invocation will flush all the buffers in a chain of |
| | | * streams. |
| | | * immediately to their intended destination. Then, if that destination is |
| | | * another byte stream, flush it. Thus one {@code flush()} invocation will |
| | | * flush all the buffers in a chain of streams. |
| | | * <p> |
| | | * If the intended destination of this stream is an abstraction |
| | | * provided by the underlying operating system, for example a file, |
| | | * then flushing the stream guarantees only that bytes previously |
| | | * written to the stream are passed to the operating system for |
| | | * writing; it does not guarantee that they are actually written to a |
| | | * physical device such as a disk drive. |
| | | * If the intended destination of this stream is an abstraction provided by |
| | | * the underlying operating system, for example a file, then flushing the |
| | | * stream guarantees only that bytes previously written to the stream are |
| | | * passed to the operating system for writing; it does not guarantee that they |
| | | * are actually written to a physical device such as a disk drive. |
| | | * |
| | | * @throws IOException |
| | | * If an error occurs while flushing. |
| | |
| | | |
| | | |
| | | /** |
| | | * Writes a boolean element using the Universal Boolean ASN.1 type |
| | | * tag. |
| | | * Writes a boolean element using the Universal Boolean ASN.1 type tag. |
| | | * |
| | | * @param value |
| | | * The boolean value. |
| | |
| | | * @throws IllegalStateException |
| | | * If there is no sequence being written. |
| | | */ |
| | | ASN1Writer writeEndSequence() throws IOException, |
| | | IllegalStateException; |
| | | ASN1Writer writeEndSequence() throws IOException, IllegalStateException; |
| | | |
| | | |
| | | |
| | |
| | | * @throws IllegalStateException |
| | | * If there is no set being written, IllegalStateException. |
| | | */ |
| | | ASN1Writer writeEndSet() throws IOException; |
| | | ASN1Writer writeEndSet() throws IOException, IllegalStateException; |
| | | |
| | | |
| | | |
| | |
| | | |
| | | |
| | | /** |
| | | * Writes an enumerated element using the Universal Enumerated ASN.1 |
| | | * type tag. |
| | | * Writes an enumerated element using the Universal Enumerated ASN.1 type tag. |
| | | * |
| | | * @param value |
| | | * The enumerated value. |
| | |
| | | |
| | | |
| | | /** |
| | | * Writes an integer element using the Universal Integer ASN.1 type |
| | | * tag. |
| | | * Writes an integer element using the Universal Integer ASN.1 type tag. |
| | | * |
| | | * @param value |
| | | * The integer value. |
| | |
| | | |
| | | |
| | | /** |
| | | * Writes an integer element using the Universal Integer ASN.1 type |
| | | * tag. |
| | | * Writes an integer element using the Universal Integer ASN.1 type tag. |
| | | * |
| | | * @param value |
| | | * The integer value. |
| | |
| | | * @throws IOException |
| | | * If an error occurs while writing the element. |
| | | */ |
| | | ASN1Writer writeOctetString(byte type, byte[] value, int offset, |
| | | int length) throws IOException; |
| | | ASN1Writer writeOctetString(byte type, byte[] value, int offset, int length) |
| | | throws IOException; |
| | | |
| | | |
| | | |
| | |
| | | * @throws IOException |
| | | * If an error occurs while writing the element. |
| | | */ |
| | | ASN1Writer writeOctetString(byte type, ByteSequence value) |
| | | throws IOException; |
| | | ASN1Writer writeOctetString(byte type, ByteSequence value) throws IOException; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Writes a string as a UTF-8 encoded octet string element using the |
| | | * provided type tag. |
| | | * Writes a string as a UTF-8 encoded octet string element using the provided |
| | | * type tag. |
| | | * |
| | | * @param type |
| | | * The type tag of the element. |
| | |
| | | * @throws IOException |
| | | * If an error occurs while writing the element. |
| | | */ |
| | | ASN1Writer writeOctetString(byte type, String value) |
| | | throws IOException; |
| | | ASN1Writer writeOctetString(byte type, String value) throws IOException; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Writes an octet string element using the Universal Octet String |
| | | * ASN.1 type tag. |
| | | * Writes an octet string element using the Universal Octet String ASN.1 type |
| | | * tag. |
| | | * |
| | | * @param value |
| | | * The byte array containing the octet string data. |
| | |
| | | |
| | | |
| | | /** |
| | | * Writes an octet string element using the Universal Octet String |
| | | * ASN.1 type tag. |
| | | * Writes an octet string element using the Universal Octet String ASN.1 type |
| | | * tag. |
| | | * |
| | | * @param value |
| | | * The octet string value. |
| | |
| | | |
| | | |
| | | /** |
| | | * Writes a string as a UTF-8 encoded octet string element using the |
| | | * Universal Octet String ASN.1 type tag. |
| | | * Writes a string as a UTF-8 encoded octet string element using the Universal |
| | | * Octet String ASN.1 type tag. |
| | | * |
| | | * @param value |
| | | * The string to be written as a UTF-8 encoded octet string. |
| | |
| | | |
| | | |
| | | /** |
| | | * Writes a sequence element using the Universal Sequence ASN.1 type |
| | | * tag. All further writes will append elements to the sequence until |
| | | * Writes a sequence element using the Universal Sequence ASN.1 type tag. All |
| | | * further writes will append elements to the sequence until |
| | | * {@link #writeEndSequence} is called. |
| | | * |
| | | * @return A reference to this ASN.1 writer. |
| | |
| | | |
| | | |
| | | /** |
| | | * Writes a sequence element using the provided type tag. All further |
| | | * writes will append elements to the sequence until |
| | | * {@link #writeEndSequence} is called. |
| | | * Writes a sequence element using the provided type tag. All further writes |
| | | * will append elements to the sequence until {@link #writeEndSequence} is |
| | | * called. |
| | | * |
| | | * @param type |
| | | * The type tag of the element. |
| | |
| | | |
| | | |
| | | /** |
| | | * Writes a set element using the Universal Set ASN.1 type tag. All |
| | | * further writes will append elements to the set until |
| | | * {@link #writeEndSet} is called. |
| | | * Writes a set element using the Universal Set ASN.1 type tag. All further |
| | | * writes will append elements to the set until {@link #writeEndSet} is |
| | | * called. |
| | | * |
| | | * @return A reference to this ASN.1 writer. |
| | | * @throws IOException |
| | |
| | | |
| | | |
| | | /** |
| | | * Writes a set element using the provided type tag. All further |
| | | * writes will append elements to the set until {@link #writeEndSet} |
| | | * is called. |
| | | * Writes a set element using the provided type tag. All further writes will |
| | | * append elements to the set until {@link #writeEndSet} is called. |
| | | * |
| | | * @param type |
| | | * The type tag of the element. |