当前位置: 首页>>代码示例>>Java>>正文


Java X509TrustManager.checkServerTrusted方法代码示例

本文整理汇总了Java中javax.net.ssl.X509TrustManager.checkServerTrusted方法的典型用法代码示例。如果您正苦于以下问题:Java X509TrustManager.checkServerTrusted方法的具体用法?Java X509TrustManager.checkServerTrusted怎么用?Java X509TrustManager.checkServerTrusted使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.net.ssl.X509TrustManager的用法示例。


在下文中一共展示了X509TrustManager.checkServerTrusted方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testLocallyTrustedCertificateChain

import javax.net.ssl.X509TrustManager; //导入方法依赖的package包/类
@Test
public void testLocallyTrustedCertificateChain() throws Exception {
    mKeyStore.addCertificate(MATCHING_HOST, PORT1, mCert3);

    X509TrustManager trustManager = TrustManagerFactory.get(MATCHING_HOST, PORT1);
    trustManager.checkServerTrusted(new X509Certificate[] { mCert3, mCaCert }, "authType");
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:8,代码来源:TrustManagerFactoryTest.java

示例2: checkServerTrusted

import javax.net.ssl.X509TrustManager; //导入方法依赖的package包/类
@Override
public void checkServerTrusted(final X509Certificate[] chain, final String authType) throws CertificateException {
    for (final X509TrustManager trustManager : trustManagers) {
        try {
            trustManager.checkServerTrusted(chain, authType);
            return;
        } catch (final CertificateException e) {
            LOGGER.debug(e.getMessage(), e);
        }
    }
    throw new CertificateException("None of the TrustManagers trust this certificate chain");
}
 
开发者ID:yuweijun,项目名称:cas-server-4.2.1,代码行数:13,代码来源:FileTrustStoreSslSocketFactory.java

示例3: checkServerTrusted

import javax.net.ssl.X509TrustManager; //导入方法依赖的package包/类
@Override
public void checkServerTrusted(X509Certificate[] certificates, String authType) throws CertificateException {
    CertificateException catchException = null;
    for (X509TrustManager tm : trustManagers) {
        try {
            tm.checkServerTrusted(certificates, authType);
            return;
        } catch (CertificateException e) {
            catchException = e;
        }
    }
    throw catchException;
}
 
开发者ID:blackarbiter,项目名称:Android_Code_Arbiter,代码行数:14,代码来源:KeyStoresTrustManager.java

示例4: testLocallyTrustedCertificateChainNotMatchingHost

import javax.net.ssl.X509TrustManager; //导入方法依赖的package包/类
@Test
public void testLocallyTrustedCertificateChainNotMatchingHost() throws Exception {
    mKeyStore.addCertificate(NOT_MATCHING_HOST, PORT1, mCert3);

    X509TrustManager trustManager = TrustManagerFactory.get(NOT_MATCHING_HOST, PORT1);
    trustManager.checkServerTrusted(new X509Certificate[] { mCert3, mCaCert }, "authType");
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:8,代码来源:TrustManagerFactoryTest.java

示例5: testGloballyTrustedCertificateNotMatchingHostOverride

import javax.net.ssl.X509TrustManager; //导入方法依赖的package包/类
@Test
public void testGloballyTrustedCertificateNotMatchingHostOverride() throws Exception {
    mKeyStore.addCertificate(MATCHING_HOST, PORT1, mLinuxComCert);

    X509TrustManager trustManager = TrustManagerFactory.get(MATCHING_HOST, PORT1);
    X509Certificate[] certificates = new X509Certificate[] { mLinuxComCert, mLinuxComFirstParentCert};
    trustManager.checkServerTrusted(certificates, "authType");
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:9,代码来源:TrustManagerFactoryTest.java

示例6: assertCertificateRejection

import javax.net.ssl.X509TrustManager; //导入方法依赖的package包/类
private void assertCertificateRejection(X509TrustManager trustManager,
        X509Certificate[] certificates) {
    boolean certificateValid;
    try {
        trustManager.checkServerTrusted(certificates, "authType");
        certificateValid = true;
    } catch (CertificateException e) {
        certificateValid = false;
    }
    assertFalse("The certificate should have been rejected but wasn't", certificateValid);
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:12,代码来源:TrustManagerFactoryTest.java

示例7: checkServerTrusted

import javax.net.ssl.X509TrustManager; //导入方法依赖的package包/类
@Override
public void checkServerTrusted(X509Certificate[] chain, String authType)
  throws CertificateException {
  X509TrustManager tm = trustManagerRef.get();
  if (tm != null) {
    tm.checkServerTrusted(chain, authType);
  } else {
    throw new CertificateException("Unknown server chain certificate: " +
                                   chain[0].toString());
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:12,代码来源:ReloadingX509TrustManager.java

示例8: main

import javax.net.ssl.X509TrustManager; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    if (initSecmod() == false) {
        return;
    }

    if ("sparc".equals(System.getProperty("os.arch")) == false) {
        // we have not updated other platforms with the proper NSS libraries yet
        System.out.println("Test currently works only on solaris-sparc, skipping");
        return;
    }

    String configName = BASE + SEP + "fips.cfg";
    Provider p = getSunPKCS11(configName);

    System.out.println(p);
    Security.addProvider(p);

    Security.removeProvider("SunJSSE");
    Provider jsse = new com.sun.net.ssl.internal.ssl.Provider(p);
    Security.addProvider(jsse);
    System.out.println(jsse.getInfo());

    KeyStore ks = KeyStore.getInstance("PKCS11", p);
    ks.load(null, "test12".toCharArray());

    X509Certificate server = loadCertificate("certs/server.cer");
    X509Certificate ca = loadCertificate("certs/ca.cer");
    X509Certificate anchor = loadCertificate("certs/anchor.cer");

    if (args.length > 1 && "sm".equals(args[0])) {
        Policy.setPolicy(Policy.getInstance("JavaPolicy",
                new URIParameter(new File(BASE, args[1]).toURI())));
        System.setSecurityManager(new SecurityManager());
    }

    KeyStore trustStore = KeyStore.getInstance("JKS");
    trustStore.load(null, null);
    trustStore.setCertificateEntry("anchor", anchor);

    TrustManagerFactory tmf = TrustManagerFactory.getInstance("PKIX");
    tmf.init(trustStore);

    X509TrustManager tm = (X509TrustManager)tmf.getTrustManagers()[0];

    X509Certificate[] chain = {server, ca, anchor};

    tm.checkServerTrusted(chain, "RSA");

    System.out.println("OK");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:51,代码来源:TrustManagerTest.java

示例9: testSelfSignedCertificateMatchingHost

import javax.net.ssl.X509TrustManager; //导入方法依赖的package包/类
@Test
public void testSelfSignedCertificateMatchingHost() throws Exception {
    mKeyStore.addCertificate(MATCHING_HOST, PORT1, mCert1);
    X509TrustManager trustManager = TrustManagerFactory.get(MATCHING_HOST, PORT1);
    trustManager.checkServerTrusted(new X509Certificate[] { mCert1 }, "authType");
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:7,代码来源:TrustManagerFactoryTest.java

示例10: testSelfSignedCertificateNotMatchingHost

import javax.net.ssl.X509TrustManager; //导入方法依赖的package包/类
@Test
public void testSelfSignedCertificateNotMatchingHost() throws Exception {
    mKeyStore.addCertificate(NOT_MATCHING_HOST, PORT1, mCert1);
    X509TrustManager trustManager = TrustManagerFactory.get(NOT_MATCHING_HOST, PORT1);
    trustManager.checkServerTrusted(new X509Certificate[] { mCert1 }, "authType");
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:7,代码来源:TrustManagerFactoryTest.java

示例11: testGloballyTrustedCertificateChain

import javax.net.ssl.X509TrustManager; //导入方法依赖的package包/类
@Test
public void testGloballyTrustedCertificateChain() throws Exception {
    X509TrustManager trustManager = TrustManagerFactory.get("www.linux.com", PORT1);
    X509Certificate[] certificates = new X509Certificate[] { mLinuxComCert, mLinuxComFirstParentCert};
    trustManager.checkServerTrusted(certificates, "authType");
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:7,代码来源:TrustManagerFactoryTest.java

示例12: testDifferentCertificatesOnSameServer

import javax.net.ssl.X509TrustManager; //导入方法依赖的package包/类
/**
 * Checks if TrustManagerFactory supports a host with different certificates for different
 * services (e.g. SMTP and IMAP).
 *
 * <p>
 * This test is to make sure entries in the keystore file aren't overwritten.
 * See <a href="https://code.google.com/p/k9mail/issues/detail?id=1326">Issue 1326</a>.
 * </p>
 *
 * @throws Exception
 *         if anything goes wrong
 */
@Test
public void testDifferentCertificatesOnSameServer() throws Exception {
    mKeyStore.addCertificate(NOT_MATCHING_HOST, PORT1, mCert1);
    mKeyStore.addCertificate(NOT_MATCHING_HOST, PORT2, mCert2);

    X509TrustManager trustManager1 = TrustManagerFactory.get(NOT_MATCHING_HOST, PORT1);
    X509TrustManager trustManager2 = TrustManagerFactory.get(NOT_MATCHING_HOST, PORT2);
    trustManager2.checkServerTrusted(new X509Certificate[] { mCert2 }, "authType");
    trustManager1.checkServerTrusted(new X509Certificate[] { mCert1 }, "authType");
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:23,代码来源:TrustManagerFactoryTest.java


注:本文中的javax.net.ssl.X509TrustManager.checkServerTrusted方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。