Package javax.net.ssl

Examples of javax.net.ssl.SSLSocket


        return socket;
    }


    public Socket createSocket(InetAddress host, int port) throws IOException {
        SSLSocket socket = null;
        socket = (SSLSocket)sslSocketFactory.createSocket(host, port);
        if ((socket != null) && (ciphers != null)) {
            socket.setEnabledCipherSuites(ciphers);
        }

        if (socket == null) {
            LogUtils.log(LOG, Level.SEVERE, "PROBLEM_CREATING_OUTBOUND_REQUEST_SOCKET",
                         new Object[]{host, port});
View Full Code Here


    }


    public Socket createSocket(InetAddress address, int port, InetAddress localAddress, int localPort)
        throws IOException {
        SSLSocket socket = null;
        socket = (SSLSocket)sslSocketFactory.createSocket(address, port, localAddress, localPort);
        if ((socket != null) && (ciphers != null)) {
            socket.setEnabledCipherSuites(ciphers);
        }

        if (socket == null) {
            LogUtils.log(LOG, Level.SEVERE, "PROBLEM_CREATING_OUTBOUND_REQUEST_SOCKET",
                         new Object[]{address, port});
View Full Code Here

        return;
      }

      sess.sendResponse("220 Ready to start TLS");

      SSLSocket s = sess.getServer().createSSLSocket(socket);
      s.startHandshake();
      log.debug("Cipher suite: " + s.getSession().getCipherSuite());

      sess.setSocket(s);
      sess.resetMessageState(); // clean slate
      sess.setTlsStarted(true);

      if (s.getNeedClientAuth())
      {
        try
        {
          Certificate[] peerCertificates = s.getSession().getPeerCertificates();
          sess.setTlsPeerCertificates(peerCertificates);
        }
        catch (SSLPeerUnverifiedException e)
        {
          // IGNORE, just leave the certificate chain null
View Full Code Here

   */
  public SSLSocket createSSLSocket(Socket socket) throws IOException
  {
    SSLSocketFactory sf = ((SSLSocketFactory) SSLSocketFactory.getDefault());
    InetSocketAddress remoteAddress = (InetSocketAddress) socket.getRemoteSocketAddress();
    SSLSocket s = (SSLSocket) (sf.createSocket(socket, remoteAddress.getHostName(), socket.getPort(), true));

    // we are a server
    s.setUseClientMode(false);

    // allow all supported cipher suites
    s.setEnabledCipherSuites(s.getSupportedCipherSuites());

    return s;
  }
View Full Code Here

     */
    protected void parseSocketInfo(Socket socket, WinstoneRequest req)
            throws IOException {
        super.parseSocketInfo(socket, req);
        if (socket instanceof SSLSocket) {
            SSLSocket s = (SSLSocket) socket;
            SSLSession ss = s.getSession();
            if (ss != null) {
                Certificate certChain[] = null;
                try {
                    certChain = ss.getPeerCertificates();
                } catch (Throwable err) {/* do nothing */
 
View Full Code Here

            EasyMock.expect(sslSocketFactory.createSocket((String)EasyMock.anyObject(),
                                                          EasyMock.anyInt())).andReturn(mockSocket);
            EasyMock.expect(sslSocketFactory.getDefaultCipherSuites()).andReturn(ciphs);
            EasyMock.expect(sslSocketFactory.getSupportedCipherSuites()).andReturn(ciphs);
            EasyMock.replay(sslSocketFactory);
            SSLSocket socket = 
                (SSLSocket)sslSocketFactoryWrapper.createSocket("localhost", 9001);
            assertTrue("Expected socket != null", socket != null);
            String[] defCiphers = sslSocketFactoryWrapper.getDefaultCipherSuites();
            assertTrue("Default Cipher suite not as expected", defCiphers[1].equals("b"));
            String[] suppCiphers = sslSocketFactoryWrapper.getSupportedCipherSuites();
View Full Code Here

   public Socket createSocket(InetAddress serverAddr, int serverPort,
      InetAddress clientAddr, int clientPort)
      throws IOException
   {
      SSLSocketFactory factory = (SSLSocketFactory) SSLSocketFactory.getDefault();
      SSLSocket socket = (SSLSocket) factory.createSocket(serverAddr, serverPort, clientAddr, clientPort);
      socket.addHandshakeCompletedListener(this);
      socket.setNeedClientAuth(needsClientAuth);
      socket.setWantClientAuth(wantsClientAuth);
      return socket;
   }
View Full Code Here

   }

   public Socket accept()
      throws IOException
   {
      SSLSocket socket = (SSLSocket) delegate.accept();
      socket.addHandshakeCompletedListener(this);
      return socket;
   }
View Full Code Here

                              InetAddress clientAddr, int clientPort)
      throws IOException
   {
      initSSLContext();
      SSLSocketFactory factory = sslCtx.getSocketFactory();
      SSLSocket socket =
         (SSLSocket)factory.createSocket(serverAddr, serverPort,
                                         clientAddr, clientPort);
      String[] supportedProtocols = socket.getSupportedProtocols();
      log.debug("Supported protocols: " + Arrays.asList(supportedProtocols));
      String[] protocols = supportedProtocols; // {"SSLv3"};
      socket.setEnabledProtocols(protocols);
      socket.addHandshakeCompletedListener(this);
      socket.setNeedClientAuth(needsClientAuth);
      socket.setWantClientAuth(wantsClientAuth);
      return socket;
   }
View Full Code Here

                              int serverPort, int timeout)
      throws IOException
   {
      initSSLContext();
      SSLSocketFactory factory = sslCtx.getSocketFactory();
      SSLSocket socket = (SSLSocket)factory.createSocket();
      socket.connect(new InetSocketAddress(serverAddr, serverPort), timeout);
      String[] supportedProtocols = socket.getSupportedProtocols();
      log.debug("Supported protocols: " + Arrays.asList(supportedProtocols));
      String[] protocols = supportedProtocols; // {"SSLv3"};
      socket.setEnabledProtocols(protocols);
      socket.addHandshakeCompletedListener(this);
      socket.setNeedClientAuth(needsClientAuth);
      socket.setWantClientAuth(wantsClientAuth);
      return socket;
   }
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.