예제 #1
0
        /**
         * Takes an X509 dir name as a string of the format "C=AU, ST=Victoria", or
         * some such, converting it into an ordered set of name attributes. lookUp
         * should provide a table of lookups, indexed by lowercase only strings and
         * yielding a DerObjectIdentifier, other than that OID. and numeric oids
         * will be processed automatically. The passed in converter is used to convert the
         * string values to the right of each equals sign to their ASN.1 counterparts.
         * <br/>
         * @param reverse true if we should start scanning from the end, false otherwise.
         * @param lookUp table of names and oids.
         * @param dirName the string dirName
         * @param converter the converter to convert string values into their ASN.1 equivalents
         */
        public X509Name(
            bool reverse,
            IDictionary lookUp,
            string dirName,
            X509NameEntryConverter converter)
        {
            this.converter = converter;
            X509NameTokenizer nTok = new X509NameTokenizer(dirName);

            while (nTok.HasMoreTokens())
            {
                string token = nTok.NextToken();
                int    index = token.IndexOf('=');

                if (index == -1)
                {
                    throw new ArgumentException("badly formated directory string");
                }

                string name             = token.Substring(0, index);
                string value            = token.Substring(index + 1);
                DerObjectIdentifier oid = DecodeOid(name, lookUp);

                if (value.IndexOf('+') > 0)
                {
                    X509NameTokenizer vTok = new X509NameTokenizer(value, '+');
                    string            v    = vTok.NextToken();

                    this.ordering.Add(oid);
                    this.values.Add(v);
                    this.added.Add(false);

                    while (vTok.HasMoreTokens())
                    {
                        string sv  = vTok.NextToken();
                        int    ndx = sv.IndexOf('=');

                        string nm = sv.Substring(0, ndx);
                        string vl = sv.Substring(ndx + 1);
                        this.ordering.Add(DecodeOid(nm, lookUp));
                        this.values.Add(vl);
                        this.added.Add(true);
                    }
                }
                else
                {
                    this.ordering.Add(oid);
                    this.values.Add(value);
                    this.added.Add(false);
                }
            }

            if (reverse)
            {
//				this.ordering.Reverse();
//				this.values.Reverse();
//				this.added.Reverse();
                IList o     = Platform.CreateArrayList();
                IList v     = Platform.CreateArrayList();
                IList a     = Platform.CreateArrayList();
                int   count = 1;

                for (int i = 0; i < this.ordering.Count; i++)
                {
                    if (!((bool)this.added[i]))
                    {
                        count = 0;
                    }

                    int index = count++;

                    o.Insert(index, this.ordering[i]);
                    v.Insert(index, this.values[i]);
                    a.Insert(index, this.added[i]);
                }

                this.ordering = o;
                this.values   = v;
                this.added    = a;
            }
        }
예제 #2
0
 /**
 * Constructs an X509 name
 * @param dirName a directory name
 */
 public X509Name(String dirName) {
     X509NameTokenizer   nTok = new X509NameTokenizer(dirName);
     
     while (nTok.HasMoreTokens()) {
         String  token = nTok.NextToken();
         int index = token.IndexOf('=');
         
         if (index == -1) {
             throw new ArgumentException("badly formated directory string");
         }
         
         String id = token.Substring(0, index).ToUpper(System.Globalization.CultureInfo.InvariantCulture);
         String value = token.Substring(index + 1);
         ArrayList vs = (ArrayList)values[id];
         if (vs == null) {
             vs = new ArrayList();
             values[id] = vs;
         }
         vs.Add(value);
     }
     
 }
예제 #3
0
 /**
 * Constructs an X509 name
 * @param dirName a directory name
 */
 public X509Name(String dirName) {
     X509NameTokenizer   nTok = new X509NameTokenizer(dirName);
     
     while (nTok.HasMoreTokens()) {
         String  token = nTok.NextToken();
         int index = token.IndexOf('=');
         
         if (index == -1) {
             throw new ArgumentException(MessageLocalization.GetComposedMessage("badly.formated.directory.string"));
         }
         
         String id = token.Substring(0, index).ToUpper(System.Globalization.CultureInfo.InvariantCulture);
         String value = token.Substring(index + 1);
         List<string> vs;
         if (!values.TryGetValue(id, out vs)) {
             vs = new List<string>();
             values[id] = vs;
         }
         vs.Add(value);
     }                
 }
예제 #4
0
        public X509Name(bool reverse, IDictionary lookUp, string dirName, X509NameEntryConverter converter)
        {
            this.converter = converter;
            X509NameTokenizer x509NameTokenizer = new X509NameTokenizer(dirName);

            while (x509NameTokenizer.HasMoreTokens())
            {
                string text = x509NameTokenizer.NextToken();
                int    num  = text.IndexOf('=');
                if (num == -1)
                {
                    throw new ArgumentException("badly formated directory string");
                }
                string name  = text.Substring(0, num);
                string text2 = text.Substring(num + 1);
                DerObjectIdentifier value = this.DecodeOid(name, lookUp);
                if (text2.IndexOf('+') > 0)
                {
                    X509NameTokenizer x509NameTokenizer2 = new X509NameTokenizer(text2, '+');
                    string            value2             = x509NameTokenizer2.NextToken();
                    this.ordering.Add(value);
                    this.values.Add(value2);
                    this.added.Add(false);
                    while (x509NameTokenizer2.HasMoreTokens())
                    {
                        string text3  = x509NameTokenizer2.NextToken();
                        int    num2   = text3.IndexOf('=');
                        string name2  = text3.Substring(0, num2);
                        string value3 = text3.Substring(num2 + 1);
                        this.ordering.Add(this.DecodeOid(name2, lookUp));
                        this.values.Add(value3);
                        this.added.Add(true);
                    }
                }
                else
                {
                    this.ordering.Add(value);
                    this.values.Add(text2);
                    this.added.Add(false);
                }
            }
            if (reverse)
            {
                IList list  = Platform.CreateArrayList();
                IList list2 = Platform.CreateArrayList();
                IList list3 = Platform.CreateArrayList();
                int   num3  = 1;
                for (int i = 0; i < this.ordering.Count; i++)
                {
                    if (!(bool)this.added[i])
                    {
                        num3 = 0;
                    }
                    int index = num3++;
                    list.Insert(index, this.ordering[i]);
                    list2.Insert(index, this.values[i]);
                    list3.Insert(index, this.added[i]);
                }
                this.ordering = list;
                this.values   = list2;
                this.added    = list3;
            }
        }
예제 #5
0
        public X509Name(bool reverse, IDictionary lookUp, string dirName, X509NameEntryConverter converter)
        {
            //IL_0054: Unknown result type (might be due to invalid IL or missing references)
            this.converter = converter;
            X509NameTokenizer x509NameTokenizer = new X509NameTokenizer(dirName);

            while (x509NameTokenizer.HasMoreTokens())
            {
                string text = x509NameTokenizer.NextToken();
                int    num  = text.IndexOf('=');
                if (num == -1)
                {
                    throw new ArgumentException("badly formated directory string");
                }
                string name  = text.Substring(0, num);
                string text2 = text.Substring(num + 1);
                DerObjectIdentifier derObjectIdentifier = DecodeOid(name, lookUp);
                if (text2.IndexOf('+') > 0)
                {
                    X509NameTokenizer x509NameTokenizer2 = new X509NameTokenizer(text2, '+');
                    string            text3 = x509NameTokenizer2.NextToken();
                    ordering.Add((object)derObjectIdentifier);
                    values.Add((object)text3);
                    added.Add((object)false);
                    while (x509NameTokenizer2.HasMoreTokens())
                    {
                        string text4 = x509NameTokenizer2.NextToken();
                        int    num2  = text4.IndexOf('=');
                        string name2 = text4.Substring(0, num2);
                        string text5 = text4.Substring(num2 + 1);
                        ordering.Add((object)DecodeOid(name2, lookUp));
                        values.Add((object)text5);
                        added.Add((object)true);
                    }
                }
                else
                {
                    ordering.Add((object)derObjectIdentifier);
                    values.Add((object)text2);
                    added.Add((object)false);
                }
            }
            if (!reverse)
            {
                return;
            }
            global::System.Collections.IList list  = Platform.CreateArrayList();
            global::System.Collections.IList list2 = Platform.CreateArrayList();
            global::System.Collections.IList list3 = Platform.CreateArrayList();
            int num3 = 1;

            for (int i = 0; i < ((global::System.Collections.ICollection)ordering).get_Count(); i++)
            {
                if (!(bool)added.get_Item(i))
                {
                    num3 = 0;
                }
                int num4 = num3++;
                list.Insert(num4, ordering.get_Item(i));
                list2.Insert(num4, values.get_Item(i));
                list3.Insert(num4, added.get_Item(i));
            }
            ordering = list;
            values   = list2;
            added    = list3;
        }
예제 #6
0
		/**
        * Takes an X509 dir name as a string of the format "C=AU, ST=Victoria", or
        * some such, converting it into an ordered set of name attributes. lookUp
        * should provide a table of lookups, indexed by lowercase only strings and
        * yielding a DerObjectIdentifier, other than that OID. and numeric oids
        * will be processed automatically. The passed in converter is used to convert the
        * string values to the right of each equals sign to their ASN.1 counterparts.
        * <br/>
        * @param reverse true if we should start scanning from the end, false otherwise.
        * @param lookUp table of names and oids.
        * @param dirName the string dirName
        * @param converter the converter to convert string values into their ASN.1 equivalents
        */
        public X509Name(
            bool					reverse,
            IDictionary				lookUp,
            string					dirName,
            X509NameEntryConverter	converter)
        {
            this.converter = converter;
            X509NameTokenizer nTok = new X509NameTokenizer(dirName);

			while (nTok.HasMoreTokens())
            {
                string token = nTok.NextToken();
                int index = token.IndexOf('=');

				if (index == -1)
                {
                    throw new ArgumentException("badly formated directory string");
                }

				string name = token.Substring(0, index);
                string value = token.Substring(index + 1);
                DerObjectIdentifier	oid = DecodeOid(name, lookUp);

				if (value.IndexOf('+') > 0)
                {
                    X509NameTokenizer vTok = new X509NameTokenizer(value, '+');
					string v = vTok.NextToken();

					this.ordering.Add(oid);
                    this.values.Add(v);
                    this.added.Add(false);

					while (vTok.HasMoreTokens())
                    {
                        string sv = vTok.NextToken();
                        int ndx = sv.IndexOf('=');

                        string nm = sv.Substring(0, ndx);
                        string vl = sv.Substring(ndx + 1);
                        this.ordering.Add(DecodeOid(nm, lookUp));
                        this.values.Add(vl);
                        this.added.Add(true);
                    }
                }
                else
                {
                    this.ordering.Add(oid);
                    this.values.Add(value);
                    this.added.Add(false);
                }
            }

			if (reverse)
            {
//				this.ordering.Reverse();
//				this.values.Reverse();
//				this.added.Reverse();
				ArrayList o = new ArrayList();
				ArrayList v = new ArrayList();
				ArrayList a = new ArrayList();
				int count = 1;

				for (int i = 0; i < this.ordering.Count; i++)
				{
					if (!((bool) this.added[i]))
					{
						count = 0;
					}

					int index = count++;

					o.Insert(index, this.ordering[i]);
					v.Insert(index, this.values[i]);
					a.Insert(index, this.added[i]);
				}

				this.ordering = o;
				this.values = v;
				this.added = a;
			}
        }
예제 #7
0
        public X509Name(bool reverse, IDictionary lookUp, string dirName, X509NameEntryConverter converter)
        {
            this.ordering  = Platform.CreateArrayList();
            this.values    = Platform.CreateArrayList();
            this.added     = Platform.CreateArrayList();
            this.converter = converter;
            X509NameTokenizer tokenizer = new X509NameTokenizer(dirName);

            while (tokenizer.HasMoreTokens())
            {
                string str   = tokenizer.NextToken();
                int    index = str.IndexOf('=');
                if (index == -1)
                {
                    throw new ArgumentException("badly formated directory string");
                }
                string name = str.Substring(0, index);
                string oid  = str.Substring(index + 1);
                DerObjectIdentifier identifier = this.DecodeOid(name, lookUp);
                if (oid.IndexOf('+') > 0)
                {
                    X509NameTokenizer tokenizer2 = new X509NameTokenizer(oid, '+');
                    string            str4       = tokenizer2.NextToken();
                    this.ordering.Add(identifier);
                    this.values.Add(str4);
                    this.added.Add(false);
                    while (tokenizer2.HasMoreTokens())
                    {
                        string str5   = tokenizer2.NextToken();
                        int    length = str5.IndexOf('=');
                        string str6   = str5.Substring(0, length);
                        string str7   = str5.Substring(length + 1);
                        this.ordering.Add(this.DecodeOid(str6, lookUp));
                        this.values.Add(str7);
                        this.added.Add(true);
                    }
                }
                else
                {
                    this.ordering.Add(identifier);
                    this.values.Add(oid);
                    this.added.Add(false);
                }
            }
            if (reverse)
            {
                IList list  = Platform.CreateArrayList();
                IList list2 = Platform.CreateArrayList();
                IList list3 = Platform.CreateArrayList();
                int   num3  = 1;
                for (int i = 0; i < this.ordering.Count; i++)
                {
                    if (!((bool)this.added[i]))
                    {
                        num3 = 0;
                    }
                    int index = num3++;
                    list.Insert(index, this.ordering[i]);
                    list2.Insert(index, this.values[i]);
                    list3.Insert(index, this.added[i]);
                }
                this.ordering = list;
                this.values   = list2;
                this.added    = list3;
            }
        }