iaik.asn1.structures
Class GeneralName

java.lang.Object
  |
  +--iaik.asn1.structures.GeneralName

public class GeneralName
extends Object

This class implements the ASN1. type "GeneralName". A GeneralName may be of one of the following types:

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
  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.ObjectID
 
Please 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, an InetAddress object is created from the String by internally calling InetAddress.getByName().

Version:
File Revision 31

Field Summary
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 Summary
GeneralName(ASN1Object generalName)
          Creates a GeneralName from an ASN1Object.
GeneralName(int type, Object generalName)
          Creates a GeneralName for given type and value.
 
Method Summary
 boolean equals(Object obj)
          Compares this GeneralName with the given GeneralName.
 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.
 String toString()
          Returns a string that represents the contents of this general name.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

otherName

public static final int otherName
GeneralName type otherName (0).

rfc822Name

public static final int rfc822Name
GeneralName type rfc822Name (1).

dNSName

public static final int dNSName
GeneralName type dNSName (2).

x400Address

public static final int x400Address
GeneralName type x400Address (3).

directoryName

public static final int directoryName
GeneralName type directoryName (4).

ediPartyName

public static final int ediPartyName
GeneralName type ediPartyName (5).

uniformResourceIdentifier

public static final int uniformResourceIdentifier
GeneralName type uniformResourceIdentifier (6).

iPAddress

public static final int iPAddress
GeneralName type iPAddress (7).

registeredID

public static final int registeredID
GeneralName type registeredID (8).
Constructor Detail

GeneralName

public GeneralName(int type,
                   Object generalName)
            throws IllegalArgumentException
Creates a GeneralName for given type and value.

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.ObjectID
 
Please 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, an InetAddress object is created from the String by internally calling InetAddress.getByName().
Parameters:
type - the type of the general name; a valid type must be used (0 ... 8)
generalName - the value for this type of general name
Throws:
IllegalArgumentException - if the supplied type is not implemented, i.e. the int specificier is "out-of-range" (only 0...8 is allowed)

GeneralName

public GeneralName(ASN1Object generalName)
            throws CodingException
Creates a GeneralName from an ASN1Object. The supplied ASN1Object represents an already existing GeneralName that may have been created by means of the toASN1Object method.
Parameters:
generalName - the general name as ASN1Object
Throws:
CodingException - if the ASN1Object is not a GeneralName or some parsing error occurs; or the supplied GeneralName type is not supported
Method Detail

toASN1Object

public ASN1Object toASN1Object()
                        throws CodingException
Returns this GeneralName object as ASN1Object.
Returns:
the value of GeneralName as ASN1Object
Throws:
CodingException - if the ASN1Object cannot be created for some reason, e.g. the type is not supported

getName

public Object getName()
Returns the value of this general name.

Depending on the type this GeneralName represents this method returns 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:                        String
  registeredID:                     iaik.asn1.ObjectID
 
Returns:
the value of this general name

getType

public int getType()
Returns the type of this general name which may lie between 0 and 8.
Returns:
the type of this general name

equals

public boolean equals(Object obj)
Compares this GeneralName with the given GeneralName.

This method uses the following criteria for comparing the two GeneralName object:

  1. If the type is different, return false
  2. Check the value:
    • If type is otherName, x400Address or ediPartyName, compare the DER encodings of the ASN1Object values
    • If type is rfc822Name, dNSName or uniformResourceIdentifier compare the String values
    • If type is registeredID compare the ObjectID values
    • If type is directoryName compare the Name values
    • If type is iPAddress compare the corresponding byte values
Overrides:
equals in class Object
Parameters:
obj - the other GeneralName
Returns:
true, if the two GeneralNames are equal, false otherwise

hashCode

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

toString

public String toString()
Returns a string that represents the contents of this general name.
Overrides:
toString in class Object
Returns:
the string representation

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