• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java PublicSuffixMatcher类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.http.conn.util.PublicSuffixMatcher的典型用法代码示例。如果您正苦于以下问题:Java PublicSuffixMatcher类的具体用法?Java PublicSuffixMatcher怎么用?Java PublicSuffixMatcher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PublicSuffixMatcher类属于org.apache.http.conn.util包,在下文中一共展示了PublicSuffixMatcher类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: createDefaultBuilder

import org.apache.http.conn.util.PublicSuffixMatcher; //导入依赖的package包/类
/**
 * Creates a builder containing the default registry entries, using the provided public suffix matcher.
 */
public static RegistryBuilder<CookieSpecProvider> createDefaultBuilder(final PublicSuffixMatcher publicSuffixMatcher) {
    final CookieSpecProvider defaultProvider = new DefaultCookieSpecProvider(publicSuffixMatcher);
    final CookieSpecProvider laxStandardProvider = new RFC6265CookieSpecProvider(
            RFC6265CookieSpecProvider.CompatibilityLevel.RELAXED, publicSuffixMatcher);
    final CookieSpecProvider strictStandardProvider = new RFC6265CookieSpecProvider(
            RFC6265CookieSpecProvider.CompatibilityLevel.STRICT, publicSuffixMatcher);
    return RegistryBuilder.<CookieSpecProvider>create()
            .register(CookieSpecs.DEFAULT, defaultProvider)
            .register("best-match", defaultProvider)
            .register("compatibility", defaultProvider)
            .register(CookieSpecs.STANDARD, laxStandardProvider)
            .register(CookieSpecs.STANDARD_STRICT, strictStandardProvider)
            .register(CookieSpecs.NETSCAPE, new NetscapeDraftSpecProvider())
            .register(CookieSpecs.IGNORE_COOKIES, new IgnoreSpecProvider());
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:19,代码来源:CookieSpecRegistries.java


示例2: DefaultCookieSpecProvider

import org.apache.http.conn.util.PublicSuffixMatcher; //导入依赖的package包/类
public DefaultCookieSpecProvider(
        final CompatibilityLevel compatibilityLevel,
        final PublicSuffixMatcher publicSuffixMatcher,
        final String[] datepatterns,
        final boolean oneHeader) {
    super();
    this.compatibilityLevel = compatibilityLevel != null ? compatibilityLevel : CompatibilityLevel.DEFAULT;
    this.publicSuffixMatcher = publicSuffixMatcher;
    this.datepatterns = datepatterns;
    this.oneHeader = oneHeader;
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:12,代码来源:DefaultCookieSpecProvider.java


示例3: PublicSuffixDomainFilter

import org.apache.http.conn.util.PublicSuffixMatcher; //导入依赖的package包/类
public PublicSuffixDomainFilter(
        final CommonCookieAttributeHandler handler, final PublicSuffixList suffixList) {
    Args.notNull(handler, "Cookie handler");
    Args.notNull(suffixList, "Public suffix list");
    this.handler = handler;
    this.publicSuffixMatcher = new PublicSuffixMatcher(suffixList.getRules(), suffixList.getExceptions());
    this.localDomainMap = createLocalDomainMap();
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:9,代码来源:PublicSuffixDomainFilter.java


示例4: RFC6265CookieSpecProvider

import org.apache.http.conn.util.PublicSuffixMatcher; //导入依赖的package包/类
public RFC6265CookieSpecProvider(
        final CompatibilityLevel compatibilityLevel,
        final PublicSuffixMatcher publicSuffixMatcher) {
    super();
    this.compatibilityLevel = compatibilityLevel != null ? compatibilityLevel : CompatibilityLevel.RELAXED;
    this.publicSuffixMatcher = publicSuffixMatcher;
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:8,代码来源:RFC6265CookieSpecProvider.java


示例5: matchDNSName

import org.apache.http.conn.util.PublicSuffixMatcher; //导入依赖的package包/类
static void matchDNSName(final String host, final List<String> subjectAlts,
                         final PublicSuffixMatcher publicSuffixMatcher) throws SSLException {
    final String normalizedHost = host.toLowerCase(Locale.ROOT);
    for (int i = 0; i < subjectAlts.size(); i++) {
        final String subjectAlt = subjectAlts.get(i);
        final String normalizedSubjectAlt = subjectAlt.toLowerCase(Locale.ROOT);
        if (matchIdentityStrict(normalizedHost, normalizedSubjectAlt, publicSuffixMatcher)) {
            return;
        }
    }
    throw new SSLException("Certificate for <" + host + "> doesn't match any " +
            "of the subject alternative names: " + subjectAlts);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:14,代码来源:DefaultHostnameVerifier.java


示例6: matchCN

import org.apache.http.conn.util.PublicSuffixMatcher; //导入依赖的package包/类
static void matchCN(final String host, final String cn,
             final PublicSuffixMatcher publicSuffixMatcher) throws SSLException {
    if (!matchIdentityStrict(host, cn, publicSuffixMatcher)) {
        throw new SSLException("Certificate for <" + host + "> doesn't match " +
                "common name of the certificate subject: " + cn);
    }
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:8,代码来源:DefaultHostnameVerifier.java


示例7: matchIdentity

import org.apache.http.conn.util.PublicSuffixMatcher; //导入依赖的package包/类
private static boolean matchIdentity(final String host, final String identity,
                                     final PublicSuffixMatcher publicSuffixMatcher,
                                     final boolean strict) {
    if (publicSuffixMatcher != null && host.contains(".")) {
        if (!matchDomainRoot(host, publicSuffixMatcher.getDomainRoot(identity, DomainType.ICANN))) {
            return false;
        }
    }

    // RFC 2818, 3.1. Server Identity
    // "...Names may contain the wildcard
    // character * which is considered to match any single domain name
    // component or component fragment..."
    // Based on this statement presuming only singular wildcard is legal
    final int asteriskIdx = identity.indexOf('*');
    if (asteriskIdx != -1) {
        final String prefix = identity.substring(0, asteriskIdx);
        final String suffix = identity.substring(asteriskIdx + 1);
        if (!prefix.isEmpty() && !host.startsWith(prefix)) {
            return false;
        }
        if (!suffix.isEmpty() && !host.endsWith(suffix)) {
            return false;
        }
        // Additional sanity checks on content selected by wildcard can be done here
        if (strict) {
            final String remainder = host.substring(
                    prefix.length(), host.length() - suffix.length());
            if (remainder.contains(".")) {
                return false;
            }
        }
        return true;
    }
    return host.equalsIgnoreCase(identity);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:37,代码来源:DefaultHostnameVerifier.java


示例8: testPublicSuffixFilter

import org.apache.http.conn.util.PublicSuffixMatcher; //导入依赖的package包/类
@Test
public void testPublicSuffixFilter() throws Exception {
    final BasicClientCookie cookie = new BasicClientCookie("name", "value");

    final PublicSuffixMatcher matcher = new PublicSuffixMatcher(DomainType.ICANN, Arrays.asList("co.uk", "com"), null);
    final PublicSuffixDomainFilter h = new PublicSuffixDomainFilter(new RFC2109DomainHandler(), matcher);

    cookie.setDomain(".co.uk");
    Assert.assertFalse(h.match(cookie, new CookieOrigin("apache.co.uk", 80, "/stuff", false)));

    cookie.setDomain("co.uk");
    Assert.assertFalse(h.match(cookie, new CookieOrigin("apache.co.uk", 80, "/stuff", false)));

    cookie.setDomain(".co.com");
    Assert.assertTrue(h.match(cookie, new CookieOrigin("apache.co.com", 80, "/stuff", false)));

    cookie.setDomain("co.com");
    Assert.assertFalse(h.match(cookie, new CookieOrigin("apache.co.com", 80, "/stuff", false)));

    cookie.setDomain(".com");
    Assert.assertFalse(h.match(cookie, new CookieOrigin("apache.com", 80, "/stuff", false)));

    cookie.setDomain("com");
    Assert.assertFalse(h.match(cookie, new CookieOrigin("apache.com", 80, "/stuff", false)));

    cookie.setDomain("apache.com");
    Assert.assertTrue(h.match(cookie, new CookieOrigin("apache.com", 80, "/stuff", false)));

    cookie.setDomain(".apache.com");
    Assert.assertTrue(h.match(cookie, new CookieOrigin("www.apache.com", 80, "/stuff", false)));

    cookie.setDomain("localhost");
    Assert.assertTrue(h.match(cookie, new CookieOrigin("localhost", 80, "/stuff", false)));
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:35,代码来源:TestBasicCookieAttribHandlers.java


示例9: setUp

import org.apache.http.conn.util.PublicSuffixMatcher; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    final ClassLoader classLoader = getClass().getClassLoader();
    final InputStream in = classLoader.getResourceAsStream(SOURCE_FILE);
    Assert.assertNotNull(in);
    final PublicSuffixList suffixList;
    try {
        final org.apache.http.conn.util.PublicSuffixListParser parser = new org.apache.http.conn.util.PublicSuffixListParser();
        suffixList = parser.parse(new InputStreamReader(in, Consts.UTF_8));
    } finally {
        in.close();
    }
    final PublicSuffixMatcher matcher = new PublicSuffixMatcher(suffixList.getRules(), suffixList.getExceptions());
    this.filter = new PublicSuffixDomainFilter(new RFC2109DomainHandler(), matcher);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:16,代码来源:TestPublicSuffixListParser.java


示例10: matchIdentity

import org.apache.http.conn.util.PublicSuffixMatcher; //导入依赖的package包/类
private static boolean matchIdentity(final String host, final String identity,
                                     final PublicSuffixMatcher publicSuffixMatcher,
                                     final boolean strict) {
    if (publicSuffixMatcher != null && host.contains(".")) {
        if (!matchDomainRoot(host, publicSuffixMatcher.getDomainRoot(identity))) {
            return false;
        }
    }

    // RFC 2818, 3.1. Server Identity
    // "...Names may contain the wildcard
    // character * which is considered to match any single domain name
    // component or component fragment..."
    // Based on this statement presuming only singular wildcard is legal
    final int asteriskIdx = identity.indexOf('*');
    if (asteriskIdx != -1) {
        final String prefix = identity.substring(0, asteriskIdx);
        final String suffix = identity.substring(asteriskIdx + 1);
        if (!prefix.isEmpty() && !host.startsWith(prefix)) {
            return false;
        }
        if (!suffix.isEmpty() && !host.endsWith(suffix)) {
            return false;
        }
        // Additional sanity checks on content selected by wildcard can be done here
        if (strict) {
            final String remainder = host.substring(
                    prefix.length(), host.length() - suffix.length());
            if (remainder.contains(".")) {
                return false;
            }
        }
        return true;
    }
    return host.equalsIgnoreCase(identity);
}
 
开发者ID:NoYouShutup,项目名称:CryptMeme,代码行数:37,代码来源:DefaultHostnameVerifier.java


示例11: main

import org.apache.http.conn.util.PublicSuffixMatcher; //导入依赖的package包/类
public final static void main(String[] args) throws Exception {

        // Use PublicSuffixMatcherLoader to load public suffix list from a file,
        // resource or from an arbitrary URL
        PublicSuffixMatcher publicSuffixMatcher = PublicSuffixMatcherLoader.load(
                new URL("https://publicsuffix.org/list/effective_tld_names.dat"));

        // Please use the publicsuffix.org URL to download the list no more than once per day !!!
        // Please consider making a local copy !!!

        DefaultHostnameVerifier hostnameVerifier = new DefaultHostnameVerifier(publicSuffixMatcher);

        RFC6265CookieSpecProvider cookieSpecProvider = new RFC6265CookieSpecProvider(publicSuffixMatcher);
        Lookup<CookieSpecProvider> cookieSpecRegistry = RegistryBuilder.<CookieSpecProvider>create()
                .register(CookieSpecs.DEFAULT, cookieSpecProvider)
                .register(CookieSpecs.STANDARD, cookieSpecProvider)
                .register(CookieSpecs.STANDARD_STRICT, cookieSpecProvider)
                .build();

        CloseableHttpClient httpclient = HttpClients.custom()
                .setSSLHostnameVerifier(hostnameVerifier)
                .setDefaultCookieSpecRegistry(cookieSpecRegistry)
                .build();
        try {

            HttpGet httpget = new HttpGet("https://httpbin.org/");

            System.out.println("executing request " + httpget.getRequestLine());

            CloseableHttpResponse response = httpclient.execute(httpget);
            try {
                HttpEntity entity = response.getEntity();

                System.out.println("----------------------------------------");
                System.out.println(response.getStatusLine());
                EntityUtils.consume(entity);
            } finally {
                response.close();
            }
        } finally {
            httpclient.close();
        }
    }
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:44,代码来源:ClientCustomPublicSuffixList.java


示例12: RFC2109SpecProvider

import org.apache.http.conn.util.PublicSuffixMatcher; //导入依赖的package包/类
public RFC2109SpecProvider(final PublicSuffixMatcher publicSuffixMatcher, final boolean oneHeader) {
    super();
    this.oneHeader = oneHeader;
    this.publicSuffixMatcher = publicSuffixMatcher;
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:6,代码来源:RFC2109SpecProvider.java


示例13: decorate

import org.apache.http.conn.util.PublicSuffixMatcher; //导入依赖的package包/类
public static CommonCookieAttributeHandler decorate(
        final CommonCookieAttributeHandler handler, final PublicSuffixMatcher publicSuffixMatcher) {
    Args.notNull(handler, "Cookie attribute handler");
    return publicSuffixMatcher != null ? new PublicSuffixDomainFilter(handler, publicSuffixMatcher) : handler;
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:6,代码来源:PublicSuffixDomainFilter.java


示例14: RFC2965SpecProvider

import org.apache.http.conn.util.PublicSuffixMatcher; //导入依赖的package包/类
public RFC2965SpecProvider(final PublicSuffixMatcher publicSuffixMatcher, final boolean oneHeader) {
    super();
    this.oneHeader = oneHeader;
    this.publicSuffixMatcher = publicSuffixMatcher;
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:6,代码来源:RFC2965SpecProvider.java


示例15: createDefault

import org.apache.http.conn.util.PublicSuffixMatcher; //导入依赖的package包/类
/**
 * Creates the default registry with the provided public suffix matcher
 */
public static Lookup<CookieSpecProvider> createDefault(final PublicSuffixMatcher publicSuffixMatcher) {
    return createDefaultBuilder(publicSuffixMatcher).build();
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:7,代码来源:CookieSpecRegistries.java


示例16: DefaultHostnameVerifier

import org.apache.http.conn.util.PublicSuffixMatcher; //导入依赖的package包/类
public DefaultHostnameVerifier(final PublicSuffixMatcher publicSuffixMatcher) {
    this.publicSuffixMatcher = publicSuffixMatcher;
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:4,代码来源:DefaultHostnameVerifier.java


示例17: matchIdentityStrict

import org.apache.http.conn.util.PublicSuffixMatcher; //导入依赖的package包/类
static boolean matchIdentityStrict(final String host, final String identity,
                                   final PublicSuffixMatcher publicSuffixMatcher) {
    return matchIdentity(host, identity, publicSuffixMatcher, true);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:5,代码来源:DefaultHostnameVerifier.java


示例18: setup

import org.apache.http.conn.util.PublicSuffixMatcher; //导入依赖的package包/类
@Before
public void setup() {
    impl = new DefaultHostnameVerifier();
    publicSuffixMatcher = new PublicSuffixMatcher(DomainType.ICANN, Arrays.asList("com", "co.jp", "gov.uk"), null);
    implWithPublicSuffixCheck = new DefaultHostnameVerifier(publicSuffixMatcher);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:7,代码来源:TestDefaultHostnameVerifier.java


示例19: AbsDefaultHostnameVerifier

import org.apache.http.conn.util.PublicSuffixMatcher; //导入依赖的package包/类
public AbsDefaultHostnameVerifier(final PublicSuffixMatcher publicSuffixMatcher) {
    this.publicSuffixMatcher = publicSuffixMatcher;
}
 
开发者ID:lucee,项目名称:Lucee4,代码行数:4,代码来源:AbsDefaultHostnameVerifier.java



注:本文中的org.apache.http.conn.util.PublicSuffixMatcher类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PPath类代码示例发布时间:2022-05-22
下一篇:
Java LayerSnowmanHead类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap