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


Java SslContextFactory.setProtocol方法代碼示例

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


在下文中一共展示了SslContextFactory.setProtocol方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: configureSsl

import org.eclipse.jetty.util.ssl.SslContextFactory; //導入方法依賴的package包/類
/**
 * Configure the SSL connection.
 * @param factory the Jetty {@link SslContextFactory}.
 * @param ssl the ssl details.
 */
protected void configureSsl(SslContextFactory factory, Ssl ssl) {
	factory.setProtocol(ssl.getProtocol());
	configureSslClientAuth(factory, ssl);
	configureSslPasswords(factory, ssl);
	factory.setCertAlias(ssl.getKeyAlias());
	if (ssl.getCiphers() != null) {
		factory.setIncludeCipherSuites(ssl.getCiphers());
	}
	if (ssl.getEnabledProtocols() != null) {
		factory.setIncludeProtocols(ssl.getEnabledProtocols());
	}
	if (getSslStoreProvider() != null) {
		try {
			factory.setKeyStore(getSslStoreProvider().getKeyStore());
			factory.setTrustStore(getSslStoreProvider().getTrustStore());
		}
		catch (Exception ex) {
			throw new IllegalStateException("Unable to set SSL store", ex);
		}
	}
	else {
		configureSslKeyStore(factory, ssl);
		configureSslTrustStore(factory, ssl);
	}
}
 
開發者ID:philwebb,項目名稱:spring-boot-concourse,代碼行數:31,代碼來源:JettyEmbeddedServletContainerFactory.java

示例2: configureSsl

import org.eclipse.jetty.util.ssl.SslContextFactory; //導入方法依賴的package包/類
/**
 * Configure the SSL connection.
 *
 * @param factory the Jetty {@link SslContextFactory}.
 * @param ssl the ssl details.
 */
protected void configureSsl(SslContextFactory factory, Ssl ssl) {
    factory.setProtocol(ssl.getProtocol());
    configureSslClientAuth(factory, ssl);
    configureSslPasswords(factory, ssl);
    factory.setCertAlias(ssl.getKeyAlias());

    if (!ObjectUtils.isEmpty(ssl.getCiphers())) {
        factory.setIncludeCipherSuites(ssl.getCiphers());
        factory.setExcludeCipherSuites();
    }

    if (ssl.getEnabledProtocols() != null) {
        factory.setIncludeProtocols(ssl.getEnabledProtocols());
    }

    if (getSslStoreProvider() != null) {
        try {
            factory.setKeyStore(getSslStoreProvider().getKeyStore());
            factory.setTrustStore(getSslStoreProvider().getTrustStore());
        } catch (Exception ex) {
            throw new IllegalStateException("Unable to set SSL store", ex);
        }
    } else {
        configureSslKeyStore(factory, ssl);
        configureSslTrustStore(factory, ssl);
    }
}
 
開發者ID:gdrouet,項目名稱:nightclazz-spring5,代碼行數:34,代碼來源:CustomJettyReactiveWebServerFactory.java

示例3: configureSsl

import org.eclipse.jetty.util.ssl.SslContextFactory; //導入方法依賴的package包/類
/**
 * Configure the SSL connection.
 * @param factory the Jetty {@link SslContextFactory}.
 * @param ssl the ssl details.
 */
protected void configureSsl(SslContextFactory factory, Ssl ssl) {
	factory.setProtocol(ssl.getProtocol());
	configureSslClientAuth(factory, ssl);
	configureSslPasswords(factory, ssl);
	factory.setCertAlias(ssl.getKeyAlias());
	if (!ObjectUtils.isEmpty(ssl.getCiphers())) {
		factory.setIncludeCipherSuites(ssl.getCiphers());
		factory.setExcludeCipherSuites();
	}
	if (ssl.getEnabledProtocols() != null) {
		factory.setIncludeProtocols(ssl.getEnabledProtocols());
	}
	if (getSslStoreProvider() != null) {
		try {
			factory.setKeyStore(getSslStoreProvider().getKeyStore());
			factory.setTrustStore(getSslStoreProvider().getTrustStore());
		}
		catch (Exception ex) {
			throw new IllegalStateException("Unable to set SSL store", ex);
		}
	}
	else {
		configureSslKeyStore(factory, ssl);
		configureSslTrustStore(factory, ssl);
	}
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:32,代碼來源:JettyEmbeddedServletContainerFactory.java

示例4: newSslConnectionFactory

import org.eclipse.jetty.util.ssl.SslContextFactory; //導入方法依賴的package包/類
private SslConnectionFactory newSslConnectionFactory() {
    Ssl sslConfig = connectorConfig.ssl();

    SslContextFactory factory = new JDiscSslContextFactory();

    sslKeyStoreConfigurator.configure(new DefaultSslKeyStoreContext(factory));
    sslTrustStoreConfigurator.configure(new DefaultSslTrustStoreContext(factory));

    switch (sslConfig.clientAuth()) {
        case NEED_AUTH:
            factory.setNeedClientAuth(true);
            break;
        case WANT_AUTH:
            factory.setWantClientAuth(true);
            break;
    }

    if (!sslConfig.prng().isEmpty()) {
        factory.setSecureRandomAlgorithm(sslConfig.prng());
    }

    setStringArrayParameter(
            factory, sslConfig.excludeProtocol(), ExcludeProtocol::name, SslContextFactory::setExcludeProtocols);
    setStringArrayParameter(
            factory, sslConfig.includeProtocol(), IncludeProtocol::name, SslContextFactory::setIncludeProtocols);
    setStringArrayParameter(
            factory, sslConfig.excludeCipherSuite(), ExcludeCipherSuite::name, SslContextFactory::setExcludeCipherSuites);
    setStringArrayParameter(
            factory, sslConfig.includeCipherSuite(), IncludeCipherSuite::name, SslContextFactory::setIncludeCipherSuites);

    factory.setKeyManagerFactoryAlgorithm(sslConfig.sslKeyManagerFactoryAlgorithm());
    factory.setProtocol(sslConfig.protocol());
    return new SslConnectionFactory(factory, HttpVersion.HTTP_1_1.asString());
}
 
開發者ID:vespa-engine,項目名稱:vespa,代碼行數:35,代碼來源:ConnectorFactory.java

示例5: createSslConnector

import org.eclipse.jetty.util.ssl.SslContextFactory; //導入方法依賴的package包/類
private ServerConnector createSslConnector(Server server, ConfigMap<String, Object> connectorCfg) throws FileNotFoundException {

		File certFile = FileUtils.getFile(null, connectorCfg.getString("cert", "keystore"));

		if (certFile != null) {

			HttpConfiguration httpsConfig = createHttpConfiguration(connectorCfg);

			SslContextFactory sslContextFactory = new SslContextFactory();
			sslContextFactory.setKeyStorePassword(connectorCfg.getString("store-pwd", "pumbaa"));
			sslContextFactory.setKeyManagerPassword(connectorCfg.getString("manager-pwd", "pumbaa"));
			sslContextFactory.setProtocol(connectorCfg.getString("protocol", "TLSv1"));

			ServerConnector connector = createServerConnector(server, connectorCfg, new SslConnectionFactory(sslContextFactory, "http/1.1"),
					new HttpConnectionFactory(httpsConfig));
			
			return connector;

		} else {
			throw new FileNotFoundException("Couldn't find keystore file");
		}

	}
 
開發者ID:PinaeOS,項目名稱:pumbaa,代碼行數:24,代碼來源:PumbaaServer.java

示例6: createHttpsJettyServer

import org.eclipse.jetty.util.ssl.SslContextFactory; //導入方法依賴的package包/類
private static JettyServer createHttpsJettyServer(boolean clientAuth) throws MalformedURLException, IOException {
    Server server = new Server();
    HttpConfiguration https_config = new HttpConfiguration();
    https_config.setSecureScheme("https");
    int port = 0;
    try (ServerSocket socket = new ServerSocket(0)) {
        port = socket.getLocalPort();
    }
    https_config.setSecurePort(port);
    https_config.setOutputBufferSize(32768);
    
    String keystorePath = DEFAULT_SERVER_KEY_STORE;
    SslContextFactory sslContextFactory = new SslContextFactory();
    File keystoreFile = new File(keystorePath);
    if (!keystoreFile.exists()) {
        throw new FileNotFoundException();
    }
    
    String trustStorePath = DEFAULT_CA_TRUST_STORE;
    File trustStoreFile = new File(trustStorePath);
    if (!trustStoreFile.exists()) {
        throw new FileNotFoundException();
    }
    
    sslContextFactory.setTrustStorePath(trustStorePath);
    sslContextFactory.setTrustStoreType(DEFAULT_SSL_STORE_TYPE);
    sslContextFactory.setTrustStorePassword(DEFAULT_CERT_PWD);

    sslContextFactory.setKeyStorePath(keystoreFile.getAbsolutePath());
    sslContextFactory.setKeyStoreType(DEFAULT_SSL_STORE_TYPE);
    sslContextFactory.setKeyStorePassword(DEFAULT_CERT_PWD);

    sslContextFactory.setProtocol(DEFAULT_SSL_PROTOCOL);
    sslContextFactory.setNeedClientAuth(clientAuth);

    ServerConnector https = new ServerConnector(server,
            new SslConnectionFactory(sslContextFactory,HttpVersion.HTTP_1_1.asString()),
                new HttpConnectionFactory(https_config));
    https.setPort(port);
    https.setIdleTimeout(500000);
    server.setConnectors(new Connector[] { https });
    HandlerList handlers = new HandlerList();
    ResourceHandler resourceHandler = new ResourceHandler();
    resourceHandler.setBaseResource(Resource.newResource("."));
    handlers.setHandlers(new Handler[]
    { resourceHandler, new DefaultHandler() });
    server.setHandler(handlers);
    return new JettyServer(server, port);
}
 
開發者ID:yahoo,項目名稱:athenz,代碼行數:50,代碼來源:SSLUtilsTest.java


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