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

ai.digital.integration.server.common.domain.AkkaSecured.kt Maven / Gradle / Ivy

There is a newer version: 23.3.0-1025.941
Show newest version
package ai.digital.integration.server.common.domain

import ai.digital.integration.server.common.util.TlsUtil
import java.io.File

class AkkaSecured(serverWorkingDir: String) {

    companion object {
        const val KEYSTORE_TYPE = "jks"
        const val KEYSTORE_TYPE_EXTENSION = "jks"
        const val MASTER_KEY_NAME = "akka_ssl_master_"
        const val WORKER_KEY_NAME = "akka_ssl_worker_"
        const val SATELLITE_KEY_NAME = "akka_ssl_satellite_"
        const val TRUSTSTORE_NAME = "akka_ssl_truststore_"
    }

    val trustStoreName: String = TRUSTSTORE_NAME
    val truststorePassword: String = TlsUtil.generatePassword(trustStoreName)
    private val confWorkDirPath: String = "$serverWorkingDir/conf"
    private val trustStoreFilePath: String = confWorkDir().toString() + "/" + trustStoreName + "." + KEYSTORE_TYPE_EXTENSION
    val keys: MutableMap = mutableMapOf()

    fun confWorkDir(): File {
        return File(confWorkDirPath)
    }

    fun trustStoreFile(): File {
        return File(trustStoreFilePath)
    }

    class KeyMeta(confWorkDir: File, keyStoreName: String) {
        fun keyStoreFile(): File {
            return File(keyStoreFilePath)
        }

        var keyStorePassword: String
        var keyPassword: String
        var keyStoreFilePath: String

        init {
            keyStorePassword = TlsUtil.generatePassword("s$keyStoreName")
            keyPassword = TlsUtil.generatePassword("k$keyStoreName")
            keyStoreFilePath = "$confWorkDir/$keyStoreName.$KEYSTORE_TYPE_EXTENSION"
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy