2002/03/21 01:19:32
[org.ibex.core.git] / src / org / bouncycastle / asn1 / x509 / GeneralName.java
1 package org.bouncycastle.asn1.x509;
2
3 import org.bouncycastle.asn1.*;
4
5 /**
6  * <pre>
7  * GeneralName ::= CHOICE {
8  *      otherName                       [0]     OtherName,
9  *      rfc822Name                      [1]     IA5String,
10  *      dNSName                         [2]     IA5String,
11  *      x400Address                     [3]     ORAddress,
12  *      directoryName                   [4]     Name,
13  *      ediPartyName                    [5]     EDIPartyName,
14  *      uniformResourceIdentifier       [6]     IA5String,
15  *      iPAddress                       [7]     OCTET STRING,
16  *      registeredID                    [8]     OBJECT IDENTIFIER}
17  *
18  * OtherName ::= SEQUENCE {
19  *      type-id    OBJECT IDENTIFIER,
20  *      value      [0] EXPLICIT ANY DEFINED BY type-id }
21  *
22  * EDIPartyName ::= SEQUENCE {
23  *      nameAssigner            [0]     DirectoryString OPTIONAL,
24  *      partyName               [1]     DirectoryString }
25  * </pre>
26  */
27 public class GeneralName
28     implements DEREncodable
29 {
30     DEREncodable  obj;
31     int           tag;
32
33     public GeneralName(
34         X509Name  directoryName)
35     {
36         this.obj = directoryName;
37         this.tag = 4;
38     }
39
40     /**
41      * When the subjectAltName extension contains an Internet mail address,
42      * the address MUST be included as an rfc822Name. The format of an
43      * rfc822Name is an "addr-spec" as defined in RFC 822 [RFC 822].
44      *
45      * When the subjectAltName extension contains a domain name service
46      * label, the domain name MUST be stored in the dNSName (an IA5String).
47      * The name MUST be in the "preferred name syntax," as specified by RFC
48      * 1034 [RFC 1034].
49      *
50      * When the subjectAltName extension contains a URI, the name MUST be
51      * stored in the uniformResourceIdentifier (an IA5String). The name MUST
52      * be a non-relative URL, and MUST follow the URL syntax and encoding
53      * rules specified in [RFC 1738].  The name must include both a scheme
54      * (e.g., "http" or "ftp") and a scheme-specific-part.  The scheme-
55      * specific-part must include a fully qualified domain name or IP
56      * address as the host.
57      *
58      * When the subjectAltName extension contains a iPAddress, the address
59      * MUST be stored in the octet string in "network byte order," as
60      * specified in RFC 791 [RFC 791]. The least significant bit (LSB) of
61      * each octet is the LSB of the corresponding byte in the network
62      * address. For IP Version 4, as specified in RFC 791, the octet string
63      * MUST contain exactly four octets.  For IP Version 6, as specified in
64      * RFC 1883, the octet string MUST contain exactly sixteen octets [RFC
65      * 1883].
66      */
67     public GeneralName(
68         DERObject name, int tag)
69     {
70         this.obj = name;
71         this.tag = tag;
72     }
73
74     public DERObject getDERObject()
75     {
76         return new DERTaggedObject(false, tag, obj);
77     }
78 }