blob: 154e4940ee3d69c3e9883fa671525b7d0762c673 (
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
|
using System;
using Org.BouncyCastle.Utilities;
namespace Org.BouncyCastle.Asn1.X500
{
public class DirectoryString
: Asn1Encodable, IAsn1Choice, IAsn1String
{
private readonly DerStringBase str;
public static DirectoryString GetInstance(object obj)
{
if (obj == null || obj is DirectoryString)
return (DirectoryString) obj;
if (obj is DerStringBase)
{
if (obj is DerT61String
|| obj is DerPrintableString
|| obj is DerUniversalString
|| obj is DerUtf8String
|| obj is DerBmpString)
{
return new DirectoryString((DerStringBase) obj);
}
}
throw new ArgumentException("unknown object in factory: " + Platform.GetTypeName(obj), "obj");
}
public static DirectoryString GetInstance(Asn1TaggedObject obj, bool isExplicit)
{
return Asn1Utilities.GetInstanceFromChoice(obj, isExplicit, GetInstance);
}
private DirectoryString(
DerStringBase str)
{
this.str = str;
}
public DirectoryString(
string str)
{
this.str = new DerUtf8String(str);
}
public string GetString()
{
return str.GetString();
}
/**
* <pre>
* DirectoryString ::= CHOICE {
* teletexString TeletexString (SIZE (1..MAX)),
* printableString PrintableString (SIZE (1..MAX)),
* universalString UniversalString (SIZE (1..MAX)),
* utf8String UTF8String (SIZE (1..MAX)),
* bmpString BMPString (SIZE (1..MAX)) }
* </pre>
*/
public override Asn1Object ToAsn1Object()
{
return str.ToAsn1Object();
}
}
}
|