Added script to generate private key. Modified source header view to show signature status.

This commit is contained in:
Koen 2023-09-28 16:21:29 +02:00
parent c8ab7f7d42
commit f19b7fa584
3 changed files with 46 additions and 0 deletions

View file

@ -23,6 +23,7 @@ class SourceHeaderView : LinearLayout {
private val _sourceVersion: TextView;
private val _sourceRepositoryUrl: TextView;
private val _sourceScriptUrl: TextView;
private val _sourceSignature: TextView;
private var _config : SourcePluginConfig? = null;
@ -38,6 +39,7 @@ class SourceHeaderView : LinearLayout {
_sourceVersion = findViewById(R.id.source_version);
_sourceRepositoryUrl = findViewById(R.id.source_repo);
_sourceScriptUrl = findViewById(R.id.source_script);
_sourceSignature = findViewById(R.id.source_signature);
_sourceBy.setOnClickListener {
if(!_config?.authorUrl.isNullOrEmpty())
@ -76,6 +78,20 @@ class SourceHeaderView : LinearLayout {
_sourceBy.setTextColor(resources.getColor(R.color.colorPrimary));
else
_sourceBy.setTextColor(Color.WHITE);
if (!config.scriptPublicKey.isNullOrEmpty() && !config.scriptSignature.isNullOrEmpty()) {
val script = StatePlugins.instance.getScript(config.id);
if (script != null && config.validate(script)) {
_sourceSignature.setTextColor(Color.rgb(0, 255, 0));
_sourceSignature.text = "Signature is valid";
} else {
_sourceSignature.setTextColor(Color.rgb(255, 0, 0));
_sourceSignature.text = "Signature is invalid";
}
} else {
_sourceSignature.setTextColor(Color.rgb(255, 0, 0));
_sourceSignature.text = "No signature available";
}
}
fun clear() {

View file

@ -144,4 +144,27 @@
android:fontFamily="@font/inter_extra_light"
android:text="https://some.repository.url/whatever/someScript.js" />
</LinearLayout>
<!--Script Url-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="14dp"
android:textColor="@color/white"
android:layout_marginTop="10dp"
android:fontFamily="@font/inter_light"
android:text="Signature" />
<TextView
android:id="@+id/source_signature"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="14dp"
android:textColor="@color/colorPrimary"
android:fontFamily="@font/inter_extra_light"
android:text="Valid" />
</LinearLayout>
</LinearLayout>

7
scripts/generate-pivate-key.sh Executable file
View file

@ -0,0 +1,7 @@
#!/bin/sh
PRIVATE_KEY=$(openssl genpkey -algorithm RSA -outform PEM)
PUBLIC_KEY=$(echo "$PRIVATE_KEY" | openssl rsa -pubout -outform PEM)
echo -en "\nPrivate key:\n$PRIVATE_KEY\n"
echo -en "\nPrivate key (base64):\n$(echo "$PRIVATE_KEY" | base64 -w 0)\n"
echo -en "\nPublic key:\n$PUBLIC_KEY\n"
echo -en "\nPublic key (base64):\n$(echo "$PUBLIC_KEY" | base64 -w 0)\n"