/** * 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; var 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) { var vTok = new X509NameTokenizer(value, '+'); string v = vTok.NextToken(); ordering.Add(oid); values.Add(v); 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); ordering.Add(DecodeOid(nm, lookUp)); values.Add(vl); added.Add(true); } } else { ordering.Add(oid); values.Add(value); 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 < ordering.Count; i++) { if (!((bool)added[i])) { count = 0; } int index = count++; o.Insert(index, ordering[i]); v.Insert(index, values[i]); a.Insert(index, added[i]); } ordering = o; values = v; added = a; } }
/** * 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; var 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) { var vTok = new X509NameTokenizer(value, '+'); string v = vTok.NextToken(); ordering.Add(oid); values.Add(v); 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); ordering.Add(DecodeOid(nm, lookUp)); values.Add(vl); added.Add(true); } } else { ordering.Add(oid); values.Add(value); 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 < ordering.Count; i++) { if (!((bool) added[i])) { count = 0; } int index = count++; o.Insert(index, ordering[i]); v.Insert(index, values[i]); a.Insert(index, added[i]); } ordering = o; values = v; added = a; } }