Exemple #1
0
        // parse backwards
        public override Rdn[] FromString(string dirName)
        {
            Rdn[] tmp = IetfUtils.rDNsFromString(dirName, this);
            Rdn[] res = new Rdn[tmp.Length];

            for (int i = 0; i != tmp.Length; i++)
            {
                res[res.Length - i - 1] = tmp[i];
            }

            return(res);
        }
Exemple #2
0
        /**
         * For all string values starting with '#' is assumed, that these are
         * already valid ASN.1 objects encoded in hex.
         * <p>
         * All other string values are send to
         * {@link AbstractX500NameStyle#encodeStringValue(ASN1ObjectIdentifier, String)}.
         * </p>
         * Subclasses should overwrite
         * {@link AbstractX500NameStyle#encodeStringValue(ASN1ObjectIdentifier, String)}
         * to change the encoding of specific types.
         *
         * @param oid the DN name of the value.
         * @param value the String representation of the value.
         */
        public Asn1Encodable StringToValue(DerObjectIdentifier oid, string value)
        {
            if (value.Length != 0 && value[0] == '#')
            {
                try
                {
                    return(IetfUtils.ValueFromHexString(value, 1));
                }
                catch (IOException)
                {
                    throw new Asn1ParsingException("can't recode value for oid " + oid.Id);
                }
            }

            if (value.Length != 0 && value[0] == '\\')
            {
                value = value.Substring(1);
            }

            return(EncodeStringValue(oid, value));
        }
Exemple #3
0
        public override string ToString(X500Name name)
        {
            StringBuilder buf   = new StringBuilder();
            bool          first = true;

            Rdn[] rdns = name.GetRdns();

            for (int i = 0; i < rdns.Length; i++)
            {
                if (first)
                {
                    first = false;
                }
                else
                {
                    buf.Append(',');
                }

                IetfUtils.AppendRdn(buf, rdns[i], mDefaultSymbols);
            }

            return(buf.ToString());
        }
Exemple #4
0
 public override Rdn[] FromString(string dirName)
 {
     return(IetfUtils.rDNsFromString(dirName, this));
 }
Exemple #5
0
 public override DerObjectIdentifier AttrNameToOID(string attrName)
 {
     return(IetfUtils.DecodeAttrName(attrName, mDefaultLookUp));
 }
Exemple #6
0
 public override string[] OidToAttrNames(DerObjectIdentifier oid)
 {
     return(IetfUtils.FindAttrNamesForOID(oid, mDefaultLookUp));
 }
Exemple #7
0
 protected bool RdnAreEqual(Rdn rdn1, Rdn rdn2)
 {
     return(IetfUtils.RdnAreEqual(rdn1, rdn2));
 }