当前位置: 首页>>代码示例>>Java>>正文


Java HandshakeCompletedListener类代码示例

本文整理汇总了Java中javax.net.ssl.HandshakeCompletedListener的典型用法代码示例。如果您正苦于以下问题:Java HandshakeCompletedListener类的具体用法?Java HandshakeCompletedListener怎么用?Java HandshakeCompletedListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


HandshakeCompletedListener类属于javax.net.ssl包,在下文中一共展示了HandshakeCompletedListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: notifyHandshakeCompletedListeners

import javax.net.ssl.HandshakeCompletedListener; //导入依赖的package包/类
final void notifyHandshakeCompletedListeners() {
    if (listeners != null && !listeners.isEmpty()) {
        // notify the listeners
        HandshakeCompletedEvent event = new HandshakeCompletedEvent(this, getActiveSession());
        for (HandshakeCompletedListener listener : listeners) {
            try {
                listener.handshakeCompleted(event);
            } catch (RuntimeException e) {
                // The RI runs the handlers in a separate thread,
                // which we do not. But we try to preserve their
                // behavior of logging a problem and not killing
                // the handshaking thread just because a listener
                // has a problem.
                Thread thread = Thread.currentThread();
                thread.getUncaughtExceptionHandler().uncaughtException(thread, e);
            }
        }
    }
}
 
开发者ID:google,项目名称:conscrypt,代码行数:20,代码来源:ConscryptSocketBase.java

示例2: HTTPConnection

import javax.net.ssl.HandshakeCompletedListener; //导入依赖的package包/类
/**
 * Creates a new HTTP or HTTPS connection on the specified port.
 * @param hostname the name of the host to connect to
 * @param port the port on the host to connect to
 * @param secure whether to use a secure connection
 * @param connectionTimeout the connection timeout
 * @param timeout the socket read timeout
 *
 * @throws IllegalArgumentException if either connectionTimeout or
 * timeout less than zero.
 */
public HTTPConnection(String hostname, int port, boolean secure,
                      int connectionTimeout, int timeout)
{
  if (connectionTimeout < 0 || timeout < 0)
    throw new IllegalArgumentException();

  this.hostname = hostname;
  this.port = port;
  this.secure = secure;
  this.connectionTimeout = connectionTimeout;
  this.timeout = timeout;
  majorVersion = minorVersion = 1;
  handshakeCompletedListeners
    = new ArrayList<HandshakeCompletedListener>(2);
}
 
开发者ID:vilie,项目名称:javify,代码行数:27,代码来源:HTTPConnection.java

示例3: HTTPConnection

import javax.net.ssl.HandshakeCompletedListener; //导入依赖的package包/类
/**
 * Creates a new HTTP or HTTPS connection on the specified port.
 * @param hostname the name of the host to connect to
 * @param port the port on the host to connect to
 * @param secure whether to use a secure connection
 * @param connectionTimeout the connection timeout
 * @param timeout the socket read timeout
 *
 * @throws IllegalArgumentException if either connectionTimeout or
 * timeout less than zero.
 */
public HTTPConnection(String hostname, int port, boolean secure,
                      int connectionTimeout, int timeout)
{
  if (connectionTimeout < 0 || timeout < 0)
    throw new IllegalArgumentException();
  
  this.hostname = hostname;
  this.port = port;
  this.secure = secure;
  this.connectionTimeout = connectionTimeout;
  this.timeout = timeout;
  majorVersion = minorVersion = 1;
  handshakeCompletedListeners
    = new ArrayList<HandshakeCompletedListener>(2);
}
 
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:27,代码来源:HTTPConnection.java

示例4: connect

import javax.net.ssl.HandshakeCompletedListener; //导入依赖的package包/类
@Override
public void connect(SocketAddress endpoint, int timeout) throws IOException {
    Date start = new Date();
    socket.connect(endpoint, timeout);
    Date end = new Date();
    RequestInfo.get().connect(start, end);
    handshakeStart = new Date();
    startHandshake();
    this.addHandshakeCompletedListener(new HandshakeCompletedListener() {
        @Override
        public void handshakeCompleted(HandshakeCompletedEvent handshakeCompletedEvent) {
            if (handshakeStart != null) {
                RequestInfo.get().ssl(handshakeStart, new Date());
            }
        }
    });
}
 
开发者ID:epam,项目名称:Wilma,代码行数:18,代码来源:SimulatedSSLSocket.java

示例5: removeHandshakeCompletedListener

import javax.net.ssl.HandshakeCompletedListener; //导入依赖的package包/类
/**
 * This method works according to the specification of implemented class.
 * @see javax.net.ssl.SSLSocket#removeHandshakeCompletedListener(HandshakeCompletedListener)
 * method documentation for more information
 */
@Override
public void removeHandshakeCompletedListener(
        HandshakeCompletedListener listener) {
    if (listener == null) {
        throw new IllegalArgumentException("Provided listener is null");
    }
    if (listeners == null) {
        throw new IllegalArgumentException(
                "Provided listener is not registered");
    }
    if (!listeners.remove(listener)) {
        throw new IllegalArgumentException(
                "Provided listener is not registered");
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:21,代码来源:SSLSocketImpl.java

示例6: notifyHandshakeCompletedListeners

import javax.net.ssl.HandshakeCompletedListener; //导入依赖的package包/类
private void notifyHandshakeCompletedListeners() {
    if (listeners != null && !listeners.isEmpty()) {
        // notify the listeners
        HandshakeCompletedEvent event =
            new HandshakeCompletedEvent(this, sslSession);
        for (HandshakeCompletedListener listener : listeners) {
            try {
                listener.handshakeCompleted(event);
            } catch (RuntimeException e) {
                // The RI runs the handlers in a separate thread,
                // which we do not. But we try to preserve their
                // behavior of logging a problem and not killing
                // the handshaking thread just because a listener
                // has a problem.
                Thread thread = Thread.currentThread();
                thread.getUncaughtExceptionHandler().uncaughtException(thread, e);
            }
        }
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:21,代码来源:OpenSSLSocketImpl.java

示例7: removeHandshakeCompletedListener

import javax.net.ssl.HandshakeCompletedListener; //导入依赖的package包/类
/**
 * The method removes a registered listener.
 * @throws IllegalArgumentException if listener is null or not registered
 */
@Override
public void removeHandshakeCompletedListener(
        HandshakeCompletedListener listener) {
    if (listener == null) {
        throw new IllegalArgumentException("Provided listener is null");
    }
    if (listeners == null) {
        throw new IllegalArgumentException(
                "Provided listener is not registered");
    }
    if (!listeners.remove(listener)) {
        throw new IllegalArgumentException(
                "Provided listener is not registered");
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:20,代码来源:OpenSSLSocketImpl.java

示例8: configure

import javax.net.ssl.HandshakeCompletedListener; //导入依赖的package包/类
/**
 * @param socket    Socket to configure
 * @param protocols Enabled SSL protocol versions
 */
protected void configure(final Socket socket, final String[] protocols) throws IOException {
    if(socket instanceof SSLSocket) {
        try {
            if(log.isDebugEnabled()) {
                log.debug(String.format("Configure SSL parameters with protocols %s", Arrays.toString(protocols)));
            }
            ((SSLSocket) socket).setEnabledProtocols(protocols);
            final List<String> ciphers = Arrays.asList(((SSLSocket) socket).getEnabledCipherSuites());
            final List<String> blacklist = preferences.getList("connection.ssl.cipher.blacklist");
            if(!blacklist.isEmpty()) {
                ciphers.removeIf(blacklist::contains);
            }
            ((SSLSocket) socket).setEnabledCipherSuites(ciphers.toArray(new String[ciphers.size()]));
            if(log.isInfoEnabled()) {
                log.info(String.format("Enabled cipher suites %s",
                        Arrays.toString(((SSLSocket) socket).getEnabledCipherSuites())));
                ((SSLSocket) socket).addHandshakeCompletedListener(new HandshakeCompletedListener() {
                    @Override
                    public void handshakeCompleted(final HandshakeCompletedEvent event) {
                        log.info(String.format("Completed handshake with %s and negotiated cipher suite %s",
                                event.getSession().getProtocol(), event.getCipherSuite()));
                        ((SSLSocket) socket).removeHandshakeCompletedListener(this);
                    }
                });
            }
        }
        catch(Exception e) {
            log.warn(String.format("Failed to configure SSL parameters %s", e.getMessage()));
        }
    }
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:36,代码来源:CustomTrustSSLProtocolSocketFactory.java

示例9: createSSLSocket

import javax.net.ssl.HandshakeCompletedListener; //导入依赖的package包/类
/**
 * Create an SSL client socket using the IOR-encoded
 * security characteristics.
 * Setting want/need client auth on a client socket has no effect so all we can do is use the right host, port, ciphers
 *
 * @param host     The target host name.
 * @param port     The target connection port.
 *
 * @return An appropriately configured client SSLSocket.
 * @exception IOException if ssl socket can't be obtained and configured.
 */
private Socket createSSLSocket(String host, int port, int requires, int supports) throws IOException {
    SSLSocketFactory factory = getSocketFactory();
    SSLSocket socket = (SSLSocket) factory.createSocket(host, port);

    socket.setSoTimeout(SOCKET_TIMEOUT_MS);

    // get a set of cipher suites appropriate for this connections requirements.
    // We request this for each connection, since the outgoing IOR's requirements may be different from
    // our server listener requirements.
    String[] iorSuites = SSLCipherSuiteDatabase.getCipherSuites(requires, supports, factory.getSupportedCipherSuites());
    socket.setEnabledCipherSuites(iorSuites);
    if (log.isDebugEnabled()) {
        log.debug("Created SSL socket to " + host + ":" + port);
        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);
                    for (int i = 0; i < certs.length; i++) {
                        Certificate cert = certs[i];
                        log.debug("cert: " + cert.toString());
                    }
                } else {
                    log.debug("handshake returned no local certs");
                }
            }
        });
    }
    return socket;
}
 
开发者ID:RuiChen08,项目名称:dacapobench,代码行数:48,代码来源:SocketFactory.java

示例10: removeHandshakeCompletedListener

import javax.net.ssl.HandshakeCompletedListener; //导入依赖的package包/类
@Override
public void removeHandshakeCompletedListener(HandshakeCompletedListener listener) {
    checkArgument(listener != null, "Provided listener is null");
    if (!listeners.remove(listener)) {
        throw new IllegalArgumentException("Provided listener is not registered");
    }
}
 
开发者ID:google,项目名称:conscrypt,代码行数:8,代码来源:ConscryptSocketBase.java

示例11: test_SSLSocket_HandshakeCompletedListener_RuntimeException

import javax.net.ssl.HandshakeCompletedListener; //导入依赖的package包/类
@Test
public void test_SSLSocket_HandshakeCompletedListener_RuntimeException() throws Exception {
    final Thread self = Thread.currentThread();
    final UncaughtExceptionHandler original = self.getUncaughtExceptionHandler();
    final RuntimeException expectedException = new RuntimeException("expected");
    final TestUncaughtExceptionHandler test = new TestUncaughtExceptionHandler();
    self.setUncaughtExceptionHandler(test);
    final TestSSLContext c = TestSSLContext.create();
    final SSLSocket client =
            (SSLSocket) c.clientContext.getSocketFactory().createSocket(c.host, c.port);
    final SSLSocket server = (SSLSocket) c.serverSocket.accept();
    Future<Void> future = runAsync(new Callable<Void>() {
        @Override
        public Void call() throws Exception {
            server.startHandshake();
            return null;
        }
    });
    client.addHandshakeCompletedListener(new HandshakeCompletedListener() {
        @Override
        public void handshakeCompleted(HandshakeCompletedEvent event) {
            throw expectedException;
        }
    });
    client.startHandshake();
    future.get();
    client.close();
    server.close();
    c.close();
    assertSame(expectedException, test.actualException);
    self.setUncaughtExceptionHandler(original);
}
 
开发者ID:google,项目名称:conscrypt,代码行数:33,代码来源:SSLSocketTest.java

示例12: addHandshakeCompletedListener

import javax.net.ssl.HandshakeCompletedListener; //导入依赖的package包/类
void addHandshakeCompletedListener(HandshakeCompletedListener l)
{
  synchronized (handshakeCompletedListeners)
    {
      handshakeCompletedListeners.add(l);
    }
}
 
开发者ID:vilie,项目名称:javify,代码行数:8,代码来源:HTTPConnection.java

示例13: removeHandshakeCompletedListener

import javax.net.ssl.HandshakeCompletedListener; //导入依赖的package包/类
void removeHandshakeCompletedListener(HandshakeCompletedListener l)
{
  synchronized (handshakeCompletedListeners)
    {
      handshakeCompletedListeners.remove(l);
    }
}
 
开发者ID:vilie,项目名称:javify,代码行数:8,代码来源:HTTPConnection.java

示例14: SSLSocketImpl

import javax.net.ssl.HandshakeCompletedListener; //导入依赖的package包/类
public SSLSocketImpl(SSLContextImpl contextImpl, String host, int port,
                     Socket underlyingSocket, boolean autoClose)
{
  engine = new SSLEngineImpl(contextImpl, host, port);
  engine.setUseClientMode(true); // default to client mode
  listeners = new HashSet<HandshakeCompletedListener>();
  this.underlyingSocket = underlyingSocket;
  this.autoClose = autoClose;
}
 
开发者ID:vilie,项目名称:javify,代码行数:10,代码来源:SSLSocketImpl.java

示例15: CustomSslSocketFactory

import javax.net.ssl.HandshakeCompletedListener; //导入依赖的package包/类
/**
 * Constructor
 *
 * @param sslSocketFactory The actual SSLSocketFactory (used by this class)
 * @param handshakeListener The class that handles "handshake completed" events
 */
public CustomSslSocketFactory(SSLSocketFactory sslSocketFactory, HandshakeCompletedListener handshakeListener,
		boolean sniEnabled) {
	this.sslSocketFactory = sslSocketFactory;
	this.handshakeListener = handshakeListener;
	this.sniEnabled = sniEnabled;
}
 
开发者ID:kaikramer,项目名称:keystore-explorer,代码行数:13,代码来源:CustomSslSocketFactory.java


注:本文中的javax.net.ssl.HandshakeCompletedListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。