All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ai.digital.integration.server.common.tls.KeytoolImportKeyToTruststoreTask.kt Maven / Gradle / Ivy

There is a newer version: 23.3.0-1025.941
Show newest version
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
            )
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy