use of javax.net.ssl.SSLServerSocket in project robovm by robovm.
the class SSLServerSocketTest method test_getSupportedCipherSuites.
/**
* @throws Exception
* javax.net.ssl.SSLServerSocket#getSupportedCipherSuites()
*/
public void test_getSupportedCipherSuites() throws Exception {
SSLServerSocket sss = getSSLServerSocket();
String[] res = sss.getSupportedCipherSuites();
assertNotNull("NULL result", res);
assertTrue("no supported cipher suites available.", res.length > 0);
}
use of javax.net.ssl.SSLServerSocket in project cloudstack by apache.
the class ConsoleProxySecureServerFactoryImpl method createSSLServerSocket.
@Override
public SSLServerSocket createSSLServerSocket(int port) throws IOException {
try {
SSLServerSocket srvSock = null;
SSLServerSocketFactory ssf = sslContext.getServerSocketFactory();
srvSock = (SSLServerSocket) ssf.createServerSocket(port);
srvSock.setEnabledProtocols(SSLUtils.getSupportedProtocols(srvSock.getEnabledProtocols()));
s_logger.info("create SSL server socket on port: " + port);
return srvSock;
} catch (Exception ioe) {
s_logger.error(ioe.toString(), ioe);
}
return null;
}
use of javax.net.ssl.SSLServerSocket in project jdk8u_jdk by JetBrains.
the class SSLEchoServer method init.
/*
* Creates server instance.
*
* @param cipherSuiteFilter Filter for enabled cipher suites
* @param sniMatcherPattern Pattern for SNI server hame
*/
static SSLEchoServer init(String cipherSuiteFilter, String sniPattern) throws NoSuchAlgorithmException, IOException {
SSLContext context = SSLContext.getDefault();
SSLServerSocketFactory ssf = (SSLServerSocketFactory) context.getServerSocketFactory();
SSLServerSocket ssocket = (SSLServerSocket) ssf.createServerSocket(0);
// specify enabled cipher suites
if (cipherSuiteFilter != null) {
String[] ciphersuites = UnboundSSLUtils.filterStringArray(ssf.getSupportedCipherSuites(), cipherSuiteFilter);
System.out.println("Server: enabled cipher suites: " + Arrays.toString(ciphersuites));
ssocket.setEnabledCipherSuites(ciphersuites);
}
// specify SNI matcher pattern
if (sniPattern != null) {
System.out.println("Server: set SNI matcher: " + sniPattern);
SNIMatcher matcher = SNIHostName.createSNIMatcher(sniPattern);
List<SNIMatcher> matchers = new ArrayList<>();
matchers.add(matcher);
SSLParameters params = ssocket.getSSLParameters();
params.setSNIMatchers(matchers);
ssocket.setSSLParameters(params);
}
return new SSLEchoServer(ssocket);
}
use of javax.net.ssl.SSLServerSocket in project jdk8u_jdk by JetBrains.
the class Timeout method main.
public static void main(String[] args) throws Exception {
// try {
SSLServerSocketFactory ssf = (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
SSLServerSocket ss = (SSLServerSocket) ssf.createServerSocket();
String[] protocols = ss.getSupportedProtocols();
for (int i = 0; i < protocols.length; i++) {
// try {
if (protocols[i].equals("SSLv2Hello")) {
continue;
}
SSLContext sslc = SSLContext.getInstance(protocols[i]);
SSLSessionContext sslsc = sslc.getServerSessionContext();
System.out.println("Protocol: " + protocols[i]);
sslsc.setSessionTimeout(Integer.MAX_VALUE);
int newtime = sslsc.getSessionTimeout();
if (newtime != Integer.MAX_VALUE) {
throw new Exception("Expected timeout: " + Integer.MAX_VALUE + ", got instead: " + newtime);
}
// } catch (Exception e) {
// }
}
// } catch (Exception e) {
// System.out.println(e);
// }
System.out.println("Finished");
}
use of javax.net.ssl.SSLServerSocket in project karaf by apache.
the class IntrospectionSupport method setProperty.
public static boolean setProperty(Object target, String name, Object value) {
try {
Class<?> clazz = target.getClass();
if (target instanceof SSLServerSocket) {
// overcome illegal access issues with internal implementation class
clazz = SSLServerSocket.class;
}
Method setter = findSetterMethod(clazz, name);
if (setter == null) {
return false;
}
// value directly
if (value == null || value.getClass() == setter.getParameterTypes()[0]) {
setter.invoke(target, value);
} else {
// We need to convert it
setter.invoke(target, convert(value, setter.getParameterTypes()[0]));
}
return true;
} catch (Exception e) {
LOG.error(String.format("Could not set property %s on %s", name, target), e);
return false;
}
}
Aggregations