|
|||||||||
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.PrintableString
This class implements the native ASN.1 type "PrintableString". PrintableString is a simple ASN.1 string type identified by the UNIVERSAL TAG number 19.
An ASN.1 PrintableString object may represent any arbitrary string of printable characters (A,B,...,Z; a,b,...,z; 0,1,...,9; space ' () + , - . / : = ?)
When creating a new PrintableString
object the value to be represented
has to be supplied as Java String
type:
String s = ...; PrintableString printableString = new PrintableString(s);Attention: When supplying the string value to be represented, no check is performed if it actually is composed only of characters belonging to PrintableString character set! An application itself has to take care for supplying a proper PrintableString value.
When calling the getValue
method for getting the inherent string
value from an ASN.1 PrintableString instance, a Java object of type String
is returned:
String s = (String)printableString.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.
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 |
PrintableString()
Creates an empty PrintableString object. |
|
PrintableString(String value)
Creates a new ASN.1 PrintableString object for the given String value. |
Method Summary | |
static void |
checkCaseInsensitive(boolean insensitive)
Decide whether to compare PrintableStrings case in sensitive or not (default: no). |
boolean |
equals(Object obj)
Compares two PrintableStrings. |
Object |
getValue()
Returns the value of this PrintableString as a String object. |
static boolean |
isPrintableString(String s)
Checks is the supplied String is a PrintableString. |
void |
setValue(Object object)
Sets the value of this PrintableString. |
Methods inherited from class iaik.asn1.ASN1String |
clone, decode, encode, 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 PrintableString()
public PrintableString(String value)
Attention: No check is performed if the supplied String value actually is composed only of characters belonging to the PrintableString character set! An application itself has to take care for supplying a proper PrintableString value.
value
- the String value this PrintableString 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
.
Attention: No check is performed if the supplied String value
actually is composed only of characters belonging to PrintableString character
set! An application itself has to take care for supplying a proper PrintableString
value.
setValue
in class ASN1Object
object
- the Java String value to be set for this PrintableStringpublic boolean equals(Object obj)
X.509 applies the following rules for comparing PrintableStrings; item (c) and (d):
(a) attribute values encoded in different types (e.g., PrintableString and BMPString) MAY be assumed to represent different strings; (b) attribute values in types other than PrintableString are case sensitive (this permits matching of attribute values as binary objects); (c) attribute values in PrintableString are not case sensitive (e.g., "Marianne Swanson" is the same as "MARIANNE SWANSON"); and (d) attribute values in PrintableString are compared after removing leading and trailing white space and converting internal substrings of one or more consecutive white space characters to a single space.For providing backwards compatibility to former IAIK PrintableString versions, for performance reasons and because PrintableStrings may not differ only case/space based in typical applications the case insensitive and space ignoring checking is turned off by default. Case insensitive and space ignoring checking may be turned on by calling static method
checkCaseInsensitive
. When case insensitive and space ignoring checking is turned on
the PrintableString byte value representation immediately
to avoid String object creation and comparison and returns true
if
the two PrintableStrings are exactly identical or differ only in spaces or
lower-upper case representation of printable characters 'A'...'Z', 'a'...'z'.
So this method anytime will give the correct result of the two PrintableStrings to
be compared are actually PrintableStrings (having characters belonging to the
PrintableString character set only). This method may fail (give an uncorrect comparison
result) if any of the two PrintableStrings to be compared have some non-printable
character represented by more than one byte and any of these bytes "case-in-sensitive"
matches to the byte at the same-position byte of the other PrintableString. However, it
might be unlikely that having two PrintableStrings with wrong characters that only
compare successfully because of the one assumption above.equals
in class ASN1String
obj
- the other PrintableStringtrue
if the two PrintableStrings are exactly identical or differ
only in spaces or lower-upper case representation of printable
characters 'A'...'Z', 'a'...'z', otherwise falsepublic static boolean isPrintableString(String s)
This method checks if the supplied String only contains printable characters (A,B,...,Z; a,b,...,z; 0,1,...,9; space ' () + , - . / : = ?).
s
- the string to be checkedtrue
if the string is a printable string,
false
if notpublic static void checkCaseInsensitive(boolean insensitive)
X.509 applies the following rules for comparing PrintableStrings; item (c) and (d):
(a) attribute values encoded in different types (e.g., PrintableString and BMPString) MAY be assumed to represent different strings; (b) attribute values in types other than PrintableString are case sensitive (this permits matching of attribute values as binary objects); (c) attribute values in PrintableString are not case sensitive (e.g., "Marianne Swanson" is the same as "MARIANNE SWANSON"); and (d) attribute values in PrintableString are compared after removing leading and trailing white space and converting internal substrings of one or more consecutive white space characters to a single space.For providing backwards compatibility to former IAIK PrintableString versions, for performance reasons and because PrintableStrings may not differ only case/space based in typical applications the case insensitive and space ignoring checking is turned off by default.
insensitive
- true
for checking case insensitive and
space ignoring; false
if not (default)
|
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 |