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

ai.digital.integration.server.common.tls.KeytoolGenKeyTask.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 ai.digital.integration.server.common.constant.ProductName
import ai.digital.integration.server.deploy.internals.EntryPointUrlUtil
import org.gradle.api.tasks.CacheableTask
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.OutputFile
import java.io.File

@CacheableTask
open class KeytoolGenKeyTask : KeytoolTask() {

    companion object {
        const val NAME = "keytoolGenKey"
    }

    @Input
    var ip = "127.0.0.1"

    @Input
    var dns = EntryPointUrlUtil(project, ProductName.DEPLOY).getHttpHost()

    @Input
    var validity: String = 360.toString()

    @Input
    var keySize: String = 2048.toString()

    @OutputFile
    override fun getOutputFile(): File {
        return File(workDir!!.absolutePath + "/" + keyname + "." + typeExtension)
    }

    override fun skipIfOutputFileExists(): Boolean {
        return true
    }

    init {
        this.doFirst {
            params = listOf(
                "-genkey",
                "-alias",
                keyname!!,
                "-ext",
                "SAN:c=DNS:$dns,IP:$ip",
                "-dname",
                "CN=localhost,O=digital.ai,OU=Deploy",
                "-keyalg",
                "RSA",
                "-keystore",
                getOutputFile().absolutePath,
                "-storetype",
                type,
                "-validity",
                validity,
                "-keysize",
                keySize
            )
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy