⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 x509name.java

📁 bouncycastle 是一个JAVA安全提供者
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
        }                for(int i = 0; i < _orderingSize; i++)         {            String  _oid   = ((DERObjectIdentifier)ordering.elementAt(i)).getId();            String  _val   = (String)values.elementAt(i);                        String _oOID = ((DERObjectIdentifier)_oxn.ordering.elementAt(i)).getId();            String _oVal = (String)_oxn.values.elementAt(i);            if (_oid.equals(_oOID))            {                _val = _val.trim().toLowerCase();                _oVal = _oVal.trim().toLowerCase();                if (_val.equals(_oVal))                {                    continue;                }                else                {                    StringBuffer    v1 = new StringBuffer();                    StringBuffer    v2 = new StringBuffer();                    if (_val.length() != 0)                    {                        char    c1 = _val.charAt(0);                        v1.append(c1);                        for (int k = 1; k < _val.length(); k++)                        {                            char    c2 = _val.charAt(k);                            if (!(c1 == ' ' && c2 == ' '))                            {                                v1.append(c2);                            }                            c1 = c2;                        }                    }                    if (_oVal.length() != 0)                    {                        char    c1 = _oVal.charAt(0);                        v2.append(c1);                        for (int k = 1; k < _oVal.length(); k++)                        {                            char    c2 = _oVal.charAt(k);                            if (!(c1 == ' ' && c2 == ' '))                            {                                v2.append(c2);                            }                            c1 = c2;                        }                    }                    if (!v1.toString().equals(v2.toString()))                    {                        return false;                    }                }            }            else            {                return false;            }        }        return true;    }    /**     * test for equality - note: case is ignored.     */    public boolean equals(Object _obj)     {        if (_obj == this)        {            return true;        }        if (_obj == null || !(_obj instanceof X509Name))        {            return false;        }                X509Name _oxn          = (X509Name)_obj;                if (this.getDERObject().equals(_oxn.getDERObject()))        {            return true;        }                int      _orderingSize = ordering.size();        if (_orderingSize != _oxn.ordering.size())         {            return false;        }                boolean[] _indexes = new boolean[_orderingSize];        for(int i = 0; i < _orderingSize; i++)         {            boolean _found = false;            String  _oid   = ((DERObjectIdentifier)ordering.elementAt(i)).getId();            String  _val   = (String)values.elementAt(i);                        for(int j = 0; j < _orderingSize; j++)             {                if (_indexes[j])                {                    continue;                }                                String _oOID = ((DERObjectIdentifier)_oxn.ordering.elementAt(j)).getId();                String _oVal = (String)_oxn.values.elementAt(j);                if (_oid.equals(_oOID))                {                    _val = _val.trim().toLowerCase();                    _oVal = _oVal.trim().toLowerCase();                    if (_val.equals(_oVal))                    {                        _indexes[j] = true;                        _found      = true;                        break;                    }                    else                    {                        StringBuffer    v1 = new StringBuffer();                        StringBuffer    v2 = new StringBuffer();                        if (_val.length() != 0)                        {                            char    c1 = _val.charAt(0);                            v1.append(c1);                            for (int k = 1; k < _val.length(); k++)                            {                                char    c2 = _val.charAt(k);                                if (!(c1 == ' ' && c2 == ' '))                                {                                    v1.append(c2);                                }                                c1 = c2;                            }                        }                        if (_oVal.length() != 0)                        {                            char    c1 = _oVal.charAt(0);                            v2.append(c1);                            for (int k = 1; k < _oVal.length(); k++)                            {                                char    c2 = _oVal.charAt(k);                                if (!(c1 == ' ' && c2 == ' '))                                {                                    v2.append(c2);                                }                                c1 = c2;                            }                        }                        if (v1.toString().equals(v2.toString()))                        {                            _indexes[j] = true;                            _found      = true;                            break;                        }                    }                }            }            if(!_found)            {                return false;            }        }                return true;    }        public int hashCode()    {        ASN1Sequence  seq = (ASN1Sequence)this.getDERObject();        Enumeration   e = seq.getObjects();        int           hashCode = 0;        while (e.hasMoreElements())        {            hashCode ^= e.nextElement().hashCode();        }        return hashCode;    }    private void appendValue(        StringBuffer        buf,        Hashtable           oidSymbols,        DERObjectIdentifier oid,        String              value)    {        String  sym = (String)oidSymbols.get(oid);        if (sym != null)        {            buf.append(sym);        }        else        {            buf.append(oid.getId());        }        buf.append("=");        int     index = buf.length();        buf.append(value);        int     end = buf.length();        while (index != end)        {            if ((buf.charAt(index) == ',')               || (buf.charAt(index) == '"')               || (buf.charAt(index) == '\\')               || (buf.charAt(index) == '+')               || (buf.charAt(index) == '<')               || (buf.charAt(index) == '>')               || (buf.charAt(index) == ';'))            {                buf.insert(index, "\\");                index++;                end++;            }            index++;        }    }    /**     * convert the structure to a string - if reverse is true the     * oids and values are listed out starting with the last element     * in the sequence (ala RFC 2253), otherwise the string will begin     * with the first element of the structure. If no string definition     * for the oid is found in oidSymbols the string value of the oid is     * added. Two standard symbol tables are provided DefaultSymbols, and     * RFC2253Symbols as part of this class.     *     * @param reverse if true start at the end of the sequence and work back.     * @param oidSymbols look up table strings for oids.     */    public String toString(        boolean     reverse,        Hashtable   oidSymbols)    {        StringBuffer            buf = new StringBuffer();        boolean                 first = true;        if (reverse)        {            for (int i = ordering.size() - 1; i >= 0; i--)            {                if (first)                {                    first = false;                }                else                {                    if (((Boolean)added.elementAt(i + 1)).booleanValue())                    {                        buf.append("+");                    }                    else                    {                        buf.append(",");                    }                }                appendValue(buf, oidSymbols,                             (DERObjectIdentifier)ordering.elementAt(i),                            (String)values.elementAt(i));            }        }        else        {            for (int i = 0; i < ordering.size(); i++)            {                if (first)                {                    first = false;                }                else                {                    if (((Boolean)added.elementAt(i)).booleanValue())                    {                        buf.append("+");                    }                    else                    {                        buf.append(",");                    }                }                appendValue(buf, oidSymbols,                             (DERObjectIdentifier)ordering.elementAt(i),                            (String)values.elementAt(i));            }        }        return buf.toString();    }    public String toString()    {        return toString(DefaultReverse, DefaultSymbols);    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -