01: package org.bouncycastle.asn1.isismtt.x509;
02:
03: import org.bouncycastle.asn1.ASN1Encodable;
04: import org.bouncycastle.asn1.DERObject;
05: import org.bouncycastle.asn1.DERString;
06: import org.bouncycastle.asn1.x500.DirectoryString;
07:
08: /**
09: * Some other restriction regarding the usage of this certificate.
10: * <p/>
11: * <pre>
12: * RestrictionSyntax ::= DirectoryString (SIZE(1..1024))
13: * </pre>
14: */
15: public class Restriction extends ASN1Encodable {
16: private DirectoryString restriction;
17:
18: public static Restriction getInstance(Object obj) {
19: if (obj == null || obj instanceof Restriction) {
20: return (Restriction) obj;
21: }
22:
23: if (obj instanceof DERString) {
24: return new Restriction(DirectoryString.getInstance(obj));
25: }
26:
27: throw new IllegalArgumentException(
28: "illegal object in getInstance: "
29: + obj.getClass().getName());
30: }
31:
32: /**
33: * Constructor from DERString.
34: * <p/>
35: * The DERString is of type RestrictionSyntax:
36: * <p/>
37: * <pre>
38: * RestrictionSyntax ::= DirectoryString (SIZE(1..1024))
39: * </pre>
40: *
41: * @param restriction A DERString.
42: */
43: private Restriction(DirectoryString restriction) {
44: this .restriction = restriction;
45: }
46:
47: /**
48: * Constructor from a given details.
49: *
50: * @param restriction The describtion of the restriction.
51: */
52: public Restriction(String restriction) {
53: this .restriction = new DirectoryString(restriction);
54: }
55:
56: public DirectoryString getRestriction() {
57: return restriction;
58: }
59:
60: /**
61: * Produce an object suitable for an ASN1OutputStream.
62: * <p/>
63: * Returns:
64: * <p/>
65: * <pre>
66: * RestrictionSyntax ::= DirectoryString (SIZE(1..1024))
67: * <p/>
68: * </pre>
69: *
70: * @return a DERObject
71: */
72: public DERObject toASN1Object() {
73: return restriction.toASN1Object();
74: }
75: }
|