Skip to content

Commit 8a28362

Browse files
authored
Add callback to ask online validation confirmation (#566)
IB-7865 Signed-off-by: Raul Metsma <[email protected]>
1 parent 14e2f1f commit 8a28362

25 files changed

+153
-101
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ jobs:
105105
container: ${{ matrix.container }}
106106
strategy:
107107
matrix:
108-
container: ['ubuntu:20.04', 'ubuntu:22.04', 'ubuntu:23.04', 'ubuntu:23.10']
108+
container: ['ubuntu:20.04', 'ubuntu:22.04', 'ubuntu:23.10']
109109
env:
110110
DEBIAN_FRONTEND: noninteractive
111111
DEBFULLNAME: github-actions

examples/DigiDocCSharp/DigiDocCSharp.csproj

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,34 @@
22
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup>
44
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5-
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
6-
<ProductVersion>8.0.30703</ProductVersion>
7-
<SchemaVersion>2.0</SchemaVersion>
5+
<Platform Condition=" '$(Platform)' == '' ">x64</Platform>
86
<ProjectGuid>{DDEE2029-EA2A-49D2-80CB-F0E2E396B005}</ProjectGuid>
97
<OutputType>Exe</OutputType>
108
<AppDesignerFolder>Properties</AppDesignerFolder>
119
<RootNamespace>DigiDocCSharp</RootNamespace>
1210
<AssemblyName>DigiDocCSharp</AssemblyName>
13-
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
14-
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
11+
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
1512
<FileAlignment>512</FileAlignment>
1613
</PropertyGroup>
17-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
18-
<PlatformTarget>x86</PlatformTarget>
14+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
15+
<PlatformTarget>AnyCPU</PlatformTarget>
1916
<DebugSymbols>true</DebugSymbols>
2017
<DebugType>full</DebugType>
21-
<Optimize>false</Optimize>
2218
<OutputPath>bin\Debug\</OutputPath>
2319
<DefineConstants>DEBUG;TRACE</DefineConstants>
2420
<ErrorReport>prompt</ErrorReport>
25-
<WarningLevel>4</WarningLevel>
2621
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
22+
<Prefer32Bit>false</Prefer32Bit>
2723
</PropertyGroup>
28-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
29-
<PlatformTarget>x86</PlatformTarget>
24+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
25+
<PlatformTarget>AnyCPU</PlatformTarget>
3026
<DebugType>pdbonly</DebugType>
3127
<Optimize>true</Optimize>
3228
<OutputPath>bin\Release\</OutputPath>
3329
<DefineConstants>TRACE</DefineConstants>
3430
<ErrorReport>prompt</ErrorReport>
35-
<WarningLevel>4</WarningLevel>
3631
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
32+
<Prefer32Bit>false</Prefer32Bit>
3733
</PropertyGroup>
3834
<PropertyGroup Condition=" '$(OS)' == 'Windows_NT' ">
3935
<DefineConstants>_WINDOWS</DefineConstants>
Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
11

2-
Microsoft Visual Studio Solution File, Format Version 11.00
3-
# Visual C# Express 2010
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.7.34009.444
5+
MinimumVisualStudioVersion = 10.0.40219.1
46
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DigiDocCSharp", "DigiDocCSharp.csproj", "{DDEE2029-EA2A-49D2-80CB-F0E2E396B005}"
57
EndProject
68
Global
79
GlobalSection(SolutionConfigurationPlatforms) = preSolution
8-
Debug|x86 = Debug|x86
9-
Release|x86 = Release|x86
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
1012
EndGlobalSection
1113
GlobalSection(ProjectConfigurationPlatforms) = postSolution
12-
{DDEE2029-EA2A-49D2-80CB-F0E2E396B005}.Debug|x86.ActiveCfg = Debug|x86
13-
{DDEE2029-EA2A-49D2-80CB-F0E2E396B005}.Debug|x86.Build.0 = Debug|x86
14-
{DDEE2029-EA2A-49D2-80CB-F0E2E396B005}.Release|x86.ActiveCfg = Release|x86
15-
{DDEE2029-EA2A-49D2-80CB-F0E2E396B005}.Release|x86.Build.0 = Release|x86
14+
{DDEE2029-EA2A-49D2-80CB-F0E2E396B005}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{DDEE2029-EA2A-49D2-80CB-F0E2E396B005}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{DDEE2029-EA2A-49D2-80CB-F0E2E396B005}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{DDEE2029-EA2A-49D2-80CB-F0E2E396B005}.Release|Any CPU.Build.0 = Release|Any CPU
1618
EndGlobalSection
1719
GlobalSection(SolutionProperties) = preSolution
1820
HideSolutionNode = FALSE
1921
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {7D43E58D-0FD9-4023-A18F-D69EE6A229E1}
24+
EndGlobalSection
2025
EndGlobal

examples/DigiDocCSharp/Program.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,10 @@ private static void Sign(string[] args)
124124
b.addDataFile(args[i], "application/octet-stream");
125125
}
126126
#if _WINDOWS
127-
using (WinSigner signer = new WinSigner())
127+
using (var signer = new WinSigner())
128128
{
129129
#else
130-
using (PKCS11Signer signer = new PKCS11Signer())
130+
using (var signer = new PKCS11Signer())
131131
{
132132
signer.setPin(args[1]);
133133
#endif
@@ -184,7 +184,8 @@ private static void Verify(string file)
184184
try
185185
{
186186
Console.WriteLine("Opening file: " + file);
187-
Container b = Container.open(file);
187+
var cb = new ContainerOpen();
188+
Container b = Container.open(file, cb);
188189

189190
Console.WriteLine("Files:");
190191
foreach (DataFile d in b.dataFiles())
@@ -226,4 +227,9 @@ private static void Version()
226227
" libdigidocpp " + digidoc.digidoc.version());
227228
}
228229
}
230+
231+
class ContainerOpen : ContainerOpenCB
232+
{
233+
override public bool validateOnline() { return true; }
234+
}
229235
}

examples/java/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66

77
## Run
88

9-
java -Djava.library.path=/Library/libdigidocpp/lib -jar build/libs/libdigidoc.jar
9+
java -Djava.library.path=/some/path/lib -jar build/libs/libdigidoc.jar
2.06 KB
Binary file not shown.
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
44
networkTimeout=10000
5+
validateDistributionUrl=true
56
zipStoreBase=GRADLE_USER_HOME
67
zipStorePath=wrapper/dists

examples/java/gradlew

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,8 @@ done
8383
# This is normally unused
8484
# shellcheck disable=SC2034
8585
APP_BASE_NAME=${0##*/}
86-
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
87-
88-
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
89-
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
86+
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
87+
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
9088

9189
# Use the maximum available, or set MAX_FD != -1 to use that value.
9290
MAX_FD=maximum
@@ -133,10 +131,13 @@ location of your Java installation."
133131
fi
134132
else
135133
JAVACMD=java
136-
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
134+
if ! command -v java >/dev/null 2>&1
135+
then
136+
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
137137
138138
Please set the JAVA_HOME variable in your environment to match the
139139
location of your Java installation."
140+
fi
140141
fi
141142

142143
# Increase the maximum file descriptors if we can.
@@ -197,6 +198,10 @@ if "$cygwin" || "$msys" ; then
197198
done
198199
fi
199200

201+
202+
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
203+
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
204+
200205
# Collect all arguments for the java command;
201206
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
202207
# shell script including quotes and variable substitutions, so put them in

examples/java/src/main/java/ee/ria/libdigidocpp/libdigidocpp.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ static void verify(String file) {
133133
try
134134
{
135135
System.out.println("Opening file: " + file);
136-
Container b = Container.open(file);
136+
ContainerOpen cb = new ContainerOpen();
137+
Container b = Container.open(file, cb);
137138
assert b != null;
138139

139140
System.out.println("Files:");
@@ -200,4 +201,10 @@ static byte[] fromHex(String s) {
200201
}
201202
return data;
202203
}
204+
205+
static private class ContainerOpen extends ContainerOpenCB
206+
{
207+
@Override
208+
public boolean validateOnline() { return true; }
209+
}
203210
}

examples/python/main.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
import sys
33
import os
44

5+
class ContainerOpenCB(digidoc.ContainerOpenCB):
6+
7+
def __init__(self):
8+
digidoc.ContainerOpenCB.__init__(self)
9+
10+
def validateOnline(self):
11+
return True
512

613
class Program:
714
digidoc.initialize()
@@ -78,7 +85,8 @@ def sign(self, args):
7885

7986
def verify(self, file):
8087
print("Opening file: " + file)
81-
doc = digidoc.Container.open(file)
88+
cb = ContainerOpenCB()
89+
doc = digidoc.Container.open(file, cb)
8290

8391
print("Files:")
8492
for d in doc.dataFiles():

0 commit comments

Comments
 (0)