package javax.net.ssl;
import java.io.IOException;
import java.security.KeyManagementException;
import java.security.SecureRandom;
/**
* The <i>Service Provider Interface</i> (SPI) for the {@code SSLContext} class.
*/
public abstract class SSLContextSpi {
/**
* Creates a new {@code SSLContextSpi} instance.
*/
public SSLContextSpi() {
super();
}
/**
* Initializes this {@code SSLContext} instance. All of the arguments are
* optional, and the security providers will be searched for the required
* implementations of the needed algorithms.
*
* @param km
* the key sources or {@code null}.
* @param tm
* the trust decision sources or {@code null}.
* @param sr
* the randomness source or {@code null.}
* @throws KeyManagementException
* if initializing this instance fails.
*/
protected abstract void engineInit(KeyManager[] km, TrustManager[] tm, SecureRandom sr)
throws KeyManagementException;
/**
* Returns a socket factory for this instance.
*
* @return a socket factory for this instance.
*/
protected abstract SSLSocketFactory engineGetSocketFactory();
/**
* Returns a server socket factory for this instance.
*
* @return a server socket factory for this instance.
*/
protected abstract SSLServerSocketFactory engineGetServerSocketFactory();
/**
* Creates an {@code SSLEngine} instance from this context with the
* specified hostname and port.
*
* @param host
* the name of the host
* @param port
* the port
* @return an {@code SSLEngine} instance from this context.
* @throws UnsupportedOperationException
* if the provider does not support the operation.
*/
protected abstract SSLEngine engineCreateSSLEngine(String host, int port);
/**
* Creates an {@code SSLEngine} instance from this context.
*
* @return an {@code SSLEngine} instance from this context.
* @throws UnsupportedOperationException
* if the provider does not support the operation.
*/
protected abstract SSLEngine engineCreateSSLEngine();
/**
* Returns the SSL session context that encapsulates the set of SSL sessions
* that can be used for the server side of the SSL handshake.
*
* @return the SSL server session context for this context or {@code null}
* if the underlying provider does not provide an implementation of
* the {@code SSLSessionContext} interface.
*/
protected abstract SSLSessionContext engineGetServerSessionContext();
/**
* Returns the SSL session context that encapsulates the set of SSL sessions
* that can be used for the client side of the SSL handshake.
*
* @return the SSL client session context for this context or {@code null}
* if the underlying provider does not provide an implementation of
* the {@code SSLSessionContext} interface.
*/
protected abstract SSLSessionContext engineGetClientSessionContext();
/**
* Returns a new SSLParameters instance that includes the default
* SSL handshake parameters values including cipher suites,
* protocols, and client authentication.
*
* <p>The default implementation returns an SSLParameters with values
* based an SSLSocket created from this instances SocketFactory.
*
* @since 1.6
*/
protected javax.net.ssl.SSLParameters engineGetDefaultSSLParameters() {
return createSSLParameters(false);
}
/**
* Returns a new SSLParameters instance that includes all
* supported cipher suites and protocols.
*
* <p>The default implementation returns an SSLParameters with values
* based an SSLSocket created from this instances SocketFactory.
*
* @since 1.6
*/
protected javax.net.ssl.SSLParameters engineGetSupportedSSLParameters() {
return createSSLParameters(true);
}
private javax.net.ssl.SSLParameters createSSLParameters(boolean supported) {
try {
SSLSocket s = (SSLSocket) engineGetSocketFactory().createSocket();
javax.net.ssl.SSLParameters p = new javax.net.ssl.SSLParameters();
String[] cipherSuites;
String[] protocols;
if (supported) {
cipherSuites = s.getSupportedCipherSuites();
protocols = s.getSupportedProtocols();
} else {
cipherSuites = s.getEnabledCipherSuites();
protocols = s.getEnabledProtocols();
}
p.setCipherSuites(cipherSuites);
p.setProtocols(protocols);
p.setNeedClientAuth(s.getNeedClientAuth());
p.setWantClientAuth(s.getWantClientAuth());
return p;
} catch (IOException e) {
/*
* SSLContext.getDefaultSSLParameters specifies to throw
* UnsupportedOperationException if there is a problem getting the
* parameters
*/
throw new UnsupportedOperationException("Could not access supported SSL parameters");
}
}
}
SSLContextSpi.rar_The Class
版权申诉
167 浏览量
2022-09-19
20:47:11
上传
评论
收藏 1KB RAR 举报
weixin_42653672
- 粉丝: 93
- 资源: 1万+
最新资源
- python-3.9.7-macosx10.9.pkg
- Last Loaded 模拟时钟.DBK
- 弱电系统方案设计安防监控技术资料门禁网络工程图纸报价资料图纸案例经典典藏:二十八层宾馆大楼全套电气施工图纸(54张)
- 2024智能云服务交付工程师(战新业务补充认真)理论考试题库含答案
- 弱电系统方案设计安防监控技术资料门禁网络工程图纸报价资料图纸案例经典的标准厂房水电图两套(参考用)
- 企业级网络安全治理全景架构图
- QColorPicker
- 弱电系统方案设计安防监控技术资料门禁网络工程图纸报价资料图纸案例江苏体育中心一期项目大型游泳馆(含负荷计算书)
- -sogou-pinyin-Release-13.8.0.8160-1111.exe
- 弱电系统方案设计安防监控技术资料门禁网络工程图纸报价资料图纸案例江苏省某档案馆防雷计算书
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈