Package javax.net.ssl

Examples of javax.net.ssl.SSLSocket


      tm
    }, null);
    SSLSocketFactory factory = context.getSocketFactory();

    System.out.println("Opening connection to " + host + ":" + port + "...");
    SSLSocket socket = (SSLSocket) factory.createSocket(host, port);
    socket.setSoTimeout(10000);
    try {
      System.out.println("Starting SSL handshake...");
      socket.startHandshake();
      socket.close();
      System.out.println();
      System.out.println("No errors, certificate is already trusted");
    } catch (SSLException e) {
      System.out.println();
      e.printStackTrace(System.out);
View Full Code Here


         this.serverSocket = serverSocket;
         bind(new InetSocketAddress(bindAddr, port), 50);
      }
      public Socket accept() throws IOException
      {
         SSLSocket s1 = (SSLSocket) serverSocket.accept();
         Socket s2 = new SSLTestSocket(timeout, initialWrites, s1);
         return s2;
      }
View Full Code Here

    {
        super.customize(endpoint, request);
        request.setScheme(HttpSchemes.HTTPS);
       
        SocketEndPoint socket_end_point = (SocketEndPoint)endpoint;
        SSLSocket sslSocket = (SSLSocket)socket_end_point.getTransport();
       
        try
        {
            SSLSession sslSession = sslSocket.getSession();
            String cipherSuite = sslSession.getCipherSuite();
            Integer keySize;
            X509Certificate[] certs;

            CachedInfo cachedInfo = (CachedInfo) sslSession.getValue(CACHED_INFO_ATTR);
View Full Code Here

        }

        mySock = (SSLSocket) sock;
        if (sock instanceof SSLSocket) {
            try {
                SSLSocket sslSock = (SSLSocket) sock;
                sslSock.setNeedClientAuth(true);
                this.handshakeCompletedListener = new HandshakeCompletedListenerImpl(
                        this);
                sslSock
                        .addHandshakeCompletedListener(this.handshakeCompletedListener);
                sslSock.startHandshake();
            } catch (SSLHandshakeException ex) {
                throw new IOException(ex.getMessage());
            }
        }
View Full Code Here

    return ctx;
  }

  private static TSocket createClient(SSLSocketFactory factory, String host, int port, int timeout) throws TTransportException {
    try {
      SSLSocket socket = (SSLSocket) factory.createSocket(host, port);
      socket.setSoTimeout(timeout);
      return new TSocket(socket);
    } catch (Exception e) {
      throw new TTransportException("Could not connect to " + host + " on port " + port, e);
    }
  }
View Full Code Here

    public Socket createSocket(String host, int port) throws IOException {
        this.initSSLContext();
        InetAddress address = InetAddress.getByName(host);

        SSLSocketFactory socketFactory = this.sslContext.getSocketFactory();
        SSLSocket socket = (SSLSocket) socketFactory.createSocket(address, port);
        if (this.jsseSecurityDomain.getProtocols() != null)
            socket.setEnabledProtocols(this.jsseSecurityDomain.getProtocols());
        if (this.jsseSecurityDomain.getCipherSuites() != null)
            socket.setEnabledCipherSuites(this.jsseSecurityDomain.getCipherSuites());
        socket.setNeedClientAuth(this.jsseSecurityDomain.isClientAuth());
        return socket;
    }
View Full Code Here

    public Socket createSocket(String host, int port, int timeout) throws IOException, TIMEOUT {
        this.initSSLContext();
        InetAddress address = InetAddress.getByName(host);

        SSLSocketFactory socketFactory = this.sslContext.getSocketFactory();
        SSLSocket socket = (SSLSocket) socketFactory.createSocket();
        socket.connect(new InetSocketAddress(address, port), timeout);
        if (this.jsseSecurityDomain.getProtocols() != null)
            socket.setEnabledProtocols(this.jsseSecurityDomain.getProtocols());
        if (this.jsseSecurityDomain.getCipherSuites() != null)
            socket.setEnabledCipherSuites(this.jsseSecurityDomain.getCipherSuites());
        socket.setNeedClientAuth(this.jsseSecurityDomain.isClientAuth());
        return socket;
    }
View Full Code Here

          if (clientSock == null) {

            clientSock = sipStack.getNetworkLayer()
                .createSSLSocket(receiverAddress, contactPort,
                    senderAddress);
            SSLSocket sslsock = (SSLSocket) clientSock;

            if (sipStack.isLoggingEnabled(LogWriter.TRACE_DEBUG)) {
              sipStack.getStackLogger().logDebug(
                  "inaddr = " + receiverAddress);
              sipStack.getStackLogger().logDebug(
                  "port = " + contactPort);
            }
            HandshakeCompletedListener listner = new HandshakeCompletedListenerImpl(
                (TLSMessageChannel) messageChannel);
            ((TLSMessageChannel) messageChannel)
                .setHandshakeCompletedListener(listner);
            sslsock.addHandshakeCompletedListener(listner);
            sslsock.setEnabledProtocols(sipStack
                .getEnabledProtocols());
            sslsock.startHandshake();
            if (sipStack.isLoggingEnabled(LogWriter.TRACE_DEBUG)) {
              this.sipStack.getStackLogger().logDebug(
                  "Handshake passed");
            }
            // allow application to enforce policy by validating the
View Full Code Here

        }

        mySock = (SSLSocket) sock;
        if (sock instanceof SSLSocket) {
            try {
                SSLSocket sslSock = (SSLSocket) sock;
                sslSock.setNeedClientAuth(true);
                this.handshakeCompletedListener = new HandshakeCompletedListenerImpl(this);
                sslSock.addHandshakeCompletedListener(this.handshakeCompletedListener);
                sslSock.startHandshake();
            } catch (SSLHandshakeException ex) {
                throw new IOException(ex.getMessage());
            }
        }
       
View Full Code Here

      {
         // need to check for handshake listener and add them if there is one
         Object obj = configuration.get(Client.HANDSHAKE_COMPLETED_LISTENER);
         if (obj != null && obj instanceof HandshakeCompletedListener)
         {
            SSLSocket sslSocket = (SSLSocket) s;
            HandshakeCompletedListener listener = (HandshakeCompletedListener) obj;
            establishHandshake(sslSocket, listener);
         }
      }
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.