Example usage for javax.net.ssl SSLEngine getPeerHost

List of usage examples for javax.net.ssl SSLEngine getPeerHost

Introduction

In this page you can find the example usage for javax.net.ssl SSLEngine getPeerHost.

Prototype

public String getPeerHost() 

Source Link

Document

Returns the host name of the peer.

Usage

From source file:mitm.BouncyCastleSslEngineSource.java

private void filterWeakCipherSuites(SSLEngine sslEngine) {
    List<String> ciphers = new LinkedList<String>();
    for (String each : sslEngine.getEnabledCipherSuites()) {
        if (each.equals(each.equals("TLS_DHE_RSA_WITH_AES_128_CBC_SHA")
                || each.equals("TLS_DHE_RSA_WITH_AES_256_CBC_SHA"))) {
            LOG.debug("Removed cipher {}", each);
        } else {/*w  w w. j  ava2s. co m*/
            ciphers.add(each);
        }
    }
    sslEngine.setEnabledCipherSuites(ciphers.toArray(new String[ciphers.size()]));
    if (LOG.isDebugEnabled()) {
        if (sslEngine.getUseClientMode()) {
            LOG.debug("Enabled server cipher suites:");
        } else {
            String host = sslEngine.getPeerHost();
            int port = sslEngine.getPeerPort();
            LOG.debug("Enabled client {}:{} cipher suites:", host, port);
        }
        for (String each : ciphers) {
            LOG.debug(each);
        }
    }
}