Package javax.net.ssl

Examples of javax.net.ssl.SSLServerSocket


    */
   public ServerSocket createServerSocket( int port,
                                           int backlog )
   throws IOException
   {
      SSLServerSocket sock = (SSLServerSocket) theDelegate.createServerSocket( port, backlog );
      setSocketModes( sock );
      return sock;
   }
View Full Code Here


   public ServerSocket createServerSocket( int         port,
                                           int         backlog,
                                           InetAddress ifAddress )
   throws IOException
   {
      SSLServerSocket sock = (SSLServerSocket) theDelegate.createServerSocket( port, backlog, ifAddress );
      setSocketModes( sock );
      return sock;
   }
View Full Code Here

   @Override
   public ServerSocket createServerSocket(int port, int backlog, InetAddress ifAddress) throws IOException
   {
      initSSLContext();
      SSLServerSocketFactory factory = sslCtx.getServerSocketFactory();
      SSLServerSocket socket = (SSLServerSocket) factory.createServerSocket(port, backlog, ifAddress);
      SSLSessionContext ctx = sslCtx.getServerSessionContext();
      System.out.println(ctx);
      if (log.isTraceEnabled())
      {
         String[] supportedProtocols = socket.getSupportedProtocols();
         log.debug("Supported protocols: " + Arrays.asList(supportedProtocols));
         String[] supportedCipherSuites = socket.getSupportedCipherSuites();
         log.debug("Supported CipherSuites: " + Arrays.asList(supportedCipherSuites));
      }
      socket.setNeedClientAuth(needsClientAuth);
      // JBAS-5815: only set the wantClientAuth property if needClientAuth hasn't been already set.
      if (!needsClientAuth)
         socket.setWantClientAuth(wantsClientAuth);

      if (protocols != null)
         socket.setEnabledProtocols(protocols);
      if (cipherSuites != null)
         socket.setEnabledCipherSuites(cipherSuites);

      DomainServerSocket handler = new DomainServerSocket(socket);
      ProxyFactory pf = new ProxyFactory();
      pf.setHandler(handler);
      pf.setSuperclass(SSLServerSocket.class);
      Class[] sig = {};
      Object[] args = {};

      SSLServerSocket proxy = null;
      try
      {
         proxy = (SSLServerSocket) pf.create(sig, args);
      }
      catch (Exception e)
View Full Code Here

  }

  private static TServerSocket createServer(SSLServerSocketFactory factory, int port, int timeout, boolean clientAuth,
                                    InetAddress ifAddress, TSSLTransportParameters params) throws TTransportException {
    try {
      SSLServerSocket serverSocket = (SSLServerSocket) factory.createServerSocket(port, 100, ifAddress);
      serverSocket.setSoTimeout(timeout);
      serverSocket.setNeedClientAuth(clientAuth);
      if (params != null && params.cipherSuites != null) {
        serverSocket.setEnabledCipherSuites(params.cipherSuites);
      }
      return new TServerSocket(serverSocket, timeout);
    } catch (Exception e) {
      throw new TTransportException("Could not bind to port " + port, e);
    }
View Full Code Here

     * 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;

        if (enabledCiphers != null) {
            socket.setEnabledCipherSuites(enabledCiphers);
        }

        String requestedProtocols = (String) attributes.get("protocols");
        setEnabledProtocols(socket, getEnabledProtocols(socket,
                                                         requestedProtocols));
View Full Code Here

    public void start() throws Exception {
        Asserts.check(servicedSocket == null, "Already running");
        final ServerSocket ssock;
        if (sslcontext != null) {
            final SSLServerSocketFactory sf = sslcontext.getServerSocketFactory();
            final SSLServerSocket sslsock = (SSLServerSocket) sf.createServerSocket();
            if (forceSSLAuth) {
                sslsock.setNeedClientAuth(true);
            } else {
                sslsock.setWantClientAuth(true);
            }
            ssock = sslsock;
        } else {
            ssock = new ServerSocket();
        }
View Full Code Here

    }

    protected void initServerSocket( final ServerSocket serverSocket )
        throws IOException
    {
        final SSLServerSocket socket = (SSLServerSocket)serverSocket;

        // Set client authentication if necessary
        socket.setNeedClientAuth( m_keyStoreAuthenticateClients );
        // Sets socket timeout
        socket.setSoTimeout( m_socketTimeOut );
    }
View Full Code Here

     * 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;

        if (enabledCiphers != null) {
            socket.setEnabledCipherSuites(enabledCiphers);
        }

        String requestedProtocols = (String) attributes.get("protocols");
        setEnabledProtocols(socket, getEnabledProtocols(socket,
                                                         requestedProtocols));
View Full Code Here

    keyManagerFactory.init(keyStore, getKeyPassword().toCharArray());
    SSLContext sslContext = SSLContext.getInstance(getSslProtocol());
    sslContext.init(keyManagerFactory.getKeyManagers(), null, null);

    // Initialize the socket
    SSLServerSocket serverSocket = null;
    String addr = getServer().getAddress();
    if (addr != null) {
      // this call may throw UnknownHostException and otherwise always
      // returns an instance of INetAddress
      // Note: textual representation of inet addresses are supported
      InetAddress iaddr = InetAddress.getByName(addr);
      // Note: the backlog of 50 is the default
      serverSocket = (SSLServerSocket) sslContext
          .getServerSocketFactory().createServerSocket(
              getServer().getPort(), 50, iaddr);
    } else {
      serverSocket = (SSLServerSocket) sslContext
          .getServerSocketFactory().createServerSocket(
              getServer().getPort());
    }

    serverSocket.setSoTimeout(60000);
    setSocket(serverSocket);
    fis.close();

    // Complete initialization
    setConfidential(true);
View Full Code Here

   public ServerSocket createServerSocket(int port, int backlog, InetAddress ifAddress)
      throws IOException
   {
      initSSLContext();
      SSLServerSocketFactory factory = sslCtx.getServerSocketFactory();
      SSLServerSocket socket = (SSLServerSocket) factory.createServerSocket(port, backlog, ifAddress);
      SSLSessionContext ctx = sslCtx.getServerSessionContext();
      System.out.println(ctx);
      if( log.isTraceEnabled() )
      {
         String[] supportedProtocols = socket.getSupportedProtocols();
         log.debug("Supported protocols: " + Arrays.asList(supportedProtocols));
         String[] supportedCipherSuites = socket.getSupportedCipherSuites();
         log.debug("Supported CipherSuites: " + Arrays.asList(supportedCipherSuites));
      }
      socket.setNeedClientAuth(needsClientAuth);
      socket.setWantClientAuth(wantsClientAuth);
      if( protocols != null )
         socket.setEnabledProtocols(protocols);
      if( cipherSuites != null )
         socket.setEnabledCipherSuites(cipherSuites);

      DomainServerSocket handler = new DomainServerSocket(socket);
      ProxyFactory pf = new ProxyFactory();
      pf.setHandler(handler);
      pf.setSuperclass(SSLServerSocket.class);
      Class[] sig = {};
      Object[] args = {};

      SSLServerSocket proxy = null;
      try
      {
         proxy = (SSLServerSocket) pf.create(sig, args);
      }
      catch (Exception e)
View Full Code Here

TOP

Related Classes of javax.net.ssl.SSLServerSocket

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.