예제 #1
0
        static public ASN1 FromString(string rdn)
        {
            if (rdn == null)
            {
                throw new ArgumentNullException("rdn");
            }

            int  pos  = 0;
            ASN1 asn1 = new ASN1(0x30);

            while (pos < rdn.Length)
            {
                X520.AttributeTypeAndValue atv = ReadAttribute(rdn, ref pos);
                atv.Value = ReadValue(rdn, ref pos);

                ASN1 sequence = new ASN1(0x31);
                sequence.Add(atv.GetASN1());
                asn1.Add(sequence);
            }
            return(asn1);
        }
예제 #2
0
        private static X520.AttributeTypeAndValue ReadAttribute(string value, ref int pos)
        {
            while ((value[pos] == ' ') && (pos < value.Length))
            {
                pos++;
            }
            int index = value.IndexOf('=', pos);

            if (index == -1)
            {
                throw new FormatException(Locale.GetText("No attribute found."));
            }
            string attributeType = value.Substring(pos, index - pos);

            X520.AttributeTypeAndValue attributeFromOid = GetAttributeFromOid(attributeType);
            if (attributeFromOid == null)
            {
                throw new FormatException(string.Format(Locale.GetText("Unknown attribute '{0}'."), attributeType));
            }
            pos = index + 1;
            return(attributeFromOid);
        }
예제 #3
0
        private static X520.AttributeTypeAndValue ReadAttribute(string value, ref int pos)
        {
            while (value[pos] == ' ' && pos < value.Length)
            {
                pos++;
            }
            int num = value.IndexOf('=', pos);

            if (num == -1)
            {
                string text = Locale.GetText("No attribute found.");
                throw new FormatException(text);
            }
            string text2 = value.Substring(pos, num - pos);

            X520.AttributeTypeAndValue attributeFromOid = X501.GetAttributeFromOid(text2);
            if (attributeFromOid == null)
            {
                string text3 = Locale.GetText("Unknown attribute '{0}'.");
                throw new FormatException(string.Format(text3, text2));
            }
            pos = num + 1;
            return(attributeFromOid);
        }