Пример #1
0
        /**
         * return an array of OIDs contained in the attribute type of each RDN in structure order.
         *
         * @return an array, possibly zero length, of DerObjectIdentifiers objects.
         */
        public DerObjectIdentifier[] GetAttributeTypes()
        {
            int count = 0;

            for (int i = 0; i != rdns.Length; i++)
            {
                Rdn rdn = rdns[i];

                count += rdn.Count;
            }

            DerObjectIdentifier[] res = new DerObjectIdentifier[count];

            count = 0;

            for (int i = 0; i != rdns.Length; i++)
            {
                Rdn rdn = rdns[i];

                if (rdn.IsMultiValued)
                {
                    AttributeTypeAndValue[] attr = rdn.GetTypesAndValues();
                    for (int j = 0; j != attr.Length; j++)
                    {
                        res[count++] = attr[j].Type;
                    }
                }
                else if (rdn.Count != 0)
                {
                    res[count++] = rdn.First.Type;
                }
            }

            return(res);
        }
Пример #2
0
        /**
         * return an array of RDNs in structure order.
         *
         * @return an array of RDN objects.
         */
        public Rdn[] GetRdns()
        {
            Rdn[] tmp = new Rdn[this.rdns.Length];

            Array.Copy(rdns, 0, tmp, 0, tmp.Length);

            return(tmp);
        }
Пример #3
0
        /// <summary>
        /// Build an X.500 name for the current builder state.
        /// </summary>
        /// <returns>A new X.500 name.</returns>
        public X500Name Build()
        {
            Rdn[] vals = new Rdn[rdns.Count];

            for (int i = 0; i != vals.Length; i++)
            {
                vals[i] = (Rdn)rdns[i];
            }

            return(new X500Name(template, vals));
        }
Пример #4
0
        private X500Name(
            IX500NameStyle style,
            Asn1Sequence seq)
        {
            this.style = style;
            this.rdns  = new Rdn[seq.Count];

            int index = 0;

            for (IEnumerator e = seq.GetEnumerator(); e.MoveNext();)
            {
                rdns[index++] = Rdn.GetInstance(e.Current);
            }
        }
Пример #5
0
        /**
         * return an array of RDNs containing the attribute type given by OID in structure order.
         *
         * @param attributeType the type OID we are looking for.
         * @return an array, possibly zero length, of RDN objects.
         */
        public Rdn[] GetRdns(DerObjectIdentifier attributeType)
        {
            Rdn[] res   = new Rdn[rdns.Length];
            int   count = 0;

            for (int i = 0; i != rdns.Length; i++)
            {
                Rdn rdn = rdns[i];

                if (rdn.IsMultiValued)
                {
                    AttributeTypeAndValue[] attr = rdn.GetTypesAndValues();
                    for (int j = 0; j != attr.Length; j++)
                    {
                        if (attr[j].Type.Equals(attributeType))
                        {
                            res[count++] = rdn;
                            break;
                        }
                    }
                }
                else
                {
                    if (rdn.First.Type.Equals(attributeType))
                    {
                        res[count++] = rdn;
                    }
                }
            }

            Rdn[] tmp = new Rdn[count];

            Array.Copy(res, 0, tmp, 0, tmp.Length);

            return(tmp);
        }