Examples of SSLSocket


Examples of com.maverick.ssl.SSLSocket

                if (host == null) {
                    throw new IOException(Messages.getString("HttpsURLConnection.noHost")); //$NON-NLS-1$
                }
                int port = url.getPort();
                try {
                    socket = new SSLSocket(host, port == -1 ? 443 : port);
                } catch (SSLException ex1) {
                    throw new SSLIOException(ex1);
                }
            }
View Full Code Here

Examples of iaik.security.ssl.SSLSocket

      return false;
    } catch (Exception ex) {
      return false;
    }

    SSLSocket ssl = null;
    SSLServerContext serverContext = new SSLServerContext();
    boolean generateDHParameters = false;     // use pre-generated Diffi-Hellman parameters

    DHParameterSpec dhparam = null;
View Full Code Here

Examples of javax.net.ssl.SSLSocket

  public HttpConnection createHttpsConnection(String host, int port)
    throws IOException
  {
    HttpConnection connection = null;
    SSLSocketFactory factory = (SSLSocketFactory)SSLSocketFactory.getDefault();
    SSLSocket socket = null;

    if (! useProxy) {
     
      socket = (SSLSocket)factory.createSocket(host,port);

    } else {
     
      Socket tunnel = new Socket(proxyHost, proxyPort);
      doTunnelHandshake(tunnel, host, port);
     
      /*
       * Ok, let's overlay the tunnel socket with SSL.
       */
      socket = (SSLSocket)factory.createSocket(tunnel, host, port, true);
     
      /*
       * send http request
       *
       * See SSLSocketClient.java for more information about why
       * there is a forced handshake here when using PrintWriters.
       */
      socket.startHandshake();
    }

    connection = new HttpConnection(socket);

    return connection;
View Full Code Here

Examples of javax.net.ssl.SSLSocket

    // Start it off as a regular socket, then layer SSL over the top of it.
    Socket tunnel = new Socket(proxy, proxyport);
    doTunnelHandshake(tunnel, host, port);

    // Ok, let's overlay the tunnel socket with SSL.
    SSLSocket socket =
      (SSLSocket) getSocketFactory().createSocket(tunnel,host.getHostName(), port, true);
    // register a callback for handshaking completion event
    socket.addHandshakeCompletedListener(
      new HandshakeCompletedListener() {
        public void handshakeCompleted(HandshakeCompletedEvent event) {
        }
      });
View Full Code Here

Examples of javax.net.ssl.SSLSocket

                    // get socket factory
                    SSLSocketFactory socFactory = ssl.getSocketFactory();

                    // create socket
                    SSLSocket ssoc = (SSLSocket) socFactory.createSocket();
                    ssoc.setUseClientMode(false);

                    // initialize socket
                    if (ssl.getEnabledCipherSuites() != null) {
                        ssoc.setEnabledCipherSuites(ssl.getEnabledCipherSuites());
                    }
                    dataSoc = ssoc;
                } else {
                    LOG.debug("Opening active data connection");
                    dataSoc = new Socket();
                }

                dataSoc.setReuseAddress(true);

                InetAddress localAddr = resolveAddress(dataConfig
                        .getActiveLocalAddress());

                // if no local address has been configured, make sure we use the same as the client connects from
                if(localAddr == null) {
                    localAddr = ((InetSocketAddress)session.getLocalAddress()).getAddress();
                }      

                SocketAddress localSocketAddress = new InetSocketAddress(localAddr, dataConfig.getActiveLocalPort());
               
                LOG.debug("Binding active data connection to {}", localSocketAddress);
                dataSoc.bind(localSocketAddress);

                dataSoc.connect(new InetSocketAddress(address, port));
            } else {

                if (secure) {
                    LOG.debug("Opening secure passive data connection");
                    // this is where we wrap the unsecured socket as a SSLSocket. This is
                    // due to the JVM bug described in FTPSERVER-241.

                    // get server socket factory
                    SslConfiguration ssl = getSslConfiguration();
                   
                    // we've already checked this, but let's do it again
                    if (ssl == null) {
                        throw new FtpException(
                                "Data connection SSL not configured");
                    }

                    SSLSocketFactory ssocketFactory = ssl.getSocketFactory();

                    Socket serverSocket = servSoc.accept();

                    SSLSocket sslSocket = (SSLSocket) ssocketFactory
                            .createSocket(serverSocket, serverSocket
                                    .getInetAddress().getHostAddress(),
                                    serverSocket.getPort(), true);
                    sslSocket.setUseClientMode(false);

                    // initialize server socket
                    if (ssl.getClientAuth() == ClientAuth.NEED) {
                        sslSocket.setNeedClientAuth(true);
                    } else if (ssl.getClientAuth() == ClientAuth.WANT) {
                        sslSocket.setWantClientAuth(true);
                    }

                    if (ssl.getEnabledCipherSuites() != null) {
                        sslSocket.setEnabledCipherSuites(ssl
                                .getEnabledCipherSuites());
                    }

                    dataSoc = sslSocket;
                } else {
View Full Code Here

Examples of javax.net.ssl.SSLSocket

      // TODO Auto-generated catch block
      e.printStackTrace();
      return null;
    }

    SSLSocket result = (SSLSocket) this.factory.createSocket(tunnel, host, port, autoClose);
    return result;
  }
View Full Code Here

Examples of javax.net.ssl.SSLSocket

      this.factory = context.getSocketFactory();
      this.isAnon = isAnon;
    }

    public synchronized Socket getSocket() throws IOException {
        SSLSocket result = (SSLSocket)factory.createSocket();
        result.setUseClientMode(true);
        if (isAnon && !addCipherSuite(result, ANON_CIPHER_SUITE) && !warned) {
          warned = true;
          logger.warning(JDBCPlugin.Util.getString("SocketUtil.anon_not_available")); //$NON-NLS-1$
        }
        return result;
View Full Code Here

Examples of javax.net.ssl.SSLSocket

      throw new SocketException("Socket closed or already open ("+ level +")");
    IOException exception = null;
    if (trustManagers.size() == 0)
      addTrustManager(new SSLDefaultTrustManager());
    SSLSocketFactory sf = null;
    SSLSocket s = null;
    for (int i = 0; i < ports.length && s == null; i++) {
      try {
        if (sf == null)
          sf = SSLSocketFactoryFactory.createSSLSocketFactory(getTrustManagers());
        s = (SSLSocket)sf.createSocket(host, ports[i]);
        s.startHandshake();
        exception = null;
      } catch (SSLNotSupportedException exc) {
        if (s != null)
          s.close();
        s = null;
        throw exc;
      } catch (IOException exc) {
        if (s != null)
          s.close();
        s = null;
        exception = exc;
      }
    }
    if (exception != null)
View Full Code Here

Examples of javax.net.ssl.SSLSocket

  public void connect() throws IOException {
    if (level != 0) // otherwise disconnected or connect
      throw new SocketException("Socket closed or already open ("+ level +")");
    IOException exception = null;
    SSLSocketFactory sf = null;
    SSLSocket s = null;
    for (int i = 0; i < ports.length && s == null; i++) {
      try {
        if (sf == null)
          sf = getSocketFactory();
        s = (SSLSocket)sf.createSocket(host, ports[i]);
        s.startHandshake();
        exception = null;
      } catch (IOException exc) {
        if (s != null)
          s.close();
        s = null;
        exception = exc;
      }
    }
    if (exception != null)
View Full Code Here

Examples of javax.net.ssl.SSLSocket

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

        return 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.