ProfessionInfo.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. using System.Collections;
  5. using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.X500;
  6. using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities;
  7. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.IsisMtt.X509
  8. {
  9. /**
  10. * Professions, specializations, disciplines, fields of activity, etc.
  11. *
  12. * <pre>
  13. * ProfessionInfo ::= SEQUENCE
  14. * {
  15. * namingAuthority [0] EXPLICIT NamingAuthority OPTIONAL,
  16. * professionItems SEQUENCE OF DirectoryString (SIZE(1..128)),
  17. * professionOids SEQUENCE OF OBJECT IDENTIFIER OPTIONAL,
  18. * registrationNumber PrintableString(SIZE(1..128)) OPTIONAL,
  19. * addProfessionInfo OCTET STRING OPTIONAL
  20. * }
  21. * </pre>
  22. *
  23. * @see BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.IsisMtt.X509.AdmissionSyntax
  24. */
  25. public class ProfessionInfo
  26. : Asn1Encodable
  27. {
  28. /**
  29. * Rechtsanw�ltin
  30. */
  31. public static readonly DerObjectIdentifier Rechtsanwltin = new DerObjectIdentifier(
  32. NamingAuthority.IdIsisMttATNamingAuthoritiesRechtWirtschaftSteuern + ".1");
  33. /**
  34. * Rechtsanwalt
  35. */
  36. public static readonly DerObjectIdentifier Rechtsanwalt = new DerObjectIdentifier(
  37. NamingAuthority.IdIsisMttATNamingAuthoritiesRechtWirtschaftSteuern + ".2");
  38. /**
  39. * Rechtsbeistand
  40. */
  41. public static readonly DerObjectIdentifier Rechtsbeistand = new DerObjectIdentifier(
  42. NamingAuthority.IdIsisMttATNamingAuthoritiesRechtWirtschaftSteuern + ".3");
  43. /**
  44. * Steuerberaterin
  45. */
  46. public static readonly DerObjectIdentifier Steuerberaterin = new DerObjectIdentifier(
  47. NamingAuthority.IdIsisMttATNamingAuthoritiesRechtWirtschaftSteuern + ".4");
  48. /**
  49. * Steuerberater
  50. */
  51. public static readonly DerObjectIdentifier Steuerberater = new DerObjectIdentifier(
  52. NamingAuthority.IdIsisMttATNamingAuthoritiesRechtWirtschaftSteuern + ".5");
  53. /**
  54. * Steuerbevollm�chtigte
  55. */
  56. public static readonly DerObjectIdentifier Steuerbevollmchtigte = new DerObjectIdentifier(
  57. NamingAuthority.IdIsisMttATNamingAuthoritiesRechtWirtschaftSteuern + ".6");
  58. /**
  59. * Steuerbevollm�chtigter
  60. */
  61. public static readonly DerObjectIdentifier Steuerbevollmchtigter = new DerObjectIdentifier(
  62. NamingAuthority.IdIsisMttATNamingAuthoritiesRechtWirtschaftSteuern + ".7");
  63. /**
  64. * Notarin
  65. */
  66. public static readonly DerObjectIdentifier Notarin = new DerObjectIdentifier(
  67. NamingAuthority.IdIsisMttATNamingAuthoritiesRechtWirtschaftSteuern + ".8");
  68. /**
  69. * Notar
  70. */
  71. public static readonly DerObjectIdentifier Notar = new DerObjectIdentifier(
  72. NamingAuthority.IdIsisMttATNamingAuthoritiesRechtWirtschaftSteuern + ".9");
  73. /**
  74. * Notarvertreterin
  75. */
  76. public static readonly DerObjectIdentifier Notarvertreterin = new DerObjectIdentifier(
  77. NamingAuthority.IdIsisMttATNamingAuthoritiesRechtWirtschaftSteuern + ".10");
  78. /**
  79. * Notarvertreter
  80. */
  81. public static readonly DerObjectIdentifier Notarvertreter = new DerObjectIdentifier(
  82. NamingAuthority.IdIsisMttATNamingAuthoritiesRechtWirtschaftSteuern + ".11");
  83. /**
  84. * Notariatsverwalterin
  85. */
  86. public static readonly DerObjectIdentifier Notariatsverwalterin = new DerObjectIdentifier(
  87. NamingAuthority.IdIsisMttATNamingAuthoritiesRechtWirtschaftSteuern + ".12");
  88. /**
  89. * Notariatsverwalter
  90. */
  91. public static readonly DerObjectIdentifier Notariatsverwalter = new DerObjectIdentifier(
  92. NamingAuthority.IdIsisMttATNamingAuthoritiesRechtWirtschaftSteuern + ".13");
  93. /**
  94. * Wirtschaftspr�ferin
  95. */
  96. public static readonly DerObjectIdentifier Wirtschaftsprferin = new DerObjectIdentifier(
  97. NamingAuthority.IdIsisMttATNamingAuthoritiesRechtWirtschaftSteuern + ".14");
  98. /**
  99. * Wirtschaftspr�fer
  100. */
  101. public static readonly DerObjectIdentifier Wirtschaftsprfer = new DerObjectIdentifier(
  102. NamingAuthority.IdIsisMttATNamingAuthoritiesRechtWirtschaftSteuern + ".15");
  103. /**
  104. * Vereidigte Buchpr�ferin
  105. */
  106. public static readonly DerObjectIdentifier VereidigteBuchprferin = new DerObjectIdentifier(
  107. NamingAuthority.IdIsisMttATNamingAuthoritiesRechtWirtschaftSteuern + ".16");
  108. /**
  109. * Vereidigter Buchpr�fer
  110. */
  111. public static readonly DerObjectIdentifier VereidigterBuchprfer = new DerObjectIdentifier(
  112. NamingAuthority.IdIsisMttATNamingAuthoritiesRechtWirtschaftSteuern + ".17");
  113. /**
  114. * Patentanw�ltin
  115. */
  116. public static readonly DerObjectIdentifier Patentanwltin = new DerObjectIdentifier(
  117. NamingAuthority.IdIsisMttATNamingAuthoritiesRechtWirtschaftSteuern + ".18");
  118. /**
  119. * Patentanwalt
  120. */
  121. public static readonly DerObjectIdentifier Patentanwalt = new DerObjectIdentifier(
  122. NamingAuthority.IdIsisMttATNamingAuthoritiesRechtWirtschaftSteuern + ".19");
  123. private readonly NamingAuthority namingAuthority;
  124. private readonly Asn1Sequence professionItems;
  125. private readonly Asn1Sequence professionOids;
  126. private readonly string registrationNumber;
  127. private readonly Asn1OctetString addProfessionInfo;
  128. public static ProfessionInfo GetInstance(
  129. object obj)
  130. {
  131. if (obj == null || obj is ProfessionInfo)
  132. {
  133. return (ProfessionInfo) obj;
  134. }
  135. if (obj is Asn1Sequence)
  136. {
  137. return new ProfessionInfo((Asn1Sequence) obj);
  138. }
  139. throw new ArgumentException("unknown object in factory: " + BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Platform.GetTypeName(obj), "obj");
  140. }
  141. /**
  142. * Constructor from Asn1Sequence.
  143. * <p/>
  144. * <p/>
  145. * <pre>
  146. * ProfessionInfo ::= SEQUENCE
  147. * {
  148. * namingAuthority [0] EXPLICIT NamingAuthority OPTIONAL,
  149. * professionItems SEQUENCE OF DirectoryString (SIZE(1..128)),
  150. * professionOids SEQUENCE OF OBJECT IDENTIFIER OPTIONAL,
  151. * registrationNumber PrintableString(SIZE(1..128)) OPTIONAL,
  152. * addProfessionInfo OCTET STRING OPTIONAL
  153. * }
  154. * </pre>
  155. *
  156. * @param seq The ASN.1 sequence.
  157. */
  158. private ProfessionInfo(
  159. Asn1Sequence seq)
  160. {
  161. if (seq.Count > 5)
  162. throw new ArgumentException("Bad sequence size: " + seq.Count);
  163. IEnumerator e = seq.GetEnumerator();
  164. e.MoveNext();
  165. Asn1Encodable o = (Asn1Encodable) e.Current;
  166. if (o is Asn1TaggedObject)
  167. {
  168. Asn1TaggedObject ato = (Asn1TaggedObject) o;
  169. if (ato.TagNo != 0)
  170. throw new ArgumentException("Bad tag number: " + ato.TagNo);
  171. namingAuthority = NamingAuthority.GetInstance(ato, true);
  172. e.MoveNext();
  173. o = (Asn1Encodable) e.Current;
  174. }
  175. professionItems = Asn1Sequence.GetInstance(o);
  176. if (e.MoveNext())
  177. {
  178. o = (Asn1Encodable) e.Current;
  179. if (o is Asn1Sequence)
  180. {
  181. professionOids = Asn1Sequence.GetInstance(o);
  182. }
  183. else if (o is DerPrintableString)
  184. {
  185. registrationNumber = DerPrintableString.GetInstance(o).GetString();
  186. }
  187. else if (o is Asn1OctetString)
  188. {
  189. addProfessionInfo = Asn1OctetString.GetInstance(o);
  190. }
  191. else
  192. {
  193. throw new ArgumentException("Bad object encountered: " + BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Platform.GetTypeName(o));
  194. }
  195. }
  196. if (e.MoveNext())
  197. {
  198. o = (Asn1Encodable) e.Current;
  199. if (o is DerPrintableString)
  200. {
  201. registrationNumber = DerPrintableString.GetInstance(o).GetString();
  202. }
  203. else if (o is DerOctetString)
  204. {
  205. addProfessionInfo = (DerOctetString) o;
  206. }
  207. else
  208. {
  209. throw new ArgumentException("Bad object encountered: " + BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Platform.GetTypeName(o));
  210. }
  211. }
  212. if (e.MoveNext())
  213. {
  214. o = (Asn1Encodable) e.Current;
  215. if (o is DerOctetString)
  216. {
  217. addProfessionInfo = (DerOctetString) o;
  218. }
  219. else
  220. {
  221. throw new ArgumentException("Bad object encountered: " + BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Platform.GetTypeName(o));
  222. }
  223. }
  224. }
  225. /**
  226. * Constructor from given details.
  227. * <p/>
  228. * <code>professionItems</code> is mandatory, all other parameters are
  229. * optional.
  230. *
  231. * @param namingAuthority The naming authority.
  232. * @param professionItems Directory strings of the profession.
  233. * @param professionOids DERObjectIdentfier objects for the
  234. * profession.
  235. * @param registrationNumber Registration number.
  236. * @param addProfessionInfo Additional infos in encoded form.
  237. */
  238. public ProfessionInfo(
  239. NamingAuthority namingAuthority,
  240. DirectoryString[] professionItems,
  241. DerObjectIdentifier[] professionOids,
  242. string registrationNumber,
  243. Asn1OctetString addProfessionInfo)
  244. {
  245. this.namingAuthority = namingAuthority;
  246. this.professionItems = new DerSequence(professionItems);
  247. if (professionOids != null)
  248. {
  249. this.professionOids = new DerSequence(professionOids);
  250. }
  251. this.registrationNumber = registrationNumber;
  252. this.addProfessionInfo = addProfessionInfo;
  253. }
  254. /**
  255. * Produce an object suitable for an Asn1OutputStream.
  256. * <p/>
  257. * Returns:
  258. * <p/>
  259. * <pre>
  260. * ProfessionInfo ::= SEQUENCE
  261. * {
  262. * namingAuthority [0] EXPLICIT NamingAuthority OPTIONAL,
  263. * professionItems SEQUENCE OF DirectoryString (SIZE(1..128)),
  264. * professionOids SEQUENCE OF OBJECT IDENTIFIER OPTIONAL,
  265. * registrationNumber PrintableString(SIZE(1..128)) OPTIONAL,
  266. * addProfessionInfo OCTET STRING OPTIONAL
  267. * }
  268. * </pre>
  269. *
  270. * @return an Asn1Object
  271. */
  272. public override Asn1Object ToAsn1Object()
  273. {
  274. Asn1EncodableVector v = new Asn1EncodableVector();
  275. v.AddOptionalTagged(true, 0, namingAuthority);
  276. v.Add(professionItems);
  277. v.AddOptional(professionOids);
  278. if (registrationNumber != null)
  279. {
  280. v.Add(new DerPrintableString(registrationNumber, true));
  281. }
  282. v.AddOptional(addProfessionInfo);
  283. return new DerSequence(v);
  284. }
  285. /**
  286. * @return Returns the addProfessionInfo.
  287. */
  288. public virtual Asn1OctetString AddProfessionInfo
  289. {
  290. get { return addProfessionInfo; }
  291. }
  292. /**
  293. * @return Returns the namingAuthority.
  294. */
  295. public virtual NamingAuthority NamingAuthority
  296. {
  297. get { return namingAuthority; }
  298. }
  299. /**
  300. * @return Returns the professionItems.
  301. */
  302. public virtual DirectoryString[] GetProfessionItems()
  303. {
  304. DirectoryString[] result = new DirectoryString[professionItems.Count];
  305. for (int i = 0; i < professionItems.Count; ++i)
  306. {
  307. result[i] = DirectoryString.GetInstance(professionItems[i]);
  308. }
  309. return result;
  310. }
  311. /**
  312. * @return Returns the professionOids.
  313. */
  314. public virtual DerObjectIdentifier[] GetProfessionOids()
  315. {
  316. if (professionOids == null)
  317. {
  318. return new DerObjectIdentifier[0];
  319. }
  320. DerObjectIdentifier[] result = new DerObjectIdentifier[professionOids.Count];
  321. for (int i = 0; i < professionOids.Count; ++i)
  322. {
  323. result[i] = DerObjectIdentifier.GetInstance(professionOids[i]);
  324. }
  325. return result;
  326. }
  327. /**
  328. * @return Returns the registrationNumber.
  329. */
  330. public virtual string RegistrationNumber
  331. {
  332. get { return registrationNumber; }
  333. }
  334. }
  335. }
  336. #pragma warning restore
  337. #endif