本文整理汇总了Java中javax.net.ssl.SSLContextSpi类的典型用法代码示例。如果您正苦于以下问题:Java SSLContextSpi类的具体用法?Java SSLContextSpi怎么用?Java SSLContextSpi使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SSLContextSpi类属于javax.net.ssl包,在下文中一共展示了SSLContextSpi类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test_createSSLEngine
import javax.net.ssl.SSLContextSpi; //导入依赖的package包/类
/**
* @throws KeyManagementException
* @tests javax.net.ssl.SSLContext#createSSLEngine()
*/
@TestTargetNew(
level = TestLevel.SUFFICIENT,
notes = "UnsupportedOperationException checking missed",
method = "createSSLEngine",
args = {}
)
public void test_createSSLEngine() throws KeyManagementException {
if (!DEFSupported) fail(NotSupportMsg);
SSLContextSpi spi = new MySSLContextSpi();
SSLContext sslContext = new MySslContext(spi, defaultProvider,
defaultProtocol);
sslContext.init(null, null, new SecureRandom());
SSLEngine sslEngine = sslContext.createSSLEngine();
assertNotNull("SSL engine is null", sslEngine);
}
示例2: test_createSSLEngineLjava_lang_StringI
import javax.net.ssl.SSLContextSpi; //导入依赖的package包/类
/**
* @throws KeyManagementException
* @tests javax.net.ssl.SSLContext#createSSLEngine(java.lang.String, int)
*/
@TestTargetNew(
level = TestLevel.SUFFICIENT,
notes = "UnsupportedOperationException checking missed",
method = "createSSLEngine",
args = {java.lang.String.class, int.class}
)
public void test_createSSLEngineLjava_lang_StringI()
throws KeyManagementException {
if (!DEFSupported) fail(NotSupportMsg);
SSLContextSpi spi = new MySSLContextSpi();
SSLContext sslContext = new MySslContext(spi, defaultProvider,
defaultProtocol);
sslContext.init(null, null, new SecureRandom());
SSLEngine sslEngine = sslContext.createSSLEngine("www.fortify.net", 80);
assertNotNull("SSL engine is null", sslEngine);
}
示例3: test_getProvider
import javax.net.ssl.SSLContextSpi; //导入依赖的package包/类
/**
* @throws NoSuchAlgorithmException
* @throws NoSuchProviderException
* @tests javax.net.ssl.SSLContext#getProvider()
*/
@TestTargetNew(
level = TestLevel.COMPLETE,
notes = "",
method = "getProvider",
args = {}
)
public void test_getProvider()
throws NoSuchAlgorithmException, NoSuchProviderException {
if (!DEFSupported) fail(NotSupportMsg);
SSLContextSpi spi = new MySSLContextSpi();
SSLContext sslContext = new MySslContext(spi, defaultProvider,
defaultProtocol);
assertEquals("Incorrect provider",
defaultProvider, sslContext.getProvider());
sslContext = SSLContext.getInstance(defaultProtocol, defaultProvider);
assertEquals("Incorrect provider",
defaultProvider, sslContext.getProvider());
sslContext = SSLContext.getInstance(defaultProtocol, defaultProviderName);
assertEquals("Incorrect provider",
defaultProvider, sslContext.getProvider());
}
示例4: test_Constructor
import javax.net.ssl.SSLContextSpi; //导入依赖的package包/类
/**
* @tests javax.net.ssl.SSLContextSpi#SSLContextSpi()
*/
@TestTargetNew(
level = TestLevel.COMPLETE,
notes = "",
method = "SSLContextSpi",
args = {}
)
public void test_Constructor() {
try {
SSLContextSpiImpl ssl = new SSLContextSpiImpl();
assertTrue(ssl instanceof SSLContextSpi);
} catch (Exception e) {
fail("Unexpected exception " + e.toString());
}
}
示例5: test_getProtocol
import javax.net.ssl.SSLContextSpi; //导入依赖的package包/类
/**
* @throws NoSuchAlgorithmException
* @throws NoSuchProviderException
* @tests javax.net.ssl.SSLContext#getProtocol()
*/
@TestTargetNew(
level = TestLevel.COMPLETE,
notes = "",
method = "getProtocol",
args = {}
)
public void test_getProtocol()
throws NoSuchAlgorithmException, NoSuchProviderException {
if (!DEFSupported) fail(NotSupportMsg);
SSLContextSpi spi = new MySSLContextSpi();
SSLContext sslContext = new MySslContext(spi, defaultProvider,
defaultProtocol);
assertEquals("Incorrect protocol",
defaultProtocol, sslContext.getProtocol());
sslContext = new MySslContext(spi, defaultProvider,
null);
assertNull("Incorrect protocol", sslContext.getProtocol());
sslContext = SSLContext.getInstance(defaultProtocol);
assertEquals("Incorrect protocol",
defaultProtocol, sslContext.getProtocol());
sslContext = SSLContext.getInstance(defaultProtocol, defaultProvider);
assertEquals("Incorrect protocol",
defaultProtocol, sslContext.getProtocol());
sslContext = SSLContext.getInstance(defaultProtocol, defaultProviderName);
assertEquals("Incorrect protocol",
defaultProtocol, sslContext.getProtocol());
}
示例6: getX509TrustManager
import javax.net.ssl.SSLContextSpi; //导入依赖的package包/类
private X509TrustManager getX509TrustManager(
Lookup<ConnectionSocketFactory> socketFactoryRegistry) {
ConnectionSocketFactory connectionSocketFactory = socketFactoryRegistry
.lookup("https");
SSLSocketFactory sslSocketFactory = getField(connectionSocketFactory,
"socketfactory");
SSLContextSpi sslContext = getField(sslSocketFactory, "context");
return getField(sslContext, "trustManager");
}
开发者ID:spring-cloud,项目名称:spring-cloud-commons,代码行数:10,代码来源:DefaultApacheHttpClientConnectionManagerFactoryTests.java
示例7: newPreferredSSLContextSpi
import javax.net.ssl.SSLContextSpi; //导入依赖的package包/类
/**
* Constructs a new instance of the preferred {@link SSLContextSpi}.
*/
public static SSLContextSpi newPreferredSSLContextSpi() {
checkAvailability();
return OpenSSLContextImpl.getPreferred();
}
示例8: TealessSSLContext
import javax.net.ssl.SSLContextSpi; //导入依赖的package包/类
TealessSSLContext(SSLContextSpi sslContextSpi, Provider provider, String s) {
super(sslContextSpi, provider, s);
}
示例9: create
import javax.net.ssl.SSLContextSpi; //导入依赖的package包/类
public static SSLContext create(SSLContextSpi sslContextSpi, Provider provider, String s) {
return new TealessSSLContext(sslContextSpi, provider, s);
}
示例10: if
import javax.net.ssl.SSLContextSpi; //导入依赖的package包/类
/**
* @throws NoSuchAlgorithmException
* @throws KeyStoreException
* @throws FileNotFoundException
* @throws KeyManagementException
* @tests javax.net.ssl.SSLContext#
* init(javax.net.ssl.KeyManager[], javax.net.ssl.TrustManager[],
* java.security.SecureRandom)
*/
@TestTargetNew(
level = TestLevel.COMPLETE,
notes = "",
method = "init",
args = {javax.net.ssl.KeyManager[].class, javax.net.ssl.TrustManager[].class, java.security.SecureRandom.class}
)
public void test_init$Ljavax_net_ssl_KeyManager$Ljavax_net_ssl_TrustManagerLjava_security_SecureRandom()
throws Exception {
if (!DEFSupported) fail(NotSupportMsg);
SSLContextSpi spi = new MySSLContextSpi();
SSLContext sslContext = new MySslContext(spi, defaultProvider,
defaultProtocol);
try {
sslContext.createSSLEngine();
fail("Expected RuntimeException was not thrown");
} catch (RuntimeException rte) {
// expected
}
try {
sslContext.init(null, null, null);
fail("KeyManagementException wasn't thrown");
} catch (KeyManagementException kme) {
//expected
}
try {
String tAlg = TrustManagerFactory.getDefaultAlgorithm();
String kAlg = KeyManagerFactory.getDefaultAlgorithm();
if (tAlg == null)
fail("TrustManagerFactory default algorithm is not defined");
if (kAlg == null)
fail("KeyManagerFactory default algorithm is not defined");
KeyManagerFactory kmf = KeyManagerFactory.getInstance(kAlg);
kmf.init(null, new char[11]);
TrustManagerFactory tmf = TrustManagerFactory.getInstance(tAlg);
KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
tmf.init(ks);
TrustManager[] tms = tmf.getTrustManagers();
sslContext.init(kmf.getKeyManagers(), tms, new SecureRandom());
} catch (Exception e) {
System.out.println("EE = " + e);
}
}
示例11: MySslContext
import javax.net.ssl.SSLContextSpi; //导入依赖的package包/类
public MySslContext(SSLContextSpi spi, Provider prov, String alg) {
super(spi, prov, alg);
}
示例12: MySSLContext
import javax.net.ssl.SSLContextSpi; //导入依赖的package包/类
public MySSLContext(SSLContextSpi spi, Provider prov, String alg) {
super(spi, prov, alg);
}
示例13: getX509TrustManager
import javax.net.ssl.SSLContextSpi; //导入依赖的package包/类
private X509TrustManager getX509TrustManager(Lookup<ConnectionSocketFactory> socketFactoryRegistry) {
ConnectionSocketFactory connectionSocketFactory = (ConnectionSocketFactory)socketFactoryRegistry.lookup("https");
SSLSocketFactory sslSocketFactory = (SSLSocketFactory)this.getField(connectionSocketFactory, "socketfactory");
SSLContextSpi sslContext = (SSLContextSpi)this.getField(sslSocketFactory, "context");
return (X509TrustManager)this.getField(sslContext, "trustManager");
}
示例14: mySSLContext
import javax.net.ssl.SSLContextSpi; //导入依赖的package包/类
public mySSLContext(SSLContextSpi spi, Provider prov, String alg) {
super(spi, prov, alg);
}