List of usage examples for javax.net.ssl SSLServerSocket setEnabledProtocols
public abstract void setEnabledProtocols(String protocols[]);
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 w w w. j a v a2 s . co 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;/*from ww w .ja v a 2 s . c o m*/ 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(); }