summary refs log tree commit diff
path: root/crypto/src/asn1/isismtt/x509/Restriction.cs
blob: eceffaf966101089dc3209584e2574dc5b1be8ec (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using Org.BouncyCastle.Asn1.X500;

namespace Org.BouncyCastle.Asn1.IsisMtt.X509
{
    /**
	* Some other restriction regarding the usage of this certificate.
	* <p/>
	* <pre>
	*  RestrictionSyntax ::= DirectoryString (SIZE(1..1024))
	* </pre>
	*/
    public class Restriction
		: Asn1Encodable
	{
        public static Restriction GetInstance(object obj)
        {
            if (obj == null)
                return null;
            if (obj is Restriction restriction)
                return restriction;
            return new Restriction(DirectoryString.GetInstance(obj));
        }

        public static Restriction GetInstance(Asn1TaggedObject taggedObject, bool declaredExplicit) =>
            new Restriction(DirectoryString.GetInstance(taggedObject, declaredExplicit));

        public static Restriction GetTagged(Asn1TaggedObject taggedObject, bool declaredExplicit) =>
            new Restriction(DirectoryString.GetTagged(taggedObject, declaredExplicit));

        private readonly DirectoryString m_restriction;

        /**
		* Constructor from DirectoryString.
		* <p/>
		* The DirectoryString is of type RestrictionSyntax:
		* <p/>
		* <pre>
		*      RestrictionSyntax ::= DirectoryString (SIZE(1..1024))
		* </pre>
		*
		* @param restriction A IAsn1String.
		*/
        private Restriction(DirectoryString restriction)
		{
			m_restriction = restriction;
		}

		/**
		* Constructor from a given details.
		*
		* @param restriction The description of the restriction.
		*/
		public Restriction(string restriction)
		{
			m_restriction = new DirectoryString(restriction);
		}

		public virtual DirectoryString RestrictionString => m_restriction;

		/**
		* Produce an object suitable for an Asn1OutputStream.
		* <p/>
		* Returns:
		* <p/>
		* <pre>
		*      RestrictionSyntax ::= DirectoryString (SIZE(1..1024))
		* <p/>
		* </pre>
		*
		* @return an Asn1Object
		*/
		public override Asn1Object ToAsn1Object() => m_restriction.ToAsn1Object();
	}
}