Package javax.net.ssl

Examples of javax.net.ssl.SSLServerSocketFactory


     */
    public void start() throws Exception {
        Asserts.check(servicedSocket == null, "Already running");
        ServerSocket ssock;
        if (sslcontext != null) {
            final SSLServerSocketFactory sf = sslcontext.getServerSocketFactory();
            ssock = sf.createServerSocket();
        } else {
            ssock = new ServerSocket();
        }

        ssock.setReuseAddress(true); // probably pointless for port '0'
View Full Code Here


     */

    /* ------------------------------------------------------------ */
    protected ServerSocket newServerSocket(String host, int port,int backlog) throws IOException
    {
        SSLServerSocketFactory factory = null;
        SSLServerSocket socket = null;

        try
        {
            factory = createFactory();

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

            if (_wantClientAuth)
                socket.setWantClientAuth(_wantClientAuth);
            if (_needClientAuth)
                socket.setNeedClientAuth(_needClientAuth);
View Full Code Here

  BlockingServletEngine(FilterChain dispatcher, ServletEngineConfiguration config)
      throws InterruptedException, IOException {
    this.config = config;
    if (config.isSecure()) {
      SSLServerSocketFactory factory = (SSLServerSocketFactory)SSLServerSocketFactory.getDefault();
      SSLServerSocket sslServerSocket = (SSLServerSocket)factory.createServerSocket(config.getPort());
      sslServerSocket.setEnabledCipherSuites(config.getEnabledCipherSuites());
      serverSocket = sslServerSocket;
    } else {
      serverSocket = new ServerSocket(config.getPort());
    }
View Full Code Here

  public String[] getEnabledCipherSuites() {
    return enabledCipherSuites;
  }

  private static Set<String> getSupportedCipherSuites() {
    SSLServerSocketFactory factory = (SSLServerSocketFactory)SSLServerSocketFactory.getDefault();
    String[] supportedSuites = factory.getSupportedCipherSuites();
    Set<String> suites = new TreeSet<String>();
    for (String suite : supportedSuites) {
      suites.add(suite);
    }
    return suites;
View Full Code Here

  }

  public ServerSocketFactory getServerSocketFactory(String type) {

    if (type.equals("SSL") || type.equals("SSLv3")) {
      SSLServerSocketFactory ssf = null;
      try {
        // set up key manager to do server authentication
        SSLContext ctx;
        KeyManagerFactory kmf;
        KeyStore ks;
View Full Code Here

        ServerSocketFactory.getDefault();
      return sf.createServerSocket(portNumber
                     ,0,
                     hostAddress);
    case SSL_BASIC:
      SSLServerSocketFactory ssf =
        (SSLServerSocketFactory)SSLServerSocketFactory.getDefault();
      return (SSLServerSocket)ssf.createServerSocket(portNumber,
                               0,
                               hostAddress);
    case SSL_PEER_AUTHENTICATION:
      SSLServerSocketFactory ssf2 =
        (SSLServerSocketFactory)SSLServerSocketFactory.getDefault();
      SSLServerSocket sss2=
        (SSLServerSocket)ssf2.createServerSocket(portNumber,
                             0,
                             hostAddress);
      sss2.setNeedClientAuth(true);
      return sss2;
    }
View Full Code Here

                ServerSocketFactory.getDefault();
            return sf.createServerSocket(portNumber
                                         ,0,
                                         hostAddress);
        case SSL_BASIC:
            SSLServerSocketFactory ssf =
                (SSLServerSocketFactory)SSLServerSocketFactory.getDefault();
            return (SSLServerSocket)ssf.createServerSocket(portNumber,
                                                           0,
                                                           hostAddress);
        case SSL_PEER_AUTHENTICATION:
            SSLServerSocketFactory ssf2 =
                (SSLServerSocketFactory)SSLServerSocketFactory.getDefault();
            SSLServerSocket sss2=
                (SSLServerSocket)ssf2.createServerSocket(portNumber,
                                                         0,
                                                         hostAddress);
            sss2.setNeedClientAuth(true);
            return sss2;
        }
View Full Code Here

    /**
     * Tests default initialized factories.
     */
    public void testDefaultInitialized() throws Exception {

        SSLServerSocketFactory ssfactory =
            (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
        SSLSocketFactory sfactory =
            (SSLSocketFactory) SSLSocketFactory.getDefault();

        assertNotNull(ssfactory.getDefaultCipherSuites());
        assertNotNull(ssfactory.getSupportedCipherSuites());
        assertNotNull(ssfactory.createServerSocket());

        assertNotNull(sfactory.getDefaultCipherSuites());
        assertNotNull(sfactory.getSupportedCipherSuites());
        assertNotNull(sfactory.createSocket());
    }
View Full Code Here

    }

    public void testSocketCreation() throws Throwable {
        SSLSocketFactory socketFactory
            = new SSLSocketFactoryImpl(JSSETestData.getSSLParameters());
        SSLServerSocketFactory serverSocketFactory
            = new SSLServerSocketFactoryImpl(JSSETestData.getSSLParameters());

        String[] enabled = {"TLS_RSA_WITH_RC4_128_MD5"};
        for (int i=0; i<4; i++) {
            SSLServerSocket ssocket;
            switch (i) {
                case 0:
                    if (doLog) {
                        System.out.println(
                            "*** ServerSocketFactory.createServerSocket()");
                    }
                    ssocket = (SSLServerSocket)
                        serverSocketFactory.createServerSocket();
                    ssocket.bind(null);
                    break;
                case 1:
                    if (doLog) {
                        System.out.println(
                            "*** ServerSocketFactory.createServerSocket(int)");
                    }
                    ssocket = (SSLServerSocket)
                        serverSocketFactory.createServerSocket(0);
                    break;
                case 2:
                    if (doLog) {
                        System.out.println(
                        "*** ServerSocketFactory.createServerSocket(int,int)");
                    }
                    ssocket = (SSLServerSocket)
                        serverSocketFactory.createServerSocket(0, 6);
                    break;
                default:
                    if (doLog) {
                        System.out.println("*** ServerSocketFactory."
                                + "createServerSocket(int,int,InetAddress)");
                    }
                    ssocket = (SSLServerSocket)
                        serverSocketFactory.createServerSocket(0, 6, null);
                    break;
            }
            ssocket.setUseClientMode(false);
            ssocket.setEnabledCipherSuites(enabled);
            for (int j=0; j<6; j++) {
View Full Code Here

    /**
     * SSLServerSocketFactory.getSupportedCipherSuites() method testing.
     */
    public void testGetSupportedCipherSuites2() throws Exception {
        SSLServerSocketFactory serverSocketFactory
            = new SSLServerSocketFactoryImpl(JSSETestData.getSSLParameters());
        String[] supported = serverSocketFactory.getSupportedCipherSuites();
        assertNotNull(supported);
        supported[0] = "NOT_SUPPORTED_CIPHER_SUITE";
        supported = serverSocketFactory.getSupportedCipherSuites();
        for (int i=0; i<supported.length; i++) {
            if ("NOT_SUPPORTED_CIPHER_SUITE".equals(supported[i])) {
                fail("Modification of the returned result "
                        + "causes the modification of the internal state");
            }
View Full Code Here

TOP

Related Classes of javax.net.ssl.SSLServerSocketFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.