Skip to content

Commit 4a4c3cb

Browse files
committed
keystore constants are not private vals
1 parent 2f10a98 commit 4a4c3cb

2 files changed

Lines changed: 20 additions & 9 deletions

File tree

src/main/kotlin/app/morphe/cli/command/PatchCommand.kt

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ import java.io.StringWriter
4747
import java.util.concurrent.Callable
4848
import java.util.logging.Logger
4949

50+
private const val DEFAULT_KEYSTORE_ALIAS = "Morphe"
51+
private const val DEFAULT_KEYSTORE_PASSWORD = "Morphe"
52+
private const val LEGACY_KEYSTORE_ALIAS = "Morphe Key"
53+
private const val LEGACY_KEYSTORE_PASSWORD = ""
54+
5055
@OptIn(ExperimentalSerializationApi::class)
5156
@VisibleForTesting
5257
@CommandLine.Command(
@@ -196,13 +201,13 @@ internal object PatchCommand : Callable<Int> {
196201
description = ["Alias of the private key and certificate pair keystore entry."],
197202
showDefaultValue = ALWAYS,
198203
)
199-
private var keyStoreEntryAlias = "Morphe" // Default now matches Manager
204+
private var keyStoreEntryAlias = DEFAULT_KEYSTORE_ALIAS // Default now matches Manager
200205

201206
@CommandLine.Option(
202207
names = ["--keystore-entry-password"],
203208
description = ["Password of the keystore entry."],
204209
)
205-
private var keyStoreEntryPassword = "Morphe" // Default now matches Manager
210+
private var keyStoreEntryPassword = DEFAULT_KEYSTORE_PASSWORD // Default now matches Manager
206211

207212
@CommandLine.Option(
208213
names = ["--signer"],
@@ -676,7 +681,7 @@ internal object PatchCommand : Callable<Int> {
676681
)
677682
} catch (e: Exception){
678683
// We retry with legacy keystore defaults here. Need to move to new defaults eventually!
679-
if (keyStoreEntryAlias == "Morphe" && keyStoreEntryPassword == "Morphe" && keystoreFilePath.exists()){
684+
if (keyStoreEntryAlias == DEFAULT_KEYSTORE_ALIAS && keyStoreEntryPassword == DEFAULT_KEYSTORE_PASSWORD && keystoreFilePath.exists()){
680685
logger.info("Retrying with legacy keystore credentials...")
681686

682687
ApkUtils.signApk(
@@ -686,8 +691,8 @@ internal object PatchCommand : Callable<Int> {
686691
ApkUtils.KeyStoreDetails(
687692
keystoreFilePath,
688693
keyStorePassword,
689-
"Morphe Key",
690-
"",
694+
LEGACY_KEYSTORE_ALIAS,
695+
LEGACY_KEYSTORE_PASSWORD,
691696
)
692697
)
693698
} else {

src/main/kotlin/app/morphe/engine/PatchEngine.kt

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ import java.util.logging.Logger
2929
/*
3030
* Single patching pipeline shared by CLI and GUI. (Eventually. Right now we are still having 2 pipelines)
3131
*/
32+
33+
private const val DEFAULT_KEYSTORE_ALIAS = "Morphe"
34+
private const val DEFAULT_KEYSTORE_PASSWORD = "Morphe"
35+
private const val LEGACY_KEYSTORE_ALIAS = "Morphe Key"
36+
private const val LEGACY_KEYSTORE_PASSWORD = ""
37+
3238
object PatchEngine {
3339

3440
enum class PatchStep {
@@ -231,8 +237,8 @@ object PatchEngine {
231237
val keystoreDetails = config.keystoreDetails ?: ApkUtils.KeyStoreDetails(
232238
File(tempDir, "morphe.keystore"),
233239
null,
234-
"Morphe",
235-
"Morphe",
240+
DEFAULT_KEYSTORE_ALIAS,
241+
DEFAULT_KEYSTORE_PASSWORD,
236242
)
237243
try {
238244
ApkUtils.signApk(
@@ -249,8 +255,8 @@ object PatchEngine {
249255
val legacyKeystoreDetails = ApkUtils.KeyStoreDetails(
250256
keystoreDetails.keyStore,
251257
null,
252-
"Morphe Key",
253-
"",
258+
LEGACY_KEYSTORE_ALIAS,
259+
LEGACY_KEYSTORE_PASSWORD,
254260
)
255261

256262
ApkUtils.signApk(

0 commit comments

Comments
 (0)