Example usage for javax.net.ssl SSLSocket isClosed

List of usage examples for javax.net.ssl SSLSocket isClosed

Introduction

In this page you can find the example usage for javax.net.ssl SSLSocket isClosed.

Prototype

public boolean isClosed() 

Source Link

Document

Returns the closed state of the socket.

Usage

From source file:org.kuali.mobility.push.factory.iOSConnectionFactory.java

@Override
public boolean validateObject(SSLSocket obj) {
    if (obj == null) {
        return false; // null is obviously not valid
    }//from  w ww . j  a va2 s .c om
    return obj.isConnected() && !obj.isClosed();
}

From source file:org.lockss.protocol.BlockingStreamComm.java

protected void handshake(SSLSocket s) throws SSLPeerUnverifiedException {
    long oldTimeout = -2;
    try {// w  ww . j  a  va  2s  .  c o m
        oldTimeout = s.getSoTimeout();
        if (absTimeout(paramSslHandshakeTimeout) < absTimeout(oldTimeout)) {
            s.setSoTimeout((int) paramSslHandshakeTimeout);
        }
    } catch (SocketException e) {
        log.warning("Couldn't save/set socket timeout before handshake", e);
    }
    try {
        SSLSession session = s.getSession();
        java.security.cert.Certificate[] certs = session.getPeerCertificates();
        log.debug(session.getPeerHost() + " via " + session.getProtocol() + " verified");
    } catch (SSLPeerUnverifiedException ex) {
        log.error(s.getInetAddress() + ":" + s.getPort() + " not verified");
        try {
            s.close();
        } catch (IOException ex2) {
            log.error("Socket close threw " + ex2);
        }
        throw ex;
    } finally {
        if (!s.isClosed() && absTimeout(paramSslHandshakeTimeout) < absTimeout(oldTimeout)) {
            try {
                s.setSoTimeout((int) oldTimeout);
            } catch (SocketException e) {
                log.warning("Couldn't restore socket timeout after handshake", e);
            }
        }
    }
}