ProfessionInfo.cs 11 KB

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