-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from Commencis/feature/sampleapp
Add Sample Application
- Loading branch information
Showing
49 changed files
with
1,240 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ jobs: | |
uses: actions/[email protected] | ||
with: | ||
distribution: 'temurin' | ||
java-version: '11' | ||
java-version: '17' | ||
cache: gradle | ||
|
||
- name: Grant execute permission for gradlew | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
kotlin.code.style=official | ||
android.useAndroidX=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget | ||
|
||
plugins { | ||
alias(libs.plugins.android.application) | ||
alias(libs.plugins.kotlin.android) | ||
id("com.commencis.secretsvaultplugin") | ||
} | ||
|
||
android { | ||
namespace = "com.commencis.secretsvaultplugin.sampleapp" | ||
compileSdk = 33 | ||
|
||
defaultConfig { | ||
applicationId = "com.commencis.secretsvaultplugin.sampleapp" | ||
minSdk = 21 | ||
targetSdk = 33 | ||
versionCode = 1 | ||
versionName = "1.0" | ||
|
||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
signingConfigs { | ||
getByName("debug") { | ||
storeFile = file("keystore/debug.jks") | ||
storePassword = "android" | ||
keyAlias = "debug" | ||
keyPassword = "android" | ||
} | ||
create("release") { | ||
storeFile = file("keystore/release.jks") | ||
storePassword = "android" | ||
keyAlias = "release" | ||
keyPassword = "android" | ||
} | ||
} | ||
|
||
buildTypes { | ||
debug { | ||
applicationIdSuffix = ".debug" | ||
signingConfig = signingConfigs.getByName("debug") | ||
} | ||
release { | ||
signingConfig = signingConfigs.getByName("release") | ||
isMinifyEnabled = true | ||
proguardFiles( | ||
getDefaultProguardFile("proguard-android-optimize.txt"), | ||
"proguard-rules.pro" | ||
) | ||
} | ||
} | ||
|
||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_11 | ||
targetCompatibility = JavaVersion.VERSION_11 | ||
} | ||
|
||
externalNativeBuild { | ||
cmake { | ||
path("src/main/cpp/CMakeLists.txt") | ||
} | ||
} | ||
|
||
flavorDimensions.add("stage") | ||
productFlavors { | ||
create("dev") { | ||
dimension = "stage" | ||
externalNativeBuild { | ||
cmake { | ||
arguments("-DsourceSet=dev") | ||
} | ||
} | ||
} | ||
create("prod") { | ||
dimension = "stage" | ||
externalNativeBuild { | ||
cmake { | ||
arguments("-DsourceSet=prod") | ||
} | ||
} | ||
} | ||
} | ||
|
||
kotlinOptions { | ||
jvmTarget = JvmTarget.JVM_11.target | ||
} | ||
} | ||
|
||
secretsVault { | ||
appSignatures.set( | ||
listOf( | ||
"1A:92:D7:89:8F:16:C4:D3:46:E2:6D:C5:0C:2F:42:B0", // keystore/debug.kjs | ||
"45:4E:FD:58:87:C2:27:D2:5E:12:F4:C6:7F:CA:53:10", // keystore/release.kjs | ||
) | ||
) | ||
obfuscationKey.set("chEYKrGb5PJx0I09oa1mlEuXE5FxPjX2") | ||
cmake { | ||
version.set("3.17") | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation(libs.androidx.activityKtx) | ||
} |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
[ | ||
{ | ||
"key": "generalKey1", | ||
"value": "generalValue1" | ||
}, | ||
{ | ||
"key": "generalKey2", | ||
"value": "generalValue2" | ||
}, | ||
{ | ||
"key": "commonFlavorKey1", | ||
"value": "commonFlavorValue1Dev", | ||
"sourceSet": "dev" | ||
}, | ||
{ | ||
"key": "commonFlavorKey1", | ||
"value": "commonFlavorValue1Prod", | ||
"sourceSet": "prod" | ||
}, | ||
{ | ||
"key": "devOnlyKey1", | ||
"value": "devOnlyValue1", | ||
"sourceSet": "dev" | ||
}, | ||
{ | ||
"key": "prodOnlyKey1", | ||
"value": "prodOnlyValue1", | ||
"sourceSet": "prod" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<string name="app_name">CSV-DBG</string> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include "../../main/cpp/common/secrets_util.cpp" | ||
|
||
extern "C" | ||
JNIEXPORT jstring JNICALL | ||
Java_com_commencis_secretsvaultplugin_sampleapp_Secrets_a0( | ||
JNIEnv* pEnv, | ||
jobject pThis) { | ||
char obfuscatedSecret[] = { 0x5a, 0xd, 0x8, 0x9, 0x56, 0xd, 0x7e, 0x59, 0x51, 0x4f, 0xd, 0x14, 0x66, 0x7, 0xf, 0x16, 0x3, 0x0, 0x73, 0x0, 0x44 }; | ||
return getOriginalKey(obfuscatedSecret, sizeof(obfuscatedSecret), pEnv); | ||
} | ||
|
||
extern "C" | ||
JNIEXPORT jstring JNICALL | ||
Java_com_commencis_secretsvaultplugin_sampleapp_Secrets_a1( | ||
JNIEnv* pEnv, | ||
jobject pThis) { | ||
char obfuscatedSecret[] = { 0x5d, 0x7, 0x13, 0x2b, 0x57, 0xf, 0x41, 0x63, 0x51, 0x55, 0x17, 0x3, 0x1 }; | ||
return getOriginalKey(obfuscatedSecret, sizeof(obfuscatedSecret), pEnv); | ||
} |
24 changes: 24 additions & 0 deletions
24
...app/src/dev/java/com/commencis/secretsvaultplugin/sampleapp/FlavorSecretProviderJava.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.commencis.secretsvaultplugin.sampleapp; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.List; | ||
|
||
import kotlin.Pair; | ||
|
||
class FlavorSecretProviderJava implements FlavorSecretProvider { | ||
|
||
private final FlavorSecretProviderJavaHelper secretHelper = new FlavorSecretProviderJavaHelper(); | ||
|
||
@NonNull | ||
@Override | ||
public Collection<Pair<String, String>> getSecretPairs() { | ||
final List<Pair<String, String>> list = new ArrayList<>(); | ||
list.add(new Pair<>("commonFlavorKey1", secretHelper.getCommonFlavorKey1())); | ||
list.add(new Pair<>("devOnlyKey1", secretHelper.getDevOnlyKey1())); | ||
return list; | ||
} | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
...src/dev/java/com/commencis/secretsvaultplugin/sampleapp/FlavorSecretProviderJavaHelper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.commencis.secretsvaultplugin.sampleapp | ||
|
||
internal class FlavorSecretProviderJavaHelper { | ||
|
||
private val secrets = Secrets() | ||
|
||
val commonFlavorKey1: String | ||
get() = secrets.getCommonFlavorKey1() | ||
|
||
val devOnlyKey1: String | ||
get() = secrets.getDevOnlyKey1() | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
...app/src/dev/java/com/commencis/secretsvaultplugin/sampleapp/FlavorSecretProviderKotlin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.commencis.secretsvaultplugin.sampleapp | ||
|
||
internal class FlavorSecretProviderKotlin : FlavorSecretProvider { | ||
|
||
private val secrets = Secrets() | ||
|
||
override val secretPairs: Collection<Pair<String, String>> | ||
get() = listOf( | ||
"commonFlavorKey1" to secrets.getCommonFlavorKey1(), | ||
"devOnlyKey1" to secrets.getDevOnlyKey1(), | ||
) | ||
|
||
} |
16 changes: 16 additions & 0 deletions
16
sampleapp/src/dev/java/com/commencis/secretsvaultplugin/sampleapp/Secrets.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.commencis.secretsvaultplugin.sampleapp | ||
|
||
class Secrets { | ||
|
||
@JvmName("a0") | ||
external fun getCommonFlavorKey1(): String | ||
|
||
@JvmName("a1") | ||
external fun getDevOnlyKey1(): String | ||
|
||
companion object { | ||
init { | ||
System.loadLibrary("secrets") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:supportsRtl="true"> | ||
|
||
<activity | ||
android:name="com.commencis.secretsvaultplugin.sampleapp.MainActivity" | ||
android:exported="true"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
|
||
</application> | ||
|
||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Sets the minimum version of CMake required to build your native library. | ||
# This ensures that a certain set of CMake features is available to | ||
# your build. | ||
cmake_minimum_required(VERSION 3.17) | ||
project(sampleapp) | ||
|
||
# Specifies a library name, specifies whether the library is STATIC or | ||
# SHARED, and provides relative paths to the source code. You can | ||
# define multiple libraries by adding multiple add_library() commands, | ||
# and CMake builds them for you. When you build your app, Gradle | ||
# automatically packages shared libraries with your APK. | ||
add_library( | ||
mainsecrets | ||
SHARED | ||
secrets.cpp | ||
) | ||
if (sourceSet STREQUAL "dev") | ||
add_library( | ||
secrets | ||
SHARED | ||
../../dev/cpp/secrets.cpp | ||
) | ||
elseif (sourceSet STREQUAL "prod") | ||
add_library( | ||
secrets | ||
SHARED | ||
../../prod/cpp/secrets.cpp | ||
) | ||
endif() |
Oops, something went wrong.