codec.x509
Class GeneralName

java.lang.Object
  |
  +--codec.asn1.ASN1AbstractType
        |
        +--codec.asn1.ASN1Choice
              |
              +--codec.x509.GeneralName
All Implemented Interfaces:
ASN1Type, Cloneable, Externalizable, Serializable

public class GeneralName
extends ASN1Choice

This class represents the GeneralName data type as denoted in X.509. It implements the following ASN1 data structure:

 GeneralName ::= CHOICE {
    otherName                     [0]  IMPLICIT OtherName 
    rfc822Name                    [1]  IMPLICIT IA5String
    dNSName                       [2]  IMPLICIT IA5String
    x400Address                   [3]  IMPLICIT ORAAddress
    directoryName                 [4]  IMPLICIT Name
    ediPartyName                  [5]  IMPLICIT EDIPartyName
    uniformRessourceIdentifier    [6]  IMPLICIT IA5String
    iPAddress                     [7]  IMPLICIT OCTET STRING
    registeredID                  [8]  IMPLICIT OBJECT IDENTIFIER
 }
 OtherName ::= SEQUENCE {
    type-id    OBJECT IDENTIFIER,
    value      [0] EXPLICIT ANY DEFINED BY type-id 
 }
 
Note that x400Address and ediPartyName are not yet implemented and will cause exceptions to be thrown.

Author:
Markus Tak
See Also:
Serialized Form

Field Summary
static int TYPE_DIRECTORY_NAME
          This value indicates the choice "directoryName"
static int TYPE_DNS_NAME
          This value indicates the choice "dNSName"
static int TYPE_EDI_PARTY_NAME
          This value indicates the choice "ediPartyName"
static int TYPE_IP_ADDRESS
          This value indicates the choice "iPAddress"
static int TYPE_OTHER_NAME
          This value indicates the choice "otherName"
static int TYPE_REGISTERED_ID
          This value indicates the choice "registeredID"
static int TYPE_RFC822_NAME
          This value indicates the choice "rfc822Name"
static int TYPE_UNIFORM_RESOURCE_IDENTIFIER
          This value indicates the choice "uniformResourceIdentifier"
static int TYPE_X400_ADDRESS
          This value indicates the choice "x400Address"
 
Constructor Summary
GeneralName()
          Builds the structure of the class ready for decoding
 
Method Summary
 ASN1Type getGeneralName()
          Returns the actual Name as ASN1Type.
 void setDirectoryName(Name dirname)
          Set the GeneralName as a directoryName.
 void setDNSName(ASN1IA5String dnsname)
          Set the GeneralName as a dNSName.Note that the ASN1IA5String object is cloned so that no side effects can occur!
 void setIPAddress(byte[] address)
          Set the GeneralName as a iPAddress.
 void setRegisteredID(ASN1ObjectIdentifier oid)
          Set the GeneralName as a registeredID.
 void setRfc822Name(ASN1IA5String rfcname)
          Set the GeneralName as a rfc822Namename.
 void setUniformResourceIdentifier(ASN1IA5String unirid)
          Set the GeneralName as uniformResourceIdentifier.Note that the ASN1IA5String object is cloned so that no side effects can occur!
 String toString()
          This method returns a "human-readable" string representation of this object's state
 
Methods inherited from class codec.asn1.ASN1Choice
addType, checkConstraints, clear, decode, encode, getInnerType, getTag, getTagClass, getType, getValue, isExplicit, isType, setConstraint, setExplicit, setInnerType, trimToSize
 
Methods inherited from class codec.asn1.ASN1AbstractType
getConstraint, isOptional, readExternal, setOptional, writeExternal
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TYPE_OTHER_NAME

public static final int TYPE_OTHER_NAME
This value indicates the choice "otherName"

TYPE_RFC822_NAME

public static final int TYPE_RFC822_NAME
This value indicates the choice "rfc822Name"

TYPE_DNS_NAME

public static final int TYPE_DNS_NAME
This value indicates the choice "dNSName"

TYPE_X400_ADDRESS

public static final int TYPE_X400_ADDRESS
This value indicates the choice "x400Address"

TYPE_DIRECTORY_NAME

public static final int TYPE_DIRECTORY_NAME
This value indicates the choice "directoryName"

TYPE_EDI_PARTY_NAME

public static final int TYPE_EDI_PARTY_NAME
This value indicates the choice "ediPartyName"

TYPE_UNIFORM_RESOURCE_IDENTIFIER

public static final int TYPE_UNIFORM_RESOURCE_IDENTIFIER
This value indicates the choice "uniformResourceIdentifier"

TYPE_IP_ADDRESS

public static final int TYPE_IP_ADDRESS
This value indicates the choice "iPAddress"

TYPE_REGISTERED_ID

public static final int TYPE_REGISTERED_ID
This value indicates the choice "registeredID"
Constructor Detail

GeneralName

public GeneralName()
Builds the structure of the class ready for decoding
Method Detail

getGeneralName

public ASN1Type getGeneralName()
                        throws X509Exception
Returns the actual Name as ASN1Type. In fact, this can be:
  • ASN1IA5String in case of rfcName, dNSName and uniformResourceIdentifier
  • ASN1OctetString in case of iPAddress
  • Name in case of directoryName
  • ASN1ObjectIdentifier in case of registeredID
  • ASN1Sequence in case of otherName
    Returns:
    the actual GeneralName value. The type depends on the chosen representation and can be either ASN1IA5String, ASN1OctetString, Name, ASN1Sequence or ASN1ObjectIdentifier.
    Throws:
    X509Exception - if there was a bad tag

  • setDirectoryName

    public void setDirectoryName(Name dirname)
    Set the GeneralName as a directoryName. Note that the given Name object is cloned so that no side effects can occur!
    Parameters:
    dirname - the name to be set

    setDNSName

    public void setDNSName(ASN1IA5String dnsname)
    Set the GeneralName as a dNSName.Note that the ASN1IA5String object is cloned so that no side effects can occur!
    Parameters:
    dnsname - the name to be set

    setIPAddress

    public void setIPAddress(byte[] address)
                      throws InvalidParameterException
    Set the GeneralName as a iPAddress. For IPv4 addresses, byte array MUST contain eight (8) octets, encoded in the style of RFC 1519 (CIDR) to represent an address range.[RFC 1519] For IPv6 addresses, it MUST contain 32 octets similarly encoded. For example, a name constraint for "class C" subnet 10.9.8.0 shall be represented as the octets 0A 09 08 00 FF FF FF 00, representing the CIDR notation 10.9.8.0/255.255.255.0.
    Parameters:
    address - the address to be set (must be either 8 or 32 bytes)
    Throws:
    InvalidParameterException - if length of address is not 8 or 32 bytes.

    setRegisteredID

    public void setRegisteredID(ASN1ObjectIdentifier oid)
    Set the GeneralName as a registeredID. Note that the given ASN1ObjectIdentifier object is cloned so that no side effects can occur!
    Parameters:
    oid - the name to be set

    setRfc822Name

    public void setRfc822Name(ASN1IA5String rfcname)
    Set the GeneralName as a rfc822Namename. Note that the ASN1IA5String object is cloned so that no side effects can occur!
    Parameters:
    rfcname - the name to be set

    setUniformResourceIdentifier

    public void setUniformResourceIdentifier(ASN1IA5String unirid)
    Set the GeneralName as uniformResourceIdentifier.Note that the ASN1IA5String object is cloned so that no side effects can occur!
    Parameters:
    unirid - the name to be set

    toString

    public String toString()
    This method returns a "human-readable" string representation of this object's state
    Overrides:
    toString in class ASN1Choice
    Returns:
    a string representation of this object


    Copyright © Fraunhofer Gesellschaft. All Rights Reserved.