Git Product home page Git Product logo

Comments (7)

nodh avatar nodh commented on August 12, 2024

The examples in the Readme have been updated to reflect the current state of the library, as seen in commit 4d9062b. So for using release 1.3.2, please have a look at https://github.com/ehn-dcc-development/hcert-kotlin/tree/1.3.2

To use it locally, run ./gradlew clean publishToMavenLocal, this will create the artifact ehn.techiop.hcert:hcert-kotlin-jvm:1.4.0-SNAPSHOT (among others).
Usage of that artifact in an Java/Gradle project with implementation 'ehn.techiop.hcert:hcert-kotlin-jvm:1.4.0-SNAPSHOT' and the verification example from the Readme works for me. What error are you getting exactly?

from hcert-kotlin.

nodh avatar nodh commented on August 12, 2024
package at.example;

import ehn.techiop.hcert.kotlin.chain.CertificateRepository;
import ehn.techiop.hcert.kotlin.chain.Chain;
import ehn.techiop.hcert.kotlin.chain.DecodeResult;
import ehn.techiop.hcert.kotlin.chain.DefaultChain;
import ehn.techiop.hcert.kotlin.chain.Error;
import ehn.techiop.hcert.kotlin.chain.VerificationResult;
import ehn.techiop.hcert.kotlin.chain.impl.PrefilledCertificateRepository;
import ehn.techiop.hcert.kotlin.data.GreenCertificate;

public class Client {

    public static void main(String[] args) throws Exception {
        // Load the certificate from somewhere ...
        String certificatePem = "-----BEGIN CERTIFICATE-----\n" +
                "MIIBvTCCAWOgAwIBAgIKAXk8i88OleLsuTAKBggqhkjOPQQDAjA2MRYwFAYDVQQD\n" +
                "DA1BVCBER0MgQ1NDQSAxMQswCQYDVQQGEwJBVDEPMA0GA1UECgwGQk1TR1BLMB4X\n" +
                "DTIxMDUwNTEyNDEwNloXDTIzMDUwNTEyNDEwNlowPTERMA8GA1UEAwwIQVQgRFND\n" +
                "IDExCzAJBgNVBAYTAkFUMQ8wDQYDVQQKDAZCTVNHUEsxCjAIBgNVBAUTATEwWTAT\n" +
                "BgcqhkjOPQIBBggqhkjOPQMBBwNCAASt1Vz1rRuW1HqObUE9MDe7RzIk1gq4XW5G\n" +
                "TyHuHTj5cFEn2Rge37+hINfCZZcozpwQKdyaporPUP1TE7UWl0F3o1IwUDAOBgNV\n" +
                "HQ8BAf8EBAMCB4AwHQYDVR0OBBYEFO49y1ISb6cvXshLcp8UUp9VoGLQMB8GA1Ud\n" +
                "IwQYMBaAFP7JKEOflGEvef2iMdtopsetwGGeMAoGCCqGSM49BAMCA0gAMEUCIQDG\n" +
                "2opotWG8tJXN84ZZqT6wUBz9KF8D+z9NukYvnUEQ3QIgdBLFSTSiDt0UJaDF6St2\n" +
                "bkUQuVHW6fQbONd731/M4nc=\n" +
                "-----END CERTIFICATE-----";
        CertificateRepository repository = new PrefilledCertificateRepository(certificatePem);
        Chain chain = DefaultChain.buildVerificationChain(repository);

        // Scan the QR code from somewhere ...
        String input = "HC1:NCFRW2EM75VOP10%EHADEW09S7JL5AH/L317E5V3D1R1R6 M*WL194XC9ZOJ%ILVLB+YMS-97RI2J7ZE7%TT TJ5EN3:8RY8L OU42DHNF-0+ SAV3*BTUTRDYJMKKJ%Q+4GQPV+%FOHF.R85 92BH:BTKKIV$AW 0O$T5JJBC0WTA*3EC:JJVOUSG.WJ/ MNOTP30$54LB0*41O52MR4R/AU33PZPL0K**4MFDQ$9M646O1MAH5OU.T4-5AR9TYDDIUOPEKI12*WNQ+6QHM.XNUMNRJO4-7+J6NMIZ13UMHF9K*F7: TBB7HD1000IXS9P3R1BW8BKCOWT1$CILA22:S:AHNMR3T0ITO%12M*H882-DPX$L3JCF1MCNHZDTEBW7V3MS3G$R3HF94K4 UJTJM1V:7B6%BA0I98PB BH977B9D2M10JJO45DF6ZHVCLA/9 MK C5GDCQC9LV4.L3%VS+P4KB40MUZ$6X1L7QOUJFJ%5G.J 4MY-TPW3SDVJG1SETG$VVZA%1GK+CU/N-1V%5NWNKA4W3RPRQNP-H8XRYLCMFVDCT*YVWDL2*QLYUM7WHYVRHL:4WJUA4DH";

        DecodeResult result = chain.decode(input);
        // Read metaInformation like expirationTime, issuedAt, issuer
        VerificationResult verificationResult = result.getVerificationResult();
        boolean isValid = verificationResult.getError() == null;
        // See list below for possible Errors, may be null
        Error error = verificationResult.getError();
        // Result data may be null
        GreenCertificate greenCertificate = result.getChainDecodeResult().getEudgc();

        System.out.println(isValid);
        System.out.println(error);
        System.out.println(greenCertificate);
    }
}

from hcert-kotlin.

Jopasa avatar Jopasa commented on August 12, 2024

@nodh Thank you for your fast response.

regarding gradle after some troubleshooting I could successfully execute the build using the provided command

After some troubleshooting and debugging, I found that the setup works in a simple maven environment, but open switching to spring boot fails. But it only fails when using spring boot maven parent.

That means when using

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.3.8.RELEASE</version>
    </parent>

and calling the sample code in a simple RestController it fails with

Exception in thread "main" java.lang.NoSuchMethodError: 'long kotlin.time.Duration$Companion.hours-UwyO8pc(int)'
	at ehn.techiop.hcert.kotlin.chain.impl.DefaultCwtService.<init>(DefaultCwtService.kt:21)
	at ehn.techiop.hcert.kotlin.chain.DefaultChain.buildVerificationChain(DefaultChain.kt:34)
	at ehn.techiop.hcert.kotlin.chain.DefaultChain.buildVerificationChain$default(DefaultChain.kt:30)
	at ehn.techiop.hcert.kotlin.chain.DefaultChain.buildVerificationChain(DefaultChain.kt)
	at at.example.Client.main(Client.java:29)

But when not using spring boot maven parent (iE all versions of needed components explicitly), there is no error. Additionally, I tested both java 11 and 8 compatibility and both java versions work / don't work equally.

This means this is probably due to some spring boot maven magic, but not related to this project.

from hcert-kotlin.

nodh avatar nodh commented on August 12, 2024

Maybe upgrading to the latest Spring Boot version 2.5.3 helps?

from hcert-kotlin.

Jopasa avatar Jopasa commented on August 12, 2024

The examples in the Readme have been updated to reflect the current state of the library, as seen in commit 4d9062b. So for using release 1.3.2, please have a look at https://github.com/ehn-dcc-development/hcert-kotlin/tree/1.3.2

To use it locally, run ./gradlew clean publishToMavenLocal, this will create the artifact ehn.techiop.hcert:hcert-kotlin-jvm:1.4.0-SNAPSHOT (among others). Usage of that artifact in an Java/Gradle project with implementation 'ehn.techiop.hcert:hcert-kotlin-jvm:1.4.0-SNAPSHOT' and the verification example from the Readme works for me. What error are you getting exactly?

both versions of the README.md (1.3.2 and the mentioned commit) include the same call

Chain chain = DefaultChain.buildVerificationChain(repository);

from hcert-kotlin.

Jopasa avatar Jopasa commented on August 12, 2024

Maybe upgrading to the latest Spring Boot version 2.5.3 helps?

I am not sure why, but it helped in fact, after upgrading to spring boot version 2.5.3 it works . . .

from hcert-kotlin.

Jopasa avatar Jopasa commented on August 12, 2024

thank you for your help, both README.md versions don't work with 1.3.2 for me, but my problem is resolved using a the new 1.4.0-SNAPSHOT version and looking forward to your next release

from hcert-kotlin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.