Inheritance: Asn1Encodable
Example #1
0
		public override void PerformTest()
		{
			GeneralName name = new GeneralName(new X509Name("CN=hello world"));
			NamingAuthority auth = new NamingAuthority(new DerObjectIdentifier("1.2.3"), "url", new DirectoryString("fred"));
			Admissions admissions = new Admissions(name, auth, new ProfessionInfo[0]);

			checkConstruction(admissions, name, auth);

			admissions = Admissions.GetInstance(null);

			if (admissions != null)
			{
				Fail("null GetInstance() failed.");
			}

			try
			{
				Admissions.GetInstance(new Object());

				Fail("GetInstance() failed to detect bad object.");
			}
			catch (ArgumentException)
			{
				// expected
			}
		}
Example #2
0
		private void checkValues(
			Admissions		admissions,
			GeneralName		name,
			NamingAuthority	auth)
		{
			checkMandatoryField("admissionAuthority", name, admissions.AdmissionAuthority);
			checkMandatoryField("namingAuthority", auth, admissions.NamingAuthority);
		}
Example #3
0
        /**
        * Constructor from a given details.
        * <p/>
        * Parameter <code>professionInfos</code> is mandatory.
        *
        * @param admissionAuthority The admission authority.
        * @param namingAuthority    The naming authority.
        * @param professionInfos    The profession infos.
        */
        public Admissions(
			GeneralName			admissionAuthority,
			NamingAuthority		namingAuthority,
			ProfessionInfo[]	professionInfos)
        {
            this.admissionAuthority = admissionAuthority;
            this.namingAuthority = namingAuthority;
            this.professionInfos = new DerSequence(professionInfos);
        }
Example #4
0
 /**
  * Constructor from a given details.
  * <p/>
  * Parameter <code>professionInfos</code> is mandatory.
  *
  * @param admissionAuthority The admission authority.
  * @param namingAuthority    The naming authority.
  * @param professionInfos    The profession infos.
  */
 public Admissions(
     GeneralName admissionAuthority,
     NamingAuthority namingAuthority,
     ProfessionInfo[]        professionInfos)
 {
     this.admissionAuthority = admissionAuthority;
     this.namingAuthority    = namingAuthority;
     this.professionInfos    = new DerSequence(professionInfos);
 }
		private void checkValues(
			NamingAuthority		auth,
			DerObjectIdentifier	namingAuthorityId,
			string				namingAuthorityURL,
			DirectoryString		namingAuthorityText)
		{
			checkOptionalField("namingAuthorityId", namingAuthorityId, auth.NamingAuthorityID);
			checkOptionalField("namingAuthorityURL", namingAuthorityURL, auth.NamingAuthorityUrl);
			checkOptionalField("namingAuthorityText", namingAuthorityText, auth.NamingAuthorityText);
		}
 public ProfessionInfo(NamingAuthority namingAuthority, DirectoryString[] professionItems, DerObjectIdentifier[] professionOids, string registrationNumber, Asn1OctetString addProfessionInfo)
 {
     this.namingAuthority = namingAuthority;
     this.professionItems = new DerSequence(professionItems);
     if (professionOids != null)
     {
         this.professionOids = new DerSequence(professionOids);
     }
     this.registrationNumber = registrationNumber;
     this.addProfessionInfo  = addProfessionInfo;
 }
Example #7
0
        /**
         * Constructor from Asn1Sequence.
         * <p/>
         * The sequence is of type ProcurationSyntax:
         * <p/>
         * <pre>
         *            Admissions ::= SEQUENCE
         *            {
         *              admissionAuthority [0] EXPLICIT GeneralName OPTIONAL
         *              namingAuthority [1] EXPLICIT NamingAuthority OPTIONAL
         *              professionInfos SEQUENCE OF ProfessionInfo
         *            }
         * </pre>
         *
         * @param seq The ASN.1 sequence.
         */
        private Admissions(
            Asn1Sequence seq)
        {
            if (seq.Count > 3)
            {
                throw new ArgumentException("Bad sequence size: " + seq.Count);
            }

            IEnumerator e = seq.GetEnumerator();

            e.MoveNext();
            Asn1Encodable o = (Asn1Encodable)e.Current;

            if (o is Asn1TaggedObject)
            {
                switch (((Asn1TaggedObject)o).TagNo)
                {
                case 0:
                    admissionAuthority = GeneralName.GetInstance((Asn1TaggedObject)o, true);
                    break;

                case 1:
                    namingAuthority = NamingAuthority.GetInstance((Asn1TaggedObject)o, true);
                    break;

                default:
                    throw new ArgumentException("Bad tag number: " + ((Asn1TaggedObject)o).TagNo);
                }
                e.MoveNext();
                o = (Asn1Encodable)e.Current;
            }
            if (o is Asn1TaggedObject)
            {
                switch (((Asn1TaggedObject)o).TagNo)
                {
                case 1:
                    namingAuthority = NamingAuthority.GetInstance((Asn1TaggedObject)o, true);
                    break;

                default:
                    throw new ArgumentException("Bad tag number: " + ((Asn1TaggedObject)o).TagNo);
                }
                e.MoveNext();
                o = (Asn1Encodable)e.Current;
            }
            professionInfos = Asn1Sequence.GetInstance(o);
            if (e.MoveNext())
            {
                throw new ArgumentException("Bad object encountered: " + e.Current.GetType().Name);
            }
        }
Example #8
0
        private Admissions(Asn1Sequence seq)
        {
            //IL_0024: Unknown result type (might be due to invalid IL or missing references)
            //IL_00aa: Unknown result type (might be due to invalid IL or missing references)
            //IL_0109: Unknown result type (might be due to invalid IL or missing references)
            //IL_014b: Unknown result type (might be due to invalid IL or missing references)
            if (seq.Count > 3)
            {
                throw new ArgumentException(string.Concat((object)"Bad sequence size: ", (object)seq.Count));
            }
            global::System.Collections.IEnumerator enumerator = seq.GetEnumerator();
            enumerator.MoveNext();
            Asn1Encodable asn1Encodable = (Asn1Encodable)enumerator.get_Current();

            if (asn1Encodable is Asn1TaggedObject)
            {
                switch (((Asn1TaggedObject)asn1Encodable).TagNo)
                {
                case 0:
                    admissionAuthority = GeneralName.GetInstance((Asn1TaggedObject)asn1Encodable, explicitly: true);
                    break;

                case 1:
                    namingAuthority = NamingAuthority.GetInstance((Asn1TaggedObject)asn1Encodable, isExplicit: true);
                    break;

                default:
                    throw new ArgumentException(string.Concat((object)"Bad tag number: ", (object)((Asn1TaggedObject)asn1Encodable).TagNo));
                }
                enumerator.MoveNext();
                asn1Encodable = (Asn1Encodable)enumerator.get_Current();
            }
            if (asn1Encodable is Asn1TaggedObject)
            {
                int tagNo = ((Asn1TaggedObject)asn1Encodable).TagNo;
                if (tagNo != 1)
                {
                    throw new ArgumentException(string.Concat((object)"Bad tag number: ", (object)((Asn1TaggedObject)asn1Encodable).TagNo));
                }
                namingAuthority = NamingAuthority.GetInstance((Asn1TaggedObject)asn1Encodable, isExplicit: true);
                enumerator.MoveNext();
                asn1Encodable = (Asn1Encodable)enumerator.get_Current();
            }
            professionInfos = Asn1Sequence.GetInstance(asn1Encodable);
            if (enumerator.MoveNext())
            {
                throw new ArgumentException("Bad object encountered: " + Platform.GetTypeName(enumerator.get_Current()));
            }
        }
Example #9
0
        private Admissions(Asn1Sequence seq)
        {
            if (seq.Count > 3)
            {
                throw new ArgumentException("Bad sequence size: " + seq.Count);
            }
            IEnumerator enumerator = seq.GetEnumerator();

            enumerator.MoveNext();
            Asn1Encodable asn1Encodable = (Asn1Encodable)enumerator.Current;

            if (asn1Encodable is Asn1TaggedObject)
            {
                switch (((Asn1TaggedObject)asn1Encodable).TagNo)
                {
                case 0:
                    this.admissionAuthority = GeneralName.GetInstance((Asn1TaggedObject)asn1Encodable, true);
                    break;

                case 1:
                    this.namingAuthority = NamingAuthority.GetInstance((Asn1TaggedObject)asn1Encodable, true);
                    break;

                default:
                    throw new ArgumentException("Bad tag number: " + ((Asn1TaggedObject)asn1Encodable).TagNo);
                }
                enumerator.MoveNext();
                asn1Encodable = (Asn1Encodable)enumerator.Current;
            }
            if (asn1Encodable is Asn1TaggedObject)
            {
                int tagNo = ((Asn1TaggedObject)asn1Encodable).TagNo;
                if (tagNo != 1)
                {
                    throw new ArgumentException("Bad tag number: " + ((Asn1TaggedObject)asn1Encodable).TagNo);
                }
                this.namingAuthority = NamingAuthority.GetInstance((Asn1TaggedObject)asn1Encodable, true);
                enumerator.MoveNext();
                asn1Encodable = (Asn1Encodable)enumerator.Current;
            }
            this.professionInfos = Asn1Sequence.GetInstance(asn1Encodable);
            if (enumerator.MoveNext())
            {
                throw new ArgumentException("Bad object encountered: " + enumerator.Current.GetType().Name);
            }
        }
		public override void PerformTest()
		{
			NamingAuthority auth =  new NamingAuthority(new DerObjectIdentifier("1.2.3"), "url", new DirectoryString("fred"));
			DirectoryString[] professionItems = { new DirectoryString("substitution") };
			DerObjectIdentifier[] professionOids = { new DerObjectIdentifier("1.2.3") };
			string registrationNumber = "12345";
			DerOctetString addProfInfo = new DerOctetString(new byte[20]);

			ProfessionInfo info = new ProfessionInfo(auth, professionItems, professionOids, registrationNumber, addProfInfo);

			checkConstruction(info, auth, professionItems, professionOids, registrationNumber, addProfInfo);

			info = new ProfessionInfo(null, professionItems, professionOids, registrationNumber, addProfInfo);

			checkConstruction(info, null, professionItems, professionOids, registrationNumber, addProfInfo);

			info = new ProfessionInfo(auth, professionItems, null, registrationNumber, addProfInfo);

			checkConstruction(info, auth, professionItems, null, registrationNumber, addProfInfo);

			info = new ProfessionInfo(auth, professionItems, professionOids, null, addProfInfo);

			checkConstruction(info, auth, professionItems, professionOids, null, addProfInfo);

			info = new ProfessionInfo(auth, professionItems, professionOids, registrationNumber, null);

			checkConstruction(info, auth, professionItems, professionOids, registrationNumber, null);

			info = ProfessionInfo.GetInstance(null);

			if (info != null)
			{
				Fail("null GetInstance() failed.");
			}

			try
			{
				ProcurationSyntax.GetInstance(new Object());

				Fail("GetInstance() failed to detect bad object.");
			}
			catch (ArgumentException)
			{
				// expected
			}
		}
Example #11
0
		/**
		* Constructor from Asn1Sequence.
		* <p/>
		* The sequence is of type ProcurationSyntax:
		* <p/>
		* <pre>
		*            Admissions ::= SEQUENCE
		*            {
		*              admissionAuthority [0] EXPLICIT GeneralName OPTIONAL
		*              namingAuthority [1] EXPLICIT NamingAuthority OPTIONAL
		*              professionInfos SEQUENCE OF ProfessionInfo
		*            }
		* </pre>
		*
		* @param seq The ASN.1 sequence.
		*/
		private Admissions(
			Asn1Sequence seq)
		{
			if (seq.Count > 3)
				throw new ArgumentException("Bad sequence size: " + seq.Count);

			IEnumerator e = seq.GetEnumerator();

			e.MoveNext();
			Asn1Encodable o = (Asn1Encodable) e.Current;
			if (o is Asn1TaggedObject)
			{
				switch (((Asn1TaggedObject)o).TagNo)
				{
					case 0:
						admissionAuthority = GeneralName.GetInstance((Asn1TaggedObject)o, true);
						break;
					case 1:
						namingAuthority = NamingAuthority.GetInstance((Asn1TaggedObject)o, true);
						break;
					default:
						throw new ArgumentException("Bad tag number: " + ((Asn1TaggedObject)o).TagNo);
				}
				e.MoveNext();
				o = (Asn1Encodable) e.Current;
			}
			if (o is Asn1TaggedObject)
			{
				switch (((Asn1TaggedObject)o).TagNo)
				{
					case 1:
						namingAuthority = NamingAuthority.GetInstance((Asn1TaggedObject)o, true);
						break;
					default:
						throw new ArgumentException("Bad tag number: " + ((Asn1TaggedObject)o).TagNo);
				}
				e.MoveNext();
				o = (Asn1Encodable) e.Current;
			}
			professionInfos = Asn1Sequence.GetInstance(o);
			if (e.MoveNext())
			{
                throw new ArgumentException("Bad object encountered: " + Platform.GetTypeName(e.Current));
			}
		}
Example #12
0
		private void checkConstruction(
			Admissions      admissions,
			GeneralName     name,
			NamingAuthority auth)
		{
			checkValues(admissions, name, auth);

			admissions = Admissions.GetInstance(admissions);

			checkValues(admissions, name, auth);

			Asn1InputStream aIn = new Asn1InputStream(admissions.ToAsn1Object().GetEncoded());

			Asn1Sequence info = (Asn1Sequence)aIn.ReadObject();

			admissions = Admissions.GetInstance(info);

			checkValues(admissions, name, auth);
		}
		private void checkConstruction(
			NamingAuthority		auth,
			DerObjectIdentifier	namingAuthorityID,
			string				namingAuthorityURL,
			DirectoryString		namingAuthorityText)
		{
			checkValues(auth, namingAuthorityID, namingAuthorityURL, namingAuthorityText);

			auth = NamingAuthority.GetInstance(auth);

			checkValues(auth, namingAuthorityID, namingAuthorityURL, namingAuthorityText);

			Asn1InputStream aIn = new Asn1InputStream(auth.ToAsn1Object().GetEncoded());

			Asn1Sequence seq = (Asn1Sequence) aIn.ReadObject();

			auth = NamingAuthority.GetInstance(seq);

			checkValues(auth, namingAuthorityID, namingAuthorityURL, namingAuthorityText);
		}
		public override void PerformTest()
		{
			DerObjectIdentifier namingAuthorityID = new DerObjectIdentifier("1.2.3");
			string namingAuthorityURL = "url";
			DirectoryString namingAuthorityText = new DirectoryString("text");

			NamingAuthority auth =  new NamingAuthority(namingAuthorityID, namingAuthorityURL, namingAuthorityText);

			checkConstruction(auth, namingAuthorityID, namingAuthorityURL, namingAuthorityText);

			auth =  new NamingAuthority(null, namingAuthorityURL, namingAuthorityText);

			checkConstruction(auth, null, namingAuthorityURL, namingAuthorityText);

			auth =  new NamingAuthority(namingAuthorityID, null, namingAuthorityText);

			checkConstruction(auth, namingAuthorityID, null, namingAuthorityText);

			auth =  new NamingAuthority(namingAuthorityID, namingAuthorityURL, null);

			checkConstruction(auth, namingAuthorityID, namingAuthorityURL, null);

			auth = NamingAuthority.GetInstance(null);

			if (auth != null)
			{
				Fail("null GetInstance() failed.");
			}

			try
			{
				NamingAuthority.GetInstance(new Object());

				Fail("GetInstance() failed to detect bad object.");
			}
			catch (ArgumentException)
			{
				// expected
			}
		}
		private void checkConstruction(
			ProfessionInfo			profInfo,
			NamingAuthority			auth,
			DirectoryString[]		professionItems,
			DerObjectIdentifier[]	professionOids,
			string					registrationNumber,
			DerOctetString			addProfInfo)
		{
			checkValues(profInfo, auth, professionItems, professionOids, registrationNumber, addProfInfo);

			profInfo = ProfessionInfo.GetInstance(profInfo);

			checkValues(profInfo, auth, professionItems, professionOids, registrationNumber, addProfInfo);

			Asn1InputStream aIn = new Asn1InputStream(profInfo.ToAsn1Object().GetEncoded());

			Asn1Sequence seq = (Asn1Sequence) aIn.ReadObject();

			profInfo = ProfessionInfo.GetInstance(seq);

			checkValues(profInfo, auth, professionItems, professionOids, registrationNumber, addProfInfo);
		}
Example #16
0
        private ProfessionInfo(Asn1Sequence seq)
        {
            //IL_0024: Unknown result type (might be due to invalid IL or missing references)
            //IL_0070: Unknown result type (might be due to invalid IL or missing references)
            //IL_010d: Unknown result type (might be due to invalid IL or missing references)
            //IL_0168: Unknown result type (might be due to invalid IL or missing references)
            //IL_01a7: Unknown result type (might be due to invalid IL or missing references)
            if (seq.Count > 5)
            {
                throw new ArgumentException(string.Concat((object)"Bad sequence size: ", (object)seq.Count));
            }
            global::System.Collections.IEnumerator enumerator = seq.GetEnumerator();
            enumerator.MoveNext();
            Asn1Encodable asn1Encodable = (Asn1Encodable)enumerator.get_Current();

            if (asn1Encodable is Asn1TaggedObject)
            {
                Asn1TaggedObject asn1TaggedObject = (Asn1TaggedObject)asn1Encodable;
                if (asn1TaggedObject.TagNo != 0)
                {
                    throw new ArgumentException(string.Concat((object)"Bad tag number: ", (object)asn1TaggedObject.TagNo));
                }
                namingAuthority = NamingAuthority.GetInstance(asn1TaggedObject, isExplicit: true);
                enumerator.MoveNext();
                asn1Encodable = (Asn1Encodable)enumerator.get_Current();
            }
            professionItems = Asn1Sequence.GetInstance(asn1Encodable);
            if (enumerator.MoveNext())
            {
                asn1Encodable = (Asn1Encodable)enumerator.get_Current();
                if (asn1Encodable is Asn1Sequence)
                {
                    professionOids = Asn1Sequence.GetInstance(asn1Encodable);
                }
                else if (asn1Encodable is DerPrintableString)
                {
                    registrationNumber = DerPrintableString.GetInstance(asn1Encodable).GetString();
                }
                else
                {
                    if (!(asn1Encodable is Asn1OctetString))
                    {
                        throw new ArgumentException("Bad object encountered: " + Platform.GetTypeName(asn1Encodable));
                    }
                    addProfessionInfo = Asn1OctetString.GetInstance(asn1Encodable);
                }
            }
            if (enumerator.MoveNext())
            {
                asn1Encodable = (Asn1Encodable)enumerator.get_Current();
                if (asn1Encodable is DerPrintableString)
                {
                    registrationNumber = DerPrintableString.GetInstance(asn1Encodable).GetString();
                }
                else
                {
                    if (!(asn1Encodable is DerOctetString))
                    {
                        throw new ArgumentException("Bad object encountered: " + Platform.GetTypeName(asn1Encodable));
                    }
                    addProfessionInfo = (DerOctetString)asn1Encodable;
                }
            }
            if (enumerator.MoveNext())
            {
                asn1Encodable = (Asn1Encodable)enumerator.get_Current();
                if (!(asn1Encodable is DerOctetString))
                {
                    throw new ArgumentException("Bad object encountered: " + Platform.GetTypeName(asn1Encodable));
                }
                addProfessionInfo = (DerOctetString)asn1Encodable;
            }
        }
Example #17
0
        private ProfessionInfo(Asn1Sequence seq)
        {
            if (seq.Count > 5)
            {
                throw new ArgumentException("Bad sequence size: " + seq.Count);
            }
            IEnumerator enumerator = seq.GetEnumerator();

            enumerator.MoveNext();
            Asn1Encodable asn1Encodable = (Asn1Encodable)enumerator.Current;

            if (asn1Encodable is Asn1TaggedObject)
            {
                Asn1TaggedObject asn1TaggedObject = (Asn1TaggedObject)asn1Encodable;
                if (asn1TaggedObject.TagNo != 0)
                {
                    throw new ArgumentException("Bad tag number: " + asn1TaggedObject.TagNo);
                }
                this.namingAuthority = NamingAuthority.GetInstance(asn1TaggedObject, true);
                enumerator.MoveNext();
                asn1Encodable = (Asn1Encodable)enumerator.Current;
            }
            this.professionItems = Asn1Sequence.GetInstance(asn1Encodable);
            if (enumerator.MoveNext())
            {
                asn1Encodable = (Asn1Encodable)enumerator.Current;
                if (asn1Encodable is Asn1Sequence)
                {
                    this.professionOids = Asn1Sequence.GetInstance(asn1Encodable);
                }
                else if (asn1Encodable is DerPrintableString)
                {
                    this.registrationNumber = DerPrintableString.GetInstance(asn1Encodable).GetString();
                }
                else
                {
                    if (!(asn1Encodable is Asn1OctetString))
                    {
                        throw new ArgumentException("Bad object encountered: " + asn1Encodable.GetType().Name);
                    }
                    this.addProfessionInfo = Asn1OctetString.GetInstance(asn1Encodable);
                }
            }
            if (enumerator.MoveNext())
            {
                asn1Encodable = (Asn1Encodable)enumerator.Current;
                if (asn1Encodable is DerPrintableString)
                {
                    this.registrationNumber = DerPrintableString.GetInstance(asn1Encodable).GetString();
                }
                else
                {
                    if (!(asn1Encodable is DerOctetString))
                    {
                        throw new ArgumentException("Bad object encountered: " + asn1Encodable.GetType().Name);
                    }
                    this.addProfessionInfo = (DerOctetString)asn1Encodable;
                }
            }
            if (!enumerator.MoveNext())
            {
                return;
            }
            asn1Encodable = (Asn1Encodable)enumerator.Current;
            if (asn1Encodable is DerOctetString)
            {
                this.addProfessionInfo = (DerOctetString)asn1Encodable;
                return;
            }
            throw new ArgumentException("Bad object encountered: " + asn1Encodable.GetType().Name);
        }
		private void checkValues(
			ProfessionInfo			profInfo,
			NamingAuthority			auth,
			DirectoryString[]		professionItems,
			DerObjectIdentifier[]	professionOids,
			string					registrationNumber,
			DerOctetString			addProfInfo)
		{
			checkOptionalField("auth", auth, profInfo.NamingAuthority);
			checkMandatoryField("professionItems", professionItems[0], profInfo.GetProfessionItems()[0]);
			if (professionOids != null)
			{
				checkOptionalField("professionOids", professionOids[0], profInfo.GetProfessionOids()[0]);
			}
			checkOptionalField("registrationNumber", registrationNumber, profInfo.RegistrationNumber);
			checkOptionalField("addProfessionInfo", addProfInfo, profInfo.AddProfessionInfo);
		}
Example #19
0
 public static NamingAuthority GetInstance(Asn1TaggedObject obj, bool isExplicit)
 {
     return(NamingAuthority.GetInstance(Asn1Sequence.GetInstance(obj, isExplicit)));
 }
Example #20
0
        /**
        * Constructor from given details.
        * <p/>
        * <code>professionItems</code> is mandatory, all other parameters are
        * optional.
        *
        * @param namingAuthority    The naming authority.
        * @param professionItems    Directory strings of the profession.
        * @param professionOids     DERObjectIdentfier objects for the
        *                           profession.
        * @param registrationNumber Registration number.
        * @param addProfessionInfo  Additional infos in encoded form.
        */
        public ProfessionInfo(
			NamingAuthority			namingAuthority,
			DirectoryString[]		professionItems,
			DerObjectIdentifier[]	professionOids,
			string					registrationNumber,
			Asn1OctetString			addProfessionInfo)
        {
            this.namingAuthority = namingAuthority;
            this.professionItems = new DerSequence(professionItems);
            this.professionOids = new DerSequence(professionOids);
            this.registrationNumber = new DerPrintableString(registrationNumber, true);
            this.addProfessionInfo = addProfessionInfo;
        }
Example #21
0
        /**
         * Constructor from Asn1Sequence.
         * <p/>
         * <p/>
         * <pre>
         *               ProfessionInfo ::= SEQUENCE
         *               {
         *                 namingAuthority [0] EXPLICIT NamingAuthority OPTIONAL,
         *                 professionItems SEQUENCE OF DirectoryString (SIZE(1..128)),
         *                 professionOids SEQUENCE OF OBJECT IDENTIFIER OPTIONAL,
         *                 registrationNumber PrintableString(SIZE(1..128)) OPTIONAL,
         *                 addProfessionInfo OCTET STRING OPTIONAL
         *               }
         * </pre>
         *
         * @param seq The ASN.1 sequence.
         */
        private ProfessionInfo(
            Asn1Sequence seq)
        {
            if (seq.Count > 5)
            {
                throw new ArgumentException("Bad sequence size: " + seq.Count);
            }

            IEnumerator e = seq.GetEnumerator();

            e.MoveNext();
            Asn1Encodable o = (Asn1Encodable)e.Current;

            if (o is Asn1TaggedObject)
            {
                Asn1TaggedObject ato = (Asn1TaggedObject)o;
                if (ato.TagNo != 0)
                {
                    throw new ArgumentException("Bad tag number: " + ato.TagNo);
                }

                namingAuthority = NamingAuthority.GetInstance(ato, true);
                e.MoveNext();
                o = (Asn1Encodable)e.Current;
            }

            professionItems = Asn1Sequence.GetInstance(o);

            if (e.MoveNext())
            {
                o = (Asn1Encodable)e.Current;
                if (o is Asn1Sequence)
                {
                    professionOids = Asn1Sequence.GetInstance(o);
                }
                else if (o is DerPrintableString)
                {
                    registrationNumber = DerPrintableString.GetInstance(o).GetString();
                }
                else if (o is Asn1OctetString)
                {
                    addProfessionInfo = Asn1OctetString.GetInstance(o);
                }
                else
                {
                    throw new ArgumentException("Bad object encountered: " + Platform.GetTypeName(o));
                }
            }

            if (e.MoveNext())
            {
                o = (Asn1Encodable)e.Current;
                if (o is DerPrintableString)
                {
                    registrationNumber = DerPrintableString.GetInstance(o).GetString();
                }
                else if (o is DerOctetString)
                {
                    addProfessionInfo = (DerOctetString)o;
                }
                else
                {
                    throw new ArgumentException("Bad object encountered: " + Platform.GetTypeName(o));
                }
            }

            if (e.MoveNext())
            {
                o = (Asn1Encodable)e.Current;
                if (o is DerOctetString)
                {
                    addProfessionInfo = (DerOctetString)o;
                }
                else
                {
                    throw new ArgumentException("Bad object encountered: " + Platform.GetTypeName(o));
                }
            }
        }
Example #22
0
        /**
        * Constructor from Asn1Sequence.
        * <p/>
        * <p/>
        * <pre>
        *               ProfessionInfo ::= SEQUENCE
        *               {
        *                 namingAuthority [0] EXPLICIT NamingAuthority OPTIONAL,
        *                 professionItems SEQUENCE OF DirectoryString (SIZE(1..128)),
        *                 professionOids SEQUENCE OF OBJECT IDENTIFIER OPTIONAL,
        *                 registrationNumber PrintableString(SIZE(1..128)) OPTIONAL,
        *                 addProfessionInfo OCTET STRING OPTIONAL
        *               }
        * </pre>
        *
        * @param seq The ASN.1 sequence.
        */
        private ProfessionInfo(
			Asn1Sequence seq)
        {
            if (seq.Count > 5)
                throw new ArgumentException("Bad sequence size: " + seq.Count);

            IEnumerator e = seq.GetEnumerator();

            e.MoveNext();
            Asn1Encodable o = (Asn1Encodable) e.Current;

            if (o is Asn1TaggedObject)
            {
                Asn1TaggedObject ato = (Asn1TaggedObject) o;
                if (ato.TagNo != 0)
                    throw new ArgumentException("Bad tag number: " + ato.TagNo);

                namingAuthority = NamingAuthority.GetInstance(ato, true);
                e.MoveNext();
                o = (Asn1Encodable) e.Current;
            }

            professionItems = Asn1Sequence.GetInstance(o);

            if (e.MoveNext())
            {
                o = (Asn1Encodable) e.Current;
                if (o is Asn1Sequence)
                {
                    professionOids = Asn1Sequence.GetInstance(o);
                }
                else if (o is DerPrintableString)
                {
                    registrationNumber = DerPrintableString.GetInstance(o);
                }
                else if (o is Asn1OctetString)
                {
                    addProfessionInfo = Asn1OctetString.GetInstance(o);
                }
                else
                {
                    throw new ArgumentException("Bad object encountered: " + o.GetType().Name);
                }
            }

            if (e.MoveNext())
            {
                o = (Asn1Encodable) e.Current;
                if (o is DerPrintableString)
                {
                    registrationNumber = DerPrintableString.GetInstance(o);
                }
                else if (o is DerOctetString)
                {
                    addProfessionInfo = (DerOctetString) o;
                }
                else
                {
                    throw new ArgumentException("Bad object encountered: " + o.GetType().Name);
                }
            }

            if (e.MoveNext())
            {
                o = (Asn1Encodable) e.Current;
                if (o is DerOctetString)
                {
                    addProfessionInfo = (DerOctetString) o;
                }
                else
                {
                    throw new ArgumentException("Bad object encountered: " + o.GetType().Name);
                }
            }
        }