|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--iaik.asn1.ASN1Object | +--iaik.asn1.ASN1String | +--iaik.asn1.UTF8String
This class implements the ASN.1 character string type "UTF8String". UTF8String is a simple ASN.1 string type identified by the UNIVERSAL TAG number 12.
UTF-8 (UCS transformation format 8) is an encoding format that has been developed for handling UCS-2/UCS-4 multi-octet character sets by applications that operate on 7, 8 bit characters. UTF-8 is specified by ISO 10646 in RFC 2279.
RFC 2279 gives an algorithm for transforming UCS-4/UCS-2 multi octet characters into UTF-8 octet sequences. This class can be used for UTF-8 encoding UCS-2/Unicode character strings according to the following rules:
When creating a new UTF8String
object the value to be represented
has to be supplied as Java String
type:
String s = ...; UTF8String UTF8String = new UTF8String(s);When calling the
getValue
method for getting the inherent string
value from an ASN.1 UTF8String instance, a Java object of type String
is returned:
String s = (String)UTF8String.getValue();DER en/decoding generally is done by means of the several methods of the
DerCoder
class; decoding alternatively may be performed by
using the DerInputStream
utility.
ASN1Object
,
ASN
Fields inherited from class iaik.asn1.ASN1String |
value |
Fields inherited from class iaik.asn1.ASN1Object |
asnType, constructed, encode_listener, indefinite_length, isStringType, stream_mode |
Constructor Summary | |
protected |
UTF8String()
Creates an empty UTF8String. |
|
UTF8String(String value)
Creates a new ASN.1 UTF8String object for the given String value. |
Method Summary | |
static String |
getRFC2253String(char[] str)
Returns a UTF-8 String representation according to RFC 2253. |
static String |
getRFC2253String(String str)
Returns a UTF-8 String representation according to RFC 2253. |
static String |
getStringFromUTF8Encoding(byte[] enc)
Decodes the string from an UTF-8 encoded byte array. |
static byte[] |
getUTF8EncodingFromCharArray(char[] str)
UTF-8 encodes the given char array. |
static byte[] |
getUTF8EncodingFromString(String str)
UTF-8 encodes the given string. |
Object |
getValue()
Returns the value of this UTF8String as a String object. |
void |
setValue(Object object)
Sets the value of this UTF8String. |
Methods inherited from class iaik.asn1.ASN1String |
clone, decode, encode, equals, hashCode, toString |
Methods inherited from class iaik.asn1.ASN1Object |
addComponent, addEncodeListener, countComponents, encodeObject, getAsnType, getComponentAt, indefiniteLength, isA, isConstructed, isStringType, setIndefiniteLength |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
protected UTF8String()
public UTF8String(String value)
value
- the String value this UTF8String object should be initialized withMethod Detail |
public Object getValue()
getValue
in class ASN1Object
public void setValue(Object object)
The supplied value has to be a Java object of type String
.
setValue
in class ASN1Object
object
- the Java String value to be set for this UTF8Stringpublic static byte[] getUTF8EncodingFromString(String str) throws CodingException
str
- the string to be encodedCodingException
- if an coding error occurspublic static byte[] getUTF8EncodingFromCharArray(char[] str) throws CodingException
str
- the char array to be encodedCodingException
- if an coding error occurspublic static String getStringFromUTF8Encoding(byte[] enc) throws CodingException
enc
- the UTF-8 encoding as byte arrayCodingException
- if an error occurs during the decoding processpublic static String getRFC2253String(String str) throws CodingException
RFC 2253 specifies a string representation of Distinguished Names as used for LDAP lookups.
The string representation returned by this method is based on the algorithm given in section 2.4 of RFC 2253 thereby applying the following escaping mechanisms:
str
- the string to be representedCodingException
- if an coding error occurspublic static String getRFC2253String(char[] str) throws CodingException
RFC 2253 specifies a string representation of Distinguished Names as used for LDAP lookups.
The string representation returned by this method is based on the algorithm given in section 2.4 of RFC 2253 thereby applying the following escaping mechanisms:
str
- the char array to be representedCodingException
- if an coding error occurs
|
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). | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |