ai.digital.integration.server.common.tls.KeytoolImportKeyToTruststoreTask.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of integration-server-gradle-plugin Show documentation
Show all versions of integration-server-gradle-plugin Show documentation
The easy way to get custom setup for Deploy up and running
package ai.digital.integration.server.common.tls
import org.gradle.api.tasks.*
import java.io.File
@CacheableTask
open class KeytoolImportKeyToTruststoreTask : KeytoolTask() {
companion object {
const val NAME = "keytoolImportKeyToTruststore"
}
@Input
var truststore: String? = null
@InputFile
@PathSensitive(PathSensitivity.ABSOLUTE)
fun getInputFile(): File {
return File(workDir!!.absolutePath + "/" + keyname + ".cer")
}
@OutputFile
override fun getOutputFile(): File {
return File(workDir!!.absolutePath + "/" + truststore + "." + typeExtension)
}
override fun skipIfOutputFileExists(): Boolean {
val params = listOf("-list", "-alias", keyname, "-deststoretype", type, "-keystore", getOutputFile().absolutePath)
val result = execTask(params, false)
return result!!.exitValue == 0
}
init {
this.doFirst {
params = listOf(
"-import", "-noprompt", "-alias", keyname!!, "-deststoretype", type,
"-file", getInputFile().absolutePath, "-keystore", getOutputFile().absolutePath
)
}
}
}