Skip to content

Commit

Permalink
Launcher: Main jar file hash check
Browse files Browse the repository at this point in the history
  • Loading branch information
A-Herzog committed Sep 28, 2023
1 parent 6a25650 commit bf8c5e5
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Simulator/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
target/
language/gettext/
language/sed/
build/Checksum_SimSystem.nsi
build/Checksum_SimTools.nsi
build/Checksum_MiniCallcenterSimulator.nsi
MiniCallcenterSimulator.cfg
5 changes: 5 additions & 0 deletions Simulator/LICENSE_COMPONENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ This file lists the third-party components used by "Simulator" project and their
- License URL: https://www.zlib.net/zlib_license.html
- Homepage: https://nsis.sourceforge.io/UAC_plug-in

### Crypto plug-in

- License: Freeware
- Homepage: https://nsis.sourceforge.io/Crypto_plug-in

## Full license texts of all used licenses

### BSD 2-Clause "Simplified" License
Expand Down
1 change: 1 addition & 0 deletions Simulator/build/Checksum_MiniCallcenterSimulator_sed.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
s/^\(.*\)$/!define CHECKSUM_SIMULATOR "\1"/p
1 change: 1 addition & 0 deletions Simulator/build/Checksum_SimSystem_sed.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
s/^\(.*\)$/!define CHECKSUM_SIMSYSTEM "\1"/p
1 change: 1 addition & 0 deletions Simulator/build/Checksum_SimTools_sed.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
s/^\(.*\)$/!define CHECKSUM_SIMTOOLS "\1"/p
37 changes: 37 additions & 0 deletions Simulator/build/Launcher.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
!define Copyright "Alexander Herzog"

!include Version.nsi
!include Checksum_SimSystem.nsi
!include Checksum_SimTools.nsi
!include Checksum_MiniCallcenterSimulator.nsi

!addplugindir ".\NSIS_Plugins"
!addincludedir ".\NSIS_Plugins"
!include LogicLib.nsh

VIProductVersion "${VERSION}.100"
VIAddVersionKey "ProductName" "${PrgName}"
Expand Down Expand Up @@ -31,6 +38,36 @@ Section ""
Call GetParameters
Pop $R1

ClearErrors
Crypto::HashFile "SHA2" "MiniCallcenterSimulator.jar"
Pop $0
${IfNot} ${Errors}
${IfNot} $0 == ${CHECKSUM_SIMULATOR}
MessageBox MB_OK "MiniCallcenterSimulator.jar checksum error"
Goto MainEnd
${EndIf}
${EndIf}

ClearErrors
Crypto::HashFile "SHA2" ".\libs\SimSystem.jar"
Pop $0
${IfNot} ${Errors}
${IfNot} $0 == ${CHECKSUM_SIMSYSTEM}
MessageBox MB_OK "SimSystem.jar checksum error"
Goto MainEnd
${EndIf}
${EndIf}

ClearErrors
Crypto::HashFile "SHA2" ".\libs\SimTools.jar"
Pop $0
${IfNot} ${Errors}
${IfNot} $0 == ${CHECKSUM_SIMTOOLS}
MessageBox MB_OK "SimTools.jar checksum error"
Goto MainEnd
${EndIf}
${EndIf}

DetailPrint "Start..."

Call GetJRE
Expand Down
Binary file added Simulator/build/NSIS_Plugins/Crypto.dll
Binary file not shown.
2 changes: 2 additions & 0 deletions Simulator/build/Setup.nsi
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
; Include used librarys
; ============================================================

Unicode false

!addplugindir ".\NSIS_Plugins"
!addincludedir ".\NSIS_Plugins"
!include nsDialogs.nsh
Expand Down
17 changes: 17 additions & 0 deletions Simulator/build/ant-build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,23 @@
</and>
</condition>

<echo message="Set MiniCallcenterSimulator.jar checksum in wrapper scripts" />
<checksum file="${Release.location}/MiniCallcenterSimulator.jar" algorithm="SHA-256" />
<exec dir="${BuildTools.location}" executable="${sed.location}/sed.exe" output="${BuildTools.location}/Checksum_MiniCallcenterSimulator.nsi">
<arg line="-nf &quot;${BuildTools.location}/Checksum_MiniCallcenterSimulator_sed.txt&quot; &quot;${Release.location}/MiniCallcenterSimulator.jar.SHA-256&quot;" />
</exec>
<delete file="${Release.location}/MiniCallcenterSimulator.jar.SHA-256" />
<checksum file="${Release.location}/libs/simsystem.jar" algorithm="SHA-256" />
<exec dir="${BuildTools.location}" executable="${sed.location}/sed.exe" output="${BuildTools.location}/Checksum_SimSystem.nsi">
<arg line="-nf &quot;${BuildTools.location}/Checksum_SimSystem_sed.txt&quot; &quot;${Release.location}/libs/simsystem.jar.SHA-256&quot;" />
</exec>
<delete file="${Release.location}/libs/simsystem.jar.SHA-256" />
<checksum file="${Release.location}/libs/simtools.jar" algorithm="SHA-256" />
<exec dir="${BuildTools.location}" executable="${sed.location}/sed.exe" output="${BuildTools.location}/Checksum_SimTools.nsi">
<arg line="-nf &quot;${BuildTools.location}/Checksum_SimTools_sed.txt&quot; &quot;${Release.location}/libs/simtools.jar.SHA-256&quot;" />
</exec>
<delete file="${Release.location}/libs/simtools.jar.SHA-256" />

<echo message="Generate exe wrapper" />
<exec executable="${NSIS.location}\makensis.exe" dir="${BuildTools.location}" if:set="NSIS.present">
<arg value="Launcher.nsi" />
Expand Down

0 comments on commit bf8c5e5

Please sign in to comment.