Ejemplo n.º 1
0
        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
            }
        }
Ejemplo n.º 2
0
        public override void PerformTest()
        {
            string          country            = "AU";
            DirectoryString typeOfSubstitution = new DirectoryString("substitution");
            GeneralName     thirdPerson        = new GeneralName(new X509Name("CN=thirdPerson"));
            IssuerSerial    certRef            = new IssuerSerial(new GeneralNames(new GeneralName(new X509Name("CN=test"))), new DerInteger(1));

            ProcurationSyntax procuration = new ProcurationSyntax(country, typeOfSubstitution, thirdPerson);

            checkConstruction(procuration, country, typeOfSubstitution, thirdPerson, null);

            procuration = new ProcurationSyntax(country, typeOfSubstitution, certRef);

            checkConstruction(procuration, country, typeOfSubstitution, null, certRef);

            procuration = new ProcurationSyntax(null, typeOfSubstitution, certRef);

            checkConstruction(procuration, null, typeOfSubstitution, null, certRef);

            procuration = new ProcurationSyntax(country, null, certRef);

            checkConstruction(procuration, country, null, null, certRef);

            procuration = ProcurationSyntax.GetInstance(null);

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

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

                Fail("GetInstance() failed to detect bad object.");
            }
            catch (ArgumentException)
            {
                // expected
            }
        }
Ejemplo n.º 3
0
        private void checkConstruction(
            ProcurationSyntax procuration,
            string country,
            DirectoryString typeOfSubstitution,
            GeneralName thirdPerson,
            IssuerSerial certRef)
        {
            checkValues(procuration, country, typeOfSubstitution, thirdPerson, certRef);

            procuration = ProcurationSyntax.GetInstance(procuration);

            checkValues(procuration, country, typeOfSubstitution, thirdPerson, certRef);

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

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

            procuration = ProcurationSyntax.GetInstance(seq);

            checkValues(procuration, country, typeOfSubstitution, thirdPerson, certRef);
        }