Example usage for javax.net.ssl SSLServerSocket setEnableSessionCreation

List of usage examples for javax.net.ssl SSLServerSocket setEnableSessionCreation

Introduction

In this page you can find the example usage for javax.net.ssl SSLServerSocket setEnableSessionCreation.

Prototype

public abstract void setEnableSessionCreation(boolean flag);

Source Link

Document

Controls whether new SSL sessions may be established by the sockets which are created from this server socket.

Usage

From source file:org.apache.geode.internal.net.SocketCreator.java

/**
 * Configure the SSLServerSocket based on this SocketCreator's settings.
 *///w w w.ja v a2 s  . c  o m
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);
    }
}

From source file:org.jgentleframework.utils.network.sockets.SSLSocketTools.java

/**
 * Creates the server socket.//from  w ww .jav a2  s . co  m
 * 
 * @param port
 *            the port
 * @param cipherSuites
 *            the cipher suites
 * @return the sSL server socket
 */
public SSLServerSocket createServerSocket(int port, SSLCipherSuites[] cipherSuites) {

    SSLServerSocket returnValue = null;
    try {
        java.security.Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
        SSLServerSocketFactory socketFactory = (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
        returnValue = (SSLServerSocket) socketFactory.createServerSocket(port);
        String[] CIPHERS = new String[cipherSuites.length];
        for (int i = 0; i < cipherSuites.length; i++) {
            CIPHERS[i] = cipherSuites[i].name();
        }
        returnValue.setEnabledCipherSuites(CIPHERS);
        returnValue.setEnableSessionCreation(true);
        return returnValue;
    } catch (IOException e) {
        if (log.isFatalEnabled()) {
            log.fatal("Could not create SSL server socket !!", e);
        }
    }
    return returnValue;
}