public class GeneralName
extends java.lang.Object
ASN.1 definition:
GeneralName ::= CHOICE { otherName [0] OtherName, rfc822Name [1] IA5String, dNSName [2] IA5String, x400Address [3] ORAddress, directoryName [4] Name, ediPartyName [5] EDIPartyName, uniformResourceIdentifier [6] IA5String, iPAddress [7] OCTET STRING, registeredID [8] OBJECT IDENTIFIER}
OtherName ::= SEQUENCE { type-id OBJECT IDENTIFIER, value [0] EXPLICIT ANY DEFINED BY type-id }
EDIPartyName ::= SEQUENCE { nameAssigner [0] DirectoryString OPTIONAL, partyName [1] DirectoryString }
DirectoryString ::= CHOICE { teletexString TeletexString (SIZE (1..maxSize), printableString PrintableString (SIZE (1..maxSize)), universalString UniversalString (SIZE (1..maxSize)), utf8String UTF8String (SIZE (1.. MAX)), bmpString BMPString (SIZE(1..maxSIZE)) }
When creating a GeneralName
object, specify the intended type
and the value to be set, e.g.:
GeneralName generalName = new GeneralName( GeneralName.uniformResourceIdentifier, "http://www.iaik.tu-graz.ac.at/");
Depending on the type the value has to be an object according to the following assignment:
TYPE VALUE ==== ===== otherName: iaik.asn1.ASN1Object or iaik.asn1.structures.OtherName (if registered) rfc822Name: java.lang.String dNSName: java.lang.String x400Address: iaik.asn1.ASN1Object directoryName: iaik.asn1.structures.Name ediPartyName: iaik.asn1.ASN1Object uniformResourceIdentifier: String iPAddress: byte[] array or java.net.InetAddress or String registeredID: iaik.asn1.ObjectIDFor type
otherName
the value may be specified either as general
ASN1Object
or as of
OtherName
implementation. In the
second case an implementation of the specific OtherName type-id
must be registered
.
For type iPAddress
the value may be specified either as byte
array (already encoded address), as InetAddress object, or as String object.
If the ip address is given a String, the preferred form has to be used by
specifying the maximum number of components (4 or 8 (if subnet mask is
included) for Ipv4 (decimal), or 16 or 32 (if subnet mask is included) for
Ipv6 (hexadecimal).
Modifier and Type | Field and Description |
---|---|
static int |
directoryName
GeneralName type
directoryName (4). |
static int |
dNSName
GeneralName type
dNSName (2). |
static int |
ediPartyName
GeneralName type
ediPartyName (5). |
static int |
iPAddress
GeneralName type
iPAddress (7). |
static int |
otherName
GeneralName type
otherName (0). |
static int |
registeredID
GeneralName type
registeredID (8). |
static int |
rfc822Name
GeneralName type
rfc822Name (1). |
static int |
uniformResourceIdentifier
GeneralName type
uniformResourceIdentifier (6). |
static int |
x400Address
GeneralName type
x400Address (3). |
Constructor and Description |
---|
GeneralName(ASN1Object generalName)
Creates a GeneralName from an ASN1Object.
|
GeneralName(int type,
java.lang.Object generalName)
Creates a GeneralName for given type and value.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj)
Compares this GeneralName with the given GeneralName.
|
java.lang.Object |
getName()
Returns the value of this general name.
|
int |
getType()
Returns the type of this general name which may lie between 0 and 8.
|
int |
hashCode()
Returns a hash code value for this object.
|
ASN1Object |
toASN1Object()
Returns this GeneralName object as ASN1Object.
|
java.lang.String |
toString()
Returns a string that represents the contents of this general name.
|
public static final int otherName
otherName
(0).public static final int rfc822Name
rfc822Name
(1).public static final int dNSName
dNSName
(2).public static final int x400Address
x400Address
(3).public static final int directoryName
directoryName
(4).public static final int ediPartyName
ediPartyName
(5).public static final int uniformResourceIdentifier
uniformResourceIdentifier
(6).public static final int iPAddress
iPAddress
(7).public static final int registeredID
registeredID
(8).public GeneralName(int type, java.lang.Object generalName) throws java.lang.IllegalArgumentException
When creating a new GeneralName object you have to specify type and corresponding value. The value has to be an object according to the following assignment:
TYPE VALUE ==== ===== otherName: iaik.asn1.ASN1Object rfc822Name: java.lang.String dNSName: java.lang.String x400Address: iaik.asn1.ASN1Object directoryName: iaik.asn1.structures.Name ediPartyName: iaik.asn1.ASN1Object uniformResourceIdentifier: String iPAddress: byte[] array or java.net.InetAddress or String registeredID: iaik.asn1.ObjectIDPlease be aware that for type iPAddress the value may be specified either as byte array (already encoded address), as InetAddress object, or as String object. If the ip address is given a String, the preferred form has to be used by specifying the maximum number of components (4 or 8 (if subnet mask is included) for Ipv4 (decimal), or 16 or 32 (if subnet mask is included) for Ipv6 (hexadecimal).
type
- the type of the general name; a valid type must be used (0 ... 8)generalName
- the value for this type of general namejava.lang.IllegalArgumentException
- if the supplied type is not implemented, i.e. the int
specificier is "out-of-range" (only 0...8 is allowed)public GeneralName(ASN1Object generalName) throws CodingException
toASN1Object
method.generalName
- the general name as ASN1ObjectCodingException
- if the ASN1Object is not a GeneralName or some parsing error
occurs; or the supplied GeneralName type is not supportedpublic ASN1Object toASN1Object() throws CodingException
CodingException
- if the ASN1Object cannot be created for some reason, e.g. the
type is not supportedpublic java.lang.Object getName()
Depending on the type this GeneralName represents this method returns an object according to the following assignment:
TYPE VALUE ==== ===== otherName: iaik.asn1.ASN1Object or iaik.asn1.structures.OtherName (if registered) rfc822Name: java.lang.String dNSName: java.lang.String x400Address: iaik.asn1.ASN1Object directoryName: iaik.asn1.structures.Name ediPartyName: iaik.asn1.ASN1Object uniformResourceIdentifier: String iPAddress: String registeredID: iaik.asn1.ObjectID
If the type of this GeneralName is otherName
this method may
return an instance of an OtherName
type or a
ASN1Object
, depending on if an implementation
of the particular OtherName type-id is
registered
or not, e.g.:
// register specific OtherName implementation OtherName.register(MyOtherName.TYPE_ID, MyOtherName.class); ... // the GeneralName GeneralName generalName = ...; // GeneralName of type OtherName? if (generalName.getType() == GeneralName.otherName) { // get the inherent name Object name = generalName.getName(); if (name instanceof OtherName) { OtherName otherName = (OtherName)name; // check OtherName type (only required if you have more OtherNames registered) if (otherName.getTypeId().equals(MyOtherName.TYPE_ID)) { myOtherName = (MyOtherName)otherName; String value = myOtherName.getValue(); } } else { // no OtherName for the specific type-id is registered ASN1Object asn1OtherName = (ASN1Object)name; } }As you see in this example, if the GeneralName represents an OtherName for which no implementation is registered,
GeneralName.getName()
returns an ASN1Object
. This is
necessary because of backwards compatibility to previous versions of
IAIK-JCE.OtherName
public int getType()
public boolean equals(java.lang.Object obj)
This method uses the following criteria for comparing the two GeneralName object:
false
equals
in class java.lang.Object
obj
- the other GeneralNametrue
, if the two GeneralNames are equal,
false
otherwisepublic int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object