Commit f730d23a authored by hdeadman's avatar hdeadman

Fix createKeystore

Setting commandLine twice in a task of type Exec was only running
the second command, never running the first one.
parent ec1eea8e
import org.apache.ivy.util.url.* import org.apache.ivy.util.url.*
import org.apache.tools.ant.taskdefs.condition.Os import org.apache.tools.ant.taskdefs.condition.Os
import java.nio.file.* import java.nio.file.*
import java.util.*
import org.gradle.internal.logging.text.StyledTextOutput;
import org.gradle.internal.logging.text.StyledTextOutputFactory; import org.gradle.internal.logging.text.StyledTextOutputFactory;
import static org.gradle.internal.logging.text.StyledTextOutput.Style; import static org.gradle.internal.logging.text.StyledTextOutput.Style;
...@@ -178,10 +176,9 @@ task casVersion (group: "build", description: "Display the current CAS version") ...@@ -178,10 +176,9 @@ task casVersion (group: "build", description: "Display the current CAS version")
} }
} }
task createKeystore (type:Exec, group: "build", description: "Create CAS keystore") { task createKeystore (group: "build", description: "Create CAS keystore") {
doFirst { doFirst {
mkdir "/etc/cas" mkdir "/etc/cas"
workingDir "."
def keystorePath = "/etc/cas/thekeystore" def keystorePath = "/etc/cas/thekeystore"
...@@ -189,24 +186,33 @@ task createKeystore (type:Exec, group: "build", description: "Create CAS keystor ...@@ -189,24 +186,33 @@ task createKeystore (type:Exec, group: "build", description: "Create CAS keystor
if (project.hasProperty("certificateDn")) { if (project.hasProperty("certificateDn")) {
dn = project.getProperty("certificateDn") dn = project.getProperty("certificateDn")
} }
def subjectAltName = "dns:example.org,dns:localhost,ip:127.0.0.1" def subjectAltName = "dns:example.org,dns:localhost,ip:127.0.0.1"
if (project.hasProperty("certificateSubAltName")) { if (project.hasProperty("certificateSubAltName")) {
subjectAltName = project.getProperty("certificateSubAltName") subjectAltName = project.getProperty("certificateSubAltName")
} }
// this will fail if thekeystore exists and has cert with cas alias already (so delete if you want to recreate)
logger.info "Generating keystore for CAS with DN ${dn}" logger.info "Generating keystore for CAS with DN ${dn}"
commandLine "keytool", "-genkeypair", "-alias", "cas", exec {
"-keyalg", "RSA", workingDir "."
"-keypass", "changeit", "-storepass", "changeit", commandLine "keytool", "-genkeypair", "-alias", "cas",
"-keystore", keystorePath, "-keyalg", "RSA",
"-dname", dn, "-ext", "SAN=${subjectAltName}" "-keypass", "changeit", "-storepass", "changeit",
"-keystore", keystorePath,
logger.info "Exporting keystore..." "-dname", dn, "-ext", "SAN=${subjectAltName}"
commandLine "keytool", "-exportcert", "-alias", "cas", }
"-storepass", "changeit", "-keystore", keystorePath, logger.info "Exporting cert from keystore..."
"-file", "/etc/cas/cas.cer" exec {
workingDir "."
commandLine "keytool", "-exportcert", "-alias", "cas",
"-storepass", "changeit", "-keystore", keystorePath,
"-file", "/etc/cas/cas.cer"
}
logger.info "Import /etc/cas/cas.cer into your Java truststore (JAVA_HOME/lib/security/cacerts)"
} }
} }
task listTemplateViews (group: "build", description: "List all CAS views") { task listTemplateViews (group: "build", description: "List all CAS views") {
dependsOn explodeWar dependsOn explodeWar
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment