當前位置: 首頁>>代碼示例>>Java>>正文


Java SSLParameters.setSNIMatchers方法代碼示例

本文整理匯總了Java中javax.net.ssl.SSLParameters.setSNIMatchers方法的典型用法代碼示例。如果您正苦於以下問題:Java SSLParameters.setSNIMatchers方法的具體用法?Java SSLParameters.setSNIMatchers怎麽用?Java SSLParameters.setSNIMatchers使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.net.ssl.SSLParameters的用法示例。


在下文中一共展示了SSLParameters.setSNIMatchers方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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

示例3: copySSLParameters

import javax.net.ssl.SSLParameters; //導入方法依賴的package包/類
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;
}
 
開發者ID:campolake,項目名稱:openjdk9,代碼行數:18,代碼來源:Utils.java

示例4: getSSLParameters

import javax.net.ssl.SSLParameters; //導入方法依賴的package包/類
/**
 * Returns the SSLParameters in effect for newly accepted connections.
 */
@Override
synchronized public SSLParameters getSSLParameters() {
    SSLParameters params = super.getSSLParameters();

    // the super implementation does not handle the following parameters
    params.setEndpointIdentificationAlgorithm(identificationProtocol);
    params.setAlgorithmConstraints(algorithmConstraints);
    params.setSNIMatchers(sniMatchers);
    params.setUseCipherSuitesOrder(preferLocalCipherSuites);


    return params;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:17,代碼來源:SSLServerSocketImpl.java

示例5: init

import javax.net.ssl.SSLParameters; //導入方法依賴的package包/類
static SSLEchoServer init(String cipherSuiteFilter,
        String sniPattern) throws NoSuchAlgorithmException, IOException {
    SSLContext context = SSLContext.getDefault();
    SSLServerSocketFactory ssf =
            (SSLServerSocketFactory) context.getServerSocketFactory();
    SSLServerSocket ssocket =
            (SSLServerSocket) ssf.createServerSocket(0);

    // specify enabled cipher suites
    if (cipherSuiteFilter != null) {
        String[] ciphersuites = UnboundSSLUtils.filterStringArray(
                ssf.getSupportedCipherSuites(), cipherSuiteFilter);
        System.out.println("Server: enabled cipher suites: "
                + Arrays.toString(ciphersuites));
        ssocket.setEnabledCipherSuites(ciphersuites);
    }

    // specify SNI matcher pattern
    if (sniPattern != null) {
        System.out.println("Server: set SNI matcher: " + sniPattern);
        SNIMatcher matcher = SNIHostName.createSNIMatcher(sniPattern);
        List<SNIMatcher> matchers = new ArrayList<>();
        matchers.add(matcher);
        SSLParameters params = ssocket.getSSLParameters();
        params.setSNIMatchers(matchers);
        ssocket.setSSLParameters(params);
    }

    return new SSLEchoServer(ssocket);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:31,代碼來源:UnboundSSLUtils.java

示例6: getSSLParameters

import javax.net.ssl.SSLParameters; //導入方法依賴的package包/類
/**
 * Returns the SSLParameters in effect for newly accepted connections.
 */
@Override
public synchronized SSLParameters getSSLParameters() {
    SSLParameters params = super.getSSLParameters();

    // the super implementation does not handle the following parameters
    params.setEndpointIdentificationAlgorithm(identificationProtocol);
    params.setAlgorithmConstraints(algorithmConstraints);
    params.setSNIMatchers(sniMatchers);
    params.setUseCipherSuitesOrder(preferLocalCipherSuites);
    params.setApplicationProtocols(applicationProtocols);

    return params;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:17,代碼來源:SSLServerSocketImpl.java

示例7: 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:campolake,項目名稱:openjdk9,代碼行數:21,代碼來源:SSLEngineTestCase.java

示例8: test_SSLParameters_setSNIMatchers_duplicatedNameThrows

import javax.net.ssl.SSLParameters; //導入方法依賴的package包/類
@Test
public void test_SSLParameters_setSNIMatchers_duplicatedNameThrows() throws Exception {
    TestUtils.assumeSNIHostnameAvailable();
    SSLParameters p = new SSLParameters();
    ArrayList<SNIMatcher> dupeMatchers = new ArrayList<SNIMatcher>();
    dupeMatchers.add(SNIHostName.createSNIMatcher("www\\.example\\.com"));
    dupeMatchers.add(SNIHostName.createSNIMatcher("www\\.example\\.com"));
    try {
        p.setSNIMatchers(dupeMatchers);
        fail("Should throw IllegalArgumentException when matchers are duplicated");
    } catch (IllegalArgumentException expected) {
        // Ignored.
    }
}
 
開發者ID:google,項目名稱:conscrypt,代碼行數:15,代碼來源:SSLParametersTest.java

示例9: test_SSLParameters_setSNIMatchers_setNull_getNull

import javax.net.ssl.SSLParameters; //導入方法依賴的package包/類
@Test
public void test_SSLParameters_setSNIMatchers_setNull_getNull() throws Exception {
    TestUtils.assumeSNIHostnameAvailable();
    SSLParameters p = new SSLParameters();
    p.setSNIMatchers(
            Collections.singletonList(SNIHostName.createSNIMatcher("www\\.example\\.com")));
    assertNotNull(p.getSNIMatchers());
    p.setSNIMatchers(null);
    assertNull(p.getSNIMatchers());
}
 
開發者ID:google,項目名稱:conscrypt,代碼行數:11,代碼來源:SSLParametersTest.java

示例10: test_SSLParameters_setSNIMatchers_setEmpty_getEmpty

import javax.net.ssl.SSLParameters; //導入方法依賴的package包/類
@Test
public void test_SSLParameters_setSNIMatchers_setEmpty_getEmpty() throws Exception {
    TestUtils.assumeSNIHostnameAvailable();
    SSLParameters p = new SSLParameters();
    p.setSNIMatchers(
            Collections.singletonList(SNIHostName.createSNIMatcher("www\\.example\\.com")));
    assertEquals(1, p.getSNIMatchers().size());
    p.setSNIMatchers(Collections.<SNIMatcher>emptyList());
    Collection<SNIMatcher> actual = p.getSNIMatchers();
    assertNotNull(actual);
    assertEquals(0, actual.size());
}
 
開發者ID:google,項目名稱:conscrypt,代碼行數:13,代碼來源:SSLParametersTest.java

示例11: test_SSLParameters_getSNIMatchers_unmodifiable

import javax.net.ssl.SSLParameters; //導入方法依賴的package包/類
@Test
public void test_SSLParameters_getSNIMatchers_unmodifiable() throws Exception {
    TestUtils.assumeSNIHostnameAvailable();
    SSLParameters p = new SSLParameters();
    p.setSNIMatchers(
            Collections.singletonList(SNIHostName.createSNIMatcher("www\\.example\\.com")));
    Collection<SNIMatcher> actual = p.getSNIMatchers();
    try {
        actual.add(SNIHostName.createSNIMatcher("www\\.google\\.com"));
        fail("Should not allow modification of list");
    } catch (UnsupportedOperationException expected) {
        // Ignored.
    }
}
 
開發者ID:google,項目名稱:conscrypt,代碼行數:15,代碼來源:SSLParametersTest.java

示例12: test_SSLSocket_SNIHostName

import javax.net.ssl.SSLParameters; //導入方法依賴的package包/類
@Test
public void test_SSLSocket_SNIHostName() throws Exception {
    TestUtils.assumeSNIHostnameAvailable();
    TestSSLContext c = TestSSLContext.create();
    final SSLSocket client = (SSLSocket) c.clientContext.getSocketFactory().createSocket();
    SSLParameters clientParams = client.getSSLParameters();
    clientParams.setServerNames(
            Collections.singletonList((SNIServerName) new SNIHostName("www.example.com")));
    client.setSSLParameters(clientParams);
    SSLParameters serverParams = c.serverSocket.getSSLParameters();
    serverParams.setSNIMatchers(
            Collections.singletonList(SNIHostName.createSNIMatcher("www\\.example\\.com")));
    c.serverSocket.setSSLParameters(serverParams);
    client.connect(new InetSocketAddress(c.host, c.port));
    final SSLSocket server = (SSLSocket) c.serverSocket.accept();
    @SuppressWarnings("unused")
    Future<?> future = runAsync(new Callable<Object>() {
        @Override
        public Object call() throws Exception {
            client.startHandshake();
            return null;
        }
    });
    server.startHandshake();
    SSLSession serverSession = server.getSession();
    assertTrue(serverSession instanceof ExtendedSSLSession);
    ExtendedSSLSession extendedServerSession = (ExtendedSSLSession) serverSession;
    List<SNIServerName> requestedNames = extendedServerSession.getRequestedServerNames();
    assertNotNull(requestedNames);
    assertEquals(1, requestedNames.size());
    SNIServerName serverName = requestedNames.get(0);
    assertEquals(StandardConstants.SNI_HOST_NAME, serverName.getType());
    assertTrue(serverName instanceof SNIHostName);
    SNIHostName serverHostName = (SNIHostName) serverName;
    assertEquals("www.example.com", serverHostName.getAsciiName());
}
 
開發者ID:google,項目名稱:conscrypt,代碼行數:37,代碼來源:SSLSocketTest.java


注:本文中的javax.net.ssl.SSLParameters.setSNIMatchers方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。