类javax.net.ssl.SSLServerSocket源码实例Demo

下面列出了怎么用javax.net.ssl.SSLServerSocket的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: Flink-CEPplus   文件: SSLUtilsTest.java
/**
 * Tests if SSLUtils set the right ssl version and cipher suites for SSLServerSocket.
 */
@Test
public void testSetSSLVersionAndCipherSuitesForSSLServerSocket() throws Exception {
	Configuration serverConfig = createInternalSslConfigWithKeyAndTrustStores();

	// set custom protocol and cipher suites
	serverConfig.setString(SecurityOptions.SSL_PROTOCOL, "TLSv1.1");
	serverConfig.setString(SecurityOptions.SSL_ALGORITHMS, "TLS_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_128_CBC_SHA256");

	try (ServerSocket socket = SSLUtils.createSSLServerSocketFactory(serverConfig).createServerSocket(0)) {
		assertTrue(socket instanceof SSLServerSocket);
		final SSLServerSocket sslSocket = (SSLServerSocket) socket;

		String[] protocols = sslSocket.getEnabledProtocols();
		String[] algorithms = sslSocket.getEnabledCipherSuites();

		assertEquals(1, protocols.length);
		assertEquals("TLSv1.1", protocols[0]);
		assertEquals(2, algorithms.length);
		assertThat(algorithms, arrayContainingInAnyOrder(
				"TLS_RSA_WITH_AES_128_CBC_SHA", "TLS_RSA_WITH_AES_128_CBC_SHA256"));
	}
}
 
源代码2 项目: IoTgo_Android_App   文件: SslContextFactory.java
public SSLServerSocket newSslServerSocket(String host,int port,int backlog) throws IOException
{
    SSLServerSocketFactory factory = _context.getServerSocketFactory();

    SSLServerSocket socket =
        (SSLServerSocket) (host==null ?
                    factory.createServerSocket(port,backlog):
                    factory.createServerSocket(port,backlog,InetAddress.getByName(host)));

    if (getWantClientAuth())
        socket.setWantClientAuth(getWantClientAuth());
    if (getNeedClientAuth())
        socket.setNeedClientAuth(getNeedClientAuth());

    socket.setEnabledCipherSuites(selectCipherSuites(
                                        socket.getEnabledCipherSuites(),
                                        socket.getSupportedCipherSuites()));
    socket.setEnabledProtocols(selectProtocols(socket.getEnabledProtocols(),socket.getSupportedProtocols()));

    return socket;
}
 
源代码3 项目: openjdk-8   文件: DefaultSSLServSocketFac.java
public static void main(String[] args) throws Exception {
    // reserve the security properties
    String reservedSSFacProvider =
        Security.getProperty("ssl.ServerSocketFactory.provider");

    try {
        Security.setProperty("ssl.ServerSocketFactory.provider", "oops");
        ServerSocketFactory ssocketFactory =
                    SSLServerSocketFactory.getDefault();
        SSLServerSocket sslServerSocket =
                    (SSLServerSocket)ssocketFactory.createServerSocket();
    } catch (Exception e) {
        if (!(e.getCause() instanceof ClassNotFoundException)) {
            throw e;
        }
        // get the expected exception
    } finally {
        // restore the security properties
        if (reservedSSFacProvider == null) {
            reservedSSFacProvider = "";
        }
        Security.setProperty("ssl.ServerSocketFactory.provider",
                                                reservedSSFacProvider);
    }
}
 
源代码4 项目: flink   文件: SSLUtilsTest.java
/**
 * Tests if SSLUtils set the right ssl version and cipher suites for SSLServerSocket.
 */
@Test
public void testSetSSLVersionAndCipherSuitesForSSLServerSocket() throws Exception {
	Configuration serverConfig = createInternalSslConfigWithKeyAndTrustStores();

	// set custom protocol and cipher suites
	serverConfig.setString(SecurityOptions.SSL_PROTOCOL, "TLSv1.1");
	serverConfig.setString(SecurityOptions.SSL_ALGORITHMS, "TLS_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_128_CBC_SHA256");

	try (ServerSocket socket = SSLUtils.createSSLServerSocketFactory(serverConfig).createServerSocket(0)) {
		assertTrue(socket instanceof SSLServerSocket);
		final SSLServerSocket sslSocket = (SSLServerSocket) socket;

		String[] protocols = sslSocket.getEnabledProtocols();
		String[] algorithms = sslSocket.getEnabledCipherSuites();

		assertEquals(1, protocols.length);
		assertEquals("TLSv1.1", protocols[0]);
		assertEquals(2, algorithms.length);
		assertThat(algorithms, arrayContainingInAnyOrder(
				"TLS_RSA_WITH_AES_128_CBC_SHA", "TLS_RSA_WITH_AES_128_CBC_SHA256"));
	}
}
 
源代码5 项目: dragonwell8_jdk   文件: DefaultSSLServSocketFac.java
public static void main(String[] args) throws Exception {
    // reserve the security properties
    String reservedSSFacProvider =
        Security.getProperty("ssl.ServerSocketFactory.provider");

    try {
        Security.setProperty("ssl.ServerSocketFactory.provider", "oops");
        ServerSocketFactory ssocketFactory =
                    SSLServerSocketFactory.getDefault();
        SSLServerSocket sslServerSocket =
                    (SSLServerSocket)ssocketFactory.createServerSocket();
    } catch (Exception e) {
        if (!(e.getCause() instanceof ClassNotFoundException)) {
            throw e;
        }
        // get the expected exception
    } finally {
        // restore the security properties
        if (reservedSSFacProvider == null) {
            reservedSSFacProvider = "";
        }
        Security.setProperty("ssl.ServerSocketFactory.provider",
                                                reservedSSFacProvider);
    }
}
 
源代码6 项目: dacapobench   文件: SocketFactory.java
/**
 * Create a server socket for this connection.
 *
 * @param port    The target listener port.
 * @param backlog The requested backlog value for the connection.
 * @param address The host address information we're publishing under.
 *
 * @return An appropriately configured ServerSocket for this
 *         connection.
 * @exception IOException
 * @exception ConnectException
 */
public ServerSocket createServerSocket(int port, int backlog, InetAddress address) throws IOException {
    try {
        // if no protection is required, just create a plain socket.
        if ((NoProtection.value & requires) == NoProtection.value) {
            if (log.isDebugEnabled()) log.debug("Created plain server socket for port " + port);
            return new ServerSocket(port, backlog, address);
        }
        else {
            // SSL is required.  Create one from the SSLServerFactory retrieved from the config.  This will
            // require additional QOS configuration after creation.
            SSLServerSocket serverSocket = (SSLServerSocket)getServerSocketFactory().createServerSocket(port, backlog, address);
            configureServerSocket(serverSocket);
            return serverSocket;
        }
    } catch (IOException ex) {
        log.error("Exception creating a client socket to "  + address.getHostName() + ":" + port, ex);
        throw ex;
    }
}
 
源代码7 项目: jdk8u_jdk   文件: CipherTestUtils.java
public static void printInfo(SSLServerSocket socket) {
    System.out.println();
    System.out.println("--- SSL ServerSocket Info ---");
    System.out.print("SupportedProtocols    : ");
    printStringArray(socket.getSupportedProtocols());
    System.out.print("SupportedCipherSuites : ");
    printStringArray(socket.getSupportedCipherSuites());
    System.out.print("EnabledProtocols      : ");
    printStringArray(socket.getEnabledProtocols());
    System.out.print("EnabledCipherSuites   : ");
    String[] supportedCipherSuites = socket.getEnabledCipherSuites();
    Arrays.sort(supportedCipherSuites);
    printStringArray(supportedCipherSuites);
    System.out.println("NeedClientAuth        : "
            + socket.getNeedClientAuth());
    System.out.println("WantClientAuth        : "
            + socket.getWantClientAuth());
    System.out.println("-----------------------");
}
 
源代码8 项目: dragonwell8_jdk   文件: CipherTestUtils.java
public static void printInfo(SSLServerSocket socket) {
    System.out.println();
    System.out.println("--- SSL ServerSocket Info ---");
    System.out.print("SupportedProtocols    : ");
    printStringArray(socket.getSupportedProtocols());
    System.out.print("SupportedCipherSuites : ");
    printStringArray(socket.getSupportedCipherSuites());
    System.out.print("EnabledProtocols      : ");
    printStringArray(socket.getEnabledProtocols());
    System.out.print("EnabledCipherSuites   : ");
    String[] supportedCipherSuites = socket.getEnabledCipherSuites();
    Arrays.sort(supportedCipherSuites);
    printStringArray(supportedCipherSuites);
    System.out.println("NeedClientAuth        : "
            + socket.getNeedClientAuth());
    System.out.println("WantClientAuth        : "
            + socket.getWantClientAuth());
    System.out.println("-----------------------");
}
 
源代码9 项目: flink   文件: SSLUtilsTest.java
/**
 * Tests if SSLUtils set the right ssl version and cipher suites for SSLServerSocket.
 */
@Test
public void testSetSSLVersionAndCipherSuitesForSSLServerSocket() throws Exception {
	Configuration serverConfig = createInternalSslConfigWithKeyAndTrustStores();

	// set custom protocol and cipher suites
	serverConfig.setString(SecurityOptions.SSL_PROTOCOL, "TLSv1.1");
	serverConfig.setString(SecurityOptions.SSL_ALGORITHMS, "TLS_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_128_CBC_SHA256");

	try (ServerSocket socket = SSLUtils.createSSLServerSocketFactory(serverConfig).createServerSocket(0)) {
		assertTrue(socket instanceof SSLServerSocket);
		final SSLServerSocket sslSocket = (SSLServerSocket) socket;

		String[] protocols = sslSocket.getEnabledProtocols();
		String[] algorithms = sslSocket.getEnabledCipherSuites();

		assertEquals(1, protocols.length);
		assertEquals("TLSv1.1", protocols[0]);
		assertEquals(2, algorithms.length);
		assertThat(algorithms, arrayContainingInAnyOrder(
				"TLS_RSA_WITH_AES_128_CBC_SHA", "TLS_RSA_WITH_AES_128_CBC_SHA256"));
	}
}
 
源代码10 项目: jdk8u_jdk   文件: JSSEServer.java
JSSEServer(CipherTestUtils cipherTest, int serverPort,
        String protocol, String cipherSuite) throws Exception {
    super(cipherTest);
    this.serverPort = serverPort;
    SSLContext serverContext = SSLContext.getInstance("TLS");
    serverContext.init(new KeyManager[]{cipherTest.getServerKeyManager()},
            new TrustManager[]{cipherTest.getServerTrustManager()},
            CipherTestUtils.secureRandom);
    SSLServerSocketFactory factory =
            (SSLServerSocketFactory)serverContext.getServerSocketFactory();
    serverSocket =
            (SSLServerSocket) factory.createServerSocket(serverPort);
    serverSocket.setEnabledProtocols(protocol.split(","));
    serverSocket.setEnabledCipherSuites(cipherSuite.split(","));

    CipherTestUtils.printInfo(serverSocket);
}
 
源代码11 项目: TencentKona-8   文件: DefaultSSLServSocketFac.java
public static void main(String[] args) throws Exception {
    // reserve the security properties
    String reservedSSFacProvider =
        Security.getProperty("ssl.ServerSocketFactory.provider");

    try {
        Security.setProperty("ssl.ServerSocketFactory.provider", "oops");
        ServerSocketFactory ssocketFactory =
                    SSLServerSocketFactory.getDefault();
        SSLServerSocket sslServerSocket =
                    (SSLServerSocket)ssocketFactory.createServerSocket();
    } catch (Exception e) {
        if (!(e.getCause() instanceof ClassNotFoundException)) {
            throw e;
        }
        // get the expected exception
    } finally {
        // restore the security properties
        if (reservedSSFacProvider == null) {
            reservedSSFacProvider = "";
        }
        Security.setProperty("ssl.ServerSocketFactory.provider",
                                                reservedSSFacProvider);
    }
}
 
源代码12 项目: hottub   文件: CipherTestUtils.java
public static void printInfo(SSLServerSocket socket) {
    System.out.println();
    System.out.println("--- SSL ServerSocket Info ---");
    System.out.print("SupportedProtocols    : ");
    printStringArray(socket.getSupportedProtocols());
    System.out.print("SupportedCipherSuites : ");
    printStringArray(socket.getSupportedCipherSuites());
    System.out.print("EnabledProtocols      : ");
    printStringArray(socket.getEnabledProtocols());
    System.out.print("EnabledCipherSuites   : ");
    String[] supportedCipherSuites = socket.getEnabledCipherSuites();
    Arrays.sort(supportedCipherSuites);
    printStringArray(supportedCipherSuites);
    System.out.println("NeedClientAuth        : "
            + socket.getNeedClientAuth());
    System.out.println("WantClientAuth        : "
            + socket.getWantClientAuth());
    System.out.println("-----------------------");
}
 
源代码13 项目: qpid-jms   文件: TestAmqpPeerRunner.java
public TestAmqpPeerRunner(TestAmqpPeer peer, SSLContext sslContext, boolean needClientCert) throws IOException
{
    int port = useFixedPort ? PORT : 0;
    this.needClientCert = needClientCert;

    if (sslContext == null)
    {
        _serverSocket = new ServerSocket(port);
    }
    else
    {
        SSLServerSocketFactory socketFactory = sslContext.getServerSocketFactory();
        _serverSocket = socketFactory.createServerSocket(port);

        SSLServerSocket sslServerSocket = (SSLServerSocket) _serverSocket;
        if (this.needClientCert)
        {
            sslServerSocket.setNeedClientAuth(true);
        }
    }

    _testFrameParser = new TestFrameParser(peer);
    _peer = peer;
}
 
源代码14 项目: TencentKona-8   文件: JSSEServer.java
JSSEServer(CipherTestUtils cipherTest, int serverPort,
        String protocol, String cipherSuite) throws Exception {
    super(cipherTest);
    this.serverPort = serverPort;
    SSLContext serverContext = SSLContext.getInstance("TLS");
    serverContext.init(new KeyManager[]{cipherTest.getServerKeyManager()},
            new TrustManager[]{cipherTest.getServerTrustManager()},
            CipherTestUtils.secureRandom);
    SSLServerSocketFactory factory =
            (SSLServerSocketFactory)serverContext.getServerSocketFactory();
    serverSocket =
            (SSLServerSocket) factory.createServerSocket(serverPort);
    serverSocket.setEnabledProtocols(protocol.split(","));
    serverSocket.setEnabledCipherSuites(cipherSuite.split(","));

    CipherTestUtils.printInfo(serverSocket);
}
 
源代码15 项目: openjdk-jdk8u   文件: DefaultSSLServSocketFac.java
public static void main(String[] args) throws Exception {
    // reserve the security properties
    String reservedSSFacProvider =
        Security.getProperty("ssl.ServerSocketFactory.provider");

    try {
        Security.setProperty("ssl.ServerSocketFactory.provider", "oops");
        ServerSocketFactory ssocketFactory =
                    SSLServerSocketFactory.getDefault();
        SSLServerSocket sslServerSocket =
                    (SSLServerSocket)ssocketFactory.createServerSocket();
    } catch (Exception e) {
        if (!(e.getCause() instanceof ClassNotFoundException)) {
            throw e;
        }
        // get the expected exception
    } finally {
        // restore the security properties
        if (reservedSSFacProvider == null) {
            reservedSSFacProvider = "";
        }
        Security.setProperty("ssl.ServerSocketFactory.provider",
                                                reservedSSFacProvider);
    }
}
 
源代码16 项目: jdk8u-dev-jdk   文件: DefaultSSLServSocketFac.java
public static void main(String[] args) throws Exception {
    // reserve the security properties
    String reservedSSFacProvider =
        Security.getProperty("ssl.ServerSocketFactory.provider");

    try {
        Security.setProperty("ssl.ServerSocketFactory.provider", "oops");
        ServerSocketFactory ssocketFactory =
                    SSLServerSocketFactory.getDefault();
        SSLServerSocket sslServerSocket =
                    (SSLServerSocket)ssocketFactory.createServerSocket();
    } catch (Exception e) {
        if (!(e.getCause() instanceof ClassNotFoundException)) {
            throw e;
        }
        // get the expected exception
    } finally {
        // restore the security properties
        if (reservedSSFacProvider == null) {
            reservedSSFacProvider = "";
        }
        Security.setProperty("ssl.ServerSocketFactory.provider",
                                                reservedSSFacProvider);
    }
}
 
源代码17 项目: yajsync   文件: SSLServerChannelFactory.java
@Override
public ServerChannel open(InetAddress address, int port, int timeout)
        throws IOException
{
    SSLServerSocket sock =
        (SSLServerSocket) _factory.createServerSocket(port,
                                                      _backlog, address);
    try {
        sock.setReuseAddress(_isReuseAddress);
        sock.setWantClientAuth(_isWantClientAuth);
        return new SSLServerChannel(sock, timeout);
    } catch (Throwable t) {
        if (!sock.isClosed()) {
            try {
                sock.close();
            } catch (Throwable tt) {
                t.addSuppressed(tt);
            }
        }
        throw t;
    }
}
 
源代码18 项目: openjdk-jdk9   文件: CipherTestUtils.java
public static void printInfo(SSLServerSocket socket) {
    System.out.println();
    System.out.println("--- SSL ServerSocket Info ---");
    System.out.print("SupportedProtocols    : ");
    printStringArray(socket.getSupportedProtocols());
    System.out.print("SupportedCipherSuites : ");
    printStringArray(socket.getSupportedCipherSuites());
    System.out.print("EnabledProtocols      : ");
    printStringArray(socket.getEnabledProtocols());
    System.out.print("EnabledCipherSuites   : ");
    String[] supportedCipherSuites = socket.getEnabledCipherSuites();
    Arrays.sort(supportedCipherSuites);
    printStringArray(supportedCipherSuites);
    System.out.println("NeedClientAuth        : "
            + socket.getNeedClientAuth());
    System.out.println("WantClientAuth        : "
            + socket.getWantClientAuth());
    System.out.println("-----------------------");
}
 
public static void main(String[] args) throws Exception {
    // reserve the security properties
    String reservedSSFacProvider =
        Security.getProperty("ssl.ServerSocketFactory.provider");

    try {
        Security.setProperty("ssl.ServerSocketFactory.provider", "oops");
        ServerSocketFactory ssocketFactory =
                    SSLServerSocketFactory.getDefault();
        SSLServerSocket sslServerSocket =
                    (SSLServerSocket)ssocketFactory.createServerSocket();
    } catch (Exception e) {
        if (!(e.getCause() instanceof ClassNotFoundException)) {
            throw e;
        }
        // get the expected exception
    } finally {
        // restore the security properties
        if (reservedSSFacProvider == null) {
            reservedSSFacProvider = "";
        }
        Security.setProperty("ssl.ServerSocketFactory.provider",
                                                reservedSSFacProvider);
    }
}
 
private static GfxdTSSLServerSocket createServer(
    SSLServerSocketFactory factory, InetSocketAddress bindAddress,
    SocketParameters params) throws TTransportException {
  try {
    SSLServerSocket serverSocket = (SSLServerSocket)factory
        .createServerSocket(bindAddress.getPort(), 100,
            bindAddress.getAddress());
    if (params != null) {
      if (params.getSSLEnabledProtocols() != null) {
        serverSocket.setEnabledProtocols(params.getSSLEnabledProtocols());
      }
      if (params.getSSLCipherSuites() != null) {
        serverSocket.setEnabledCipherSuites(params.getSSLCipherSuites());
      }
      serverSocket.setNeedClientAuth(params.getSSLClientAuth());
    }
    return new GfxdTSSLServerSocket(serverSocket, bindAddress, params);
  } catch (Exception e) {
    throw new TTransportException(TTransportException.NOT_OPEN,
        "Could not bind to host:port " + bindAddress.toString(), e);
  }
}
 
源代码21 项目: openjdk-jdk8u-backup   文件: CipherTestUtils.java
public static void printInfo(SSLServerSocket socket) {
    System.out.println();
    System.out.println("--- SSL ServerSocket Info ---");
    System.out.print("SupportedProtocols    : ");
    printStringArray(socket.getSupportedProtocols());
    System.out.print("SupportedCipherSuites : ");
    printStringArray(socket.getSupportedCipherSuites());
    System.out.print("EnabledProtocols      : ");
    printStringArray(socket.getEnabledProtocols());
    System.out.print("EnabledCipherSuites   : ");
    String[] supportedCipherSuites = socket.getEnabledCipherSuites();
    Arrays.sort(supportedCipherSuites);
    printStringArray(supportedCipherSuites);
    System.out.println("NeedClientAuth        : "
            + socket.getNeedClientAuth());
    System.out.println("WantClientAuth        : "
            + socket.getWantClientAuth());
    System.out.println("-----------------------");
}
 
源代码22 项目: ambry   文件: EchoServer.java
/**
 * Create an EchoServer that supports SSL connections
 */
public EchoServer(SSLFactory sslFactory, int port) throws Exception {
  this.port = port;
  if (sslFactory == null) {
    this.serverSocket = new ServerSocket(port);
  } else {
    SSLContext sslContext = sslFactory.getSSLContext();
    this.serverSocket = sslContext.getServerSocketFactory().createServerSocket(port);

    // enable mutual authentication
    ((SSLServerSocket) this.serverSocket).setNeedClientAuth(true);
  }
  this.threads = Collections.synchronizedList(new ArrayList<Thread>());
  this.sockets = Collections.synchronizedList(new ArrayList<Socket>());
  this.exceptions = Collections.synchronizedList(new ArrayList<Exception>());
}
 
@Override
public ServerSocket createServerSocket(int port) throws IOException  {
    SSLServerSocket sslServerSocket =
            (SSLServerSocket) sslServerSocketFactory.createServerSocket(port, 0, bindAddress);
    if (getEnabledCipherSuites() != null) {
        sslServerSocket.setEnabledCipherSuites(getEnabledCipherSuites());
    }
    if (getEnabledProtocols() == null) {
        sslServerSocket.setEnabledProtocols(defaultProtocols);
    } else {
        sslServerSocket.setEnabledProtocols(getEnabledProtocols());
    }
    sslServerSocket.setNeedClientAuth(getNeedClientAuth());
    return sslServerSocket;
}
 
源代码24 项目: jdk8u-jdk   文件: Timeout.java
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");
    }
 
源代码25 项目: openjdk-jdk9   文件: ECCurvesconstraints.java
void doServerSide() throws Exception {
    SSLContext context = generateSSLContext(false);
    SSLServerSocketFactory sslssf = context.getServerSocketFactory();
    SSLServerSocket sslServerSocket =
        (SSLServerSocket)sslssf.createServerSocket(serverPort);
    serverPort = sslServerSocket.getLocalPort();

    /*
     * Signal Client, we're ready for his connect.
     */
    serverReady = true;

    SSLSocket sslSocket = (SSLSocket)sslServerSocket.accept();
    try {
        sslSocket.setSoTimeout(5000);
        sslSocket.setSoLinger(true, 5);

        InputStream sslIS = sslSocket.getInputStream();
        OutputStream sslOS = sslSocket.getOutputStream();

        sslIS.read();
        sslOS.write('A');
        sslOS.flush();

        throw new Exception("EC curve secp224k1 should be disabled");
    } catch (SSLHandshakeException she) {
        // expected exception: no cipher suites in common
        System.out.println("Expected exception: " + she);
    } finally {
        sslSocket.close();
        sslServerSocket.close();
    }
}
 
源代码26 项目: PacketProxy   文件: Https.java
public static ServerSocket createServerSSLSocket(int listen_port, String commonName, CA ca, String ApplicationProtocol) throws Exception {
	SSLServerSocket serverSocket = (SSLServerSocket)createServerSSLSocket(listen_port, commonName, ca);
	SSLParameters sslp = serverSocket.getSSLParameters();
	String[] serverAPs ={ ApplicationProtocol };
	sslp.setApplicationProtocols(serverAPs);
	serverSocket.setSSLParameters(sslp);
	return serverSocket;
}
 
源代码27 项目: jdk8u-jdk   文件: UnboundSSLUtils.java
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);
}
 
源代码28 项目: dragonwell8_jdk   文件: UnboundSSLUtils.java
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);
}
 
源代码29 项目: dragonwell8_jdk   文件: DisabledAlgorithms.java
static SSLServer init(String[] ciphersuites)
        throws IOException {
    SSLServerSocketFactory ssf = (SSLServerSocketFactory)
            SSLServerSocketFactory.getDefault();
    SSLServerSocket ssocket = (SSLServerSocket)
            ssf.createServerSocket(0);

    if (ciphersuites != null) {
        System.out.println("Server: enable cipher suites: "
                + java.util.Arrays.toString(ciphersuites));
        ssocket.setEnabledCipherSuites(ciphersuites);
    }

    return new SSLServer(ssocket);
}
 
源代码30 项目: wildfly-core   文件: WrapperSSLContext.java
private void setSslParams(final ServerSocket socket) {
    if (socket instanceof SSLServerSocket) {
        SSLServerSocket sslSocket = (SSLServerSocket) socket;
        if (enabledCipherSuites.length > 0) {
            sslSocket.setEnabledCipherSuites(enabledCipherSuites);
        }
        if (enabledProtocols.length > 0) {
            sslSocket.setEnabledProtocols(enabledProtocols);
        }
    }
}
 
 类所在包