private void checkConstruction(
            NameOrPseudonym id,
            string pseudonym,
            DirectoryString surname,
            Asn1Sequence givenName)
        {
            checkValues(id, pseudonym, surname, givenName);

            id = NameOrPseudonym.GetInstance(id);

            checkValues(id, pseudonym, surname, givenName);

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

            if (surname != null)
            {
                Asn1Sequence seq = (Asn1Sequence)aIn.ReadObject();

                id = NameOrPseudonym.GetInstance(seq);
            }
            else
            {
                IAsn1String s = (IAsn1String)aIn.ReadObject();

                id = NameOrPseudonym.GetInstance(s);
            }

            checkValues(id, pseudonym, surname, givenName);
        }
 public ProcurationSyntax(string country, DirectoryString typeOfSubstitution, IssuerSerial certRef)
 {
     this.country            = country;
     this.typeOfSubstitution = typeOfSubstitution;
     thirdPerson             = null;
     this.certRef            = certRef;
 }
        public override void PerformTest()
        {
            string          pseudonym = "pseudonym";
            DirectoryString surname   = new DirectoryString("surname");
            Asn1Sequence    givenName = new DerSequence(new DirectoryString("givenName"));

            NameOrPseudonym id = new NameOrPseudonym(pseudonym);

            checkConstruction(id, pseudonym, null, null);

            id = new NameOrPseudonym(surname, givenName);

            checkConstruction(id, null, surname, givenName);

            id = NameOrPseudonym.GetInstance(null);

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

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

                Fail("GetInstance() failed to detect bad object.");
            }
            catch (ArgumentException)
            {
                // expected
            }
        }
Example #4
0
        public SignerLocation(
            Asn1Sequence seq)
        {
            foreach (Asn1TaggedObject obj in seq)
            {
                switch (obj.TagNo)
                {
                case 0:
                    this.countryName = DirectoryString.GetInstance(obj, true);
                    break;

                case 1:
                    this.localityName = DirectoryString.GetInstance(obj, true);
                    break;

                case 2:
                    bool isExplicit = obj.IsExplicit();                                 // handle erroneous implicitly tagged sequences
                    this.postalAddress = Asn1Sequence.GetInstance(obj, isExplicit);
                    if (postalAddress != null && postalAddress.Count > 6)
                    {
                        throw new ArgumentException("postal address must contain less than 6 strings");
                    }
                    break;

                default:
                    throw new ArgumentException("illegal tag");
                }
            }
        }
 public ProcurationSyntax(string country, DirectoryString typeOfSubstitution, GeneralName thirdPerson)
 {
     this.country            = country;
     this.typeOfSubstitution = typeOfSubstitution;
     this.thirdPerson        = thirdPerson;
     certRef = null;
 }
Example #6
0
 public SignerLocation(
     DirectoryString countryName,
     DirectoryString localityName,
     DirectoryString[] postalAddress)
     : this(countryName, localityName, new DerSequence(postalAddress))
 {
 }
Example #7
0
 /**
  * Constructor from a given details.
  *
  * @param surname   The surname.
  * @param givenName A sequence of directory strings making up the givenName
  */
 public NameOrPseudonym(
     DirectoryString surname,
     Asn1Sequence givenName)
 {
     this.surname   = surname;
     this.givenName = givenName;
 }
Example #8
0
 public SignerLocation(
     DerUtf8String countryName,
     DerUtf8String localityName,
     Asn1Sequence postalAddress)
     : this(DirectoryString.GetInstance(countryName), DirectoryString.GetInstance(localityName), postalAddress)
 {
 }
Example #9
0
 private NamingAuthority(Asn1Sequence seq)
 {
     //IL_0024: Unknown result type (might be due to invalid IL or missing references)
     //IL_009c: Unknown result type (might be due to invalid IL or missing references)
     //IL_00f7: Unknown result type (might be due to invalid IL or missing references)
     //IL_0136: 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();
     if (enumerator.MoveNext())
     {
         Asn1Encodable asn1Encodable = (Asn1Encodable)enumerator.get_Current();
         if (asn1Encodable is DerObjectIdentifier)
         {
             namingAuthorityID = (DerObjectIdentifier)asn1Encodable;
         }
         else if (asn1Encodable is DerIA5String)
         {
             namingAuthorityUrl = DerIA5String.GetInstance(asn1Encodable).GetString();
         }
         else
         {
             if (!(asn1Encodable is IAsn1String))
             {
                 throw new ArgumentException("Bad object encountered: " + Platform.GetTypeName(asn1Encodable));
             }
             namingAuthorityText = DirectoryString.GetInstance(asn1Encodable);
         }
     }
     if (enumerator.MoveNext())
     {
         Asn1Encodable asn1Encodable2 = (Asn1Encodable)enumerator.get_Current();
         if (asn1Encodable2 is DerIA5String)
         {
             namingAuthorityUrl = DerIA5String.GetInstance(asn1Encodable2).GetString();
         }
         else
         {
             if (!(asn1Encodable2 is IAsn1String))
             {
                 throw new ArgumentException("Bad object encountered: " + Platform.GetTypeName(asn1Encodable2));
             }
             namingAuthorityText = DirectoryString.GetInstance(asn1Encodable2);
         }
     }
     if (enumerator.MoveNext())
     {
         Asn1Encodable asn1Encodable3 = (Asn1Encodable)enumerator.get_Current();
         if (!(asn1Encodable3 is IAsn1String))
         {
             throw new ArgumentException("Bad object encountered: " + Platform.GetTypeName(asn1Encodable3));
         }
         namingAuthorityText = DirectoryString.GetInstance(asn1Encodable3);
     }
 }
Example #10
0
 /**
  * Constructor from given details.
  * <p/>
  * All parameters can be combined.
  *
  * @param namingAuthorityID   ObjectIdentifier for naming authority.
  * @param namingAuthorityUrl  URL for naming authority.
  * @param namingAuthorityText Textual representation of naming authority.
  */
 public NamingAuthority(
     DerObjectIdentifier namingAuthorityID,
     string namingAuthorityUrl,
     DirectoryString namingAuthorityText)
 {
     this.namingAuthorityID   = namingAuthorityID;
     this.namingAuthorityUrl  = namingAuthorityUrl;
     this.namingAuthorityText = namingAuthorityText;
 }
Example #11
0
 public PersonalData(NameOrPseudonym nameOrPseudonym, BigInteger nameDistinguisher, DerGeneralizedTime dateOfBirth, DirectoryString placeOfBirth, string gender, DirectoryString postalAddress)
 {
     this.nameOrPseudonym   = nameOrPseudonym;
     this.dateOfBirth       = dateOfBirth;
     this.gender            = gender;
     this.nameDistinguisher = nameDistinguisher;
     this.postalAddress     = postalAddress;
     this.placeOfBirth      = placeOfBirth;
 }
Example #12
0
 public virtual DirectoryString[] GetProfessionItems()
 {
     DirectoryString[] array = new DirectoryString[professionItems.Count];
     for (int i = 0; i < professionItems.Count; i++)
     {
         array[i] = DirectoryString.GetInstance(professionItems[i]);
     }
     return(array);
 }
Example #13
0
        private NamingAuthority(Asn1Sequence seq)
        {
            if (seq.Count > 3)
            {
                throw new ArgumentException("Bad sequence size: " + seq.Count);
            }
            IEnumerator enumerator = seq.GetEnumerator();

            if (enumerator.MoveNext())
            {
                Asn1Encodable asn1Encodable = (Asn1Encodable)enumerator.Current;
                if (asn1Encodable is DerObjectIdentifier)
                {
                    this.namingAuthorityID = (DerObjectIdentifier)asn1Encodable;
                }
                else if (asn1Encodable is DerIA5String)
                {
                    this.namingAuthorityUrl = DerIA5String.GetInstance(asn1Encodable).GetString();
                }
                else
                {
                    if (!(asn1Encodable is IAsn1String))
                    {
                        throw new ArgumentException("Bad object encountered: " + asn1Encodable.GetType().Name);
                    }
                    this.namingAuthorityText = DirectoryString.GetInstance(asn1Encodable);
                }
            }
            if (enumerator.MoveNext())
            {
                Asn1Encodable asn1Encodable2 = (Asn1Encodable)enumerator.Current;
                if (asn1Encodable2 is DerIA5String)
                {
                    this.namingAuthorityUrl = DerIA5String.GetInstance(asn1Encodable2).GetString();
                }
                else
                {
                    if (!(asn1Encodable2 is IAsn1String))
                    {
                        throw new ArgumentException("Bad object encountered: " + asn1Encodable2.GetType().Name);
                    }
                    this.namingAuthorityText = DirectoryString.GetInstance(asn1Encodable2);
                }
            }
            if (!enumerator.MoveNext())
            {
                return;
            }
            Asn1Encodable asn1Encodable3 = (Asn1Encodable)enumerator.Current;

            if (asn1Encodable3 is IAsn1String)
            {
                this.namingAuthorityText = DirectoryString.GetInstance(asn1Encodable3);
                return;
            }
            throw new ArgumentException("Bad object encountered: " + asn1Encodable3.GetType().Name);
        }
Example #14
0
 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 DirectoryString[] GetGivenName()
		{
			DirectoryString[] items = new DirectoryString[givenName.Count];
			int count = 0;
			foreach (object o in givenName)
			{
				items[count++] = DirectoryString.GetInstance(o);
			}
			return items;
		}
    public DirectoryString[] GetGivenName()
    {
        DirectoryString[] array = new DirectoryString[givenName.Count];
        int num = 0;

        foreach (object item in givenName)
        {
            array[num++] = DirectoryString.GetInstance(item);
        }
        return(array);
    }
Example #17
0
        public DirectoryString[] GetGivenName()
        {
            DirectoryString[] array = new DirectoryString[this.givenName.Count];
            int num = 0;

            foreach (object current in this.givenName)
            {
                array[num++] = DirectoryString.GetInstance(current);
            }
            return(array);
        }
Example #18
0
        /**
         * @return Returns the professionItems.
         */
        public virtual DirectoryString[] GetProfessionItems()
        {
            DirectoryString[] result = new DirectoryString[professionItems.Count];

            for (int i = 0; i < professionItems.Count; ++i)
            {
                result[i] = DirectoryString.GetInstance(professionItems[i]);
            }

            return(result);
        }
Example #19
0
 public static AdditionalInformationSyntax GetInstance(object obj)
 {
     if (obj is AdditionalInformationSyntax)
     {
         return((AdditionalInformationSyntax)obj);
     }
     if (obj is IAsn1String)
     {
         return(new AdditionalInformationSyntax(DirectoryString.GetInstance(obj)));
     }
     throw new ArgumentException("Unknown object in GetInstance: " + obj.GetType().Name, "obj");
 }
Example #20
0
 private void checkValues(
     ProcurationSyntax procuration,
     string country,
     DirectoryString typeOfSubstitution,
     GeneralName thirdPerson,
     IssuerSerial certRef)
 {
     checkOptionalField("country", country, procuration.Country);
     checkOptionalField("typeOfSubstitution", typeOfSubstitution, procuration.TypeOfSubstitution);
     checkOptionalField("thirdPerson", thirdPerson, procuration.ThirdPerson);
     checkOptionalField("certRef", certRef, procuration.CertRef);
 }
 public static Restriction GetInstance(object obj)
 {
     if (obj is Restriction)
     {
         return((Restriction)obj);
     }
     if (obj is IAsn1String)
     {
         return(new Restriction(DirectoryString.GetInstance(obj)));
     }
     throw new ArgumentException("Unknown object in GetInstance: " + Platform.GetTypeName(obj), "obj");
 }
		/**
		* Constructor from Asn1Sequence.
		* <p/>
		* The sequence is of type NameOrPseudonym:
		* <p/>
		* <pre>
		*       NameOrPseudonym ::= CHOICE {
		*     	   surAndGivenName SEQUENCE {
		*     	     surName DirectoryString,
		*     	     givenName SEQUENCE OF DirectoryString
		*         },
		*     	   pseudonym DirectoryString
		*       }
		* </pre>
		*
		* @param seq The ASN.1 sequence.
		*/
		private NameOrPseudonym(
			Asn1Sequence seq)
		{
			if (seq.Count != 2)
				throw new ArgumentException("Bad sequence size: " + seq.Count);

			if (!(seq[0] is IAsn1String))
				throw new ArgumentException("Bad object encountered: " + seq[0].GetType().Name);

			surname = DirectoryString.GetInstance(seq[0]);
			givenName = Asn1Sequence.GetInstance(seq[1]);
		}
Example #23
0
 public static AdditionalInformationSyntax GetInstance(object obj)
 {
     //IL_0038: Unknown result type (might be due to invalid IL or missing references)
     if (obj is AdditionalInformationSyntax)
     {
         return((AdditionalInformationSyntax)obj);
     }
     if (obj is IAsn1String)
     {
         return(new AdditionalInformationSyntax(DirectoryString.GetInstance(obj)));
     }
     throw new ArgumentException("Unknown object in GetInstance: " + Platform.GetTypeName(obj), "obj");
 }
        public override void PerformTest()
        {
            NameOrPseudonym    nameOrPseudonym   = new NameOrPseudonym("pseudonym");
            IBigInteger        nameDistinguisher = BigInteger.ValueOf(10);
            DerGeneralizedTime dateOfBirth       = new DerGeneralizedTime("20070315173729Z");
            DirectoryString    placeOfBirth      = new DirectoryString("placeOfBirth");
            string             gender            = "M";
            DirectoryString    postalAddress     = new DirectoryString("address");

            PersonalData data = new PersonalData(nameOrPseudonym, nameDistinguisher, dateOfBirth, placeOfBirth, gender, postalAddress);

            checkConstruction(data, nameOrPseudonym, nameDistinguisher, dateOfBirth, placeOfBirth, gender, postalAddress);

            data = new PersonalData(nameOrPseudonym, null, dateOfBirth, placeOfBirth, gender, postalAddress);

            checkConstruction(data, nameOrPseudonym, null, dateOfBirth, placeOfBirth, gender, postalAddress);

            data = new PersonalData(nameOrPseudonym, nameDistinguisher, null, placeOfBirth, gender, postalAddress);

            checkConstruction(data, nameOrPseudonym, nameDistinguisher, null, placeOfBirth, gender, postalAddress);

            data = new PersonalData(nameOrPseudonym, nameDistinguisher, dateOfBirth, null, gender, postalAddress);

            checkConstruction(data, nameOrPseudonym, nameDistinguisher, dateOfBirth, null, gender, postalAddress);

            data = new PersonalData(nameOrPseudonym, nameDistinguisher, dateOfBirth, placeOfBirth, null, postalAddress);

            checkConstruction(data, nameOrPseudonym, nameDistinguisher, dateOfBirth, placeOfBirth, null, postalAddress);

            data = new PersonalData(nameOrPseudonym, nameDistinguisher, dateOfBirth, placeOfBirth, gender, null);

            checkConstruction(data, nameOrPseudonym, nameDistinguisher, dateOfBirth, placeOfBirth, gender, null);

            data = PersonalData.GetInstance(null);

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

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

                Fail("GetInstance() failed to detect bad object.");
            }
            catch (ArgumentException)
            {
                // expected
            }
        }
Example #25
0
        private SignerLocation(
            DirectoryString countryName,
            DirectoryString localityName,
            Asn1Sequence postalAddress)
        {
            if (postalAddress != null && postalAddress.Count > 6)
            {
                throw new ArgumentException("postal address must contain less than 6 strings");
            }

            this.countryName   = countryName;
            this.localityName  = localityName;
            this.postalAddress = postalAddress;
        }
Example #26
0
        public DirectoryString[] GetPostal()
        {
            if (postalAddress == null)
            {
                return(null);
            }

            DirectoryString[] dirStrings = new DirectoryString[postalAddress.Count];
            for (int i = 0; i != dirStrings.Length; i++)
            {
                dirStrings[i] = DirectoryString.GetInstance(postalAddress[i]);
            }

            return(dirStrings);
        }
Example #27
0
 private NameOrPseudonym(Asn1Sequence seq)
 {
     //IL_0024: Unknown result type (might be due to invalid IL or missing references)
     //IL_004e: Unknown result type (might be due to invalid IL or missing references)
     if (seq.Count != 2)
     {
         throw new ArgumentException(string.Concat((object)"Bad sequence size: ", (object)seq.Count));
     }
     if (!(seq[0] is IAsn1String))
     {
         throw new ArgumentException("Bad object encountered: " + Platform.GetTypeName(seq[0]));
     }
     surname   = DirectoryString.GetInstance(seq[0]);
     givenName = Asn1Sequence.GetInstance(seq[1]);
 }
        public static Restriction GetInstance(
            object obj)
        {
            if (obj == null || obj is Restriction)
            {
                return (Restriction) obj;
            }

            if (obj is IAsn1String)
            {
                return new Restriction(DirectoryString.GetInstance(obj));
            }

            throw new ArgumentException("unknown object in factory: " + obj.GetType().Name, "obj");
        }
Example #29
0
        public static AdditionalInformationSyntax GetInstance(
            object obj)
        {
            if (obj is AdditionalInformationSyntax)
            {
                return((AdditionalInformationSyntax)obj);
            }

            if (obj is IAsn1String)
            {
                return(new AdditionalInformationSyntax(DirectoryString.GetInstance(obj)));
            }

            throw new ArgumentException("Unknown object in GetInstance: " + BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Platform.GetTypeName(obj), "obj");
        }
Example #30
0
 public static NameOrPseudonym GetInstance(object obj)
 {
     if (obj == null || obj is NameOrPseudonym)
     {
         return((NameOrPseudonym)obj);
     }
     if (obj is IAsn1String)
     {
         return(new NameOrPseudonym(DirectoryString.GetInstance(obj)));
     }
     if (obj is Asn1Sequence)
     {
         return(new NameOrPseudonym((Asn1Sequence)obj));
     }
     throw new ArgumentException("unknown object in factory: " + obj.GetType().Name, "obj");
 }
Example #31
0
 public virtual bool IsSubsetOf( DirectoryString operand )
 {
     return this.IsSubsetOf( operand, true );
 }
Example #32
0
 public virtual bool IsSubsetOf( DirectoryString operand, bool ignoreCase )
 {
     if (operand == null)
     {
         return false;
     }
     else if (operand.m_separatedSite.Count == 0)
     {
         return this.m_separatedSite.Count == 0 || this.m_separatedSite.Count > 0 && String.Compare( (String)this.m_separatedSite[0], "*", false, CultureInfo.InvariantCulture) == 0;
     }
     else if (this.m_separatedSite.Count == 0)
     {
         return String.Compare( (String)operand.m_separatedSite[0], "*", false, CultureInfo.InvariantCulture) == 0;
     }
     else
     {
         return base.IsSubsetOf( operand, ignoreCase );
     }
 }