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"
...@@ -193,20 +190,29 @@ task createKeystore (type:Exec, group: "build", description: "Create CAS keystor ...@@ -193,20 +190,29 @@ task createKeystore (type:Exec, group: "build", description: "Create CAS keystor
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}"
exec {
workingDir "."
commandLine "keytool", "-genkeypair", "-alias", "cas", commandLine "keytool", "-genkeypair", "-alias", "cas",
"-keyalg", "RSA", "-keyalg", "RSA",
"-keypass", "changeit", "-storepass", "changeit", "-keypass", "changeit", "-storepass", "changeit",
"-keystore", keystorePath, "-keystore", keystorePath,
"-dname", dn, "-ext", "SAN=${subjectAltName}" "-dname", dn, "-ext", "SAN=${subjectAltName}"
}
logger.info "Exporting keystore..." logger.info "Exporting cert from keystore..."
exec {
workingDir "."
commandLine "keytool", "-exportcert", "-alias", "cas", commandLine "keytool", "-exportcert", "-alias", "cas",
"-storepass", "changeit", "-keystore", keystorePath, "-storepass", "changeit", "-keystore", keystorePath,
"-file", "/etc/cas/cas.cer" "-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