Examples of SSLServerSocket


Examples of javax.net.ssl.SSLServerSocket

      return s;
   }

   public ServerSocket createServerSocket(int port, int backlog) throws IOException
   {
      SSLServerSocket s = (SSLServerSocket) domainFactory.createServerSocket(port, backlog);

      if (request_mutual_auth)
         s.setWantClientAuth(request_mutual_auth);
      else if (require_mutual_auth)
         s.setNeedClientAuth(require_mutual_auth);

      return s;
   }
View Full Code Here

Examples of javax.net.ssl.SSLServerSocket

      return s;
   }

   public ServerSocket createServerSocket(int port, int backlog, InetAddress ifAddress) throws IOException
   {
      SSLServerSocket s = (SSLServerSocket) domainFactory.createServerSocket(port, backlog, ifAddress);

      if (request_mutual_auth)
         s.setWantClientAuth(request_mutual_auth);
      else if (require_mutual_auth)
         s.setNeedClientAuth(require_mutual_auth);

      return s;
   }
View Full Code Here

Examples of javax.net.ssl.SSLServerSocket

    protected ServerSocket newServerSocket( InetAddrPort p_address,
                                            int p_acceptQueueSize )
        throws IOException
    {
        SSLServerSocket serverSocket = (SSLServerSocket)super.newServerSocket(p_address, p_acceptQueueSize);
        if(serverSocket.getNeedClientAuth()) {
         
               serverSocket.setNeedClientAuth(require);
               setNeedClientAuth(require);
               if(!require)
                  serverSocket.setWantClientAuth(true);
        }
       
       
        String[] ciphers = serverSocket.getSupportedCipherSuites();
        String[] protocols = serverSocket.getSupportedProtocols();
       
        if(log.isInfoEnabled()) {
          log.info("The following protocols are supported:");
          for(int i=0;i<protocols.length;i++) {
            log.info("     " + protocols[i]);
          }
        }
       
        if(createAvailableCipherSuitesList) {
          File f = new File(ContextHolder.getContext().getTempDirectory(), "availableCipherSuites.txt");
          BufferedWriter writer = null;
         
          try {
              writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(f)));
              if(log.isInfoEnabled())
                log.info("The following cipher suites are supported:");
            for(int i=0;i<ciphers.length;i++) {
          if(log.isInfoEnabled())
            log.info("     " + ciphers[i]);
          writer.write(ciphers[i]);
          writer.newLine();
        }
      } catch (Throwable e) {
        log.error("Could not create cipher list!", e);
        configureContext = false;
      } finally {
        if(writer!=null)
          writer.close();
      }
      createAvailableCipherSuitesList = false;
        }
       
        if(configureContext) {
         
          PropertyList list = ContextHolder.getContext().getConfig().retrievePropertyList(new ContextKey("ssl.supportedProtocols"));
         
          if(!list.isEmpty()) {
            serverSocket.setEnabledProtocols(list.asArray());
          }
           
          list = ContextHolder.getContext().getConfig().retrievePropertyList(new ContextKey("ssl.supportedCiphers"));
         
          if(!list.isEmpty()) {
            serverSocket.setEnabledCipherSuites(list.asArray());
          }
        }
       
        protocols = serverSocket.getEnabledProtocols();
       
        if(log.isInfoEnabled()) {
        log.info("The following protocols are enabled:");
      for(int i=0;i<protocols.length;i++) {
        log.info("     " + protocols[i]);
      }
        }
   
   
        ciphers = serverSocket.getEnabledCipherSuites();
      if(log.isInfoEnabled()) {
        log.info("The following cipher suites are enabled:");
      for(int i=0;i<ciphers.length;i++) {
        log.info("     " + ciphers[i]);
      }
View Full Code Here

Examples of javax.net.ssl.SSLServerSocket

     * @param port the port to which to bind the secure ServerSocket
     * @throws Exception if a network or security provider error occurs
     */
    public ServerSocket createServerSocket(int port) throws Exception {

        SSLServerSocket ss;

        ss = (SSLServerSocket) getServerSocketFactoryImpl()
            .createServerSocket(port);

        if (Error.TRACESYSTEMOUT) {
            Error.printSystemOut("[" + this + "]: createServerSocket()");
            Error.printSystemOut("capabilities for " + ss + ":");
            Error.printSystemOut("----------------------------");
            dump("supported cipher suites", ss.getSupportedCipherSuites());
            dump("enabled cipher suites", ss.getEnabledCipherSuites());
        }

        return ss;
    }
View Full Code Here

Examples of javax.net.ssl.SSLServerSocket

     * @throws Exception if a network or security provider error occurs
     */
    public ServerSocket createServerSocket(int port,
                                           String address) throws Exception {

        SSLServerSocket ss;
        InetAddress     addr;

        addr = InetAddress.getByName(address);
        ss = (SSLServerSocket) getServerSocketFactoryImpl()
            .createServerSocket(port, 128, addr);

        if (Error.TRACE) {
            Error.printSystemOut("[" + this + "]: createServerSocket()");
            Error.printSystemOut("capabilities for " + ss + ":");
            Error.printSystemOut("----------------------------");
            dump("supported cipher suites", ss.getSupportedCipherSuites());
            dump("enabled cipher suites", ss.getEnabledCipherSuites());
        }

        return ss;
    }
View Full Code Here

Examples of javax.net.ssl.SSLServerSocket

  @Override
  public ServerSocket newServerSocket() throws IOException
  {
    SSLServerSocketFactory factory = null;
    SSLServerSocket socket = null;

    try
    {
      factory = createFactory();

      socket = (SSLServerSocket) (getHost() == null ? factory.createServerSocket(getPort(),
          getBacklogSize()) : factory.createServerSocket(getPort(), getBacklogSize(), InetAddress
          .getByName(getHost())));

      if (_wantClientAuth)
        socket.setWantClientAuth(_wantClientAuth);
      if (_needClientAuth)
        socket.setNeedClientAuth(_needClientAuth);

      if (_excludeCipherSuites != null && _excludeCipherSuites.length > 0)
      {
        List<String> excludedCSList = Arrays.asList(_excludeCipherSuites);
        String[] enabledCipherSuites = socket.getEnabledCipherSuites();
        List<String> enabledCSList = new ArrayList<String>(Arrays.asList(enabledCipherSuites));
        Iterator<String> exIter = excludedCSList.iterator();

        while (exIter.hasNext())
        {
          String cipherName = exIter.next();
          if (enabledCSList.contains(cipherName))
          {
            enabledCSList.remove(cipherName);
          }
        }
        enabledCipherSuites = (String[]) enabledCSList.toArray(new String[enabledCSList.size()]);

        socket.setEnabledCipherSuites(enabledCipherSuites);
      }

    }
    catch (IOException e)
    {
View Full Code Here

Examples of javax.net.ssl.SSLServerSocket

    if (host == null)
      serverSocket = factory.createServerSocket(port, listen);
    else
      serverSocket = factory.createServerSocket(port, listen, host);

    SSLServerSocket sslServerSocket = (SSLServerSocket) serverSocket;
   
    if (_cipherSuites != null) {
      sslServerSocket.setEnabledCipherSuites(_cipherSuites);
    }
   
    if (_cipherSuitesForbidden != null) {
      String []cipherSuites = sslServerSocket.getEnabledCipherSuites();
     
      if (cipherSuites == null)
        cipherSuites = sslServerSocket.getSupportedCipherSuites();
     
      ArrayList<String> cipherList = new ArrayList<String>();
     
      for (String cipher : cipherSuites) {
        if (! isCipherForbidden(cipher, _cipherSuitesForbidden)) {
          cipherList.add(cipher);
        }
      }
     
      cipherSuites = new String[cipherList.size()];
      cipherList.toArray(cipherSuites);
     
      sslServerSocket.setEnabledCipherSuites(cipherSuites);
    }

    if (_protocols != null) {
      sslServerSocket.setEnabledProtocols(_protocols);
    }
   
    if ("required".equals(_verifyClient))
      sslServerSocket.setNeedClientAuth(true);
    else if ("optional".equals(_verifyClient))
      sslServerSocket.setWantClientAuth(true);

    return new QServerSocketWrapper(serverSocket);
  }
View Full Code Here

Examples of javax.net.ssl.SSLServerSocket

                               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

Examples of javax.net.ssl.SSLServerSocket

                               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

Examples of javax.net.ssl.SSLServerSocket

     * Configures the given SSL server socket with the requested cipher suites,
     * protocol versions, and need for client authentication
     */
    private void initServerSocket(ServerSocket ssocket) {

        SSLServerSocket socket = (SSLServerSocket) ssocket;

        socket.setEnabledCipherSuites(enabledCiphers);
        socket.setEnabledProtocols(enabledProtocols);

        // we don't know if client auth is needed -
        // after parsing the request we may re-handshake
        configureClientAuth(socket);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.