iaik.asn1
Class ASN1String

java.lang.Object
  |
  +--iaik.asn1.ASN1Object
        |
        +--iaik.asn1.ASN1String
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
BMPString, GeneralString, IA5String, NumericString, PrintableString, T61String, UNIString, UTF8String, VisibleString

public abstract class ASN1String
extends ASN1Object

Abstract super class for all ASN.1 String types.

This class extends ASN1Object for grouping all ASN.1 String type implementing classes.

Version:
File Revision 11
See Also:
BMPString, GeneralString, IA5String, NumericString, PrintableString, T61String, UNIString, UTF8String, VisibleString

Field Summary
protected  byte[] value
          The value as byte material representing the String value encoding.
 
Fields inherited from class iaik.asn1.ASN1Object
asnType, constructed, encode_listener, indefinite_length, isStringType, stream_mode
 
Constructor Summary
protected ASN1String()
          Creates an empty ASN1String.
 
Method Summary
 Object clone()
          Returns a clone of this ASN1String.
protected  void decode(int length, InputStream is)
          Decodes a ASN1String value from the given InputStream.
protected  void encode(OutputStream os)
          DER encodes this ASN1String and writes the result to the given output stream.
 boolean equals(Object obj)
          Compares two ASN.1 Strings.
 int hashCode()
          Returns a hash code for this object.
 String toString()
          Returns a string that represents the contents of this ASN1String.
 
Methods inherited from class iaik.asn1.ASN1Object
addComponent, addEncodeListener, countComponents, encodeObject, getAsnType, getComponentAt, getValue, indefiniteLength, isA, isConstructed, isStringType, setIndefiniteLength, setValue
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

value

protected byte[] value
The value as byte material representing the String value encoding.
Constructor Detail

ASN1String

protected ASN1String()
Creates an empty ASN1String.
Method Detail

clone

public Object clone()
Returns a clone of this ASN1String.
Overrides:
clone in class ASN1Object
Returns:
a clone of this ASN1String

encode

protected void encode(OutputStream os)
               throws IOException
DER encodes this ASN1String and writes the result to the given output stream.

This is a protected method and will not be used by an application for DER encoding a ASN1String object. An application will call one of the encode methods of the DerCoder class for performing the encoding, and the DerCoder internally will call this encode method.

Overrides:
encode in class ASN1Object
Parameters:
os - the output stream to which to write the data
Throws:
IOException - if an I/O error occurs while writing to the stream

decode

protected void decode(int length,
                      InputStream is)
               throws IOException
Decodes a ASN1String value from the given InputStream. The given input stream carries DER encoded data, and the next length bytes to be read represent the value of an ASN.1 object of type ASN1String.

This is a protected method and will not be used by an application for decoding a DER encoded ASN1String. An application will call one of the decode methods of the DerCoder class for performing the decoding. The DerCoder then determines the number of bytes (length) occupied by the value of this ASN1String object and internally calls this decode method for actually reading the value. No check is performed if the received value actually is composed only of characters belonging to the ASN1String typical character set!

Overrides:
decode in class ASN1Object
Parameters:
length - the already decoded length, i.e. number of the bytes representing the value of the ASN1String to be decoded
is - the input stream from which the DER encoded data is read in
Throws:
IOException - if there is a problem with the InputStream

toString

public String toString()
Returns a string that represents the contents of this ASN1String.
Overrides:
toString in class ASN1Object
Returns:
the string representation
See Also:
ASN1Object.toString()

equals

public boolean equals(Object obj)
Compares two ASN.1 Strings.
Overrides:
equals in class Object
Parameters:
obj - the other ASN.1 String
Returns:
true, if the two ASN1Strings are equal, false otherwise

hashCode

public int hashCode()
Returns a hash code for this object.
Overrides:
hashCode in class Object
Returns:
the hash code

This Javadoc may contain text parts from Internet Standard specifications (RFC 2459, 3280, 3039, 2560, 1521, 821, 822, 2253, 1319, 1321, ,2630, 2631, 2268, 3058, 2984, 2104, 2144, 2040, 2311, 2279, see copyright note) and RSA Data Security Public-Key Cryptography Standards (PKCS#1,3,5,7,8,9,10,12, see copyright note).

IAIK-JCE 3.1 with IAIK-JCE CC Core 3.1, (c) 1997-2004 IAIK