Package javax.net.ssl

Examples of javax.net.ssl.SSLSocket


                              int port, boolean autoClose)
      throws IOException
   {
      initSSLContext();
      SSLSocketFactory factory = sslCtx.getSocketFactory();
      SSLSocket socket =
         (SSLSocket)factory.createSocket(s, host, port, autoClose);
      String[] supportedProtocols = socket.getSupportedProtocols();
      String[] protocols = supportedProtocols; // {"SSLv3"};
      socket.setEnabledProtocols(protocols);
      socket.addHandshakeCompletedListener(this);
      socket.setNeedClientAuth(needsClientAuth);
      socket.setWantClientAuth(wantsClientAuth);
      return socket;
   }
View Full Code Here


  
   public Socket createSocket() throws IOException
   {
       initSSLContext();
       SSLSocketFactory factory = sslCtx.getSocketFactory();
       SSLSocket socket = (SSLSocket) factory.createSocket();
       String[] supportedProtocols = socket.getSupportedProtocols();
       String[] protocols = supportedProtocols; // {"SSLv3"};
       socket.setEnabledProtocols(protocols);
       socket.addHandshakeCompletedListener(this);
       socket.setNeedClientAuth(needsClientAuth);
       socket.setWantClientAuth(wantsClientAuth);
       return socket;
   }
View Full Code Here

   */
   public java.net.Socket createSocket(String host, int port)
      throws IOException
   {
      SSLSocketFactory factory = (SSLSocketFactory) SSLSocketFactory.getDefault();
      SSLSocket socket = (SSLSocket) factory.createSocket(host, port);
      socket.addHandshakeCompletedListener(this);
      socket.setWantClientAuth(wantsClientAuth);
      socket.setNeedClientAuth(needsClientAuth);
      log.debug("createSocket, host="+host+", port="+port
         +",needsClientAuth="+needsClientAuth+", wantsClientAuth="+wantsClientAuth);
      return socket;
   }
View Full Code Here

    public static void setFactoryImpl(Class socketFactoryImpl) {
        CustomSSLSocketFactory.socketFactoryImpl = socketFactoryImpl;
    }
   
    public Socket createSocket() throws IOException {
        SSLSocket theSocket = (SSLSocket) getSocketFactory().createSocket();
        return theSocket;
    }
View Full Code Here

        SSLSocket theSocket = (SSLSocket) getSocketFactory().createSocket();
        return theSocket;
    }

    public Socket createSocket(String hostname, int port) throws IOException, UnknownHostException {
        SSLSocket theSocket = (SSLSocket) getSocketFactory().createSocket(hostname, port);
        return theSocket;
    }
View Full Code Here

        SSLSocket theSocket = (SSLSocket) getSocketFactory().createSocket(hostname, port);
        return theSocket;
    }

    public Socket createSocket(String hostname, int port, InetAddress arg2, int arg3) throws IOException, UnknownHostException {
        SSLSocket theSocket = (SSLSocket) getSocketFactory().createSocket(hostname, port, arg2, arg3);
        return theSocket;
    }
View Full Code Here

        SSLSocket theSocket = (SSLSocket) getSocketFactory().createSocket(hostname, port, arg2, arg3);
        return theSocket;
    }

    public Socket createSocket(InetAddress arg0, int arg1) throws IOException {
        SSLSocket theSocket = (SSLSocket) getSocketFactory().createSocket(arg0, arg1);
        return theSocket;
    }
View Full Code Here

        SSLSocket theSocket = (SSLSocket) getSocketFactory().createSocket(arg0, arg1);
        return theSocket;
    }

    public Socket createSocket(InetAddress arg0, int arg1, InetAddress arg2, int arg3) throws IOException {
        SSLSocket theSocket = (SSLSocket) getSocketFactory().createSocket(arg0, arg1, arg2, arg3);
        return theSocket;
    }
View Full Code Here

        }
    }
   
    public Socket negotiateSSL(final Socket sock) throws Exception {

        SSLSocket sslsock;
       
        try {
            sslsock=(SSLSocket)this.sslSocketFactory.createSocket(
                    sock,
                    sock.getInetAddress().getHostAddress(),
                    sock.getPort(),
                    true);

            sslsock.addHandshakeCompletedListener(
                    new HandshakeCompletedListener() {
                       public void handshakeCompleted(
                          final HandshakeCompletedEvent event) {
                          System.out.println("Handshake finished!");
                          System.out.println(
                          "\t CipherSuite:" + event.getCipherSuite());
                          System.out.println(
                          "\t SessionId " + event.getSession());
                          System.out.println(
                          "\t PeerHost " + event.getSession().getPeerHost());
                       }
                    }
                 );            
           
            sslsock.setUseClientMode(false);
            final String[] suites = sslsock.getSupportedCipherSuites();
            sslsock.setEnabledCipherSuites(suites);
//            start handshake
            sslsock.startHandshake();
           
            //String cipherSuite = sslsock.getSession().getCipherSuite();
           
            return sslsock;
        } catch (final Exception e) {
View Full Code Here

    }

// ----------------------------- subclass overrides ----------------------------
    public void configureSocket(Socket socket) {

        SSLSocket s;

        super.configureSocket(socket);

        s = (SSLSocket) socket;

        s.addHandshakeCompletedListener(this);
    }
View Full Code Here

TOP

Related Classes of javax.net.ssl.SSLSocket

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.