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


Java TrustManager类代码示例

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


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

示例1: createSSLContext

import com.sun.net.ssl.TrustManager; //导入依赖的package包/类
private static SSLContext createSSLContext() {
    try {
        ClassLoader cl = SimpleSocketFactory.class.getClassLoader();
        URL url = cl.getResource("org/apache/commons/httpclient/ssl/simpleserver.keystore");
        KeyStore keystore  = KeyStore.getInstance("jks");
        keystore.load(url.openStream(), "nopassword".toCharArray());
        TrustManagerFactory tmfactory = TrustManagerFactory.getInstance(
                TrustManagerFactory.getDefaultAlgorithm());
        tmfactory.init(keystore);
        TrustManager[] trustmanagers = tmfactory.getTrustManagers(); 
        SSLContext sslcontext = SSLContext.getInstance("TLS");
        sslcontext.init(null, trustmanagers, null);
        return sslcontext;
    } catch (Exception ex) {
        // this is not the way a sane exception handling should be done
        // but for our simple HTTP testing framework this will suffice
        LOG.error(ex.getMessage(), ex);
        throw new IllegalStateException(ex.getMessage());
    }

}
 
开发者ID:magneticmoon,项目名称:httpclient3-ntml,代码行数:22,代码来源:SimpleSSLTestProtocolSocketFactory.java

示例2: createTrustManagers

import com.sun.net.ssl.TrustManager; //导入依赖的package包/类
private static TrustManager[] createTrustManagers(final KeyStore keystore)
    throws KeyStoreException, NoSuchAlgorithmException
{ 
    if (keystore == null) {
        throw new IllegalArgumentException("Keystore may not be null");
    }
    LOG.debug("Initializing trust manager");
    TrustManagerFactory tmfactory = TrustManagerFactory.getInstance(
        TrustManagerFactory.getDefaultAlgorithm());
    tmfactory.init(keystore);
    TrustManager[] trustmanagers = tmfactory.getTrustManagers();
    for (int i = 0; i < trustmanagers.length; i++) {
        if (trustmanagers[i] instanceof X509TrustManager) {
            trustmanagers[i] = new AuthSSLX509TrustManager(
                (X509TrustManager)trustmanagers[i]); 
        }
    }
    return trustmanagers; 
}
 
开发者ID:magneticmoon,项目名称:httpclient3-ntml,代码行数:20,代码来源:AuthSSLProtocolSocketFactory.java

示例3: createTrustManagers

import com.sun.net.ssl.TrustManager; //导入依赖的package包/类
private static TrustManager[] createTrustManagers(final KeyStore keystore, String algorithm)
    throws KeyStoreException, NoSuchAlgorithmException
{ 
    if (keystore == null) {
        throw new IllegalArgumentException("Keystore may not be null");
    }
    log.debug("Initializing trust manager");
    if (StringUtils.isEmpty(algorithm)) {
    	algorithm=TrustManagerFactory.getDefaultAlgorithm();
    	log.debug("using default TrustManager algorithm ["+algorithm+"]");
    } else {
    	log.debug("using configured TrustManager algorithm ["+algorithm+"]");
    }
    TrustManagerFactory tmfactory = TrustManagerFactory.getInstance(algorithm);
    tmfactory.init(keystore);
    TrustManager[] trustmanagers = tmfactory.getTrustManagers();
    return trustmanagers; 
}
 
开发者ID:ibissource,项目名称:iaf,代码行数:19,代码来源:AuthSSLProtocolSocketFactoryForJsse10x.java

示例4: createSSLContext

import com.sun.net.ssl.TrustManager; //导入依赖的package包/类
private static SSLContext createSSLContext() {
    try {
        ClassLoader cl = SimpleSocketFactory.class.getClassLoader();
        URL url = cl.getResource("org/apache/commons/httpclient/ssl/simpleserver.keystore");
        KeyStore keystore  = KeyStore.getInstance("jks");
        InputStream is = null;
        try {
            is = url.openStream();
            keystore.load(is, "nopassword".toCharArray());
        } finally {
            if (is != null) is.close();
        }
        TrustManagerFactory tmfactory = TrustManagerFactory.getInstance(
                TrustManagerFactory.getDefaultAlgorithm());
        tmfactory.init(keystore);
        TrustManager[] trustmanagers = tmfactory.getTrustManagers(); 
        SSLContext sslcontext = SSLContext.getInstance("TLS");
        sslcontext.init(null, trustmanagers, null);
        return sslcontext;
    } catch (Exception ex) {
        // this is not the way a sane exception handling should be done
        // but for our simple HTTP testing framework this will suffice
        LOG.error(ex.getMessage(), ex);
        throw new IllegalStateException(ex.getMessage());
    }

}
 
开发者ID:jenkinsci,项目名称:lib-commons-httpclient,代码行数:28,代码来源:SimpleSSLTestProtocolSocketFactory.java

示例5: EasyX509TrustManager

import com.sun.net.ssl.TrustManager; //导入依赖的package包/类
/**
 * Constructor for EasyX509TrustManager.
 */
public EasyX509TrustManager(KeyStore keystore) throws NoSuchAlgorithmException, KeyStoreException {
    super();
    TrustManagerFactory factory = TrustManagerFactory.getInstance("SunX509");
    factory.init(keystore);
    TrustManager[] trustmanagers = factory.getTrustManagers();
    if (trustmanagers.length == 0) {
        throw new NoSuchAlgorithmException("SunX509 trust manager not supported");
    }
    this.standardTrustManager = (X509TrustManager) trustmanagers[0];
}
 
开发者ID:intuit,项目名称:Tank,代码行数:14,代码来源:EasyX509TrustManager.java

示例6: createEasySSLContext

import com.sun.net.ssl.TrustManager; //导入依赖的package包/类
private static SSLContext createEasySSLContext() {
    try {
        SSLContext context = SSLContext.getInstance("SSL");
        context.init(
                null,
                new TrustManager[] { new EasyX509TrustManager(null) },
                null);
        return context;
    } catch (Exception e) {
        LOG.error(e.getMessage(), e);
        throw new HttpClientError(e.toString());
    }
}
 
开发者ID:intuit,项目名称:Tank,代码行数:14,代码来源:EasySSLProtocolSocketFactory.java

示例7: initSSL

import com.sun.net.ssl.TrustManager; //导入依赖的package包/类
protected final Object initSSL(SSL ssl, TrustChain tc, KeyMaterial k)
    throws NoSuchAlgorithmException, KeyStoreException,
    CertificateException, KeyManagementException, IOException {
    SSLContext context = SSLContext.getInstance(ssl.getDefaultProtocol());
    TrustManager[] trustManagers = null;
    KeyManager[] keyManagers = null;
    if (tc != null) {
        trustManagers = (TrustManager[]) tc.getTrustManagers();
    }
    if (k != null) {
        keyManagers = (KeyManager[]) k.getKeyManagers();
    }
    if (keyManagers != null) {
        for (int i = 0; i < keyManagers.length; i++) {
            if (keyManagers[i] instanceof X509KeyManager) {
                X509KeyManager km = (X509KeyManager) keyManagers[i];
                keyManagers[i] = new Java13KeyManagerWrapper(km, k, ssl);
            }
        }
    }
    if (trustManagers != null) {
        for (int i = 0; i < trustManagers.length; i++) {
            if (trustManagers[i] instanceof X509TrustManager) {
                X509TrustManager tm = (X509TrustManager) trustManagers[i];
                trustManagers[i] = new Java13TrustManagerWrapper(tm, tc, ssl);
            }
        }
    }
    context.init(keyManagers, trustManagers, null);
    return context;
}
 
开发者ID:drankye,项目名称:haox,代码行数:32,代码来源:Java13.java

示例8: EasyX509TrustManager

import com.sun.net.ssl.TrustManager; //导入依赖的package包/类
/**
 * Constructor for EasyX509TrustManager.
 */
public EasyX509TrustManager(KeyStore keystore) throws NoSuchAlgorithmException, KeyStoreException {
    super();
    TrustManagerFactory factory = TrustManagerFactory.getInstance("SunX509");
    factory.init(keystore);
    TrustManager[] trustmanagers = factory.getTrustManagers();
    if (trustmanagers.length == 0) {
        throw new NoSuchAlgorithmException("SunX509 trust manager not supported");
    }
    this.standardTrustManager = (X509TrustManager)trustmanagers[0];
}
 
开发者ID:magneticmoon,项目名称:httpclient3-ntml,代码行数:14,代码来源:EasyX509TrustManager.java

示例9: createEasySSLContext

import com.sun.net.ssl.TrustManager; //导入依赖的package包/类
private static SSLContext createEasySSLContext() {
    try {
        SSLContext context = SSLContext.getInstance("SSL");
        context.init(
          null, 
          new TrustManager[] {new EasyX509TrustManager(null)}, 
          null);
        return context;
    } catch (Exception e) {
        LOG.error(e.getMessage(), e);
        throw new HttpClientError(e.toString());
    }
}
 
开发者ID:magneticmoon,项目名称:httpclient3-ntml,代码行数:14,代码来源:EasySSLProtocolSocketFactory.java

示例10: AuthSslTrustManager

import com.sun.net.ssl.TrustManager; //导入依赖的package包/类
AuthSslTrustManager(KeyStore keystore, TrustManager[] trustmanagers) throws NoSuchAlgorithmException, KeyStoreException {
	if (trustmanagers == null || trustmanagers.length == 0) {
		TrustManagerFactory factory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
		factory.init(keystore);
		trustmanagers = factory.getTrustManagers();
	}
	if (trustmanagers.length != 1) {
		throw new NoSuchAlgorithmException("Only works with X509 trustmanagers");
	}
	trustManager = (X509TrustManager)trustmanagers[0];
}
 
开发者ID:ibissource,项目名称:iaf,代码行数:12,代码来源:AuthSSLProtocolSocketFactoryForJsse10x.java

示例11: EasyX509TrustManager

import com.sun.net.ssl.TrustManager; //导入依赖的package包/类
/**
 * Constructor for EasyX509TrustManager.
 */
public EasyX509TrustManager(KeyStore keystore) throws NoSuchAlgorithmException, KeyStoreException {
	super();
	TrustManagerFactory factory = TrustManagerFactory.getInstance("SunX509");
	factory.init(keystore);
	TrustManager[] trustmanagers = factory.getTrustManagers();
	if (trustmanagers.length == 0) {
		throw new NoSuchAlgorithmException("SunX509 trust manager not supported");
	}
	this.standardTrustManager = (X509TrustManager) trustmanagers[0];
}
 
开发者ID:NCIP,项目名称:cagrid-core,代码行数:14,代码来源:EasyX509TrustManager.java

示例12: createEasySSLContext

import com.sun.net.ssl.TrustManager; //导入依赖的package包/类
private static SSLContext createEasySSLContext() {
	try {
		SSLContext context = SSLContext.getInstance("SSL");
		context.init(null, new TrustManager[]{new EasyX509TrustManager(null)}, null);
		return context;
	} catch (Exception e) {
		LOG.error(e.getMessage(), e);
		throw new HttpClientError(e.toString());
	}
}
 
开发者ID:NCIP,项目名称:cagrid-core,代码行数:11,代码来源:EasySSLProtocolSocketFactory.java


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