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

ai.digital.integration.server.common.util.TlsUtil.kt Maven / Gradle / Ivy

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

import ai.digital.integration.server.common.domain.AkkaSecured
import ai.digital.integration.server.common.domain.Tls
import ai.digital.integration.server.deploy.internals.DeployExtensionUtil
import org.apache.commons.lang3.StringUtils
import org.gradle.api.Project

class TlsUtil {

    companion object {

        fun setTls(project: Project, tls: Tls?): Tls? {
            DeployExtensionUtil.getExtension(project).tls = tls
            return tls
        }

        fun getTls(project: Project, workDir: String): Tls? {
            val ext = DeployExtensionUtil.getExtension(project)
            if (ext.tls == null) {
                val tls = Tls(workDir)
                setTls(project, tls)
            }
            return ext.tls
        }

        fun setAkkaSecured(project: Project, akkaSecured: AkkaSecured?): AkkaSecured? {
            val ext = DeployExtensionUtil.getExtension(project)
            ext.akkaSecured = akkaSecured
            return akkaSecured
        }

        fun getAkkaSecured(project: Project, workDir: String): AkkaSecured? {
            val ext = DeployExtensionUtil.getExtension(project)
            if (ext.akkaSecured == null) {
                val akkaSecured = AkkaSecured(workDir)
                setAkkaSecured(project, akkaSecured)
            }
            return ext.akkaSecured
        }

        fun generatePassword(name: String): String {
            return StringUtils.rightPad(StringUtils.substring(name, 0, 8), 8, "12345678")
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy