Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
7bb1f7eb
Commit
7bb1f7eb
authored
Jul 24, 2014
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polishing: use passed-in ssl instance rather than calling getSsl()
parent
0960908b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
37 deletions
+36
-37
JettyEmbeddedServletContainerFactory.java
.../embedded/jetty/JettyEmbeddedServletContainerFactory.java
+19
-20
TomcatEmbeddedServletContainerFactory.java
...mbedded/tomcat/TomcatEmbeddedServletContainerFactory.java
+17
-17
No files found.
spring-boot/src/main/java/org/springframework/boot/context/embedded/jetty/JettyEmbeddedServletContainerFactory.java
View file @
7bb1f7eb
...
@@ -69,7 +69,7 @@ import org.springframework.util.StringUtils;
...
@@ -69,7 +69,7 @@ import org.springframework.util.StringUtils;
* @see JettyEmbeddedServletContainer
* @see JettyEmbeddedServletContainer
*/
*/
public
class
JettyEmbeddedServletContainerFactory
extends
public
class
JettyEmbeddedServletContainerFactory
extends
AbstractEmbeddedServletContainerFactory
implements
ResourceLoaderAware
{
AbstractEmbeddedServletContainerFactory
implements
ResourceLoaderAware
{
private
List
<
Configuration
>
configurations
=
new
ArrayList
<
Configuration
>();
private
List
<
Configuration
>
configurations
=
new
ArrayList
<
Configuration
>();
...
@@ -130,47 +130,46 @@ public class JettyEmbeddedServletContainerFactory extends
...
@@ -130,47 +130,46 @@ public class JettyEmbeddedServletContainerFactory extends
}
}
protected
void
configureSslContextFactory
(
SslContextFactory
sslContextFactory
,
Ssl
ssl
)
{
protected
void
configureSslContextFactory
(
SslContextFactory
sslContextFactory
,
Ssl
ssl
)
{
sslContextFactory
.
setProtocol
(
getSsl
()
.
getProtocol
());
sslContextFactory
.
setProtocol
(
ssl
.
getProtocol
());
if
(
getSsl
()
.
getClientAuth
()
==
ClientAuth
.
NEED
)
{
if
(
ssl
.
getClientAuth
()
==
ClientAuth
.
NEED
)
{
sslContextFactory
.
setNeedClientAuth
(
true
);
sslContextFactory
.
setNeedClientAuth
(
true
);
sslContextFactory
.
setWantClientAuth
(
true
);
sslContextFactory
.
setWantClientAuth
(
true
);
}
}
else
if
(
getSsl
()
.
getClientAuth
()
==
ClientAuth
.
WANT
)
{
else
if
(
ssl
.
getClientAuth
()
==
ClientAuth
.
WANT
)
{
sslContextFactory
.
setWantClientAuth
(
true
);
sslContextFactory
.
setWantClientAuth
(
true
);
}
}
if
(
getSsl
()
.
getKeyStorePassword
()
!=
null
)
{
if
(
ssl
.
getKeyStorePassword
()
!=
null
)
{
sslContextFactory
.
setKeyStorePassword
(
getSsl
()
.
getKeyStorePassword
());
sslContextFactory
.
setKeyStorePassword
(
ssl
.
getKeyStorePassword
());
}
}
if
(
getSsl
()
.
getKeyPassword
()
!=
null
)
{
if
(
ssl
.
getKeyPassword
()
!=
null
)
{
sslContextFactory
.
setKeyManagerPassword
(
getSsl
()
.
getKeyPassword
());
sslContextFactory
.
setKeyManagerPassword
(
ssl
.
getKeyPassword
());
}
}
sslContextFactory
.
setCertAlias
(
getSsl
()
.
getKeyAlias
());
sslContextFactory
.
setCertAlias
(
ssl
.
getKeyAlias
());
try
{
try
{
sslContextFactory
.
setKeyStoreResource
(
Resource
.
newResource
(
ResourceUtils
sslContextFactory
.
setKeyStoreResource
(
Resource
.
newResource
(
ResourceUtils
.
getURL
(
getSsl
()
.
getKeyStore
())));
.
getURL
(
ssl
.
getKeyStore
())));
}
}
catch
(
IOException
e
)
{
catch
(
IOException
e
)
{
throw
new
EmbeddedServletContainerException
(
"Could not find key store '"
throw
new
EmbeddedServletContainerException
(
"Could not find key store '"
+
getSsl
()
.
getKeyStore
()
+
"'"
,
e
);
+
ssl
.
getKeyStore
()
+
"'"
,
e
);
}
}
if
(
getSsl
()
.
getCiphers
()
!=
null
)
{
if
(
ssl
.
getCiphers
()
!=
null
)
{
sslContextFactory
.
setIncludeCipherSuites
(
getSsl
()
.
getCiphers
());
sslContextFactory
.
setIncludeCipherSuites
(
ssl
.
getCiphers
());
}
}
if
(
getSsl
()
.
getTrustStorePassword
()
!=
null
)
{
if
(
ssl
.
getTrustStorePassword
()
!=
null
)
{
sslContextFactory
.
setTrustStorePassword
(
getSsl
()
.
getTrustStorePassword
());
sslContextFactory
.
setTrustStorePassword
(
ssl
.
getTrustStorePassword
());
}
}
if
(
getSsl
()
.
getTrustStore
()
!=
null
)
{
if
(
ssl
.
getTrustStore
()
!=
null
)
{
try
{
try
{
sslContextFactory
.
setTrustStoreResource
(
Resource
sslContextFactory
.
setTrustStoreResource
(
Resource
.
newResource
(
ResourceUtils
.
getURL
(
getSsl
()
.
getTrustStore
())));
.
newResource
(
ResourceUtils
.
getURL
(
ssl
.
getTrustStore
())));
}
}
catch
(
IOException
e
)
{
catch
(
IOException
e
)
{
throw
new
EmbeddedServletContainerException
(
throw
new
EmbeddedServletContainerException
(
"Could not find trust store '"
+
getSsl
().
getTrustStore
()
+
"'"
,
"Could not find trust store '"
+
ssl
.
getTrustStore
()
+
"'"
,
e
);
e
);
}
}
}
}
}
}
...
@@ -203,7 +202,7 @@ public class JettyEmbeddedServletContainerFactory extends
...
@@ -203,7 +202,7 @@ public class JettyEmbeddedServletContainerFactory extends
initializersToUse
);
initializersToUse
);
context
.
setConfigurations
(
configurations
);
context
.
setConfigurations
(
configurations
);
context
.
getSessionHandler
().
getSessionManager
()
context
.
getSessionHandler
().
getSessionManager
()
.
setMaxInactiveInterval
(
getSessionTimeout
());
.
setMaxInactiveInterval
(
getSessionTimeout
());
postProcessWebAppContext
(
context
);
postProcessWebAppContext
(
context
);
}
}
...
...
spring-boot/src/main/java/org/springframework/boot/context/embedded/tomcat/TomcatEmbeddedServletContainerFactory.java
View file @
7bb1f7eb
...
@@ -79,7 +79,7 @@ import org.springframework.util.StringUtils;
...
@@ -79,7 +79,7 @@ import org.springframework.util.StringUtils;
* @see TomcatEmbeddedServletContainer
* @see TomcatEmbeddedServletContainer
*/
*/
public
class
TomcatEmbeddedServletContainerFactory
extends
public
class
TomcatEmbeddedServletContainerFactory
extends
AbstractEmbeddedServletContainerFactory
implements
ResourceLoaderAware
{
AbstractEmbeddedServletContainerFactory
implements
ResourceLoaderAware
{
private
static
final
String
DEFAULT_PROTOCOL
=
"org.apache.coyote.http11.Http11NioProtocol"
;
private
static
final
String
DEFAULT_PROTOCOL
=
"org.apache.coyote.http11.Http11NioProtocol"
;
...
@@ -226,7 +226,7 @@ public class TomcatEmbeddedServletContainerFactory extends
...
@@ -226,7 +226,7 @@ public class TomcatEmbeddedServletContainerFactory extends
if
(
connector
.
getProtocolHandler
()
instanceof
AbstractProtocol
)
{
if
(
connector
.
getProtocolHandler
()
instanceof
AbstractProtocol
)
{
if
(
getAddress
()
!=
null
)
{
if
(
getAddress
()
!=
null
)
{
((
AbstractProtocol
)
connector
.
getProtocolHandler
())
((
AbstractProtocol
)
connector
.
getProtocolHandler
())
.
setAddress
(
getAddress
());
.
setAddress
(
getAddress
());
}
}
}
}
if
(
getUriEncoding
()
!=
null
)
{
if
(
getUriEncoding
()
!=
null
)
{
...
@@ -258,40 +258,40 @@ public class TomcatEmbeddedServletContainerFactory extends
...
@@ -258,40 +258,40 @@ public class TomcatEmbeddedServletContainerFactory extends
protected
void
configureJsseProtocol
(
AbstractHttp11JsseProtocol
jsseProtocol
,
Ssl
ssl
)
{
protected
void
configureJsseProtocol
(
AbstractHttp11JsseProtocol
jsseProtocol
,
Ssl
ssl
)
{
jsseProtocol
.
setSSLEnabled
(
true
);
jsseProtocol
.
setSSLEnabled
(
true
);
jsseProtocol
.
setSslProtocol
(
getSsl
()
.
getProtocol
());
jsseProtocol
.
setSslProtocol
(
ssl
.
getProtocol
());
if
(
getSsl
()
.
getClientAuth
()
==
ClientAuth
.
NEED
)
{
if
(
ssl
.
getClientAuth
()
==
ClientAuth
.
NEED
)
{
jsseProtocol
.
setClientAuth
(
Boolean
.
TRUE
.
toString
());
jsseProtocol
.
setClientAuth
(
Boolean
.
TRUE
.
toString
());
}
}
else
if
(
getSsl
()
.
getClientAuth
()
==
ClientAuth
.
WANT
)
{
else
if
(
ssl
.
getClientAuth
()
==
ClientAuth
.
WANT
)
{
jsseProtocol
.
setClientAuth
(
"want"
);
jsseProtocol
.
setClientAuth
(
"want"
);
}
}
jsseProtocol
.
setKeystorePass
(
getSsl
()
.
getKeyStorePassword
());
jsseProtocol
.
setKeystorePass
(
ssl
.
getKeyStorePassword
());
jsseProtocol
.
setKeyPass
(
getSsl
()
.
getKeyPassword
());
jsseProtocol
.
setKeyPass
(
ssl
.
getKeyPassword
());
jsseProtocol
.
setKeyAlias
(
getSsl
()
.
getKeyAlias
());
jsseProtocol
.
setKeyAlias
(
ssl
.
getKeyAlias
());
try
{
try
{
jsseProtocol
.
setKeystoreFile
(
ResourceUtils
.
getFile
(
getSsl
()
.
getKeyStore
())
jsseProtocol
.
setKeystoreFile
(
ResourceUtils
.
getFile
(
ssl
.
getKeyStore
())
.
getAbsolutePath
());
.
getAbsolutePath
());
}
}
catch
(
FileNotFoundException
e
)
{
catch
(
FileNotFoundException
e
)
{
throw
new
EmbeddedServletContainerException
(
"Could not find key store "
throw
new
EmbeddedServletContainerException
(
"Could not find key store "
+
getSsl
()
.
getKeyStore
(),
e
);
+
ssl
.
getKeyStore
(),
e
);
}
}
jsseProtocol
.
setCiphers
(
StringUtils
.
arrayToCommaDelimitedString
(
getSsl
()
jsseProtocol
.
getCiphers
()));
.
setCiphers
(
StringUtils
.
arrayToCommaDelimitedString
(
ssl
.
getCiphers
()));
if
(
getSsl
()
.
getTrustStore
()
!=
null
)
{
if
(
ssl
.
getTrustStore
()
!=
null
)
{
try
{
try
{
jsseProtocol
.
setTruststoreFile
(
ResourceUtils
.
getFile
(
jsseProtocol
.
setTruststoreFile
(
ResourceUtils
.
getFile
(
ssl
.
getTrustStore
())
getSsl
().
getTrustStore
())
.
getAbsolutePath
());
.
getAbsolutePath
());
}
}
catch
(
FileNotFoundException
e
)
{
catch
(
FileNotFoundException
e
)
{
throw
new
EmbeddedServletContainerException
(
"Could not find trust store "
throw
new
EmbeddedServletContainerException
(
"Could not find trust store "
+
getSsl
()
.
getTrustStore
(),
e
);
+
ssl
.
getTrustStore
(),
e
);
}
}
}
}
jsseProtocol
.
setTruststorePass
(
getSsl
()
.
getTrustStorePassword
());
jsseProtocol
.
setTruststorePass
(
ssl
.
getTrustStorePassword
());
}
}
/**
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment