当前位置: 首页>>代码示例>>Java>>正文


Java SSLParameters类代码示例

本文整理汇总了Java中javax.net.ssl.SSLParameters的典型用法代码示例。如果您正苦于以下问题:Java SSLParameters类的具体用法?Java SSLParameters怎么用?Java SSLParameters使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SSLParameters类属于javax.net.ssl包,在下文中一共展示了SSLParameters类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: copySSLParameters

import javax.net.ssl.SSLParameters; //导入依赖的package包/类
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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:Utils.java

示例2: configureTlsExtensions

import javax.net.ssl.SSLParameters; //导入依赖的package包/类
@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();
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:Jdk9Platform.java

示例3: configureTlsExtensions

import javax.net.ssl.SSLParameters; //导入依赖的package包/类
@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);
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:Jdk9Platform.java

示例4: JedisFactory

import javax.net.ssl.SSLParameters; //导入依赖的package包/类
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;
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:20,代码来源:JedisFactory.java

示例5: JedisPool

import javax.net.ssl.SSLParameters; //导入依赖的package包/类
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());
	}
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:21,代码来源:JedisPool.java

示例6: JedisShardInfo

import javax.net.ssl.SSLParameters; //导入依赖的package包/类
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;
	}
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:19,代码来源:JedisShardInfo.java

示例7: setupNodeIfNotExist

import javax.net.ssl.SSLParameters; //导入依赖的package包/类
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();
	}
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:18,代码来源:JedisClusterInfoCache.java

示例8: connectWithShardInfoAndCustomHostnameVerifier

import javax.net.ssl.SSLParameters; //导入依赖的package包/类
/**
 * 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();
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:20,代码来源:SSLJedisTest.java

示例9: connectWithShardInfoAndCustomSocketFactory

import javax.net.ssl.SSLParameters; //导入依赖的package包/类
/**
 * 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();
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:19,代码来源:SSLJedisTest.java

示例10: connectWithShardInfoAndCustomHostnameVerifierByIpAddress

import javax.net.ssl.SSLParameters; //导入依赖的package包/类
/**
 * 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.
  }
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:32,代码来源:SSLJedisTest.java

示例11: createSslEngine

import javax.net.ssl.SSLParameters; //导入依赖的package包/类
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;
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:22,代码来源:SslFactory.java

示例12: HttpResponseImpl

import javax.net.ssl.SSLParameters; //导入依赖的package包/类
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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:HttpResponseImpl.java

示例13: initSecure

import javax.net.ssl.SSLParameters; //导入依赖的package包/类
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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:Http2TestServer.java

示例14: getClientSSLEngine

import javax.net.ssl.SSLParameters; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:SSLEngineTestCase.java

示例15: getServerSSLEngine

import javax.net.ssl.SSLParameters; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:SSLEngineTestCase.java


注:本文中的javax.net.ssl.SSLParameters类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。