Java 类javax.net.ssl.SSLParameters 实例源码

项目:kafka-0.11.0.0-src-with-comment    文件:SslFactory.java   
public SSLEngine createSslEngine(String peerHost, int peerPort) {
    SSLEngine sslEngine = sslContext.createSSLEngine(peerHost, peerPort);
    if (cipherSuites != null) sslEngine.setEnabledCipherSuites(cipherSuites);
    if (enabledProtocols != null) sslEngine.setEnabledProtocols(enabledProtocols);

    // SSLParameters#setEndpointIdentificationAlgorithm enables endpoint validation
    // only in client mode. Hence, validation is enabled only for clients.
    if (mode == Mode.SERVER) {
        sslEngine.setUseClientMode(false);
        if (needClientAuth)
            sslEngine.setNeedClientAuth(needClientAuth);
        else
            sslEngine.setWantClientAuth(wantClientAuth);
    } else {
        sslEngine.setUseClientMode(true);
        SSLParameters sslParams = sslEngine.getSSLParameters();
        sslParams.setEndpointIdentificationAlgorithm(endpointIdentification);
        sslEngine.setSSLParameters(sslParams);
    }
    return sslEngine;
}
项目:openjdk-jdk10    文件:Utils.java   
public static SSLParameters copySSLParameters(SSLParameters p) {
    SSLParameters p1 = new SSLParameters();
    p1.setAlgorithmConstraints(p.getAlgorithmConstraints());
    p1.setCipherSuites(p.getCipherSuites());
    // JDK 8 EXCL START
    p1.setEnableRetransmissions(p.getEnableRetransmissions());
    p1.setMaximumPacketSize(p.getMaximumPacketSize());
    // JDK 8 EXCL END
    p1.setEndpointIdentificationAlgorithm(p.getEndpointIdentificationAlgorithm());
    p1.setNeedClientAuth(p.getNeedClientAuth());
    String[] protocols = p.getProtocols();
    if (protocols != null) {
        p1.setProtocols(protocols.clone());
    }
    p1.setSNIMatchers(p.getSNIMatchers());
    p1.setServerNames(p.getServerNames());
    p1.setUseCipherSuitesOrder(p.getUseCipherSuitesOrder());
    p1.setWantClientAuth(p.getWantClientAuth());
    return p1;
}
项目:GitHub    文件:Jdk9Platform.java   
@Override
public void configureTlsExtensions(SSLSocket sslSocket, String hostname,
    List<Protocol> protocols) {
  try {
    SSLParameters sslParameters = sslSocket.getSSLParameters();

    List<String> names = alpnProtocolNames(protocols);

    setProtocolMethod.invoke(sslParameters,
        new Object[] {names.toArray(new String[names.size()])});

    sslSocket.setSSLParameters(sslParameters);
  } catch (IllegalAccessException | InvocationTargetException e) {
    throw new AssertionError();
  }
}
项目:GitHub    文件:Jdk9Platform.java   
@Override
public void configureTlsExtensions(SSLSocket sslSocket, String hostname,
    List<Protocol> protocols) {
  try {
    SSLParameters sslParameters = sslSocket.getSSLParameters();

    List<String> names = alpnProtocolNames(protocols);

    setProtocolMethod.invoke(sslParameters,
        new Object[] {names.toArray(new String[names.size()])});

    sslSocket.setSSLParameters(sslParameters);
  } catch (IllegalAccessException | InvocationTargetException e) {
    throw assertionError("unable to set ssl parameters", e);
  }
}
项目:JRediClients    文件:JedisFactory.java   
public JedisFactory(final URI uri, final int connectionTimeout, final int soTimeout, final String clientName,
        final boolean ssl, final SSLSocketFactory sslSocketFactory, final SSLParameters sslParameters,
        final HostnameVerifier hostnameVerifier) {
    if (!JedisURIHelper.isValid(uri)) {
        throw new InvalidURIException(
                String.format("Cannot open Redis connection due invalid URI. %s", uri.toString()));
    }

    this.hostAndPort.set(new HostAndPort(uri.getHost(), uri.getPort()));
    this.connectionTimeout = connectionTimeout;
    this.soTimeout = soTimeout;
    this.password = JedisURIHelper.getPassword(uri);
    this.database = JedisURIHelper.getDBIndex(uri);
    this.clientName = clientName;
    this.ssl = ssl;
    this.sslSocketFactory = sslSocketFactory;
    this.sslParameters = sslParameters;
    this.hostnameVerifier = hostnameVerifier;
}
项目:JRediClients    文件:JedisPool.java   
public JedisPool(final String host, final SSLSocketFactory sslSocketFactory, final SSLParameters sslParameters,
        final HostnameVerifier hostnameVerifier) {
    URI uri = URI.create(host);
    if (JedisURIHelper.isValid(uri)) {
        String h = uri.getHost();
        int port = uri.getPort();
        String password = JedisURIHelper.getPassword(uri);
        int database = JedisURIHelper.getDBIndex(uri);
        boolean ssl = uri.getScheme().equals("rediss");
        this.internalPool = new GenericObjectPool<Jedis>(
                new JedisFactory(h, port, Protocol.DEFAULT_TIMEOUT, Protocol.DEFAULT_TIMEOUT, password, database,
                        null, ssl, sslSocketFactory, sslParameters, hostnameVerifier),
                new GenericObjectPoolConfig());
    } else {
        this.internalPool = new GenericObjectPool<Jedis>(
                new JedisFactory(host, Protocol.DEFAULT_PORT, Protocol.DEFAULT_TIMEOUT, Protocol.DEFAULT_TIMEOUT,
                        null, Protocol.DEFAULT_DATABASE, null, false, null, null, null),
                new GenericObjectPoolConfig());
    }
}
项目:JRediClients    文件:JedisShardInfo.java   
public JedisShardInfo(String host, SSLSocketFactory sslSocketFactory, SSLParameters sslParameters,
        HostnameVerifier hostnameVerifier) {
    super(Sharded.DEFAULT_WEIGHT);
    URI uri = URI.create(host);
    if (JedisURIHelper.isValid(uri)) {
        this.host = uri.getHost();
        this.port = uri.getPort();
        this.password = JedisURIHelper.getPassword(uri);
        this.db = JedisURIHelper.getDBIndex(uri);
        this.ssl = uri.getScheme().equals("rediss");
        this.sslSocketFactory = sslSocketFactory;
        this.sslParameters = sslParameters;
        this.hostnameVerifier = hostnameVerifier;
    } else {
        this.host = host;
        this.port = Protocol.DEFAULT_PORT;
    }
}
项目:JRediClients    文件:JedisShardInfo.java   
public JedisShardInfo(URI uri, SSLSocketFactory sslSocketFactory, SSLParameters sslParameters,
        HostnameVerifier hostnameVerifier) {
    super(Sharded.DEFAULT_WEIGHT);
    if (!JedisURIHelper.isValid(uri)) {
        throw new InvalidURIException(
                String.format("Cannot open Redis connection due invalid URI. %s", uri.toString()));
    }

    this.host = uri.getHost();
    this.port = uri.getPort();
    this.password = JedisURIHelper.getPassword(uri);
    this.db = JedisURIHelper.getDBIndex(uri);
    this.ssl = uri.getScheme().equals("rediss");
    this.sslSocketFactory = sslSocketFactory;
    this.sslParameters = sslParameters;
    this.hostnameVerifier = hostnameVerifier;
}
项目:JRediClients    文件:JedisClusterInfoCache.java   
public JedisPool setupNodeIfNotExist(HostAndPort node, boolean ssl, SSLSocketFactory sslSocketFactory,
        SSLParameters sslParameters, HostnameVerifier hostnameVerifier) {
    w.lock();
    try {
        String nodeKey = getNodeKey(node);
        JedisPool existingPool = nodes.get(nodeKey);
        if (existingPool != null)
            return existingPool;

        JedisPool nodePool = new JedisPool(poolConfig, node.getHost(), node.getPort(), connectionTimeout, soTimeout,
                password, 0, null, ssl, sslSocketFactory, sslParameters, hostnameVerifier);
        nodes.put(nodeKey, nodePool);
        return nodePool;
    } finally {
        w.unlock();
    }
}
项目:JRediClients    文件:SSLJedisTest.java   
/**
 * Tests opening an SSL/TLS connection to redis with a custom hostname
 * verifier.
 */
@Test
public void connectWithShardInfoAndCustomHostnameVerifier() {
  final URI uri = URI.create("rediss://localhost:6390");
  final SSLSocketFactory sslSocketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
  final SSLParameters sslParameters = new SSLParameters();

  HostnameVerifier hostnameVerifier = new BasicHostnameVerifier();
  JedisShardInfo shardInfo = new JedisShardInfo(uri, sslSocketFactory, sslParameters, hostnameVerifier);
  shardInfo.setPassword("foobared");

  Jedis jedis = new Jedis(shardInfo);
  jedis.get("foo");
  jedis.disconnect();
  jedis.close();
}
项目:JRediClients    文件:SSLJedisTest.java   
/**
 * Tests opening an SSL/TLS connection to redis with a custom socket factory.
 */
@Test
public void connectWithShardInfoAndCustomSocketFactory() throws Exception {
  final URI uri = URI.create("rediss://localhost:6390");
  final SSLSocketFactory sslSocketFactory = createTrustStoreSslSocketFactory();
  final SSLParameters sslParameters = new SSLParameters();

  HostnameVerifier hostnameVerifier = new BasicHostnameVerifier();
  JedisShardInfo shardInfo = new JedisShardInfo(uri, sslSocketFactory, sslParameters, hostnameVerifier);
  shardInfo.setPassword("foobared");

  Jedis jedis = new Jedis(shardInfo);
  jedis.get("foo");
  jedis.disconnect();
  jedis.close();
}
项目:JRediClients    文件:SSLJedisTest.java   
/**
 * Tests opening an SSL/TLS connection to redis with a custom hostname
 * verifier. This test should fail because "127.0.0.1" does not match the
 * certificate subject common name and there are no subject alternative names
 * in the certificate.
 */
@Test
public void connectWithShardInfoAndCustomHostnameVerifierByIpAddress() {
  final URI uri = URI.create("rediss://127.0.0.1:6390");
  final SSLSocketFactory sslSocketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
  final SSLParameters sslParameters = new SSLParameters();

  HostnameVerifier hostnameVerifier = new BasicHostnameVerifier();
  JedisShardInfo shardInfo = new JedisShardInfo(uri, sslSocketFactory, sslParameters, hostnameVerifier);
  shardInfo.setPassword("foobared");

  Jedis jedis = new Jedis(shardInfo);
  try {
    jedis.get("foo");
    Assert.fail("The code did not throw the expected JedisConnectionException.");
  } catch (JedisConnectionException e) {
    Assert.assertEquals("The JedisConnectionException does not contain the expected message.",
        "The connection to '127.0.0.1' failed ssl/tls hostname verification.", e.getMessage());
  }

  try {
    jedis.close();
  } catch (Throwable e1) {
    // Expected.
  }
}
项目:openjdk-jdk10    文件:HttpResponseImpl.java   
public HttpResponseImpl(Response response,
                        HttpRequestImpl pushRequest,
                        ImmutableHeaders headers,
                        Stream<T> stream,
                        SSLParameters sslParameters,
                        T body) {
    this.responseCode = response.statusCode();
    this.exchange = null;
    this.initialRequest = null; // ## fix this
    this.finalRequest = pushRequest;
    this.headers = headers;
    //this.trailers = null;
    this.sslParameters = sslParameters;
    this.uri = finalRequest.uri(); // TODO: take from headers
    this.version = HttpClient.Version.HTTP_2;
    this.connection = stream.connection();
    this.stream = stream;
    this.body = body;
}
项目:openjdk-jdk10    文件:Http2TestServer.java   
final ServerSocket initSecure(int port) throws Exception {
    ServerSocketFactory fac;
    if (sslContext != null) {
        fac = sslContext.getServerSocketFactory();
    } else {
        fac = SSLServerSocketFactory.getDefault();
    }
    SSLServerSocket se = (SSLServerSocket) fac.createServerSocket(port);
    SSLParameters sslp = se.getSSLParameters();
    sslp.setApplicationProtocols(new String[]{"h2"});
    se.setSSLParameters(sslp);
    se.setEnabledCipherSuites(se.getSupportedCipherSuites());
    se.setEnabledProtocols(se.getSupportedProtocols());
    // other initialisation here
    return se;
}
项目:openjdk-jdk10    文件:SSLEngineTestCase.java   
/**
 * Returns client ssl engine.
 *
 * @param context - SSLContext to get SSLEngine from.
 * @param useSNI  - flag used to enable or disable using SNI extension.
 *                Needed for Kerberos.
 */
public static SSLEngine getClientSSLEngine(
        SSLContext context, boolean useSNI) {

    SSLEngine clientEngine = context.createSSLEngine(HOST, 80);
    clientEngine.setUseClientMode(true);
    if (useSNI) {
        SNIHostName serverName = new SNIHostName(SERVER_NAME);
        List<SNIServerName> serverNames = new ArrayList<>();
        serverNames.add(serverName);
        SSLParameters params = clientEngine.getSSLParameters();
        params.setServerNames(serverNames);
        clientEngine.setSSLParameters(params);
    }
    return clientEngine;
}
项目:openjdk-jdk10    文件:SSLEngineTestCase.java   
/**
 * Returns server ssl engine.
 *
 * @param context - SSLContext to get SSLEngine from.
 * @param useSNI  - flag used to enable or disable using SNI extension.
 *                Needed for Kerberos.
 */
public static SSLEngine getServerSSLEngine(
        SSLContext context, boolean useSNI) {

    SSLEngine serverEngine = context.createSSLEngine();
    serverEngine.setUseClientMode(false);
    if (useSNI) {
        SNIMatcher matcher = SNIHostName.createSNIMatcher(SNI_PATTERN);
        List<SNIMatcher> matchers = new ArrayList<>();
        matchers.add(matcher);
        SSLParameters params = serverEngine.getSSLParameters();
        params.setSNIMatchers(matchers);
        serverEngine.setSSLParameters(params);
    }
    return serverEngine;
}
项目:openjdk9    文件:Utils.java   
static SSLParameters copySSLParameters(SSLParameters p) {
    SSLParameters p1 = new SSLParameters();
    p1.setAlgorithmConstraints(p.getAlgorithmConstraints());
    p1.setCipherSuites(p.getCipherSuites());
    p1.setEnableRetransmissions(p.getEnableRetransmissions());
    p1.setEndpointIdentificationAlgorithm(p.getEndpointIdentificationAlgorithm());
    p1.setMaximumPacketSize(p.getMaximumPacketSize());
    p1.setNeedClientAuth(p.getNeedClientAuth());
    String[] protocols = p.getProtocols();
    if (protocols != null)
        p1.setProtocols(protocols.clone());
    p1.setSNIMatchers(p.getSNIMatchers());
    p1.setServerNames(p.getServerNames());
    p1.setUseCipherSuitesOrder(p.getUseCipherSuitesOrder());
    p1.setWantClientAuth(p.getWantClientAuth());
    return p1;
}
项目:kafka    文件:SslFactory.java   
public SSLEngine createSslEngine(String peerHost, int peerPort) {
    SSLEngine sslEngine = sslContext.createSSLEngine(peerHost, peerPort);
    if (cipherSuites != null) sslEngine.setEnabledCipherSuites(cipherSuites);
    if (enabledProtocols != null) sslEngine.setEnabledProtocols(enabledProtocols);

    if (mode == Mode.SERVER) {
        sslEngine.setUseClientMode(false);
        if (needClientAuth)
            sslEngine.setNeedClientAuth(needClientAuth);
        else
            sslEngine.setWantClientAuth(wantClientAuth);
    } else {
        sslEngine.setUseClientMode(true);
        SSLParameters sslParams = sslEngine.getSSLParameters();
        sslParams.setEndpointIdentificationAlgorithm(endpointIdentification);
        sslEngine.setSSLParameters(sslParams);
    }
    return sslEngine;
}
项目:conscrypt    文件:SSLEngineTest.java   
@Test
public void test_SSLEngine_getSSLParameters() throws Exception {
    TestSSLContext c = TestSSLContext.create();
    SSLEngine e = c.clientContext.createSSLEngine();

    SSLParameters p = e.getSSLParameters();
    assertNotNull(p);

    String[] cipherSuites = p.getCipherSuites();
    assertNotSame(cipherSuites, e.getEnabledCipherSuites());
    assertEquals(Arrays.asList(cipherSuites), Arrays.asList(e.getEnabledCipherSuites()));

    String[] protocols = p.getProtocols();
    assertNotSame(protocols, e.getEnabledProtocols());
    assertEquals(Arrays.asList(protocols), Arrays.asList(e.getEnabledProtocols()));

    assertEquals(p.getWantClientAuth(), e.getWantClientAuth());
    assertEquals(p.getNeedClientAuth(), e.getNeedClientAuth());

    c.close();
}
项目:cosmic    文件:ConsoleProxySecureServerFactoryImpl.java   
@Override
public HttpServer createHttpServerInstance(final int port) throws IOException {
    try {
        final HttpsServer server = HttpsServer.create(new InetSocketAddress(port), 5);
        server.setHttpsConfigurator(new HttpsConfigurator(sslContext) {
            @Override
            public void configure(final HttpsParameters params) {
                final SSLContext c = getSSLContext();

                // get the default parameters
                final SSLParameters sslparams = c.getDefaultSSLParameters();

                params.setSSLParameters(sslparams);
                // statement above could throw IAE if any params invalid.
                // eg. if app has a UI and parameters supplied by a user.
            }
        });

        s_logger.info("create HTTPS server instance on port: " + port);
        return server;
    } catch (final Exception ioe) {
        s_logger.error(ioe.toString(), ioe);
    }
    return null;
}
项目:drill    文件:SSLConfigClient.java   
@Override
public SSLEngine createSSLEngine(BufferAllocator allocator, String peerHost, int peerPort) {
  SSLEngine engine = super.createSSLEngine(allocator, peerHost, peerPort);

  if (!this.disableHostVerification()) {
    SSLParameters sslParameters = engine.getSSLParameters();
    // only available since Java 7
    sslParameters.setEndpointIdentificationAlgorithm("HTTPS");
    engine.setSSLParameters(sslParameters);
  }

  engine.setUseClientMode(true);

  try {
    engine.setEnableSessionCreation(true);
  } catch (Exception e) {
    // Openssl implementation may throw this.
    logger.debug("Session creation not enabled. Exception: {}", e.getMessage());
  }

  return engine;
}
项目:conscrypt    文件:PlatformTest.java   
@Test
public void test_setSSLParameters_Socket() throws Exception {
    assumeJava8();
    Socket socket = new OpenSSLSocketFactoryImpl().createSocket();
    SSLParametersImpl impl = SSLParametersImpl.getDefault();
    SSLParameters params = new SSLParameters();
    List<SNIServerName> names = new ArrayList<SNIServerName>();
    names.add(new SNIHostName("some.host"));
    params.setServerNames(names);
    params.setUseCipherSuitesOrder(false);
    params.setEndpointIdentificationAlgorithm("ABC");
    String[] applicationProtocols = new String[] {"foo", "bar"};
    if (isJavaVersion(9)) {
        setApplicationProtocols(params, applicationProtocols);
    }
    Platform.setSSLParameters(params, impl, (AbstractConscryptSocket) socket);
    assertEquals("some.host", ((AbstractConscryptSocket) socket).getHostname());
    assertFalse(impl.getUseCipherSuitesOrder());
    assertEquals("ABC", impl.getEndpointIdentificationAlgorithm());
    if (isJavaVersion(9)) {
        assertArrayEquals(applicationProtocols, impl.getApplicationProtocols());
    }
}
项目:conscrypt    文件:PlatformTest.java   
@Test
public void test_setSSLParameters_Engine() throws Exception {
    assumeJava8();
    SSLParametersImpl impl = SSLParametersImpl.getDefault();
    SSLParameters params = new SSLParameters();
    ConscryptEngine engine = new ConscryptEngine(impl);
    List<SNIServerName> names = new ArrayList<SNIServerName>();
    names.add(new SNIHostName("some.host"));
    params.setServerNames(names);
    params.setUseCipherSuitesOrder(false);
    params.setEndpointIdentificationAlgorithm("ABC");
    String[] applicationProtocols = new String[] {"foo", "bar"};
    if (isJavaVersion(9)) {
        setApplicationProtocols(params, applicationProtocols);
    }
    Platform.setSSLParameters(params, impl, engine);
    assertEquals("some.host", engine.getHostname());
    assertFalse(impl.getUseCipherSuitesOrder());
    assertEquals("ABC", impl.getEndpointIdentificationAlgorithm());
    if (isJavaVersion(9)) {
        assertArrayEquals(applicationProtocols, impl.getApplicationProtocols());
    }
}
项目:conscrypt    文件:PlatformTest.java   
@Test
public void test_getSSLParameters_Engine() throws Exception {
    assumeJava8();
    SSLParametersImpl impl = SSLParametersImpl.getDefault();
    SSLParameters params = new SSLParameters();
    ConscryptEngine engine = new ConscryptEngine(impl);
    impl.setUseCipherSuitesOrder(false);
    impl.setEndpointIdentificationAlgorithm("ABC");
    engine.setHostname("some.host");
    String[] applicationProtocols = new String[] {"foo", "bar"};
    if (isJavaVersion(9)) {
        impl.setApplicationProtocols(applicationProtocols);
    }
    Platform.getSSLParameters(params, impl, engine);
    assertEquals("some.host", ((SNIHostName) params.getServerNames().get(0)).getAsciiName());
    assertFalse(params.getUseCipherSuitesOrder());
    assertEquals("ABC", params.getEndpointIdentificationAlgorithm());
    if (isJavaVersion(9)) {
        assertArrayEquals(applicationProtocols, getApplicationProtocols(params));
    }
}
项目:conscrypt    文件:Platform.java   
@TargetApi(24)
private static String getSniHostnameFromParams(SSLParameters params)
        throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
    Method m_getServerNames = params.getClass().getMethod("getServerNames");
    @SuppressWarnings("unchecked")
    List<SNIServerName> serverNames = (List<SNIServerName>) m_getServerNames.invoke(params);
    if (serverNames != null) {
        for (SNIServerName serverName : serverNames) {
            if (serverName.getType() == StandardConstants.SNI_HOST_NAME) {
                return ((SNIHostName) serverName).getAsciiName();
            }
        }
    }

    return null;
}
项目:conscrypt    文件:SSLConfigurationAsserts.java   
/**
 * Asserts that the provided {@link SSLContext} has the expected default configuration, and that
 * {@link SSLSocketFactory}, {@link SSLServerSocketFactory}, {@link SSLSocket},
 * {@link SSLServerSocket} and {@link SSLEngine} instances created from the context match the
 * configuration.
 */
public static void assertSSLContextDefaultConfiguration(SSLContext sslContext)
        throws IOException {
    SSLParameters defaultParameters = sslContext.getDefaultSSLParameters();
    StandardNames.assertSSLContextEnabledProtocols(
            sslContext.getProtocol(), defaultParameters.getProtocols());
    StandardNames.assertDefaultCipherSuites(defaultParameters.getCipherSuites());
    assertFalse(defaultParameters.getWantClientAuth());
    assertFalse(defaultParameters.getNeedClientAuth());
    SSLParameters supportedParameters = sslContext.getSupportedSSLParameters();
    StandardNames.assertSupportedCipherSuites(supportedParameters.getCipherSuites());
    StandardNames.assertSupportedProtocols(supportedParameters.getProtocols());
    assertFalse(supportedParameters.getWantClientAuth());
    assertFalse(supportedParameters.getNeedClientAuth());
    assertContainsAll("Unsupported enabled cipher suites",
            supportedParameters.getCipherSuites(), defaultParameters.getCipherSuites());
    assertContainsAll("Unsupported enabled protocols", supportedParameters.getProtocols(),
            defaultParameters.getProtocols());
    assertSSLSocketFactoryConfigSameAsSSLContext(sslContext.getSocketFactory(), sslContext);
    assertSSLServerSocketFactoryConfigSameAsSSLContext(
            sslContext.getServerSocketFactory(), sslContext);
    SSLEngine sslEngine = sslContext.createSSLEngine();
    assertFalse(sslEngine.getUseClientMode());
    assertSSLEngineConfigSameAsSSLContext(sslEngine, sslContext);
}
项目:GitHub    文件:Jdk9Platform.java   
public static Jdk9Platform buildIfSupported() {
  // Find JDK 9 new methods
  try {
    Method setProtocolMethod =
        SSLParameters.class.getMethod("setApplicationProtocols", String[].class);
    Method getProtocolMethod = SSLSocket.class.getMethod("getApplicationProtocol");

    return new Jdk9Platform(setProtocolMethod, getProtocolMethod);
  } catch (NoSuchMethodException ignored) {
    // pre JDK 9
  }

  return null;
}
项目:GitHub    文件:Jdk9Platform.java   
public static Jdk9Platform buildIfSupported() {
  // Find JDK 9 new methods
  try {
    Method setProtocolMethod =
        SSLParameters.class.getMethod("setApplicationProtocols", String[].class);
    Method getProtocolMethod = SSLSocket.class.getMethod("getApplicationProtocol");

    return new Jdk9Platform(setProtocolMethod, getProtocolMethod);
  } catch (NoSuchMethodException ignored) {
    // pre JDK 9
  }

  return null;
}
项目:AndroidAsyncHTTP    文件:MySSLSocketFactory.java   
/**
 * Activate supported protocols on the socket.
 * @param socket The socket on which to activate secure protocols.
 */
private void enableSecureProtocols(Socket socket) {
    // set all supported protocols
    try {
        SSLParameters params = sslContext.getSupportedSSLParameters();
        ((SSLSocket) socket).setEnabledProtocols(params.getProtocols());
    }catch (Exception e)
    {
        Log.w("enableSecureProtocols", e);
    }
}
项目:JRediClients    文件:Connection.java   
public Connection(final String host, final int port, final boolean ssl, SSLSocketFactory sslSocketFactory,
        SSLParameters sslParameters, HostnameVerifier hostnameVerifier) {
    this.host = host;
    this.port = port;
    this.ssl = ssl;
    this.sslSocketFactory = sslSocketFactory;
    this.sslParameters = sslParameters;
    this.hostnameVerifier = hostnameVerifier;
}
项目:JRediClients    文件:JedisFactory.java   
public JedisFactory(final String host, final int port, final int connectionTimeout, final int soTimeout,
        final String password, final int database, final String clientName, final boolean ssl,
        final SSLSocketFactory sslSocketFactory, final SSLParameters sslParameters,
        final HostnameVerifier hostnameVerifier) {
    this.hostAndPort.set(new HostAndPort(host, port));
    this.connectionTimeout = connectionTimeout;
    this.soTimeout = soTimeout;
    this.password = password;
    this.database = database;
    this.clientName = clientName;
    this.ssl = ssl;
    this.sslSocketFactory = sslSocketFactory;
    this.sslParameters = sslParameters;
    this.hostnameVerifier = hostnameVerifier;
}
项目:JRediClients    文件:JedisPool.java   
public JedisPool(final GenericObjectPoolConfig poolConfig, final String host, int port, int timeout,
        final String password, final int database, final String clientName, final boolean ssl,
        final SSLSocketFactory sslSocketFactory, final SSLParameters sslParameters,
        final HostnameVerifier hostnameVerifier) {
    this(poolConfig, host, port, timeout, timeout, password, database, clientName, ssl, sslSocketFactory,
            sslParameters, hostnameVerifier);
}
项目:JRediClients    文件:JedisPool.java   
public JedisPool(final GenericObjectPoolConfig poolConfig, final String host, int port, final int connectionTimeout,
        final int soTimeout, final String password, final int database, final String clientName, final boolean ssl,
        final SSLSocketFactory sslSocketFactory, final SSLParameters sslParameters,
        final HostnameVerifier hostnameVerifier) {
    super(poolConfig, new JedisFactory(host, port, connectionTimeout, soTimeout, password, database, clientName,
            ssl, sslSocketFactory, sslParameters, hostnameVerifier));
}
项目:JRediClients    文件:JedisPool.java   
public JedisPool(final GenericObjectPoolConfig poolConfig, final URI uri, final int connectionTimeout,
        final int soTimeout, final SSLSocketFactory sslSocketFactory, final SSLParameters sslParameters,
        final HostnameVerifier hostnameVerifier) {
    super(poolConfig, new JedisFactory(uri, connectionTimeout, soTimeout, null,
                    (uri.getScheme() != null && uri.getScheme().equals("rediss")), sslSocketFactory, sslParameters,
                    hostnameVerifier));
}
项目:JRediClients    文件:BinaryJedis.java   
public BinaryJedis(final String host, final int port, final int timeout, final boolean ssl,
        final SSLSocketFactory sslSocketFactory, final SSLParameters sslParameters,
        final HostnameVerifier hostnameVerifier) {
    client = new Client(host, port, ssl, sslSocketFactory, sslParameters, hostnameVerifier);
    client.setConnectionTimeout(timeout);
    client.setSoTimeout(timeout);
}
项目:JRediClients    文件:BinaryJedis.java   
public BinaryJedis(final String host, final int port, final int connectionTimeout, final int soTimeout,
        final String password, final int database, final boolean ssl, final SSLSocketFactory sslSocketFactory,
        final SSLParameters sslParameters, final HostnameVerifier hostnameVerifier) {
    client = new Client(host, port, ssl, sslSocketFactory, sslParameters, hostnameVerifier);
    client.setConnectionTimeout(connectionTimeout);
    client.setSoTimeout(soTimeout);
    client.setPassword(password);
    client.setDb(database);
}
项目:JRediClients    文件:BinaryJedis.java   
public BinaryJedis(final URI uri, final int connectionTimeout, final int soTimeout,
        final SSLSocketFactory sslSocketFactory, final SSLParameters sslParameters,
        final HostnameVerifier hostnameVerifier) {
    initializeClientFromURI(uri, sslSocketFactory, sslParameters, hostnameVerifier);
    client.setConnectionTimeout(connectionTimeout);
    client.setSoTimeout(soTimeout);
}
项目:JRediClients    文件:JedisShardInfo.java   
public JedisShardInfo(String host, int port, int timeout, String name, boolean ssl,
        SSLSocketFactory sslSocketFactory, SSLParameters sslParameters, HostnameVerifier hostnameVerifier) {
    this(host, port, timeout, timeout, Sharded.DEFAULT_WEIGHT);
    this.name = name;
    this.ssl = ssl;
    this.sslSocketFactory = sslSocketFactory;
    this.sslParameters = sslParameters;
    this.hostnameVerifier = hostnameVerifier;
}
项目:JRediClients    文件:JedisShardInfo.java   
public JedisShardInfo(String host, int port, int connectionTimeout, int soTimeout, int weight, boolean ssl,
        SSLSocketFactory sslSocketFactory, SSLParameters sslParameters, HostnameVerifier hostnameVerifier) {
    super(weight);
    this.host = host;
    this.port = port;
    this.connectionTimeout = connectionTimeout;
    this.soTimeout = soTimeout;
    this.ssl = ssl;
    this.sslSocketFactory = sslSocketFactory;
    this.sslParameters = sslParameters;
    this.hostnameVerifier = hostnameVerifier;
}
项目:JRediClients    文件:JedisShardInfo.java   
public JedisShardInfo(String host, String name, int port, int timeout, int weight, boolean ssl,
        SSLSocketFactory sslSocketFactory, SSLParameters sslParameters, HostnameVerifier hostnameVerifier) {
    super(weight);
    this.host = host;
    this.name = name;
    this.port = port;
    this.connectionTimeout = timeout;
    this.soTimeout = timeout;
    this.ssl = ssl;
    this.sslSocketFactory = sslSocketFactory;
    this.sslParameters = sslParameters;
    this.hostnameVerifier = hostnameVerifier;
}