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

📄 pkixnameconstraintvalidator.java

📁 kmlnjlkj nlkjlkjkljl okopokipoipo oipipipo i
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
                {                    union.add(email1);                }                else                {                    union.add(email1);                    union.add(email2);                }            }            else            {                if (withinDomain(email2, email1))                {                    union.add(email1);                }                else                {                    union.add(email1);                    union.add(email2);                }            }        }        // email specifies a host        else        {            if (email2.indexOf('@') != -1)            {                String _sub = email2.substring(email1.indexOf('@') + 1);                if (_sub.equalsIgnoreCase(email1))                {                    union.add(email1);                }                else                {                    union.add(email1);                    union.add(email2);                }            }            // email2 specifies a domain            else if (email2.startsWith("."))            {                if (withinDomain(email1, email2))                {                    union.add(email2);                }                else                {                    union.add(email1);                    union.add(email2);                }            }            // email2 specifies a particular host            else            {                if (email1.equalsIgnoreCase(email2))                {                    union.add(email1);                }                else                {                    union.add(email1);                    union.add(email2);                }            }        }    }    private Set intersectDNS(Set permitted, Set dnss)    {        Set intersect = new HashSet();        for (Iterator it = dnss.iterator(); it.hasNext();)        {            String dns = extractNameAsString(((GeneralSubtree)it.next())                .getBase());            if (permitted == null)            {                if (dns != null)                {                    intersect.add(dns);                }            }            else            {                Iterator _iter = permitted.iterator();                while (_iter.hasNext())                {                    String _permitted = (String)_iter.next();                    if (withinDomain(_permitted, dns))                    {                        intersect.add(_permitted);                    }                    else if (withinDomain(dns, _permitted))                    {                        intersect.add(dns);                    }                }            }        }        return intersect;    }    protected Set unionDNS(Set excluded, String dns)    {        if (excluded.isEmpty())        {            if (dns == null)            {                return excluded;            }            excluded.add(dns);            return excluded;        }        else        {            Set union = new HashSet();            Iterator _iter = excluded.iterator();            while (_iter.hasNext())            {                String _permitted = (String)_iter.next();                if (withinDomain(_permitted, dns))                {                    union.add(dns);                }                else if (withinDomain(dns, _permitted))                {                    union.add(_permitted);                }                else                {                    union.add(_permitted);                    union.add(dns);                }            }            return union;        }    }    /**     * The most restricting part from <code>email1</code> and     * <code>email2</code> is added to the intersection <code>intersect</code>.     *     * @param email1    Email address constraint 1.     * @param email2    Email address constraint 2.     * @param intersect The intersection.     */    private void intersectEmail(String email1, String email2, Set intersect)    {        // email1 is a particular address        if (email1.indexOf('@') != -1)        {            String _sub = email1.substring(email1.indexOf('@') + 1);            // both are a particular mailbox            if (email2.indexOf('@') != -1)            {                if (email1.equalsIgnoreCase(email2))                {                    intersect.add(email1);                }            }            // email2 specifies a domain            else if (email2.startsWith("."))            {                if (withinDomain(_sub, email2))                {                    intersect.add(email1);                }            }            // email2 specifies a particular host            else            {                if (_sub.equalsIgnoreCase(email2))                {                    intersect.add(email1);                }            }        }        // email specifies a domain        else if (email1.startsWith("."))        {            if (email2.indexOf('@') != -1)            {                String _sub = email2.substring(email1.indexOf('@') + 1);                if (withinDomain(_sub, email1))                {                    intersect.add(email2);                }            }            // email2 specifies a domain            else if (email2.startsWith("."))            {                if (withinDomain(email1, email2)                    || email1.equalsIgnoreCase(email2))                {                    intersect.add(email1);                }                else if (withinDomain(email2, email1))                {                    intersect.add(email2);                }            }            else            {                if (withinDomain(email2, email1))                {                    intersect.add(email2);                }            }        }        // email1 specifies a host        else        {            if (email2.indexOf('@') != -1)            {                String _sub = email2.substring(email2.indexOf('@') + 1);                if (_sub.equalsIgnoreCase(email1))                {                    intersect.add(email2);                }            }            // email2 specifies a domain            else if (email2.startsWith("."))            {                if (withinDomain(email1, email2))                {                    intersect.add(email1);                }            }            // email2 specifies a particular host            else            {                if (email1.equalsIgnoreCase(email2))                {                    intersect.add(email1);                }            }        }    }    private void checkExcludedURI(Set excluded, String uri)        throws PKIXNameConstraintValidatorException    {        if (excluded.isEmpty())        {            return;        }        Iterator it = excluded.iterator();        while (it.hasNext())        {            String str = ((String)it.next());            if (isUriConstrained(uri, str))            {                throw new PKIXNameConstraintValidatorException(                    "URI is from an excluded subtree.");            }        }    }    private Set intersectURI(Set permitted, Set uris)    {        Set intersect = new HashSet();        for (Iterator it = uris.iterator(); it.hasNext();)        {            String uri = extractNameAsString(((GeneralSubtree)it.next())                .getBase());            if (permitted == null)            {                if (uri != null)                {                    intersect.add(uri);                }            }            else            {                Iterator _iter = permitted.iterator();                while (_iter.hasNext())                {                    String _permitted = (String)_iter.next();                    intersectURI(_permitted, uri, intersect);                }            }        }        return intersect;    }    private Set unionURI(Set excluded, String uri)    {        if (excluded.isEmpty())        {            if (uri == null)            {                return excluded;            }            excluded.add(uri);            return excluded;        }        else        {            Set union = new HashSet();            Iterator _iter = excluded.iterator();            while (_iter.hasNext())            {                String _excluded = (String)_iter.next();                unionURI(_excluded, uri, union);            }            return union;        }    }    private void intersectURI(String email1, String email2, Set intersect)    {        // email1 is a particular address        if (email1.indexOf('@') != -1)        {            String _sub = email1.substring(email1.indexOf('@') + 1);            // both are a particular mailbox            if (email2.indexOf('@') != -1)            {                if (email1.equalsIgnoreCase(email2))                {                    intersect.add(email1);                }            }            // email2 specifies a domain            else if (email2.startsWith("."))            {                if (withinDomain(_sub, email2))                {                    intersect.add(email1);                }            }            // email2 specifies a particular host            else            {                if (_sub.equalsIgnoreCase(email2))                {                    intersect.add(email1);                }            }        }        // email specifies a domain        else if (email1.startsWith("."))        {            if (email2.indexOf('@') != -1)            {                String _sub = email2.substring(email1.indexOf('@') + 1);                if (withinDomain(_sub, email1))                {                    intersect.add(email2);                }            }            // email2 specifies a domain            else if (email2.startsWith("."))            {                if (withinDomain(email1, email2)                    || email1.equalsIgnoreCase(email2))                {                    intersect.add(email1);                }                else if (withinDomain(email2, email1))                {                    intersect.add(email2);                }            }            else            {                if (withinDomain(email2, email1))                {                    intersect.add(email2);                }            }        }        // email1 specifies a host        else        {            if (email2.indexOf('@') != -1)            {                String _sub = email2.substring(email2.indexOf('@') + 1);                if (_sub.equalsIgnoreCase(email1))                {                    intersect.add(email2);                }            }            // email2 specifies a domain            else if (email2.startsWith("."))            {                if (withinDomain(email1, email2))                {                    intersect.add(email1);                }            }            // email2 specifies a particular host            else            {                if (email1.equalsIgnoreCase(email2))                {                    intersect.add(email1);                }            }        }    }    private void checkPermittedURI(Set permitted, String uri)        throws PKIXNameConstraintValidatorException    {        if (permitted == null)        {            return;        }        Iterator it = permitted.iterator();        while (it.hasNext())        {            String str = ((String)it.next());            if (isUriConstrained(uri, str))            {                return;            }        }        if (uri.length() == 0 && permitted.size() == 0)        {            return;        }        throw new PKIXNameConstraintValidatorException(            "URI is not from a permitted subtree.");    }    private boolean isUriConstrained(String uri, String constraint)    {        String host = extractHostFromURL(uri);        // a host        if (!constraint.startsWith("."))        {            if (host.equalsIgnoreCase(constraint))            {                return true;            }        }        // in sub domain or domain        else if (withinDomain(host, constraint))        {            return true;        }        return false;    }    private static String extractHostFromURL(String url)    {        // see RFC 1738        // remove ':' after protocol, e.g. http:        String sub = url.substring(url.indexOf(':') + 1);        // extract host from Common Internet Scheme Syntax, e.g. http://        if (sub.indexOf("//") != -1)        {            sub = sub.substring(sub.indexOf("//") + 2);        }        // first remove port, e.g. http://test.com:21        if (sub.lastIndexOf(':') != -1)        {            sub = sub.substring(0, sub.lastIndexOf(':'));        }        // remove user and password, e.g. http://john:password@test.com        sub = sub.substring(sub.indexOf(':') + 1);        sub = sub.substring(sub.indexOf('@') + 1);        // remove local parts, e.g. http://test.com/bla

⌨️ 快捷键说明

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