本文整理汇总了Java中javax.net.ssl.SSLServerSocket.setEnableSessionCreation方法的典型用法代码示例。如果您正苦于以下问题:Java SSLServerSocket.setEnableSessionCreation方法的具体用法?Java SSLServerSocket.setEnableSessionCreation怎么用?Java SSLServerSocket.setEnableSessionCreation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.net.ssl.SSLServerSocket
的用法示例。
在下文中一共展示了SSLServerSocket.setEnableSessionCreation方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: finishServerSocket
import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
/**
* Configure the SSLServerSocket based on this SocketCreator's settings.
*/
private void finishServerSocket(SSLServerSocket serverSocket) throws IOException {
serverSocket.setUseClientMode(false);
if (this.sslConfig.isRequireAuth()) {
// serverSocket.setWantClientAuth( true );
serverSocket.setNeedClientAuth(true);
}
serverSocket.setEnableSessionCreation(true);
// restrict protocols
String[] protocols = this.sslConfig.getProtocolsAsStringArray();
if (!"any".equalsIgnoreCase(protocols[0])) {
serverSocket.setEnabledProtocols(protocols);
}
// restrict ciphers
String[] ciphers = this.sslConfig.getCiphersAsStringArray();
if (!"any".equalsIgnoreCase(ciphers[0])) {
serverSocket.setEnabledCipherSuites(ciphers);
}
}
示例2: test_EnableSessionCreation
import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
/**
* @throws IOException
* @tests javax.net.ssl.SSLServerSocket#setEnableSessionCreation(boolean flag)
* @tests javax.net.ssl.SSLServerSocket#getEnableSessionCreation()
*/
@TestTargets({
@TestTargetNew(
level = TestLevel.COMPLETE,
notes = "",
method = "getEnableSessionCreation",
args = {}
),
@TestTargetNew(
level = TestLevel.COMPLETE,
notes = "",
method = "setEnableSessionCreation",
args = {boolean.class}
)
})
public void test_EnableSessionCreation() throws Exception {
SSLServerSocket sss = getSSLServerSocket();
assertTrue(sss.getEnableSessionCreation());
sss.setEnableSessionCreation(false);
assertFalse(sss.getEnableSessionCreation());
sss.setEnableSessionCreation(true);
assertTrue(sss.getEnableSessionCreation());
}
示例3: getServerSocket
import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
/**
* Gets a server socket - this gets as SSL socket instead of the standard
* socket returned in the base class.
*/
@Override
protected ServerSocket getServerSocket() throws IOException {
// Just to make sure it's set before we start
final SSLContext context = getSSLContext();
final SSLServerSocketFactory factory = context.getServerSocketFactory();
final SSLServerSocket ss = (SSLServerSocket) (listenAddress == null ? factory.createServerSocket(listenPort, HttpListener.BACKLOG_COUNT) : factory.createServerSocket(listenPort, HttpListener.BACKLOG_COUNT,
InetAddress.getByName(listenAddress)));
ss.setEnableSessionCreation(Boolean.TRUE);
if (performClientAuth) {
ss.setNeedClientAuth(Boolean.TRUE);
}
return ss;
}
示例4: testSetGetEnableSessionCreation
import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
/**
* setEnableSessionCreation(boolean flag) method testing.
* getEnableSessionCreation() method testing.
*/
public void testSetGetEnableSessionCreation() throws Exception {
SSLServerSocket ssocket = createSSLServerSocket();
ssocket.setEnableSessionCreation(false);
assertFalse("Result does not correspond to expected",
ssocket.getEnableSessionCreation());
ssocket.setEnableSessionCreation(true);
assertTrue("Result does not correspond to expected",
ssocket.getEnableSessionCreation());
}