~brian-thomason/+junk/bouncycastle

« back to all changes in this revision

Viewing changes to src/org/bouncycastle/asn1/isismtt/x509/AdditionalInformationSyntax.java

  • Committer: Brian Thomason
  • Date: 2011-12-20 17:20:32 UTC
  • Revision ID: brian.thomason@canonical.com-20111220172032-rdtm13jgdxtksacr
Initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package org.bouncycastle.asn1.isismtt.x509;
 
2
 
 
3
import org.bouncycastle.asn1.ASN1Encodable;
 
4
import org.bouncycastle.asn1.ASN1String;
 
5
import org.bouncycastle.asn1.DERObject;
 
6
import org.bouncycastle.asn1.x500.DirectoryString;
 
7
 
 
8
/**
 
9
 * Some other information of non-restrictive nature regarding the usage of this
 
10
 * certificate.
 
11
 * 
 
12
 * <pre>
 
13
 *    AdditionalInformationSyntax ::= DirectoryString (SIZE(1..2048))
 
14
 * </pre>
 
15
 */
 
16
public class AdditionalInformationSyntax extends ASN1Encodable
 
17
{
 
18
    private DirectoryString information;
 
19
 
 
20
    public static AdditionalInformationSyntax getInstance(Object obj)
 
21
    {
 
22
        if (obj instanceof AdditionalInformationSyntax)
 
23
        {
 
24
            return (AdditionalInformationSyntax)obj;
 
25
        }
 
26
 
 
27
        if (obj instanceof ASN1String)
 
28
        {
 
29
            return new AdditionalInformationSyntax(DirectoryString.getInstance(obj));
 
30
        }
 
31
 
 
32
        throw new IllegalArgumentException("illegal object in getInstance: " + obj.getClass().getName());
 
33
    }
 
34
 
 
35
    private AdditionalInformationSyntax(DirectoryString information)
 
36
    {
 
37
        this.information = information;
 
38
    }
 
39
 
 
40
    /**
 
41
     * Constructor from a given details.
 
42
     *
 
43
     * @param information The describtion of the information.
 
44
     */
 
45
    public AdditionalInformationSyntax(String information)
 
46
    {
 
47
        this(new DirectoryString(information));
 
48
    }
 
49
 
 
50
    public DirectoryString getInformation()
 
51
    {
 
52
        return information;
 
53
    }
 
54
 
 
55
    /**
 
56
     * Produce an object suitable for an ASN1OutputStream.
 
57
     * <p/>
 
58
     * Returns:
 
59
     * <p/>
 
60
     * <pre>
 
61
     *   AdditionalInformationSyntax ::= DirectoryString (SIZE(1..2048))
 
62
     * </pre>
 
63
     *
 
64
     * @return a DERObject
 
65
     */
 
66
    public DERObject toASN1Object()
 
67
    {
 
68
        return information.toASN1Object();
 
69
    }
 
70
}