Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/Java/Threema/buildSrc/src/main/kotlin/utils/     Datei vom 25.3.2026 mit Größe 1 kB image not shown  

Quelle  KeystoreUtils.kt   Sprache: unbekannt

 
Spracherkennung für: .kt vermutete Sprache: Unknown {[0] [0] [0]} [Methode: Schwerpunktbildung, einfache Gewichte, sechs Dimensionen]

package utils

import com.android.build.api.dsl.ApkSigningConfig
import java.util.Properties
import java.io.File

/**
 * Look up the keystore with the specified name in a `keystore` directory
 * adjacent to this project directory. If it exists, return a signing config.
 * Otherwise, return null.
 */
fun findKeystore(projectDir: File, name: String): KeystoreConfig? {
    val basePath = "${projectDir.absolutePath}/../../keystore"
    val storePath = "$basePath/$name.keystore"
    val storeFile = File(storePath)
    if (!storeFile.isFile) {
        return null
    }

    val propertiesPath = "$basePath/$name.properties"
    val propertiesFile = File(propertiesPath)
    val props = if (propertiesFile.isFile) {
        readPropertiesFile(propertiesFile)
    } else {
        null
    }

    return KeystoreConfig(
        storeFile = storeFile,
        storePassword = props?.getProperty("storePassword"),
        keyAlias = props?.getProperty("keyAlias"),
        keyPassword = props?.getProperty("keyPassword"),
    )
}

private fun readPropertiesFile(propertiesFile: File): Properties =
    Properties()
        .apply {
            propertiesFile.inputStream().use { inStream ->
                load(inStream)
            }
        }

fun ApkSigningConfig.apply(keystore: KeystoreConfig) {
    storeFile = keystore.storeFile
    storePassword = keystore.storePassword
    keyAlias = keystore.keyAlias
    keyPassword = keystore.keyPassword
}

data class KeystoreConfig(
    val storeFile: File,
    val storePassword: String?,
    val keyAlias: String?,
    val keyPassword: String?,
)

[Dauer der Verarbeitung: 0.19 Sekunden, vorverarbeitet 2026-04-27]