Example usage for javax.net.ssl SSLServerSocket setEnabledCipherSuites

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

Introduction

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

Prototype

public abstract void setEnabledCipherSuites(String suites[]);

Source Link

Document

Sets the cipher suites enabled for use by accepted connections.

Usage

From source file:org.wso2.carbon.databridge.receiver.binary.BinaryDataReceiver.java

private void startSecureTransmission() throws IOException, DataBridgeException {
    ServerConfiguration serverConfig = ServerConfiguration.getInstance();
    String keyStore = serverConfig.getFirstProperty("Security.KeyStore.Location");
    if (keyStore == null) {
        keyStore = System.getProperty("Security.KeyStore.Location");
        if (keyStore == null) {
            throw new DataBridgeException(
                    "Cannot start agent server, not valid Security.KeyStore.Location is null");
        }//from  w w w .j  ava2  s .  c  om
    }
    String keyStorePassword = serverConfig.getFirstProperty("Security.KeyStore.Password");
    if (keyStorePassword == null) {
        keyStorePassword = System.getProperty("Security.KeyStore.Password");
        if (keyStorePassword == null) {
            throw new DataBridgeException(
                    "Cannot start agent server, not valid Security.KeyStore.Password is null ");
        }
    }
    System.setProperty("javax.net.ssl.keyStore", keyStore);
    System.setProperty("javax.net.ssl.keyStorePassword", keyStorePassword);
    SSLServerSocketFactory sslserversocketfactory = (SSLServerSocketFactory) SSLServerSocketFactory
            .getDefault();
    SSLServerSocket sslserversocket = (SSLServerSocket) sslserversocketfactory
            .createServerSocket(binaryDataReceiverConfiguration.getSSLPort());
    sslserversocket.setEnabledCipherSuites(sslserversocket.getSupportedCipherSuites());
    for (int i = 0; i < binaryDataReceiverConfiguration.getSizeOfSSLThreadPool(); i++) {
        sslReceiverExecutorService.execute(new BinaryTransportReceiver(sslserversocket));
    }
    log.info("Started Binary SSL Transport on port : " + binaryDataReceiverConfiguration.getSSLPort());
}

From source file:org.wso2.carbon.databridge.receiver.binary.internal.BinaryDataReceiver.java

private void startSecureTransmission() throws IOException, DataBridgeException {
    String keyStore = dataBridgeReceiverService.getInitialConfig().getKeyStoreLocation();
    if (keyStore == null) {
        ServerConfiguration serverConfig = ServerConfiguration.getInstance();
        keyStore = serverConfig.getFirstProperty("Security.KeyStore.Location");
        if (keyStore == null) {
            keyStore = System.getProperty("Security.KeyStore.Location");
            if (keyStore == null) {
                throw new DataBridgeException(
                        "Cannot start binary agent server, not valid Security.KeyStore.Location is null");
            }//from  ww w. ja v  a 2s .  c o  m
        }
    }
    String keyStorePassword = dataBridgeReceiverService.getInitialConfig().getKeyStorePassword();
    if (keyStorePassword == null) {
        ServerConfiguration serverConfig = ServerConfiguration.getInstance();
        keyStorePassword = serverConfig.getFirstProperty("Security.KeyStore.Password");
        if (keyStorePassword == null) {
            keyStorePassword = System.getProperty("Security.KeyStore.Password");
            if (keyStorePassword == null) {
                throw new DataBridgeException(
                        "Cannot start binary agent server, not valid Security.KeyStore.Password is null ");
            }
        }
    }
    System.setProperty("javax.net.ssl.keyStore", keyStore);
    System.setProperty("javax.net.ssl.keyStorePassword", keyStorePassword);
    SSLServerSocketFactory sslserversocketfactory = (SSLServerSocketFactory) SSLServerSocketFactory
            .getDefault();
    SSLServerSocket sslserversocket = (SSLServerSocket) sslserversocketfactory
            .createServerSocket(binaryDataReceiverConfiguration.getSSLPort());

    String sslProtocols = binaryDataReceiverConfiguration.getSslProtocols();
    if (sslProtocols != null && sslProtocols.length() != 0) {
        String[] sslProtocolsArray = sslProtocols.split(",");
        sslserversocket.setEnabledProtocols(sslProtocolsArray);
    }

    String ciphers = binaryDataReceiverConfiguration.getCiphers();
    if (ciphers != null && ciphers.length() != 0) {
        String[] ciphersArray = ciphers.split(",");
        sslserversocket.setEnabledCipherSuites(ciphersArray);
    } else {
        sslserversocket.setEnabledCipherSuites(sslserversocket.getSupportedCipherSuites());
    }

    Thread thread = new Thread(new BinarySecureEventServerAcceptor(sslserversocket));
    thread.start();
    log.info("Started Binary SSL Transport on port : " + binaryDataReceiverConfiguration.getSSLPort());
}

From source file:org.wso2.carbon.databridge.receiver.thrift.ThriftDataReceiver.java

protected void startSecureEventTransmission(String hostName, int port, String sslProtocols, String ciphers,
        String keyStore, String keyStorePassword, DataBridgeReceiverService dataBridgeReceiverService)
        throws TransportException, UnknownHostException {
    TSSLTransportFactory.TSSLTransportParameters params = new TSSLTransportFactory.TSSLTransportParameters();
    params.setKeyStore(keyStore, keyStorePassword);

    TServerSocket serverTransport;/*w  w w  .  j  av  a 2s  .com*/
    try {
        InetAddress inetAddress = InetAddress.getByName(hostName);
        serverTransport = TSSLTransportFactory.getServerSocket(port, DataBridgeConstants.CLIENT_TIMEOUT_MS,
                inetAddress, params);
        SSLServerSocket sslServerSocket = (javax.net.ssl.SSLServerSocket) serverTransport.getServerSocket();
        if (sslProtocols != null && sslProtocols.length() != 0) {
            String[] sslProtocolsArray = sslProtocols.split(",");
            sslServerSocket.setEnabledProtocols(sslProtocolsArray);
        }

        if (ciphers != null && ciphers.length() != 0) {
            String[] ciphersArray = ciphers.split(",");
            sslServerSocket.setEnabledCipherSuites(ciphersArray);
        }

        log.info("Thrift Server started at " + hostName);
    } catch (TTransportException e) {
        throw new TransportException("Thrift transport exception occurred ", e);
    }

    ThriftSecureEventTransmissionService.Processor<ThriftSecureEventTransmissionServiceImpl> processor = new ThriftSecureEventTransmissionService.Processor<ThriftSecureEventTransmissionServiceImpl>(
            new ThriftSecureEventTransmissionServiceImpl(dataBridgeReceiverService));
    authenticationServer = new TThreadPoolServer(
            new TThreadPoolServer.Args(serverTransport).processor(processor));
    Thread thread = new Thread(new ServerThread(authenticationServer));
    log.info("Thrift SSL port : " + port);
    thread.start();
}