Search in sources :

Example 1 with SslSocketFactory

use of com.github.jh3nd3rs0n.jargyle.internal.net.ssl.SslSocketFactory in project jargyle by jh3nd3rs0n.

the class SslSocketFactoryImpl method newSocket.

@Override
public Socket newSocket(final Socket socket, final String host, final int port, final boolean autoClose) throws IOException {
    synchronized (this) {
        if (this.sslContext == null) {
            this.sslContext = this.getSslContext();
        }
    }
    SslSocketFactory factory = SslSocketFactory.newInstance(this.sslContext);
    SSLSocket sslSocket = (SSLSocket) factory.newSocket(socket, host, port, autoClose);
    Properties properties = this.socksClient.getProperties();
    Words enabledCipherSuites = properties.getValue(SslPropertySpecConstants.SSL_ENABLED_CIPHER_SUITES);
    String[] cipherSuites = enabledCipherSuites.toStringArray();
    if (cipherSuites.length > 0) {
        sslSocket.setEnabledCipherSuites(cipherSuites);
    }
    Words enabledProtocols = properties.getValue(SslPropertySpecConstants.SSL_ENABLED_PROTOCOLS);
    String[] protocols = enabledProtocols.toStringArray();
    if (protocols.length > 0) {
        sslSocket.setEnabledProtocols(protocols);
    }
    return sslSocket;
}
Also used : SslSocketFactory(com.github.jh3nd3rs0n.jargyle.internal.net.ssl.SslSocketFactory) SSLSocket(javax.net.ssl.SSLSocket) Words(com.github.jh3nd3rs0n.jargyle.common.text.Words)

Example 2 with SslSocketFactory

use of com.github.jh3nd3rs0n.jargyle.internal.net.ssl.SslSocketFactory in project jargyle by jh3nd3rs0n.

the class SslSocketFactoryImpl method newSocket.

@Override
public Socket newSocket(final Socket socket, final InputStream consumed, final boolean autoClose) throws IOException {
    synchronized (this) {
        if (this.sslContext == null) {
            this.sslContext = this.getSslContext();
        }
    }
    SslSocketFactory factory = SslSocketFactory.newInstance(this.sslContext);
    SSLSocket sslSocket = (SSLSocket) factory.newSocket(socket, consumed, autoClose);
    Settings settings = this.configuration.getSettings();
    Words enabledCipherSuites = settings.getLastValue(SslSettingSpecConstants.SSL_ENABLED_CIPHER_SUITES);
    String[] cipherSuites = enabledCipherSuites.toStringArray();
    if (cipherSuites.length > 0) {
        sslSocket.setEnabledCipherSuites(cipherSuites);
    }
    Words enabledProtocols = settings.getLastValue(SslSettingSpecConstants.SSL_ENABLED_PROTOCOLS);
    String[] protocols = enabledProtocols.toStringArray();
    if (protocols.length > 0) {
        sslSocket.setEnabledProtocols(protocols);
    }
    if (settings.getLastValue(SslSettingSpecConstants.SSL_NEED_CLIENT_AUTH).booleanValue()) {
        sslSocket.setNeedClientAuth(true);
    }
    if (settings.getLastValue(SslSettingSpecConstants.SSL_WANT_CLIENT_AUTH).booleanValue()) {
        sslSocket.setWantClientAuth(true);
    }
    return sslSocket;
}
Also used : SslSocketFactory(com.github.jh3nd3rs0n.jargyle.internal.net.ssl.SslSocketFactory) SSLSocket(javax.net.ssl.SSLSocket) Words(com.github.jh3nd3rs0n.jargyle.common.text.Words)

Aggregations

Words (com.github.jh3nd3rs0n.jargyle.common.text.Words)2 SslSocketFactory (com.github.jh3nd3rs0n.jargyle.internal.net.ssl.SslSocketFactory)2 SSLSocket (javax.net.ssl.SSLSocket)2