本文整理汇总了Java中javax.net.ssl.SSLServerSocket.setSoTimeout方法的典型用法代码示例。如果您正苦于以下问题:Java SSLServerSocket.setSoTimeout方法的具体用法?Java SSLServerSocket.setSoTimeout怎么用?Java SSLServerSocket.setSoTimeout使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.net.ssl.SSLServerSocket
的用法示例。
在下文中一共展示了SSLServerSocket.setSoTimeout方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configureServerSocket
import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
/**
* Set the server socket configuration to our required
* QOS values.
*
* A small experiment shows that setting either (want, need) parameter to either true or false sets the
* other parameter to false.
*
* @param serverSocket
* The newly created SSLServerSocket.
*
* @throws IOException if server socket can't be configured
*/
private void configureServerSocket(SSLServerSocket serverSocket) throws IOException {
// set the authentication value and cipher suite info.
serverSocket.setEnabledCipherSuites(cipherSuites);
if (clientAuthRequired) {
serverSocket.setNeedClientAuth(true);
} else if (clientAuthSupported) {
serverSocket.setWantClientAuth(true);
} else {
serverSocket.setNeedClientAuth(false); //could set want with the same effect
}
serverSocket.setSoTimeout(SOCKET_TIMEOUT_MS);
if (log.isDebugEnabled()) {
log.debug("Created SSL server socket on port " + serverSocket.getLocalPort());
log.debug(" client authentication " + (clientAuthSupported ? "SUPPORTED" : "UNSUPPORTED"));
log.debug(" client authentication " + (clientAuthRequired ? "REQUIRED" : "OPTIONAL"));
log.debug(" cipher suites:");
for (int i = 0; i < cipherSuites.length; i++) {
log.debug(" " + cipherSuites[i]);
}
}
}
示例2: JSSEServer
import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
public JSSEServer(SSLContext context, String constraint,
boolean needClientAuth) throws Exception {
TLSRestrictions.setConstraint("Server", constraint);
SSLServerSocketFactory serverFactory = context.getServerSocketFactory();
server = (SSLServerSocket) serverFactory.createServerSocket(0);
server.setSoTimeout(TLSRestrictions.TIMEOUT);
server.setNeedClientAuth(needClientAuth); // for dual authentication
System.out.println("Server: port=" + getPort());
}
示例3: JSSEServer
import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
JSSEServer(CipherTest cipherTest) throws Exception {
super(cipherTest);
SSLContext serverContext = SSLContext.getInstance("TLS");
serverContext.init(
new KeyManager[] { CipherTest.keyManager },
new TrustManager[] { CipherTest.trustManager },
CipherTest.secureRandom);
SSLServerSocketFactory factory = (SSLServerSocketFactory)serverContext.getServerSocketFactory();
serverSocket = (SSLServerSocket)factory.createServerSocket(0);
serverSocket.setSoTimeout(CipherTest.TIMEOUT);
CipherTest.serverPort = serverSocket.getLocalPort();
serverSocket.setEnabledCipherSuites(factory.getSupportedCipherSuites());
serverSocket.setWantClientAuth(true);
}
示例4: JSSEServer
import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
public JSSEServer(SSLContext context,
boolean needClientAuth) throws Exception {
SSLServerSocketFactory serverFactory = context.getServerSocketFactory();
server = (SSLServerSocket) serverFactory.createServerSocket(0);
server.setSoTimeout(TLSRestrictions.TIMEOUT);
server.setNeedClientAuth(needClientAuth); // for dual authentication
System.out.println("Server: port=" + getPort());
}
示例5: createServer
import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
private static TServerSocket createServer(SSLServerSocketFactory factory, int port, int timeout, boolean clientAuth,
InetAddress ifAddress, TSSLTransportParameters params) throws TTransportException {
try {
SSLServerSocket serverSocket = (SSLServerSocket) factory.createServerSocket(port, 100, ifAddress);
serverSocket.setSoTimeout(timeout);
serverSocket.setNeedClientAuth(clientAuth);
if (params != null && params.cipherSuites != null) {
serverSocket.setEnabledCipherSuites(params.cipherSuites);
}
return new TServerSocket(new TServerSocket.ServerSocketTransportArgs().
serverSocket(serverSocket).clientTimeout(timeout));
} catch (Exception e) {
throw new TTransportException("Could not bind to port " + port, e);
}
}
示例6: HTTPServer
import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
/**
* Creates an HTTP Server based on the parameters
* This class extends Thread
* @param root
* @param portNumber
* @param ssl
* @param sslFile
* @param sslPass
* @throws IOException
*/
public HTTPServer(String root,int portNumber,boolean ssl,String sslFile,String sslPass) throws IOException{
this.root = root;
this.ssl = ssl;
run = true;
// create the server's socket
if(ssl){
/*
SSL stuff
*/
try{
String password = sslPass;
String keystore = sslFile;
/* Create keystore */
KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
keyStore.load(new FileInputStream(keystore), password.toCharArray());
/* Get factory for the given keystore */
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
tmf.init(keyStore);
SSLContext ctx = SSLContext.getInstance("SSL");
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
kmf.init(keyStore, password.toCharArray());
// ...
ctx.init(kmf.getKeyManagers(), null, null);
SSLServerSocketFactory factory = ctx.getServerSocketFactory();
serverSocket = (SSLServerSocket) factory.createServerSocket(portNumber);
}catch(Exception e){e.printStackTrace();}
}else{
// create the server socket and a timeout
serverSocket = new ServerSocket(portNumber);
serverSocket.setSoTimeout(15000);
}
}
示例7: createServer
import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
private static TServerSocket createServer(SSLServerSocketFactory factory, int port, int timeout, boolean clientAuth,
InetAddress ifAddress, TSSLTransportParameters params) throws TTransportException {
try {
SSLServerSocket serverSocket = (SSLServerSocket) factory.createServerSocket(port, 100, ifAddress);
serverSocket.setSoTimeout(timeout);
serverSocket.setNeedClientAuth(clientAuth);
if (params != null && params.cipherSuites != null) {
serverSocket.setEnabledCipherSuites(params.cipherSuites);
}
return new TServerSocket(serverSocket, timeout);
} catch (Exception e) {
throw new TTransportException("Could not bind to port " + port, e);
}
}