本文整理汇总了Java中org.springframework.boot.context.embedded.Ssl类的典型用法代码示例。如果您正苦于以下问题:Java Ssl类的具体用法?Java Ssl怎么用?Java Ssl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Ssl类属于org.springframework.boot.context.embedded包,在下文中一共展示了Ssl类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: configureSslTrustStore
import org.springframework.boot.context.embedded.Ssl; //导入依赖的package包/类
private void configureSslTrustStore(SslContextFactory factory, Ssl ssl) {
if (ssl.getTrustStorePassword() != null) {
factory.setTrustStorePassword(ssl.getTrustStorePassword());
}
if (ssl.getTrustStore() != null) {
try {
URL url = ResourceUtils.getURL(ssl.getTrustStore());
factory.setTrustStoreResource(Resource.newResource(url));
}
catch (IOException ex) {
throw new EmbeddedServletContainerException(
"Could not find trust store '" + ssl.getTrustStore() + "'", ex);
}
}
if (ssl.getTrustStoreType() != null) {
factory.setTrustStoreType(ssl.getTrustStoreType());
}
if (ssl.getTrustStoreProvider() != null) {
factory.setTrustStoreProvider(ssl.getTrustStoreProvider());
}
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:22,代码来源:JettyEmbeddedServletContainerFactory.java
示例2: configureSslKeyStore
import org.springframework.boot.context.embedded.Ssl; //导入依赖的package包/类
private void configureSslKeyStore(SslContextFactory factory, Ssl ssl) {
try {
URL url = ResourceUtils.getURL(ssl.getKeyStore());
factory.setKeyStoreResource(Resource.newResource(url));
}
catch (IOException ex) {
throw new EmbeddedServletContainerException(
"Could not find key store '" + ssl.getKeyStore() + "'", ex);
}
if (ssl.getKeyStoreType() != null) {
factory.setKeyStoreType(ssl.getKeyStoreType());
}
if (ssl.getKeyStoreProvider() != null) {
factory.setKeyStoreProvider(ssl.getKeyStoreProvider());
}
}
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:17,代码来源:JettyEmbeddedServletContainerFactory.java
示例3: configureSslTrustStore
import org.springframework.boot.context.embedded.Ssl; //导入依赖的package包/类
private void configureSslTrustStore(AbstractHttp11JsseProtocol<?> protocol, Ssl ssl) {
if (ssl.getTrustStore() != null) {
try {
protocol.setTruststoreFile(
ResourceUtils.getURL(ssl.getTrustStore()).toString());
}
catch (FileNotFoundException ex) {
throw new EmbeddedServletContainerException(
"Could not load trust store: " + ex.getMessage(), ex);
}
}
protocol.setTruststorePass(ssl.getTrustStorePassword());
if (ssl.getTrustStoreType() != null) {
protocol.setTruststoreType(ssl.getTrustStoreType());
}
if (ssl.getTrustStoreProvider() != null) {
protocol.setTruststoreProvider(ssl.getTrustStoreProvider());
}
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:21,代码来源:TomcatEmbeddedServletContainerFactory.java
示例4: getKeyManagers
import org.springframework.boot.context.embedded.Ssl; //导入依赖的package包/类
private KeyManager[] getKeyManagers() {
try {
KeyStore keyStore = getKeyStore();
KeyManagerFactory keyManagerFactory = KeyManagerFactory
.getInstance(KeyManagerFactory.getDefaultAlgorithm());
Ssl ssl = getSsl();
char[] keyPassword = (ssl.getKeyPassword() != null
? ssl.getKeyPassword().toCharArray() : null);
if (keyPassword == null && ssl.getKeyStorePassword() != null) {
keyPassword = ssl.getKeyStorePassword().toCharArray();
}
keyManagerFactory.init(keyStore, keyPassword);
return keyManagerFactory.getKeyManagers();
}
catch (Exception ex) {
throw new IllegalStateException(ex);
}
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:19,代码来源:UndertowEmbeddedServletContainerFactory.java
示例5: sslCiphersConfiguration
import org.springframework.boot.context.embedded.Ssl; //导入依赖的package包/类
@Test
public void sslCiphersConfiguration() throws Exception {
Ssl ssl = new Ssl();
ssl.setKeyStore("test.jks");
ssl.setKeyStorePassword("secret");
ssl.setCiphers(new String[] { "ALPHA", "BRAVO", "CHARLIE" });
TomcatEmbeddedServletContainerFactory factory = getFactory();
factory.setSsl(ssl);
Tomcat tomcat = getTomcat(factory);
Connector connector = tomcat.getConnector();
SSLHostConfig[] sslHostConfigs = connector.getProtocolHandler()
.findSslHostConfigs();
assertThat(sslHostConfigs[0].getCiphers()).isEqualTo("ALPHA:BRAVO:CHARLIE");
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:18,代码来源:TomcatEmbeddedServletContainerFactoryTests.java
示例6: sslEnabledMultipleProtocolsConfiguration
import org.springframework.boot.context.embedded.Ssl; //导入依赖的package包/类
@Test
public void sslEnabledMultipleProtocolsConfiguration() throws Exception {
Ssl ssl = getSsl(null, "password", "src/test/resources/test.jks");
ssl.setEnabledProtocols(new String[] { "TLSv1.1", "TLSv1.2" });
ssl.setCiphers(new String[] { "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256", "BRAVO" });
TomcatEmbeddedServletContainerFactory factory = getFactory();
factory.setSsl(ssl);
this.container = factory
.getEmbeddedServletContainer(sessionServletRegistration());
this.container.start();
Tomcat tomcat = ((TomcatEmbeddedServletContainer) this.container).getTomcat();
Connector connector = tomcat.getConnector();
SSLHostConfig sslHostConfig = connector.getProtocolHandler()
.findSslHostConfigs()[0];
assertThat(sslHostConfig.getSslProtocol()).isEqualTo("TLS");
assertThat(sslHostConfig.getEnabledProtocols())
.containsExactlyInAnyOrder("TLSv1.1", "TLSv1.2");
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:22,代码来源:TomcatEmbeddedServletContainerFactoryTests.java
示例7: sslEnabledProtocolsConfiguration
import org.springframework.boot.context.embedded.Ssl; //导入依赖的package包/类
@Test
public void sslEnabledProtocolsConfiguration() throws Exception {
Ssl ssl = getSsl(null, "password", "src/test/resources/test.jks");
ssl.setEnabledProtocols(new String[] { "TLSv1.2" });
ssl.setCiphers(new String[] { "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256", "BRAVO" });
TomcatEmbeddedServletContainerFactory factory = getFactory();
factory.setSsl(ssl);
this.container = factory
.getEmbeddedServletContainer(sessionServletRegistration());
Tomcat tomcat = ((TomcatEmbeddedServletContainer) this.container).getTomcat();
Connector connector = tomcat.getConnector();
this.container.start();
SSLHostConfig sslHostConfig = connector.getProtocolHandler()
.findSslHostConfigs()[0];
assertThat(sslHostConfig.getSslProtocol()).isEqualTo("TLS");
assertThat(sslHostConfig.getEnabledProtocols()).containsExactly("TLSv1.2");
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:21,代码来源:TomcatEmbeddedServletContainerFactoryTests.java
示例8: sslCiphersConfiguration
import org.springframework.boot.context.embedded.Ssl; //导入依赖的package包/类
@Test
public void sslCiphersConfiguration() throws Exception {
Ssl ssl = new Ssl();
ssl.setKeyStore("src/test/resources/test.jks");
ssl.setKeyStorePassword("secret");
ssl.setKeyPassword("password");
ssl.setCiphers(new String[] { "ALPHA", "BRAVO", "CHARLIE" });
JettyEmbeddedServletContainerFactory factory = getFactory();
factory.setSsl(ssl);
this.container = factory.getEmbeddedServletContainer();
this.container.start();
JettyEmbeddedServletContainer jettyContainer = (JettyEmbeddedServletContainer) this.container;
ServerConnector connector = (ServerConnector) jettyContainer.getServer()
.getConnectors()[0];
SslConnectionFactory connectionFactory = connector
.getConnectionFactory(SslConnectionFactory.class);
assertThat(connectionFactory.getSslContextFactory().getIncludeCipherSuites())
.containsExactly("ALPHA", "BRAVO", "CHARLIE");
assertThat(connectionFactory.getSslContextFactory().getExcludeCipherSuites())
.isEmpty();
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:25,代码来源:JettyEmbeddedServletContainerFactoryTests.java
示例9: sslEnabledMultiProtocolsConfiguration
import org.springframework.boot.context.embedded.Ssl; //导入依赖的package包/类
@Test
public void sslEnabledMultiProtocolsConfiguration() throws Exception {
Ssl ssl = new Ssl();
ssl.setKeyStore("src/test/resources/test.jks");
ssl.setKeyStorePassword("secret");
ssl.setKeyPassword("password");
ssl.setCiphers(new String[] { "ALPHA", "BRAVO", "CHARLIE" });
ssl.setEnabledProtocols(new String[] { "TLSv1.1", "TLSv1.2" });
JettyEmbeddedServletContainerFactory factory = getFactory();
factory.setSsl(ssl);
this.container = factory.getEmbeddedServletContainer();
this.container.start();
JettyEmbeddedServletContainer jettyContainer = (JettyEmbeddedServletContainer) this.container;
ServerConnector connector = (ServerConnector) jettyContainer.getServer()
.getConnectors()[0];
SslConnectionFactory connectionFactory = connector
.getConnectionFactory(SslConnectionFactory.class);
assertThat(connectionFactory.getSslContextFactory().getIncludeProtocols())
.isEqualTo(new String[] { "TLSv1.1", "TLSv1.2" });
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:25,代码来源:JettyEmbeddedServletContainerFactoryTests.java
示例10: sslEnabledProtocolsConfiguration
import org.springframework.boot.context.embedded.Ssl; //导入依赖的package包/类
@Test
public void sslEnabledProtocolsConfiguration() throws Exception {
Ssl ssl = new Ssl();
ssl.setKeyStore("src/test/resources/test.jks");
ssl.setKeyStorePassword("secret");
ssl.setKeyPassword("password");
ssl.setCiphers(new String[] { "ALPHA", "BRAVO", "CHARLIE" });
ssl.setEnabledProtocols(new String[] { "TLSv1.1" });
JettyEmbeddedServletContainerFactory factory = getFactory();
factory.setSsl(ssl);
this.container = factory.getEmbeddedServletContainer();
this.container.start();
JettyEmbeddedServletContainer jettyContainer = (JettyEmbeddedServletContainer) this.container;
ServerConnector connector = (ServerConnector) jettyContainer.getServer()
.getConnectors()[0];
SslConnectionFactory connectionFactory = connector
.getConnectionFactory(SslConnectionFactory.class);
assertThat(connectionFactory.getSslContextFactory().getIncludeProtocols())
.isEqualTo(new String[] { "TLSv1.1" });
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:25,代码来源:JettyEmbeddedServletContainerFactoryTests.java
示例11: customize
import org.springframework.boot.context.embedded.Ssl; //导入依赖的package包/类
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
KeystoreConfig cert = configureKeystore();
if(cert == null) {
log.debug("Ssl is not enabled due to no any configured keystore.");
return;
}
String keystorePath = cert.getKeystore().getAbsolutePath();
log.debug("Configure ssl with {} keystore.", keystorePath);
Ssl ssl = new Ssl();
ssl.setEnabled(true);
ssl.setKeyStore(keystorePath);
ssl.setKeyStorePassword(cert.getKeystorePassword());
ssl.setKeyPassword(cert.getKeyPassword());
container.setSsl(ssl);
}
开发者ID:codeabovelab,项目名称:haven-platform,代码行数:17,代码来源:SslServletContainerCustomizer.java
示例12: configureSsl
import org.springframework.boot.context.embedded.Ssl; //导入依赖的package包/类
/**
* Configure Tomcat's {@link AbstractHttp11JsseProtocol} for SSL.
* @param protocol the protocol
* @param ssl the ssl details
*/
protected void configureSsl(AbstractHttp11JsseProtocol<?> protocol, Ssl ssl) {
protocol.setSSLEnabled(true);
protocol.setSslProtocol(ssl.getProtocol());
configureSslClientAuth(protocol, ssl);
protocol.setKeystorePass(ssl.getKeyStorePassword());
protocol.setKeyPass(ssl.getKeyPassword());
protocol.setKeyAlias(ssl.getKeyAlias());
protocol.setCiphers(StringUtils.arrayToCommaDelimitedString(ssl.getCiphers()));
if (ssl.getEnabledProtocols() != null) {
protocol.setProperty("sslEnabledProtocols",
StringUtils.arrayToCommaDelimitedString(ssl.getEnabledProtocols()));
}
if (getSslStoreProvider() != null) {
configureSslStoreProvider(protocol, getSslStoreProvider());
}
else {
configureSslKeyStore(protocol, ssl);
configureSslTrustStore(protocol, ssl);
}
}
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:26,代码来源:TomcatEmbeddedServletContainerFactory.java
示例13: getKeyManagers
import org.springframework.boot.context.embedded.Ssl; //导入依赖的package包/类
private KeyManager[] getKeyManagers() {
try {
KeyStore keyStore = getKeyStore();
KeyManagerFactory keyManagerFactory = KeyManagerFactory
.getInstance(KeyManagerFactory.getDefaultAlgorithm());
Ssl ssl = getSsl();
String keyPassword = ssl.getKeyPassword();
if (keyPassword == null) {
keyPassword = ssl.getKeyStorePassword();
}
keyManagerFactory.init(keyStore, keyPassword.toCharArray());
return keyManagerFactory.getKeyManagers();
}
catch (Exception ex) {
throw new IllegalStateException(ex);
}
}
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:18,代码来源:UndertowEmbeddedServletContainerFactory.java
示例14: configureSsl
import org.springframework.boot.context.embedded.Ssl; //导入依赖的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
示例15: sslCiphersConfiguration
import org.springframework.boot.context.embedded.Ssl; //导入依赖的package包/类
@Test
public void sslCiphersConfiguration() throws Exception {
Ssl ssl = new Ssl();
ssl.setKeyStore("test.jks");
ssl.setKeyStorePassword("secret");
ssl.setCiphers(new String[] { "ALPHA", "BRAVO", "CHARLIE" });
TomcatEmbeddedServletContainerFactory factory = getFactory();
factory.setSsl(ssl);
Tomcat tomcat = getTomcat(factory);
Connector connector = tomcat.getConnector();
AbstractHttp11JsseProtocol<?> jsseProtocol = (AbstractHttp11JsseProtocol<?>) connector
.getProtocolHandler();
assertThat(jsseProtocol.getCiphers()).isEqualTo("ALPHA,BRAVO,CHARLIE");
}
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:18,代码来源:TomcatEmbeddedServletContainerFactoryTests.java
示例16: sslEnabledMultipleProtocolsConfiguration
import org.springframework.boot.context.embedded.Ssl; //导入依赖的package包/类
@Test
public void sslEnabledMultipleProtocolsConfiguration() throws Exception {
Ssl ssl = new Ssl();
ssl.setKeyStore("test.jks");
ssl.setKeyStorePassword("secret");
ssl.setEnabledProtocols(new String[] { "TLSv1.1", "TLSv1.2" });
ssl.setCiphers(new String[] { "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256", "BRAVO" });
TomcatEmbeddedServletContainerFactory factory = getFactory();
factory.setSsl(ssl);
this.container = factory
.getEmbeddedServletContainer(sessionServletRegistration());
Tomcat tomcat = ((TomcatEmbeddedServletContainer) this.container).getTomcat();
Connector connector = tomcat.getConnector();
AbstractHttp11JsseProtocol<?> jsseProtocol = (AbstractHttp11JsseProtocol<?>) connector
.getProtocolHandler();
assertThat(jsseProtocol.getSslProtocol()).isEqualTo("TLS");
assertThat(jsseProtocol.getProperty("sslEnabledProtocols"))
.isEqualTo("TLSv1.1,TLSv1.2");
}
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:23,代码来源:TomcatEmbeddedServletContainerFactoryTests.java
示例17: sslEnabledProtocolsConfiguration
import org.springframework.boot.context.embedded.Ssl; //导入依赖的package包/类
@Test
public void sslEnabledProtocolsConfiguration() throws Exception {
Ssl ssl = new Ssl();
ssl.setKeyStore("test.jks");
ssl.setKeyStorePassword("secret");
ssl.setEnabledProtocols(new String[] { "TLSv1.2" });
ssl.setCiphers(new String[] { "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256", "BRAVO" });
TomcatEmbeddedServletContainerFactory factory = getFactory();
factory.setSsl(ssl);
this.container = factory
.getEmbeddedServletContainer(sessionServletRegistration());
Tomcat tomcat = ((TomcatEmbeddedServletContainer) this.container).getTomcat();
Connector connector = tomcat.getConnector();
AbstractHttp11JsseProtocol<?> jsseProtocol = (AbstractHttp11JsseProtocol<?>) connector
.getProtocolHandler();
assertThat(jsseProtocol.getSslProtocol()).isEqualTo("TLS");
assertThat(jsseProtocol.getProperty("sslEnabledProtocols")).isEqualTo("TLSv1.2");
}
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:22,代码来源:TomcatEmbeddedServletContainerFactoryTests.java
示例18: sslCiphersConfiguration
import org.springframework.boot.context.embedded.Ssl; //导入依赖的package包/类
@Test
public void sslCiphersConfiguration() throws Exception {
Ssl ssl = new Ssl();
ssl.setKeyStore("src/test/resources/test.jks");
ssl.setKeyStorePassword("secret");
ssl.setKeyPassword("password");
ssl.setCiphers(new String[] { "ALPHA", "BRAVO", "CHARLIE" });
JettyEmbeddedServletContainerFactory factory = getFactory();
factory.setSsl(ssl);
this.container = factory.getEmbeddedServletContainer();
this.container.start();
JettyEmbeddedServletContainer jettyContainer = (JettyEmbeddedServletContainer) this.container;
ServerConnector connector = (ServerConnector) jettyContainer.getServer()
.getConnectors()[0];
SslConnectionFactory connectionFactory = connector
.getConnectionFactory(SslConnectionFactory.class);
assertThat(connectionFactory.getSslContextFactory().getIncludeCipherSuites())
.containsExactly("ALPHA", "BRAVO", "CHARLIE");
}
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:23,代码来源:JettyEmbeddedServletContainerFactoryTests.java
示例19: configureSslTrustStore
import org.springframework.boot.context.embedded.Ssl; //导入依赖的package包/类
private void configureSslTrustStore(AbstractHttp11JsseProtocol<?> protocol, Ssl ssl) {
if (ssl.getTrustStore() != null) {
try {
protocol.setTruststoreFile(
ResourceUtils.getURL(ssl.getTrustStore()).toString());
}
catch (FileNotFoundException ex) {
throw new EmbeddedServletContainerException(
"Could not load trust store: " + ex.getMessage(), ex);
}
}
protocol.setTruststorePass(ssl.getTrustStorePassword());
if (ssl.getTrustStoreType() != null) {
protocol.setTruststoreType(ssl.getTrustStoreType());
}
if (ssl.getTrustStoreProvider() != null) {
protocol.setTruststoreProvider(ssl.getTrustStoreProvider());
}
}
开发者ID:Nephilim84,项目名称:contestparser,代码行数:20,代码来源:TomcatEmbeddedServletContainerFactory.java
示例20: getKeyManagers
import org.springframework.boot.context.embedded.Ssl; //导入依赖的package包/类
private KeyManager[] getKeyManagers() {
try {
Ssl ssl = getSsl();
String keyStoreType = ssl.getKeyStoreType();
if (keyStoreType == null) {
keyStoreType = "JKS";
}
KeyStore keyStore = KeyStore.getInstance(keyStoreType);
URL url = ResourceUtils.getURL(ssl.getKeyStore());
keyStore.load(url.openStream(), ssl.getKeyStorePassword().toCharArray());
// Get key manager to provide client credentials.
KeyManagerFactory keyManagerFactory = KeyManagerFactory
.getInstance(KeyManagerFactory.getDefaultAlgorithm());
char[] keyPassword = ssl.getKeyPassword() != null
? ssl.getKeyPassword().toCharArray()
: ssl.getKeyStorePassword().toCharArray();
keyManagerFactory.init(keyStore, keyPassword);
return keyManagerFactory.getKeyManagers();
}
catch (Exception ex) {
throw new IllegalStateException(ex);
}
}
开发者ID:Nephilim84,项目名称:contestparser,代码行数:25,代码来源:UndertowEmbeddedServletContainerFactory.java
注:本文中的org.springframework.boot.context.embedded.Ssl类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论