public abstract class ASN1String extends ASN1Object
This class extends ASN1Object
for
grouping all ASN.1 String type implementing classes.
BMPString
,
GeneralString
,
IA5String
,
NumericString
,
PrintableString
,
T61String
,
UNIString
,
UTF8String
,
VisibleString
Modifier and Type | Field and Description |
---|---|
protected byte[] |
value
The value as byte material representing the String value encoding.
|
asnType, constructed, encode_listener, indefinite_length, isStringType, stream_mode
Modifier | Constructor and Description |
---|---|
protected |
ASN1String()
Creates an empty ASN1String.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
clone()
Returns a clone of this ASN1String.
|
protected void |
decode(int length,
java.io.InputStream is)
Decodes a ASN1String value from the given InputStream.
|
protected void |
encode(java.io.OutputStream os)
DER encodes this ASN1String and writes the result to the
given output stream.
|
boolean |
equals(java.lang.Object obj)
Compares two ASN.1 Strings.
|
byte[] |
getByteValue()
Gets the (raw, not decoded into a String) value as byte array.
|
int |
hashCode()
Returns a hash code for this object.
|
static void |
setIgnoreConstructedEncodingForSimpleTypes(boolean ignore)
Generally the Basic Encoding Rules (BER) allow ASN.1 String types to be primitive
or constructed encoded.
|
void |
setIndefiniteLength(boolean indefiniteLength)
Does nothing (primitive String types are encoded with definite length in any case).
|
java.lang.String |
toString()
Returns a string that represents the contents of this ASN1String.
|
addComponent, addEncodeListener, countComponents, encodeObject, getAsnType, getComponentAt, getValue, indefiniteLength, isA, isConstructed, isStringType, setValue
protected byte[] value
public static void setIgnoreConstructedEncodingForSimpleTypes(boolean ignore)
ignoreConstructedEncoding
method you can advice IAIK-JCE
to ignore constructed encoding -- if ever used -- for simple types. In this
case IAIK-JCE tries to read the contents but the value
obtained from the ASN1Object may not fully represent its actual value.ignore
- whether to ignore constructed encoding for simple types
like IA5String, UTF8String, BIT_STRING (except for
OCTET_STRING) (default: false
, an exception
is thrown when the constructed method has been used for encoding
a simple type)public java.lang.Object clone()
clone
in class ASN1Object
public void setIndefiniteLength(boolean indefiniteLength)
setIndefiniteLength
in class ASN1Object
indefiniteLength
- ignoredprotected void encode(java.io.OutputStream os) throws java.io.IOException
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.
encode
in class ASN1Object
os
- the output stream to which to write the datajava.io.IOException
- if an I/O error occurs while writing to the streamprotected void decode(int length, java.io.InputStream is) throws java.io.IOException
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!
decode
in class ASN1Object
length
- the already decoded length, i.e. number of the bytes
representing the value of the ASN1String to be decodedis
- the input stream from which the DER encoded data is read injava.io.IOException
- if there is a problem with the InputStreampublic byte[] getByteValue()
public java.lang.String toString()
toString
in class ASN1Object
ASN1Object.toString()
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- the other ASN.1 Stringtrue
, if the two ASN1Strings are equal,
false
otherwisepublic int hashCode()
hashCode
in class java.lang.Object