Package javax.net.ssl

Examples of javax.net.ssl.HandshakeCompletedListener


        SSLContext sslCtx = SSLContext.getInstance("TLS");
        sslCtx.init(null, trustAllCerts, new java.security.SecureRandom());
        SSLSocketFactory socketFactory = sslCtx.getSocketFactory();
        SSLSocket socket = (SSLSocket) socketFactory.createSocket("localhost", getPort());

        socket.addHandshakeCompletedListener(new HandshakeCompletedListener() {
            @Override
            public void handshakeCompleted(HandshakeCompletedEvent event) {
                handshakeDone = true;
            }
        });
View Full Code Here


        SSLContext sslCtx = SSLContext.getInstance("TLS");
        sslCtx.init(null, TesterSupport.getTrustManagers(), null);
        SSLSocketFactory socketFactory = sslCtx.getSocketFactory();
        SSLSocket socket = (SSLSocket) socketFactory.createSocket("localhost", getPort());

        socket.addHandshakeCompletedListener(new HandshakeCompletedListener() {
            @Override
            public void handshakeCompleted(HandshakeCompletedEvent event) {
                handshakeDone = true;
            }
        });
View Full Code Here

        SSLContext sslCtx = SSLContext.getInstance("TLS");
        sslCtx.init(null, trustAllCerts, new java.security.SecureRandom());
        SSLSocketFactory socketFactory = sslCtx.getSocketFactory();
        SSLSocket socket = (SSLSocket) socketFactory.createSocket("localhost", getPort());

        socket.addHandshakeCompletedListener(new HandshakeCompletedListener() {
            @Override
            public void handshakeCompleted(HandshakeCompletedEvent event) {
                handshakeDone = true;
            }
        });
View Full Code Here

        SSLContext sslCtx = SSLContext.getInstance("TLS");
        sslCtx.init(null, trustAllCerts, new java.security.SecureRandom());
        SSLSocketFactory socketFactory = sslCtx.getSocketFactory();
        SSLSocket socket = (SSLSocket) socketFactory.createSocket("localhost", getPort());

        socket.addHandshakeCompletedListener(new HandshakeCompletedListener() {
            @Override
            public void handshakeCompleted(HandshakeCompletedEvent event) {
                handshakeDone = true;
            }
        });
View Full Code Here

            log.debug("    cipher suites:");

            for (int i = 0; i < iorSuites.length; i++) {
                log.debug("    " + iorSuites[i]);
            }
            socket.addHandshakeCompletedListener(new HandshakeCompletedListener() {

                public void handshakeCompleted(HandshakeCompletedEvent handshakeCompletedEvent) {
                    Certificate[] certs = handshakeCompletedEvent.getLocalCertificates();
                    if (certs != null) {
                        log.debug("handshake returned local certs count: " + certs.length);
View Full Code Here

                        "inaddr = " + dst);
                logger.logDebug(
                        "port = " + dstPort);
            }

            HandshakeCompletedListener listner
                    = new HandshakeCompletedListenerImpl(channel);

            channel.setHandshakeCompletedListener(listner);
            sslsock.addHandshakeCompletedListener(listner);
            sslsock.setEnabledProtocols(sipStack.getEnabledProtocols());
View Full Code Here

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

                        try {
                            sipStack
                                    .getTlsSecurityPolicy()
                                    .enforceTlsPolicy(
                                            messageChannel
                                                    .getEncapsulatedClientTransaction());
                        } catch (SecurityException ex) {
                            throw new IOException(ex.getMessage());
                        }

                        if (logger.isLoggingEnabled(LogWriter.TRACE_DEBUG)) {
                            this.logger.logDebug(
                                    "TLS Security policy passed");
                        }
                        OutputStream outputStream = clientSock
                                .getOutputStream();
                        writeChunks(outputStream, bytes, length);
                        putSocket(key, clientSock);
                        break;
                    } else {
                        try {
                            OutputStream outputStream = clientSock
                                    .getOutputStream();
                            writeChunks(outputStream, bytes, length);
                            break;
                        } catch (IOException ex) {
                            if (logger.isLoggingEnabled())
                                logger.logException(ex);
                            // old connection is bad.
                            // remove from our table.
                            removeSocket(key);

                            try {
                                logger.logDebug(
                                        "Closing socket");
                                clientSock.close();
                            } catch (Exception e) {
                            }
                            clientSock = null;
                            retry_count++;
                        }
                    }
                }
            } catch (SSLHandshakeException ex) {
                removeSocket(key);
                throw ex;
            } catch (IOException ex) {
                removeSocket(key);

                if (!isClient) {
                    receiverAddress = InetAddress.getByName(messageChannel
                            .getViaHost());
                    contactPort = messageChannel.getViaPort();
                    if (contactPort == -1)
                        contactPort = 5060;

                    key = makeKey(receiverAddress, messageChannel
                            .getViaPort());
                    clientSock = this.getSocket(key);
                    if (clientSock == null) {
                        if (logger.isLoggingEnabled(LogWriter.TRACE_DEBUG)) {
                            logger.logDebug(
                                    "inaddr = " + receiverAddress +
                                    " port = " + contactPort);
                        }
                        SSLSocket sslsock = sipStack.getNetworkLayer().createSSLSocket(
                                receiverAddress, contactPort, senderAddress);
                        OutputStream outputStream = sslsock
                                .getOutputStream();
                        HandshakeCompletedListener listner = new HandshakeCompletedListenerImpl(
                                (TLSMessageChannel) messageChannel);
                        ((TLSMessageChannel) messageChannel)
                                .setHandshakeCompletedListener(listner);
                        sslsock.addHandshakeCompletedListener(listner);
                        sslsock.setEnabledProtocols(sipStack
View Full Code Here

                int oldTimeout = _socket.getSoTimeout();
                if (handshakeTimeout > 0)           
                    _socket.setSoTimeout(handshakeTimeout);

                final SSLSocket ssl=(SSLSocket)_socket;
                ssl.addHandshakeCompletedListener(new HandshakeCompletedListener()
                {
                    boolean handshook=false;
                    public void handshakeCompleted(HandshakeCompletedEvent event)
                    {
                        if (handshook)
View Full Code Here

              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
View Full Code Here

     * method testing.
     * removeHandshakeCompletedListener( HandshakeCompletedListener listener)
     * method testing.
     */
    public void testAddRemoveHandshakeCompletedListener() throws Exception {
        HandshakeCompletedListener listener =
            new HandshakeCompletedListener() {
                public void handshakeCompleted(
                        HandshakeCompletedEvent event) { }
            };
        SSLSocket socket = createSSLSocket();
        socket.addHandshakeCompletedListener(listener);
        try {
            socket.addHandshakeCompletedListener(null);
            fail("Expected IllegalArgumentException was not thrown.");
        } catch (IllegalArgumentException e) { }
        try {
            socket.removeHandshakeCompletedListener(null);
            fail("Expected IllegalArgumentException was not thrown.");
        } catch (IllegalArgumentException e) { }
        try {
            socket.removeHandshakeCompletedListener(
                    new HandshakeCompletedListener() {
                        public void handshakeCompleted(
                                HandshakeCompletedEvent event) { }
                    });
            fail("Expected IllegalArgumentException was not thrown.");
        } catch (IllegalArgumentException e) { }
View Full Code Here

TOP

Related Classes of javax.net.ssl.HandshakeCompletedListener

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.