Permalink
Browse files

GRAILS-9621 added support for configuring clientAuth and configurable…

… truststores
  • Loading branch information...
1 parent b03eba1 commit d50790a22aac623b5d7b7c6e197cf89d4c67693e Grant Currey committed Nov 29, 2012
@@ -28,6 +28,7 @@ import org.springframework.util.ReflectionUtils
import org.apache.catalina.Loader
import org.apache.catalina.Context
import grails.util.Environment
+
/**
* Serves the app, without packaging as a war and runs it in the same JVM.
*/
@@ -43,7 +44,7 @@ class InlineExplodedTomcatServer extends TomcatServer {
contextPath = ''
}
- tomcat.setBaseDir( tomcatDir.absolutePath )
+ tomcat.setBaseDir(tomcatDir.absolutePath)
context = tomcat.addWebapp(contextPath, basedir)
boolean shouldScan = checkAndInitializingClasspathScanning()
@@ -118,7 +119,7 @@ class InlineExplodedTomcatServer extends TomcatServer {
sslConnector.scheme = "https"
sslConnector.secure = true
sslConnector.port = httpsPort
- sslConnector.setProperty("SSLEnabled","true")
+ sslConnector.setProperty("SSLEnabled", "true")
sslConnector.setAttribute("keystoreFile", keystoreFile.absolutePath)
sslConnector.setAttribute("keystorePass", keyPassword)
sslConnector.URIEncoding = 'UTF-8'
@@ -131,14 +132,14 @@ class InlineExplodedTomcatServer extends TomcatServer {
CONSOLE.addStatus "Using truststore $truststore"
sslConnector.setAttribute("truststoreFile", truststore)
sslConnector.setAttribute("truststorePass", trustPassword)
- sslConnector.setAttribute("clientAuth", "want")
+ sslConnector.setAttribute("clientAuth", getConfigParam("clientAuth") ?: "want")
}
tomcat.service.addConnector(sslConnector)
}
tomcat.start()
- if(Environment.isFork()) {
+ if (Environment.isFork()) {
IsolatedTomcat.startKillSwitch(tomcat, httpPort)
}
}
@@ -161,7 +162,7 @@ class InlineExplodedTomcatServer extends TomcatServer {
return
}
- System.setProperty("javax.sql.DataSource.Factory","org.apache.commons.dbcp.BasicDataSourceFactory");
+ System.setProperty("javax.sql.DataSource.Factory", "org.apache.commons.dbcp.BasicDataSourceFactory");
jndiEntries.each { name, resCfg ->
@@ -176,8 +177,8 @@ class InlineExplodedTomcatServer extends TomcatServer {
res.description = resCfg.remove("description")
res.scope = resCfg.remove("scope")
// now it's only the custom properties left in the Map...
- resCfg.each {key, value ->
- res.setProperty (key, value)
+ resCfg.each { key, value ->
+ res.setProperty(key, value)
}
context.namingResources.addResource res
@@ -69,9 +69,16 @@ abstract class TomcatServer implements EmbeddableServer {
keyPassword = "123456"
}
- truststore = "${buildSettings.grailsWorkDir}/ssl/truststore"
+ def userTruststore = getConfigParam("truststorePath")
+ if (userKeystore) {
+ truststore = userTruststore
+ trustPassword = getConfigParam("truststorePassword") ?: "changeit"
+ } else {
+ truststore = "${buildSettings.grailsWorkDir}/ssl/truststore"
+ trustPassword = "123456"
+ }
+
truststoreFile = new File(truststore)
- trustPassword = "123456"
System.setProperty('org.mortbay.xml.XmlParser.NotValidating', 'true')
@@ -165,15 +172,15 @@ abstract class TomcatServer implements EmbeddableServer {
}
getKeyToolClass().main(
- "-genkey",
- "-alias", "localhost",
- "-dname", "CN=localhost,OU=Test,O=Test,C=US",
- "-keyalg", "RSA",
- "-validity", "365",
- "-storepass", "key",
- "-keystore", keystoreFile.absolutePath,
- "-storepass", keyPassword,
- "-keypass", keyPassword)
+ "-genkey",
+ "-alias", "localhost",
+ "-dname", "CN=localhost,OU=Test,O=Test,C=US",
+ "-keyalg", "RSA",
+ "-validity", "365",
+ "-storepass", "key",
+ "-keystore", keystoreFile.absolutePath,
+ "-storepass", keyPassword,
+ "-keypass", keyPassword)
println 'Created SSL Certificate.'
}

0 comments on commit d50790a

Please sign in to comment.