Example usage for javax.net.ssl SSLEngine setEnabledProtocols

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

Introduction

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

Prototype

public abstract void setEnabledProtocols(String protocols[]);

Source Link

Document

Set the protocol versions enabled for use on this engine.

Usage

From source file:com.eucalyptus.crypto.util.SslSetup.java

public static SSLEngine getServerEngine() {//TODO:GRZE: @Configurability
    final SSLEngine engine = SERVER_CONTEXT.createSSLEngine();
    engine.setUseClientMode(false);//from  w w  w .jav a2  s .  c o m
    engine.setWantClientAuth(false);
    engine.setNeedClientAuth(false);
    engine.setEnabledProtocols(
            SslUtils.getEnabledProtocols(SERVER_SSL_PROTOCOLS, engine.getSupportedProtocols()));
    engine.setEnabledCipherSuites(
            SslUtils.getEnabledCipherSuites(SERVER_SSL_CIPHERS, SERVER_SUPPORTED_CIPHERS));
    return engine;
}

From source file:org.siddhiesb.transport.http.conn.ServerSSLSetupHandler.java

public void initalize(final SSLEngine sslengine) throws SSLException {
    if (clientAuth != null) {
        switch (clientAuth) {
        case OPTIONAL:
            sslengine.setWantClientAuth(true);
            break;
        case REQUIRED:
            sslengine.setNeedClientAuth(true);
        }/* w  w  w . j a va2  s. c  o  m*/
    }
    // set handshake protocols if they are specified in transport
    // configuration.
    if (httpsProtocols != null) {
        sslengine.setEnabledProtocols(httpsProtocols);
    }

}

From source file:com.hypersocket.server.HypersocketServerImpl.java

public SSLEngine createSSLEngine(InetSocketAddress localAddress, InetSocketAddress remoteAddress) {

    SSLEngine engine = getSSLContext(localAddress, remoteAddress).createSSLEngine();

    engine.setUseClientMode(false);//from www  .j a v a2 s.c o  m
    engine.setWantClientAuth(false);

    if (enabledCipherSuites != null && enabledCipherSuites.length > 0) {
        engine.setEnabledCipherSuites(enabledCipherSuites);
    }
    if (enabledProtocols != null && enabledProtocols.length > 0) {
        engine.setEnabledProtocols(enabledProtocols);
    }
    return engine;

}

From source file:org.apache.cxf.transport.http.asyncclient.AsyncHTTPConduit.java

public void initializeSSLEngine(SSLContext sslcontext, SSLEngine sslengine) {
    TLSClientParameters tlsClientParameters = getTlsClientParameters();
    if (tlsClientParameters == null) {
        tlsClientParameters = new TLSClientParameters();
    }// ww w  . j a v a2 s. c  o m

    String[] cipherSuites = SSLUtils.getCiphersuitesToInclude(tlsClientParameters.getCipherSuites(),
            tlsClientParameters.getCipherSuitesFilter(), sslcontext.getSocketFactory().getDefaultCipherSuites(),
            SSLUtils.getSupportedCipherSuites(sslcontext), LOG);
    sslengine.setEnabledCipherSuites(cipherSuites);

    String protocol = tlsClientParameters.getSecureSocketProtocol() != null
            ? tlsClientParameters.getSecureSocketProtocol()
            : "TLS";

    String p[] = findProtocols(protocol, sslengine.getSupportedProtocols());
    if (p != null) {
        sslengine.setEnabledProtocols(p);
    }
}

From source file:org.apache.hadoop.security.ssl.SSLFactory.java

/**
 * Returns a configured SSLEngine./*  w w  w  .j  a  v  a  2 s  .com*/
 *
 * @return the configured SSLEngine.
 * @throws GeneralSecurityException thrown if the SSL engine could not
 * be initialized.
 * @throws IOException thrown if and IO error occurred while loading
 * the server keystore.
 */
public SSLEngine createSSLEngine() throws GeneralSecurityException, IOException {
    SSLEngine sslEngine = context.createSSLEngine();
    if (mode == Mode.CLIENT) {
        sslEngine.setUseClientMode(true);
    } else {
        sslEngine.setUseClientMode(false);
        sslEngine.setNeedClientAuth(requireClientCert);
        disableExcludedCiphers(sslEngine);
    }
    sslEngine.setEnabledProtocols(enabledProtocols);
    return sslEngine;
}

From source file:org.apache.hadoop.security.ssl.SslSelectChannelConnectorSecure.java

/**
 * Disable SSLv3 protocol./*w w w .j a v  a  2s  .c om*/
 */
@Override
protected SSLEngine createSSLEngine() throws IOException {
    SSLEngine engine = super.createSSLEngine();
    ArrayList<String> nonSSLProtocols = new ArrayList<String>();
    for (String p : engine.getEnabledProtocols()) {
        if (!p.contains("SSLv3")) {
            nonSSLProtocols.add(p);
        }
    }
    engine.setEnabledProtocols(nonSSLProtocols.toArray(new String[nonSSLProtocols.size()]));
    return engine;
}

From source file:org.apache.http.HC4.nio.conn.ssl.SSLIOSessionStrategy.java

@Override
public SSLIOSession upgrade(final HttpHost host, final IOSession iosession) throws IOException {
    Asserts.check(!(iosession instanceof SSLIOSession), "I/O session is already upgraded to TLS/SSL");
    final SSLIOSession ssliosession = new SSLIOSession(iosession, SSLMode.CLIENT, this.sslContext,
            new SSLSetupHandler() {

                @Override/* www . j  ava 2 s  .c o  m*/
                public void initalize(final SSLEngine sslengine) throws SSLException {
                    if (supportedProtocols != null) {
                        sslengine.setEnabledProtocols(supportedProtocols);
                    }
                    if (supportedCipherSuites != null) {
                        sslengine.setEnabledCipherSuites(supportedCipherSuites);
                    }
                    initializeEngine(sslengine);
                }

                @Override
                public void verify(final IOSession iosession, final SSLSession sslsession) throws SSLException {
                    verifySession(host, iosession, sslsession);
                }

            });
    iosession.setAttribute(SSLIOSession.SESSION_KEY, ssliosession);
    ssliosession.initialize();
    return ssliosession;
}