예제 #1
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);
 }
예제 #2
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));
            }
        }
예제 #3
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);
     if (professionOids != null)
     {
         this.professionOids = new DerSequence(professionOids);
     }
     this.registrationNumber = registrationNumber;
     this.addProfessionInfo  = addProfessionInfo;
 }
예제 #4
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));
                }
            }
        }