use of javax.net.ssl.SSLServerSocketFactory in project wildfly by wildfly.
the class LegacySSLSocketFactory method createSSLServerSocket.
public ServerSocket createSSLServerSocket(int port, int backlog, InetAddress inetAddress) throws IOException {
this.initSSLContext();
SSLServerSocketFactory serverSocketFactory = this.sslContext.getServerSocketFactory();
SSLServerSocket serverSocket = (SSLServerSocket) serverSocketFactory.createServerSocket(port, backlog, inetAddress);
if (this.jsseSecurityDomain.getProtocols() != null) {
serverSocket.setEnabledProtocols(this.jsseSecurityDomain.getProtocols());
}
if (this.jsseSecurityDomain.getCipherSuites() != null) {
serverSocket.setEnabledCipherSuites(this.jsseSecurityDomain.getCipherSuites());
}
if (this.jsseSecurityDomain.isClientAuth() || this.require_mutual_auth) {
serverSocket.setNeedClientAuth(true);
} else {
serverSocket.setWantClientAuth(this.request_mutual_auth);
}
return serverSocket;
}
use of javax.net.ssl.SSLServerSocketFactory in project karaf by apache.
the class ConnectorServerFactory method setupSsl.
private void setupSsl() throws GeneralSecurityException {
SSLServerSocketFactory sssf = keystoreManager.createSSLServerFactory(null, secureProtocol, algorithm, keyStore, keyAlias, trustStore, keyStoreAvailabilityTimeout);
RMIServerSocketFactory rssf = new KarafSslRMIServerSocketFactory(sssf, this.isClientAuth(), getRmiServerHost());
RMIClientSocketFactory rcsf = new SslRMIClientSocketFactory();
environment.put(RMIConnectorServer.RMI_SERVER_SOCKET_FACTORY_ATTRIBUTE, rssf);
environment.put(RMIConnectorServer.RMI_CLIENT_SOCKET_FACTORY_ATTRIBUTE, rcsf);
//@TODO secure RMI connector as well?
//env.put("com.sun.jndi.rmi.factory.socket", rcsf);
}
use of javax.net.ssl.SSLServerSocketFactory in project robovm by robovm.
the class SSLContextSpiTest method test_commonTest_01.
/**
* SSLContextSpi#engineGetClientSessionContext()
* SSLContextSpi#engineGetServerSessionContext()
* SSLContextSpi#engineGetServerSocketFactory()
* SSLContextSpi#engineGetSocketFactory()
* Verify exception when SSLContextSpi object wasn't initialiazed.
*/
public void test_commonTest_01() {
SSLContextSpiImpl ssl = new SSLContextSpiImpl();
try {
SSLSessionContext slsc = ssl.engineGetClientSessionContext();
fail("RuntimeException wasn't thrown");
} catch (RuntimeException re) {
String str = re.getMessage();
if (!str.equals("Not initialiazed"))
fail("Incorrect exception message: " + str);
} catch (Exception e) {
fail("Incorrect exception " + e + " was thrown");
}
try {
SSLSessionContext slsc = ssl.engineGetServerSessionContext();
fail("RuntimeException wasn't thrown");
} catch (RuntimeException re) {
String str = re.getMessage();
if (!str.equals("Not initialiazed"))
fail("Incorrect exception message: " + str);
} catch (Exception e) {
fail("Incorrect exception " + e + " was thrown");
}
try {
SSLServerSocketFactory sssf = ssl.engineGetServerSocketFactory();
fail("RuntimeException wasn't thrown");
} catch (RuntimeException re) {
String str = re.getMessage();
if (!str.equals("Not initialiazed"))
fail("Incorrect exception message: " + str);
} catch (Exception e) {
fail("Incorrect exception " + e + " was thrown");
}
try {
SSLSocketFactory ssf = ssl.engineGetSocketFactory();
fail("RuntimeException wasn't thrown");
} catch (RuntimeException re) {
String str = re.getMessage();
if (!str.equals("Not initialiazed"))
fail("Incorrect exception message: " + str);
} catch (Exception e) {
fail("Incorrect exception " + e + " was thrown");
}
}
use of javax.net.ssl.SSLServerSocketFactory in project Payara by payara.
the class IIOPSSLSocketFactory method createSSLServerSocket.
// ----- END implements com.sun.corba.ee.spi.transport.ORBSocketFactory -----
/**
* Create an SSL server socket at the specified InetSocketAddress. If the type
* is SSL_MUTUALAUTH then SSL client authentication is requested.
*/
private ServerSocket createSSLServerSocket(String type, InetSocketAddress inetSocketAddress) throws IOException {
if (inetSocketAddress == null) {
throw new IOException(getFormatMessage("iiop.invalid_sslserverport", new Object[] { null }));
}
int port = inetSocketAddress.getPort();
Integer iport = Integer.valueOf(port);
SSLInfo sslInfo = (SSLInfo) portToSSLInfo.get(iport);
if (sslInfo == null) {
throw new IOException(getFormatMessage("iiop.invalid_sslserverport", new Object[] { iport }));
}
SSLServerSocketFactory ssf = sslInfo.getContext().getServerSocketFactory();
String[] ssl3TlsCiphers = sslInfo.getSsl3TlsCiphers();
String[] ssl2Ciphers = sslInfo.getSsl2Ciphers();
String[] ciphers = null;
if (ssl3TlsCiphers != null || ssl2Ciphers != null) {
String[] socketCiphers = ssf.getDefaultCipherSuites();
ciphers = mergeCiphers(socketCiphers, ssl3TlsCiphers, ssl2Ciphers);
}
String[] cs = null;
if (_logger.isLoggable(Level.FINE)) {
cs = ssf.getSupportedCipherSuites();
for (int i = 0; i < cs.length; ++i) {
_logger.log(Level.FINE, "Cipher Suite: " + cs[i]);
}
}
ServerSocket ss = null;
try {
// bugfix for 6349541
// specify the ip address to bind to, 50 is the default used
// by the ssf implementation when only the port is specified
ss = ssf.createServerSocket(port, BACKLOG, inetSocketAddress.getAddress());
if (ciphers != null) {
((SSLServerSocket) ss).setEnabledCipherSuites(ciphers);
}
} catch (IOException e) {
_logger.log(Level.SEVERE, "iiop.createsocket_exception", new Object[] { type, String.valueOf(port) });
_logger.log(Level.SEVERE, "", e);
throw e;
}
try {
if (type.equals(SSL_MUTUALAUTH)) {
_logger.log(Level.FINE, "Setting Mutual auth");
((SSLServerSocket) ss).setNeedClientAuth(true);
}
} catch (Exception e) {
_logger.log(Level.SEVERE, "iiop.cipher_exception", e);
throw new IOException(e.getMessage());
}
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "Created server socket:" + ss);
}
return ss;
}
use of javax.net.ssl.SSLServerSocketFactory in project engineblock by engineblock.
the class TCPServerActivity method createPrintWriter.
@Override
protected synchronized Writer createPrintWriter() {
String host = getActivityDef().getParams().getOptionalString("host").orElse("localhost");
int port = getActivityDef().getParams().getOptionalInteger("port").orElse(12345);
if (listenerSocket == null || listenerSocket.isClosed()) {
try {
InetAddress hostAddr = InetAddress.getByName(host);
listenerSocket = socketFactory.createServerSocket(port, 10, hostAddr);
if (socketFactory instanceof SSLServerSocketFactory) {
logger.info("SSL enabled on server socket " + listenerSocket);
}
SocketAcceptor socketAcceptor = new SocketAcceptor(queue, listenerSocket);
managedShutdown.add(socketAcceptor);
Thread acceptorThread = new Thread(socketAcceptor);
acceptorThread.setDaemon(true);
acceptorThread.setName("Listener/" + listenerSocket);
acceptorThread.start();
} catch (IOException e) {
throw new RuntimeException("Error listening on listenerSocket:" + e, e);
}
}
QueueWriterAdapter queueWriterAdapter = new QueueWriterAdapter(this.queue);
logger.info("initialized queue writer:" + queueWriterAdapter);
return queueWriterAdapter;
}
Aggregations