├── .editorconfig ├── .github ├── ISSUE_TEMPLATE │ ├── 01_bug.md │ ├── 02_feature_request.md │ ├── 03_enhancement.md │ └── 04_question.md └── workflows │ ├── ci-dependency-check.yml │ ├── ci-deploy.yml │ ├── ci-main.yml │ ├── ci-openapi.yml │ ├── ci-pull-request.yml │ ├── ci-release-notes.yml │ ├── ci-release.yml │ └── ci-sonar.yml ├── .gitignore ├── .grenrc.js ├── .ort.yml ├── CODEOWNERS ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── Dockerfile ├── LICENSE ├── NOTICE ├── README.md ├── THIRD-PARTY-NOTICES ├── certs └── PlaceYourGatewayAccessKeysHere.md ├── codestyle └── checkstyle.xml ├── docker-compose.yml ├── docs ├── dgca-verifier-service.md └── dgca_overview.png ├── owasp └── suppressions.xml ├── pom.xml ├── settings.xml ├── src ├── main │ ├── java │ │ └── eu │ │ │ └── europa │ │ │ └── ec │ │ │ └── dgc │ │ │ └── verifier │ │ │ ├── DgcVerifierServiceApplication.java │ │ │ ├── config │ │ │ ├── DgcConfigProperties.java │ │ │ ├── ErrorHandler.java │ │ │ ├── OpenApiConfig.java │ │ │ ├── SchedulerConfig.java │ │ │ └── ShedLockConfig.java │ │ │ ├── dto │ │ │ └── TrustedIssuerDto.java │ │ │ ├── entity │ │ │ ├── InfoEntity.java │ │ │ ├── ShedlockEntity.java │ │ │ ├── SignerInformationEntity.java │ │ │ └── TrustedIssuerEntity.java │ │ │ ├── exception │ │ │ └── BadRequestException.java │ │ │ ├── mapper │ │ │ └── IssuerMapper.java │ │ │ ├── repository │ │ │ ├── InfoRepository.java │ │ │ ├── SignerInformationRepository.java │ │ │ └── TrustedIssuerRepository.java │ │ │ ├── restapi │ │ │ ├── controller │ │ │ │ ├── ContextController.java │ │ │ │ ├── SignerInformationController.java │ │ │ │ └── TrustedIssuerController.java │ │ │ └── dto │ │ │ │ ├── CertificatesLookupResponseItemDto.java │ │ │ │ ├── DeltaListDto.java │ │ │ │ ├── KidDto.java │ │ │ │ └── ProblemReportDto.java │ │ │ └── service │ │ │ ├── InfoService.java │ │ │ ├── SignerCertificateDownloadService.java │ │ │ ├── SignerCertificateDownloadServiceImpl.java │ │ │ ├── SignerInformationService.java │ │ │ ├── TrustedIssuerDownloadService.java │ │ │ ├── TrustedIssuerDownloadServiceImpl.java │ │ │ └── TrustedIssuerService.java │ └── resources │ │ ├── application-cloud.yml │ │ ├── application.yml │ │ ├── db │ │ ├── changelog.xml │ │ └── changelog │ │ │ ├── alter-signer-information.xml │ │ │ ├── create-info-table.xml │ │ │ ├── create-trusted-issuer-table.xml │ │ │ └── init-tables.xml │ │ ├── logback-spring.xml │ │ └── static │ │ └── context.json └── test │ ├── java │ └── eu │ │ └── europa │ │ └── ec │ │ └── dgc │ │ └── verifier │ │ ├── OpenApiTest.java │ │ ├── restapi │ │ └── controller │ │ │ ├── ContextControllerIntegrationTest.java │ │ │ ├── ContextControllerWithEnvironmentIntegrationTest.java │ │ │ ├── SignerInformationIntegrationTest.java │ │ │ └── TrustedIssuerIntegrationTest.java │ │ ├── service │ │ ├── InfoServiceTest.java │ │ ├── SignerCertificateDownloadServiceImplTest.java │ │ ├── SignerInformationServiceTest.java │ │ └── TrustedIssuerDownloadServiceImplTest.java │ │ └── testdata │ │ ├── SignerInformationTestHelper.java │ │ └── TrustedIssuerTestHelper.java │ └── resources │ └── application.yml └── templates └── file-header.txt /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | indent_style = space 7 | indent_size = 2 8 | insert_final_newline = true 9 | 10 | [*.java] 11 | indent_size = 4 12 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/01_bug.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "\U0001F6A8 Bug" 3 | about: Did you come across a bug or unexpected behaviour differing from the docs? 4 | labels: bug 5 | --- 6 | 7 | 13 | 14 | ## Describe the bug 15 | 16 | 17 | 18 | ## Expected behaviour 19 | 20 | 21 | 22 | ## Steps to reproduce the issue 23 | 24 | 25 | 26 | 32 | 33 | ## Technical details 34 | 35 | - Host Machine OS (Windows/Linux/Mac): 36 | 37 | ## Possible Fix 38 | 39 | 40 | 41 | ## Additional context 42 | 43 | 44 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/02_feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "\U0001F381 Feature Request" 3 | about: Do you have an idea for a new feature? 4 | labels: feature request 5 | --- 6 | 7 | 13 | 14 | ## Feature description 15 | 16 | 21 | 22 | ## Problem and motivation 23 | 24 | 28 | 29 | ## Is this something you're interested in working on 30 | 31 | 32 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/03_enhancement.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "\u23F1\uFE0F Enhancement" 3 | about: Do you have an idea for an enhancement? 4 | labels: enhancement 5 | --- 6 | 7 | 13 | 14 | ## Current Implementation 15 | 16 | 17 | 18 | ## Suggested Enhancement 19 | 20 | 24 | 25 | ## Expected Benefits 26 | 27 | 31 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/04_question.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "\U00002753 Question" 3 | about: If you have questions about pieces of the code or documentation for this component, please post them here. 4 | labels: question 5 | --- 6 | 7 | 13 | 14 | ## Your Question 15 | 16 | 17 | 18 | * Source File: 19 | * Line(s): 20 | * Question: 21 | -------------------------------------------------------------------------------- /.github/workflows/ci-dependency-check.yml: -------------------------------------------------------------------------------- 1 | name: ci-dependency-check 2 | on: 3 | schedule: 4 | - cron: "0 1 * * 0" # Each Sunday at 01:00 UTC 5 | pull_request: 6 | types: 7 | - opened 8 | - synchronize 9 | - reopened 10 | jobs: 11 | build: 12 | runs-on: ubuntu-22.04 13 | steps: 14 | - uses: actions/setup-java@v2 15 | with: 16 | java-version: 17 17 | distribution: adopt 18 | - uses: actions/checkout@v2 19 | with: 20 | fetch-depth: 0 21 | - uses: actions/cache@v2 22 | with: 23 | path: | 24 | ~/.m2/repository 25 | key: ${{ runner.os }}-${{ hashFiles('**/pom.xml') }} 26 | - name: version 27 | run: |- 28 | APP_SHA=$(git rev-parse --short ${GITHUB_SHA}) 29 | APP_LATEST_REV=$(git rev-list --tags --max-count=1) 30 | APP_LATEST_TAG=$(git describe --tags ${APP_LATEST_REV} 2> /dev/null || echo 0.0.0) 31 | echo "APP_VERSION=${APP_LATEST_TAG}-${APP_SHA}" >> ${GITHUB_ENV} 32 | - name: mvn 33 | run: |- 34 | mvn dependency-check:check \ 35 | --batch-mode \ 36 | --file ./pom.xml \ 37 | --settings ./settings.xml \ 38 | --define app.packages.username="${APP_PACKAGES_USERNAME}" \ 39 | --define app.packages.password="${APP_PACKAGES_PASSWORD}" \ 40 | env: 41 | APP_PACKAGES_USERNAME: ${{ github.actor }} 42 | APP_PACKAGES_PASSWORD: ${{ secrets.GITHUB_TOKEN }} 43 | -------------------------------------------------------------------------------- /.github/workflows/ci-deploy.yml: -------------------------------------------------------------------------------- 1 | name: ci-deploy 2 | on: 3 | workflow_dispatch: 4 | inputs: 5 | version: 6 | required: true 7 | description: Version to deploy 8 | jobs: 9 | deploy: 10 | runs-on: ubuntu-22.04 11 | environment: dev 12 | env: 13 | APP_VERSION: ${{ github.event.inputs.version }} 14 | steps: 15 | - name: cf setup 16 | run: |- 17 | curl -sL "https://packages.cloudfoundry.org/stable?release=${CF_RELEASE}&version=${CF_VERSION}" | \ 18 | sudo tar -zx -C /usr/local/bin 19 | env: 20 | CF_VERSION: 7.2.0 21 | CF_RELEASE: linux64-binary 22 | - name: cf push 23 | run: |- 24 | cf api ${CF_API} 25 | cf auth 26 | cf target -o ${CF_ORG} -s ${CF_SPACE} 27 | cf push ${APP_NAME} --docker-image ${APP_IMAGE}:${APP_VERSION} --docker-username ${CF_DOCKER_USERNAME} 28 | env: 29 | APP_NAME: dgca-verifier-service-eu-test 30 | APP_IMAGE: docker.pkg.github.com/${{ github.repository }}/dgca-verifier-service 31 | CF_API: ${{ secrets.CF_API }} 32 | CF_ORG: ${{ secrets.CF_ORG }} 33 | CF_SPACE: ${{ secrets.CF_SPACE }} 34 | CF_USERNAME: ${{ secrets.CF_USERNAME }} 35 | CF_PASSWORD: ${{ secrets.CF_PASSWORD }} 36 | CF_DOCKER_USERNAME: ${{ secrets.CF_DOCKER_USERNAME }} 37 | CF_DOCKER_PASSWORD: ${{ secrets.CF_DOCKER_PASSWORD }} 38 | -------------------------------------------------------------------------------- /.github/workflows/ci-main.yml: -------------------------------------------------------------------------------- 1 | name: ci-main 2 | on: 3 | push: 4 | branches: 5 | - main 6 | jobs: 7 | build: 8 | runs-on: ubuntu-22.04 9 | steps: 10 | - uses: actions/setup-java@v2 11 | with: 12 | java-version: 17 13 | distribution: adopt 14 | - uses: actions/checkout@v2 15 | with: 16 | fetch-depth: 0 17 | - uses: actions/cache@v2 18 | with: 19 | path: | 20 | ~/.m2/repository 21 | key: ${{ runner.os }}-${{ hashFiles('**/pom.xml') }} 22 | - name: version 23 | run: |- 24 | APP_SHA=$(git rev-parse --short ${GITHUB_SHA}) 25 | APP_LATEST_REV=$(git rev-list --tags --max-count=1) 26 | APP_LATEST_TAG=$(git describe --tags ${APP_LATEST_REV} 2> /dev/null || echo 0.0.0) 27 | echo "APP_VERSION=${APP_LATEST_TAG}-${APP_SHA}" >> ${GITHUB_ENV} 28 | - name: copyContext 29 | run: |- 30 | rm ./src/main/resources/static/context.json 31 | echo '${{ secrets.CONTEXT_FILE }}' > ./src/main/resources/static/context.json 32 | - name: mvn 33 | run: |- 34 | mvn versions:set \ 35 | --batch-mode \ 36 | --file ./pom.xml \ 37 | --settings ./settings.xml \ 38 | --define newVersion="${APP_VERSION}" 39 | mvn clean verify \ 40 | --batch-mode \ 41 | --file ./pom.xml \ 42 | --settings ./settings.xml \ 43 | --define app.packages.username="${APP_PACKAGES_USERNAME}" \ 44 | --define app.packages.password="${APP_PACKAGES_PASSWORD}" 45 | env: 46 | APP_PACKAGES_USERNAME: ${{ github.actor }} 47 | APP_PACKAGES_PASSWORD: ${{ secrets.GITHUB_TOKEN }} 48 | - name: docker 49 | run: |- 50 | echo "${APP_PACKAGES_PASSWORD}" | docker login "${APP_PACKAGES_URL}" \ 51 | --username "${APP_PACKAGES_USERNAME}" \ 52 | --password-stdin 53 | docker build . \ 54 | --file ./Dockerfile \ 55 | --tag "${APP_PACKAGES_URL}:${APP_VERSION}" 56 | docker push "${APP_PACKAGES_URL}:${APP_VERSION}" 57 | env: 58 | APP_PACKAGES_URL: docker.pkg.github.com/${{ github.repository }}/dgca-verifier-service 59 | APP_PACKAGES_USERNAME: ${{ github.actor }} 60 | APP_PACKAGES_PASSWORD: ${{ secrets.GITHUB_TOKEN }} 61 | -------------------------------------------------------------------------------- /.github/workflows/ci-openapi.yml: -------------------------------------------------------------------------------- 1 | name: ci-openapi 2 | on: 3 | workflow_dispatch: 4 | release: 5 | types: 6 | - created 7 | jobs: 8 | release: 9 | runs-on: ubuntu-22.04 10 | steps: 11 | - uses: actions/setup-java@v2 12 | with: 13 | java-version: 17 14 | distribution: adopt 15 | - uses: actions/checkout@v2 16 | with: 17 | fetch-depth: 0 18 | - uses: actions/cache@v2 19 | with: 20 | path: | 21 | ~/.m2/repository 22 | key: ${{ runner.os }}-${{ hashFiles('**/pom.xml') }} 23 | - name: version 24 | run: >- 25 | APP_SHA=$(git rev-parse --short ${GITHUB_SHA}); 26 | APP_TAG=${GITHUB_REF/refs\/tags\/} 27 | APP_VERSION=${APP_TAG}; 28 | echo "APP_SHA=${APP_SHA}" >> ${GITHUB_ENV}; 29 | echo "APP_TAG=${APP_TAG}" >> ${GITHUB_ENV}; 30 | echo "APP_VERSION=${APP_VERSION}" >> ${GITHUB_ENV}; 31 | - name: mvn 32 | run: >- 33 | mvn versions:set 34 | --batch-mode 35 | --file ./pom.xml 36 | --settings ./settings.xml 37 | --define newVersion="${APP_VERSION}"; 38 | mvn clean verify 39 | --batch-mode 40 | --file ./pom.xml 41 | --settings ./settings.xml 42 | --define app.packages.username="${APP_PACKAGES_USERNAME}" 43 | --define app.packages.password="${APP_PACKAGES_PASSWORD}"; 44 | env: 45 | APP_PACKAGES_USERNAME: ${{ github.actor }} 46 | APP_PACKAGES_PASSWORD: ${{ secrets.GITHUB_TOKEN }} 47 | - name: Upload Artifact 48 | uses: actions/upload-artifact@v2 49 | with: 50 | name: openapi.json 51 | path: target/openapi.json 52 | - name: Checkout OpenApi Doc Branch 53 | uses: actions/checkout@v2 54 | with: 55 | ref: openapi-doc 56 | - name: Delete existing openapi.json 57 | run: rm -f openapi.json 58 | - name: Download openapi.json 59 | uses: actions/download-artifact@v2 60 | with: 61 | name: openapi.json 62 | - name: Commit and Push changes 63 | run: | 64 | git config user.name github-actions 65 | git config user.email github-actions@github.com 66 | git commit -a --allow-empty -m "Update OpenAPI JSON" 67 | git push 68 | -------------------------------------------------------------------------------- /.github/workflows/ci-pull-request.yml: -------------------------------------------------------------------------------- 1 | name: ci-pull-request 2 | on: 3 | pull_request: 4 | types: 5 | - opened 6 | - synchronize 7 | - reopened 8 | jobs: 9 | build: 10 | runs-on: ubuntu-22.04 11 | steps: 12 | - uses: actions/setup-java@v2 13 | with: 14 | java-version: 17 15 | distribution: adopt 16 | - uses: actions/checkout@v2 17 | with: 18 | fetch-depth: 0 19 | - uses: actions/cache@v2 20 | with: 21 | path: | 22 | ~/.m2/repository 23 | key: ${{ runner.os }}-${{ hashFiles('**/pom.xml') }} 24 | - name: mvn 25 | run: |- 26 | mvn clean package \ 27 | --batch-mode \ 28 | --file ./pom.xml \ 29 | --settings ./settings.xml \ 30 | --define app.packages.username="${APP_PACKAGES_USERNAME}" \ 31 | --define app.packages.password="${APP_PACKAGES_PASSWORD}" 32 | env: 33 | APP_PACKAGES_USERNAME: ${{ github.actor }} 34 | APP_PACKAGES_PASSWORD: ${{ secrets.GITHUB_TOKEN }} 35 | - name: docker 36 | run: |- 37 | docker build . \ 38 | --file ./Dockerfile 39 | -------------------------------------------------------------------------------- /.github/workflows/ci-release-notes.yml: -------------------------------------------------------------------------------- 1 | name: ci-release-notes 2 | on: 3 | release: 4 | types: 5 | - created 6 | jobs: 7 | release-notes: 8 | runs-on: ubuntu-22.04 9 | env: 10 | APP_VERSION: ${{ github.event.release.tag_name }} 11 | steps: 12 | - uses: actions/checkout@v2 13 | with: 14 | fetch-depth: 0 15 | - name: release-notes 16 | run: npx github-release-notes release --override --tags ${APP_VERSION} 17 | env: 18 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 19 | GREN_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 20 | -------------------------------------------------------------------------------- /.github/workflows/ci-release.yml: -------------------------------------------------------------------------------- 1 | name: ci-release 2 | on: 3 | release: 4 | types: 5 | - created 6 | jobs: 7 | build: 8 | runs-on: ubuntu-22.04 9 | env: 10 | APP_VERSION: ${{ github.event.release.tag_name }} 11 | steps: 12 | - uses: actions/setup-java@v2 13 | with: 14 | java-version: 17 15 | distribution: adopt 16 | - uses: actions/checkout@v2 17 | with: 18 | fetch-depth: 0 19 | - uses: actions/cache@v2 20 | with: 21 | path: | 22 | ~/.m2/repository 23 | key: ${{ runner.os }}-${{ hashFiles('**/pom.xml') }} 24 | - name: mvn 25 | run: |- 26 | mvn versions:set \ 27 | --batch-mode \ 28 | --file ./pom.xml \ 29 | --settings ./settings.xml \ 30 | --define newVersion="${APP_VERSION}" 31 | mvn clean deploy \ 32 | --batch-mode \ 33 | --file ./pom.xml \ 34 | --settings ./settings.xml \ 35 | --define app.packages.username="${APP_PACKAGES_USERNAME}" \ 36 | --define app.packages.password="${APP_PACKAGES_PASSWORD}" 37 | env: 38 | APP_PACKAGES_USERNAME: ${{ github.actor }} 39 | APP_PACKAGES_PASSWORD: ${{ secrets.GITHUB_TOKEN }} 40 | - name: docker 41 | run: |- 42 | echo "${APP_PACKAGES_PASSWORD}" | docker login "${APP_PACKAGES_URL}" \ 43 | --username "${APP_PACKAGES_USERNAME}" \ 44 | --password-stdin 45 | docker build . \ 46 | --file ./Dockerfile \ 47 | --tag "${APP_PACKAGES_URL}:latest" \ 48 | --tag "${APP_PACKAGES_URL}:${APP_VERSION}" 49 | docker push "${APP_PACKAGES_URL}:latest" 50 | docker push "${APP_PACKAGES_URL}:${APP_VERSION}" 51 | env: 52 | APP_PACKAGES_URL: docker.pkg.github.com/${{ github.repository }}/dgca-verifier-service 53 | APP_PACKAGES_USERNAME: ${{ github.actor }} 54 | APP_PACKAGES_PASSWORD: ${{ secrets.GITHUB_TOKEN }} 55 | - name: assets 56 | run: |- 57 | gh release upload ${APP_VERSION} \ 58 | --clobber \ 59 | ./target/openapi.json#openapi-${APP_VERSION}.json \ 60 | ./target/generated-resources/licenses.xml#licenses-${APP_VERSION}.xml 61 | env: 62 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 63 | deploy: 64 | runs-on: ubuntu-20.04 65 | environment: dev 66 | needs: 67 | - build 68 | env: 69 | APP_VERSION: ${{ github.event.release.tag_name }} 70 | steps: 71 | - name: cf setup 72 | run: |- 73 | curl -sL "https://packages.cloudfoundry.org/stable?release=${CF_RELEASE}&version=${CF_VERSION}" | \ 74 | sudo tar -zx -C /usr/local/bin 75 | env: 76 | CF_VERSION: 7.2.0 77 | CF_RELEASE: linux64-binary 78 | - name: cf push 79 | run: |- 80 | cf api ${CF_API} 81 | cf auth 82 | cf target -o ${CF_ORG} -s ${CF_SPACE} 83 | cf push ${APP_NAME} --docker-image ${APP_IMAGE}:${APP_VERSION} --docker-username ${CF_DOCKER_USERNAME} 84 | env: 85 | APP_NAME: dgca-verifier-service-eu-test 86 | APP_IMAGE: docker.pkg.github.com/${{ github.repository }}/dgca-verifier-service 87 | CF_API: ${{ secrets.CF_API }} 88 | CF_ORG: ${{ secrets.CF_ORG }} 89 | CF_SPACE: ${{ secrets.CF_SPACE }} 90 | CF_USERNAME: ${{ secrets.CF_USERNAME }} 91 | CF_PASSWORD: ${{ secrets.CF_PASSWORD }} 92 | CF_DOCKER_USERNAME: ${{ secrets.CF_DOCKER_USERNAME }} 93 | CF_DOCKER_PASSWORD: ${{ secrets.CF_DOCKER_PASSWORD }} 94 | -------------------------------------------------------------------------------- /.github/workflows/ci-sonar.yml: -------------------------------------------------------------------------------- 1 | name: ci-sonar 2 | on: 3 | workflow_dispatch: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | types: 9 | - opened 10 | - synchronize 11 | - reopened 12 | jobs: 13 | sonar: 14 | runs-on: ubuntu-22.04 15 | steps: 16 | - uses: actions/setup-java@v3 17 | with: 18 | java-version: 17 19 | distribution: adopt 20 | - uses: actions/checkout@v3 21 | with: 22 | fetch-depth: 0 23 | - uses: actions/cache@v3 24 | with: 25 | path: | 26 | ~/.m2/repository 27 | key: ${{ runner.os }}-${{ hashFiles('**/pom.xml') }} 28 | - name: mvn 29 | run: |- 30 | mvn verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar \ 31 | --batch-mode \ 32 | --file ./pom.xml \ 33 | --settings ./settings.xml \ 34 | --define app.packages.username="${APP_PACKAGES_USERNAME}" \ 35 | --define app.packages.password="${APP_PACKAGES_PASSWORD}" 36 | env: 37 | SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} 38 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 39 | APP_PACKAGES_USERNAME: ${{ github.actor }} 40 | APP_PACKAGES_PASSWORD: ${{ secrets.GITHUB_TOKEN }} 41 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/** 5 | !**/src/test/** 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | .jpb 22 | 23 | ### NetBeans ### 24 | /nbproject/ 25 | /nbbuild/ 26 | /dist/ 27 | /.nb-gradle/ 28 | build/ 29 | 30 | ### VS Code ### 31 | .vscode/ 32 | 33 | ### Others ### 34 | ~$*.docx 35 | *.b64 36 | /testdata/ 37 | *.log 38 | 39 | /keystore 40 | 41 | /tools/* 42 | !/tools/*.bat 43 | !/tools/*.sh 44 | 45 | ### MAC OS ### 46 | .DS_STORE 47 | 48 | .settings.xml 49 | pom.xml.versionsBackup 50 | -------------------------------------------------------------------------------- /.grenrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | "dataSource": "prs", 3 | "prefix": "", 4 | "onlyMilestones": false, 5 | "groupBy": { 6 | "Enhancements": [ 7 | "enhancement", 8 | "internal" 9 | ], 10 | "Bug Fixes": [ 11 | "bug" 12 | ], 13 | "Documentation": [ 14 | "documentation" 15 | ], 16 | "Others": [ 17 | "other" 18 | ] 19 | }, 20 | "changelogFilename": "CHANGELOG.md", 21 | "template": { 22 | commit: ({ message, url, author, name }) => `- [${message}](${url}) - ${author ? `@${author}` : name}`, 23 | issue: "- {{name}} [{{text}}]({{url}})", 24 | noLabel: "other", 25 | group: "\n#### {{heading}}\n", 26 | changelogTitle: "# Changelog\n\n", 27 | release: "## {{release}} ({{date}})\n{{body}}", 28 | releaseSeparator: "\n---\n\n" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /.ort.yml: -------------------------------------------------------------------------------- 1 | excludes: 2 | scopes: 3 | - pattern: "provided" 4 | reason: "PROVIDED_DEPENDENCY_OF" 5 | comment: "Packages provided at runtime by the JDK or container only." 6 | - pattern: "test" 7 | reason: "TEST_DEPENDENCY_OF" 8 | comment: "Packages for testing only." -------------------------------------------------------------------------------- /CODEOWNERS: -------------------------------------------------------------------------------- 1 | # This file provides an overview of code owners in this repository. 2 | 3 | # Each line is a file pattern followed by one or more owners. 4 | # The last matching pattern has the most precedence. 5 | # For more details, read the following article on GitHub: https://help.github.com/articles/about-codeowners/. 6 | 7 | # These are the default owners for the whole content of this repository. The default owners are automatically added as reviewers when you open a pull request, unless different owners are specified in the file. 8 | * @eu-digital-green-certificates/dgca-verifier-service-members 9 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | 2 | # Contributor Covenant Code of Conduct 3 | 4 | ## Our Pledge 5 | 6 | We as members, contributors, and leaders pledge to make participation in our 7 | community a harassment-free experience for everyone, regardless of age, body 8 | size, visible or invisible disability, ethnicity, sex characteristics, gender 9 | identity and expression, level of experience, education, socio-economic status, 10 | nationality, personal appearance, race, religion, or sexual identity 11 | and orientation. 12 | 13 | We pledge to act and interact in ways that contribute to an open, welcoming, 14 | diverse, inclusive, and healthy community. 15 | 16 | ## Our Standards 17 | 18 | Examples of behavior that contributes to a positive environment for our 19 | community include: 20 | 21 | * Demonstrating empathy and kindness toward other people 22 | * Being respectful of differing opinions, viewpoints, and experiences 23 | * Giving and gracefully accepting constructive feedback 24 | * Accepting responsibility and apologizing to those affected by our mistakes, 25 | and learning from the experience 26 | * Focusing on what is best not just for us as individuals, but for the 27 | overall community 28 | 29 | Examples of unacceptable behavior include: 30 | 31 | * The use of sexualized language or imagery, and sexual attention or 32 | advances of any kind 33 | * Trolling, insulting or derogatory comments, and personal or political attacks 34 | * Public or private harassment 35 | * Publishing others' private information, such as a physical or email 36 | address, without their explicit permission 37 | * Other conduct which could reasonably be considered inappropriate in a 38 | professional setting 39 | 40 | ## Enforcement Responsibilities 41 | 42 | Community leaders are responsible for clarifying and enforcing our standards of 43 | acceptable behavior and will take appropriate and fair corrective action in 44 | response to any behavior that they deem inappropriate, threatening, offensive, 45 | or harmful. 46 | 47 | Community leaders have the right and responsibility to remove, edit, or reject 48 | comments, commits, code, wiki edits, issues, and other contributions that are 49 | not aligned to this Code of Conduct, and will communicate reasons for moderation 50 | decisions when appropriate. 51 | 52 | ## Scope 53 | 54 | This Code of Conduct applies within all community spaces, and also applies when 55 | an individual is officially representing the community in public spaces. 56 | Examples of representing our community include using an official e-mail address, 57 | posting via an official social media account, or acting as an appointed 58 | representative at an online or offline event. 59 | 60 | ## Enforcement 61 | 62 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 63 | reported to the community leaders responsible for enforcement at 64 | [opensource@telekom.de](mailto:opensource@telekom.de). 65 | All complaints will be reviewed and investigated promptly and fairly. 66 | 67 | All community leaders are obligated to respect the privacy and security of the 68 | reporter of any incident. 69 | 70 | ## Enforcement Guidelines 71 | 72 | Community leaders will follow these Community Impact Guidelines in determining 73 | the consequences for any action they deem in violation of this Code of Conduct: 74 | 75 | ### 1. Correction 76 | 77 | **Community Impact**: Use of inappropriate language or other behavior deemed 78 | unprofessional or unwelcome in the community. 79 | 80 | **Consequence**: A private, written warning from community leaders, providing 81 | clarity around the nature of the violation and an explanation of why the 82 | behavior was inappropriate. A public apology may be requested. 83 | 84 | ### 2. Warning 85 | 86 | **Community Impact**: A violation through a single incident or series 87 | of actions. 88 | 89 | **Consequence**: A warning with consequences for continued behavior. No 90 | interaction with the people involved, including unsolicited interaction with 91 | those enforcing the Code of Conduct, for a specified period of time. This 92 | includes avoiding interactions in community spaces as well as external channels 93 | like social media. Violating these terms may lead to a temporary or 94 | permanent ban. 95 | 96 | ### 3. Temporary Ban 97 | 98 | **Community Impact**: A serious violation of community standards, including 99 | sustained inappropriate behavior. 100 | 101 | **Consequence**: A temporary ban from any sort of interaction or public 102 | communication with the community for a specified period of time. No public or 103 | private interaction with the people involved, including unsolicited interaction 104 | with those enforcing the Code of Conduct, is allowed during this period. 105 | Violating these terms may lead to a permanent ban. 106 | 107 | ### 4. Permanent Ban 108 | 109 | **Community Impact**: Demonstrating a pattern of violation of community 110 | standards, including sustained inappropriate behavior, harassment of an 111 | individual, or aggression toward or disparagement of classes of individuals. 112 | 113 | **Consequence**: A permanent ban from any sort of public interaction within 114 | the community. 115 | 116 | ## Attribution 117 | 118 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 119 | version 2.0, available at 120 | https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. 121 | 122 | Community Impact Guidelines were inspired by [Mozilla's code of conduct 123 | enforcement ladder](https://github.com/mozilla/diversity). 124 | 125 | [homepage]: https://www.contributor-covenant.org 126 | 127 | For answers to common questions about this code of conduct, see the FAQ at 128 | https://www.contributor-covenant.org/faq. Translations are available at 129 | https://www.contributor-covenant.org/translations. 130 | 131 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | ## Code of conduct 4 | 5 | All members of the project community must abide by the [Contributor Covenant, version 2.0](CODE_OF_CONDUCT.md). 6 | Only by respecting each other can we develop a productive, collaborative community. 7 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting [opensource@telekom.de](mailto:opensource@telekom.de) and/or a project maintainer. 8 | 9 | We appreciate your courtesy of avoiding political questions here. Issues which are not related to the project itself will be closed by our community managers. 10 | 11 | ## Engaging in our project 12 | 13 | We use GitHub to manage reviews of pull requests. 14 | 15 | * If you are a new contributor, see: [Steps to Contribute](#steps-to-contribute) 16 | 17 | * If you have a trivial fix or improvement, go ahead and create a pull request, addressing (with `@...`) a suitable maintainer of this repository (see [CODEOWNERS](CODEOWNERS) of the repository you want to contribute to) in the description of the pull request. 18 | 19 | * If you plan to do something more involved, please reach out to us and send an [email](mailto:opensource@telekom.de). This will avoid unnecessary work and surely give you and us a good deal of inspiration. 20 | 21 | * Relevant coding style guidelines are available in the respective sub-repositories as they are programming language-dependent. 22 | 23 | ## Steps to Contribute 24 | 25 | Should you wish to work on an issue, please claim it first by commenting on the GitHub issue that you want to work on. This is to prevent duplicated efforts from other contributors on the same issue. 26 | 27 | If you have questions about one of the issues, please comment on them, and one of the maintainers will clarify. 28 | 29 | We kindly ask you to follow the [Pull Request Checklist](#Pull-Request-Checklist) to ensure reviews can happen accordingly. 30 | 31 | ## Contributing Code 32 | 33 | You are welcome to contribute code in order to fix a bug or to implement a new feature. 34 | 35 | The following rule governs code contributions: 36 | 37 | * Contributions must be licensed under the [Apache 2.0 License](./LICENSE) 38 | * Newly created files must be opened by an instantiated version of the file 'templates/file-header.txt' 39 | * At least if you add a new file to the repository, add your name into the contributor section of the file NOTICE (please respect the preset entry structure) 40 | 41 | ## Contributing Documentation 42 | 43 | You are welcome to contribute documentation to the project. 44 | 45 | The following rule governs documentation contributions: 46 | 47 | * Contributions must be licensed under the same license as code, the [Apache 2.0 License](./LICENSE) 48 | 49 | ## Pull Request Checklist 50 | 51 | * Branch from the main branch and, if needed, rebase to the current main branch before submitting your pull request. If it doesn't merge cleanly with main you may be asked to rebase your changes. 52 | 53 | * Commits should be as small as possible while ensuring that each commit is correct independently (i.e., each commit should compile and pass tests). 54 | 55 | * Test your changes as thoroughly as possible before you commit them. Preferably, automate your test by unit/integration tests. If tested manually, provide information about the test scope in the PR description (e.g. “Test passed: Upgrade version from 0.42 to 0.42.23.”). 56 | 57 | * Create _Work In Progress [WIP]_ pull requests only if you need clarification or an explicit review before you can continue your work item. 58 | 59 | * If your patch is not getting reviewed or you need a specific person to review it, you can @-reply a reviewer asking for a review in the pull request or a comment, or you can ask for a review by contacting us via [email](mailto:opensource@telekom.de). 60 | 61 | * Post review: 62 | * If a review requires you to change your commit(s), please test the changes again. 63 | * Amend the affected commit(s) and force push onto your branch. 64 | * Set respective comments in your GitHub review to resolved. 65 | * Create a general PR comment to notify the reviewers that your amendments are ready for another round of review. 66 | 67 | ## Issues and Planning 68 | 69 | * We use GitHub issues to track bugs and enhancement requests. 70 | 71 | * Please provide as much context as possible when you open an issue. The information you provide must be comprehensive enough to reproduce that issue for the assignee. Therefore, contributors may use but aren't restricted to the issue template provided by the project maintainers. 72 | 73 | * When creating an issue, try using one of our issue templates which already contain some guidelines on which content is expected to process the issue most efficiently. If no template applies, you can of course also create an issue from scratch. 74 | 75 | * Please apply one or more applicable [labels](/../../labels) to your issue so that all community members are able to cluster the issues better. 76 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM adoptopenjdk:11-jre-hotspot 2 | COPY ./target/*.jar /app/app.jar 3 | WORKDIR /app 4 | ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar ./app.jar" ] 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2021 T-Systems International GmbH and all other contributors. 2 | 3 | This project is licensed under Apache License, Version 2.0; 4 | you may not use them except in compliance with the License. 5 | 6 | Contributors: 7 | ------------- 8 | 9 | Daniel Eder [daniel-eder], T-Mobile International Austria GmbH 10 | Andreas Scheibal [ascheibal], T-Systems International GmbH -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | EU Digital COVID Certificate Verifier Service 3 |

4 | 5 |

6 | 7 | 8 | 9 |

10 | 11 |

12 | About • 13 | Development • 14 | Documentation • 15 | Support • 16 | Contribute • 17 | Contributors • 18 | Licensing 19 |

20 | 21 | ## About 22 | 23 | This repository contains the source code of the Digital Green Certificates Verifier Service. 24 | 25 | The DGC Verifier Service is part of the national backends and caches the public keys that are distributed through the [DGCG](https://github.com/eu-digital-green-certificates/dgc-gateway). It is accessed by the DGC Verifier Apps ([Android](https://github.com/eu-digital-green-certificates/dgca-verifier-app-android), [iOS](https://github.com/eu-digital-green-certificates/dgca-verifier-app-ios)) to update the key store periodically. 26 | 27 | ## Development 28 | 29 | **Note:** The verifier service needs a connection to the gateway in order to run. There is no standalone version available. 30 | 31 | ### Prerequisites 32 | 33 | - [Open JDK 11](https://openjdk.java.net) 34 | - [Maven](https://maven.apache.org) 35 | - [Docker](https://www.docker.com) 36 | - An installation of the [DGCG](https://github.com/eu-digital-green-certificates/dgc-gateway) 37 | - Keys to access the [DGCG](https://github.com/eu-digital-green-certificates/dgc-gateway) via the 38 | [DGCG Connector](https://github.com/eu-digital-green-certificates/dgc-lib) of the [DGC-lib](https://github.com/eu-digital-green-certificates/dgc-lib) 39 | - Authenticate to [Github Packages](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-apache-maven-registry) 40 | 41 | #### Needed keys for accessing the DGC Gateway 42 |

43 | For accessing the DGC Gateway via the DGC Connector you need the following keys in place: 44 | 45 | - The public key of the used Gateway. The public key should be stored in the *tls_trust_store*. If you use one of the 46 | provided gateways, you will get the public key as .pem from DIGIT. This .pem needs to be converted into pkcs12 format: 47 | ```` 48 | openssl pkcs12 -export -in pub_tls.pem -name trust -out tls_trust_store.p12 49 | ```` 50 | - Your key pair for accessing the Gateway stored in *tls_key_store*. This needs to be generated by yourself and then whitelisted by operations team (see [onboarding manual](https://github.com/eu-digital-green-certificates/dgc-participating-countries/blob/main/gateway/OnboardingChecklist.md) of the Gateway). To use it in the verifier service this needs to be converted as well into pkcs12 format: 51 | ```` 52 | openssl pkcs12 -export -in tls.pem -inkey tls_private.pem -name 1 -out tls_key_store.p12 53 | ```` 54 | 55 | - The public key of the TrustAnchor of the Gateway. If you use one of the provided Gateways you will get it as well, at onboarding. The key should be stored in a jks file. 56 | 57 | For more information on how to generate certificates for DGC Gateway and how to run your own local one, please have a look in the documentation of the [Gateway](https://github.com/eu-digital-green-certificates/dgc-gateway). 58 | 59 | #### Authenticating in to GitHub Packages 60 | 61 | As some of the required libraries (and/or versions are pinned/available only from GitHub Packages) You need to authenticate 62 | to [GitHub Packages](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-apache-maven-registry) 63 | The following steps need to be followed 64 | 65 | - Create [PAT](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token) with scopes: 66 | - `read:packages` for downloading packages 67 | 68 | ##### GitHub Maven 69 | 70 | - Copy/Augment `~/.m2/settings.xml` with the contents of `settings.xml` present in this repository 71 | - Replace `${app.packages.username}` with your github username 72 | - Replace `${app.packages.password}` with the generated PAT 73 | 74 | ##### GitHub Docker Registry 75 | 76 | - Run `docker login docker.pkg.github.com/eu-digital-green-certificates` before running further docker commands. 77 | - Use your GitHub username as username 78 | - Use the generated PAT as password 79 | 80 | 81 | 82 | For further information about the keys and certificates needed, please refer to the documentation of the 83 | [DGCG](https://github.com/eu-digital-green-certificates/dgc-gateway) and the 84 | [DGC-lib](https://github.com/eu-digital-green-certificates/dgc-lib) 85 | 86 | ### Build 87 | 88 | Whether you cloned or downloaded the 'zipped' sources you will either find the sources in the chosen checkout-directory or get a zip file with the source code, which you can expand to a folder of your choice. 89 | 90 | In either case open a terminal pointing to the directory you put the sources in. The local build process is described afterwards depending on the way you choose. 91 | 92 | 93 | #### Build with maven 94 | Building this project is done with maven. 95 | 96 | * Check [settings.xml](settings.xml) in the root folder of this git repository as example. 97 | Copy the servers to your own `~/.m2/settings.xml` in order to connect the GitHub repositories we use in our code. Provide your GitHub username and access token (see [GitHub Help](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token)) under the variables suggested. 98 | 99 | * Run the following command from the project root folder 100 | ```shell 101 | mvn clean install 102 | ``` 103 | All required dependencies will be downloaded, the project build and the artifact stored in your local repository. 104 | #### Run with docker 105 | * Perform maven build as described above 106 | * Place the keys and certificates named [above](#access-keys) into the ***certs*** folder. 107 | * Adjust the values in the [docker-compose.yml](docker-compose.yml) file to fit the url for the gateway you use and 108 | your keys and certificates you have to access it. 109 | ```yaml 110 | - DGC_GATEWAY_CONNECTOR_ENDPOINT=https://dgc-gateway.example.com 111 | - DGC_GATEWAY_CONNECTOR_TLSTRUSTSTORE_PATH=file:/ec/prod/app/san/dgc/tls_trust_store.p12 112 | - DGC_GATEWAY_CONNECTOR_TLSTRUSTSTORE_PASSWORD=dgcg-p4ssw0rd 113 | - DGC_GATEWAY_CONNECTOR_TLSKEYSTORE_ALIAS=1 114 | - DGC_GATEWAY_CONNECTOR_TLSKEYSTORE_PATH=file:/ec/prod/app/san/dgc/tls_key_store.p12 115 | - DGC_GATEWAY_CONNECTOR_TLSKEYSTORE_PASSWORD=dgcg-p4ssw0rd 116 | - DGC_GATEWAY_CONNECTOR_TRUSTANCHOR_ALIAS=ta 117 | - DGC_GATEWAY_CONNECTOR_TRUSTANCHOR_PATH=file:/ec/prod/app/san/dgc/trust_anchor.jks 118 | - DGC_GATEWAY_CONNECTOR_TRUSTANCHOR_PASSWORD=dgcg-p4ssw0rd 119 | ``` 120 | ***Note:*** Leave the path as is and only change the file names, as the ***certs*** folder will be mapped to this folder inside the docker container. 121 | 122 | * Run the following command from the project root folder 123 | 124 | ```shell 125 | docker-compose up --build 126 | ``` 127 | 128 | After all containers have started, you will be able to reach the service on your [local machine](http://localhost:8080/api/docs) under port 8080. 129 | 130 | ## Documentation 131 | 132 | [OpenAPI Spec](https://eu-digital-green-certificates.github.io/dgca-verifier-service/) 133 | 134 | [Service description](./docs/dgca-verifier-service.md) 135 | 136 | 137 | ## Support and feedback 138 | 139 | The following channels are available for discussions, feedback, and support requests: 140 | 141 | | Type | Channel | 142 | | ------------------------ | ------------------------------------------------------ | 143 | | **Issues** | | 144 | | **Other requests** | | 145 | 146 | ## How to contribute 147 | 148 | Contribution and feedback is encouraged and always welcome. For more information about how to contribute, the project structure, as well as additional contribution information, see our [Contribution Guidelines](./CONTRIBUTING.md). By participating in this project, you agree to abide by its [Code of Conduct](./CODE_OF_CONDUCT.md) at all times. 149 | 150 | ## Contributors 151 | 152 | Our commitment to open source means that we are enabling -in fact encouraging- all interested parties to contribute and become part of its developer community. 153 | 154 | ## Licensing 155 | 156 | Copyright (C) 2021 T-Systems International GmbH and all other contributors 157 | 158 | Licensed under the **Apache License, Version 2.0** (the "License"); you may not use this file except in compliance with the License. 159 | 160 | You may obtain a copy of the License at https://www.apache.org/licenses/LICENSE-2.0. 161 | 162 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the [LICENSE](./LICENSE) for the specific language governing permissions and limitations under the License. 163 | -------------------------------------------------------------------------------- /certs/PlaceYourGatewayAccessKeysHere.md: -------------------------------------------------------------------------------- 1 | ### Note: 2 | 3 | If you want to run the verifier service via the given docker-compose file, place your keys to access the 4 | [DGCG](https://github.com/eu-digital-green-certificates/dgc-gateway) in this folder and adjust the file names 5 | in the [docker-compose.yml](../docker-compose.yml) file. 6 | 7 | Further information can be found in the [README](../README.md) 8 | -------------------------------------------------------------------------------- /codestyle/checkstyle.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 52 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 69 | 70 | 71 | 73 | 74 | 75 | 81 | 82 | 83 | 84 | 87 | 88 | 89 | 90 | 91 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 109 | 111 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 158 | 159 | 160 | 161 | 163 | 164 | 165 | 166 | 168 | 169 | 170 | 171 | 173 | 174 | 175 | 176 | 178 | 179 | 180 | 181 | 183 | 184 | 185 | 186 | 188 | 189 | 190 | 191 | 193 | 194 | 195 | 196 | 198 | 199 | 200 | 201 | 203 | 204 | 205 | 206 | 208 | 210 | 212 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 242 | 243 | 244 | 246 | 247 | 248 | 249 | 254 | 255 | 256 | 257 | 260 | 261 | 262 | 263 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 277 | 278 | 279 | 280 | 281 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 315 | 316 | 317 | 318 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | 3 | services: 4 | postgres: 5 | image: library/postgres:9.6 6 | container_name: dgc-verifier-service-postgres 7 | ports: 8 | - 5432:5432 9 | environment: 10 | POSTGRES_DB: postgres 11 | POSTGRES_USER: postgres 12 | POSTGRES_PASSWORD: postgres 13 | restart: unless-stopped 14 | networks: 15 | persistence: 16 | 17 | backend: 18 | build: . 19 | image: eu-digital-green-certificates/dgc-verifier-service 20 | container_name: dgc-verifier-service 21 | ports: 22 | - 8080:8080 23 | volumes: 24 | - ./certs:/ec/prod/app/san/dgc 25 | environment: 26 | - SERVER_PORT=8080 27 | - SPRING_PROFILES_ACTIVE=cloud 28 | - SPRING_DATASOURCE_URL=jdbc:postgresql://dgc-verifier-service-postgres:5432/postgres 29 | - SPRING_DATASOURCE_USERNAME=postgres 30 | - SPRING_DATASOURCE_PASSWORD=postgres 31 | - DGC_GATEWAY_CONNECTOR_ENDPOINT=https://dgc-gateway.example.com 32 | - DGC_GATEWAY_CONNECTOR_TLSTRUSTSTORE_PATH=file:/ec/prod/app/san/dgc/tls_trust_store.p12 33 | - DGC_GATEWAY_CONNECTOR_TLSTRUSTSTORE_PASSWORD=dgcg-p4ssw0rd 34 | - DGC_GATEWAY_CONNECTOR_TLSKEYSTORE_ALIAS=1 35 | - DGC_GATEWAY_CONNECTOR_TLSKEYSTORE_PATH=file:/ec/prod/app/san/dgc/tls_key_store.p12 36 | - DGC_GATEWAY_CONNECTOR_TLSKEYSTORE_PASSWORD=dgcg-p4ssw0rd 37 | - DGC_GATEWAY_CONNECTOR_TRUSTANCHOR_ALIAS=ta 38 | - DGC_GATEWAY_CONNECTOR_TRUSTANCHOR_PATH=file:/ec/prod/app/san/dgc/trust_anchor.jks 39 | - DGC_GATEWAY_CONNECTOR_TRUSTANCHOR_PASSWORD=dgcg-p4ssw0rd 40 | depends_on: 41 | - postgres 42 | networks: 43 | backend: 44 | persistence: 45 | 46 | networks: 47 | backend: 48 | persistence: 49 | -------------------------------------------------------------------------------- /docs/dgca-verifier-service.md: -------------------------------------------------------------------------------- 1 | # European Digital Green Certificate Applications 2 | ## DGCA-Verifier-Service 3 | 4 | ### Intention 5 | The DGCA-Verifier-Service provides a template implementation for a member state backend service for a verifier application. 6 | 7 | ### General Overview 8 | A general overview of how the different member state backends work together, can be seen in the following picture. 9 | 10 | ![DGCA overview](dgca_overview.png "DGCA Overview") 11 | 12 | As you can see in the picture, each member state backend provides the services for it's own applications (e.g. verifier, issuer and wallet). 13 | The member state synchronises the validation certificates over the [DGCGateway](https://github.com/eu-digital-green-certificates/dgc-gateway). 14 | 15 | ### Purpose and functionality of the DGCA-Verifier-Service 16 | The verifier service basically caches the public keys that are distributed through the [DGCG](https://github.com/eu-digital-green-certificates/dgc-gateway) to the member states backends. 17 | The service provides the Trust List of certificates for the verifier apps. The apps can get the list to update their key store via an api. 18 | To have an actual trust list the verifier service periodically polls the [DGCG](https://github.com/eu-digital-green-certificates/dgc-gateway) 19 | for the actual trust list. 20 | 21 | In the git repository you will find two implementations of that download functionality: 22 | 23 | - The first one ([SignerCertificateDownloadServiceImpl](../src/main/java/eu/europa/ec/dgc/verifier/service/SignerCertificateDownloadServiceImpl.java)) implements the common access two the Digital Green Certificate Gateway via the [DGC-lib](https://github.com/eu-digital-green-certificates/dgc-lib). 24 | The DGC-lib provides a download connector, which handles the download and check of the certificates from the Digital Green Certificate Gateway. 25 | 26 | 27 | - The second one ([SignerCertificateDownloadBtpServiceImpl](../src/main/java/eu/europa/ec/dgc/verifier/service/SignerCertificateDownloadBtpServiceImpl.java)) is a demo implementation to connect to the Digital Green Certificate Gateway on SAP's Business Technology Plattform. 28 | This implementation serves as a reference where you already have an endpoint to the gateway provided by your runtime environment and using the connector from the dgc-lib on top would be superfluous. In this case the endpoint is fully configured via the destination API 29 | available on BTP and the checks of the downloaded certificates must be done by the service. 30 | 31 | 32 | In both cases the downloaded keys were stored in a postgres db and revoked keys were removed from it. The keys can than be requested by the verifier apps using the api described in the next section. 33 | 34 | 35 | 36 | ### API documentation 37 | 38 | The api is described with [OpenApi v3](https://swagger.io). You can access the API documentation in your web browser, when you run the service : 39 | 40 | /swagger 41 | 42 | Which results in the following URL on your local machine: 43 | http://localhost:8080/swagger 44 | 45 | From the latest release you can see the OpenApi doc online here: [OpenAPI Spec](https://eu-digital-green-certificates.github.io/dgca-verifier-service/) 46 | 47 | It is also possible to download the OpenApi file in json format from the latest release: 48 | * [openapi.json](https://github.com/eu-digital-green-certificates/dgca-verifier-service/releases/latest/download/openapi.json) 49 | 50 | You can than put the file in the openapi viewer of your choice. ([editor.swagger.io](https://editor.swagger.io) for example) 51 | 52 | 53 | ### Further Information 54 | Further information can be found at [ec.europa.eu/health](https://ec.europa.eu/health/ehealth/covid-19_en) 55 | Especially at [Volume 4: Digital Green Certificate Applications](https://ec.europa.eu/health/sites/default/files/ehealth/docs/digital-green-certificates_v4_en.pdf) 56 | And the github repository of the [DGCG](https://github.com/eu-digital-green-certificates/dgc-gateway) 57 | -------------------------------------------------------------------------------- /docs/dgca_overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eu-digital-green-certificates/dgca-verifier-service/1db7757d0be20d5e0a48bdfe50b2c6af97b533a2/docs/dgca_overview.png -------------------------------------------------------------------------------- /owasp/suppressions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | see https://github.com/jeremylong/DependencyCheck/issues/1827> 5 | CVE-2018-1258 6 | 7 | 8 | see https://github.com/jeremylong/DependencyCheck/issues/2952 9 | CVE-2011-2732 10 | CVE-2011-2731 11 | CVE-2012-5055 12 | 13 | 14 | see https://tomcat.apache.org/security-9.html#Apache_Tomcat_9.x_vulnerabilities vulnerability is fixed in tomcat 9.0.38 15 | CVE-2020-13943 16 | 17 | 18 | 19 | 20 | da214a6f44ee5811c97f3b53a6dda31edf25ac9e 21 | CVE-2016-9878 22 | CVE-2018-1270 23 | CVE-2018-1271 24 | CVE-2018-1272 25 | CVE-2020-5421 26 | 27 | 28 | 29 | CVE-2021-22118 30 | 31 | 32 | H2 is only used for Unit Testing. Version 2.x includes major breaking changes. 33 | CVE-2021-23463 34 | CVE-2018-14335 35 | CVE-2022-45868 36 | 37 | 38 | No fix available, still analyzed 39 | CVE-2023-35116 40 | 41 | 42 | False positive, Dependency Updated but still matches for fixed version 43 | CVE-2022-45688 44 | 45 | 46 | -------------------------------------------------------------------------------- /settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | false 5 | 6 | 7 | dgc-github 8 | ${app.packages.username} 9 | ${app.packages.password} 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/java/eu/europa/ec/dgc/verifier/DgcVerifierServiceApplication.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * ---license-start 3 | * eu-digital-green-certificates / dgca-verifier-service 4 | * --- 5 | * Copyright (C) 2021 T-Systems International GmbH and all other contributors 6 | * --- 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * ---license-end 19 | */ 20 | 21 | package eu.europa.ec.dgc.verifier; 22 | 23 | import eu.europa.ec.dgc.verifier.config.DgcConfigProperties; 24 | import org.springframework.boot.SpringApplication; 25 | import org.springframework.boot.autoconfigure.SpringBootApplication; 26 | import org.springframework.boot.context.properties.EnableConfigurationProperties; 27 | import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; 28 | 29 | /** 30 | * The Application class. 31 | */ 32 | @SpringBootApplication 33 | @EnableConfigurationProperties(DgcConfigProperties.class) 34 | public class DgcVerifierServiceApplication extends SpringBootServletInitializer { 35 | 36 | /** 37 | * The main Method. 38 | * 39 | * @param args the args for the main method 40 | */ 41 | public static void main(String[] args) { 42 | SpringApplication.run(DgcVerifierServiceApplication.class, args); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/eu/europa/ec/dgc/verifier/config/DgcConfigProperties.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * ---license-start 3 | * eu-digital-green-certificates / dgca-verifier-service 4 | * --- 5 | * Copyright (C) 2021 T-Systems International GmbH and all other contributors 6 | * --- 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * ---license-end 19 | */ 20 | 21 | package eu.europa.ec.dgc.verifier.config; 22 | 23 | import lombok.Getter; 24 | import lombok.Setter; 25 | import org.springframework.boot.context.properties.ConfigurationProperties; 26 | 27 | @Getter 28 | @Setter 29 | @ConfigurationProperties("dgc") 30 | public class DgcConfigProperties { 31 | 32 | private final CertificatesDownloader certificatesDownloader = new CertificatesDownloader(); 33 | 34 | private final TrustedIssuerDownloader trustedIssuerDownloader = new TrustedIssuerDownloader(); 35 | 36 | private String context = ""; 37 | 38 | @Getter 39 | @Setter 40 | public static class CertificatesDownloader { 41 | private Integer timeInterval; 42 | private Integer lockLimit; 43 | } 44 | 45 | @Getter 46 | @Setter 47 | public static class TrustedIssuerDownloader { 48 | private boolean enabled; 49 | private Integer timeInterval; 50 | private Integer lockLimit; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/eu/europa/ec/dgc/verifier/config/ErrorHandler.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * ---license-start 3 | * eu-digital-green-certificates / dgca-verifier-service 4 | * --- 5 | * Copyright (C) 2021 T-Systems International GmbH and all other contributors 6 | * --- 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * ---license-end 19 | */ 20 | 21 | package eu.europa.ec.dgc.verifier.config; 22 | 23 | import eu.europa.ec.dgc.verifier.exception.BadRequestException; 24 | import eu.europa.ec.dgc.verifier.restapi.dto.ProblemReportDto; 25 | import lombok.RequiredArgsConstructor; 26 | import lombok.extern.slf4j.Slf4j; 27 | import org.springframework.context.annotation.Configuration; 28 | import org.springframework.http.HttpStatus; 29 | import org.springframework.http.MediaType; 30 | import org.springframework.http.ResponseEntity; 31 | import org.springframework.web.bind.annotation.ControllerAdvice; 32 | import org.springframework.web.bind.annotation.ExceptionHandler; 33 | import org.springframework.web.server.ResponseStatusException; 34 | import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; 35 | 36 | @ControllerAdvice 37 | @Configuration 38 | @RequiredArgsConstructor 39 | @Slf4j 40 | public class ErrorHandler extends ResponseEntityExceptionHandler { 41 | 42 | /** 43 | * Handles {@link BadRequestException} when a validation failed. 44 | * 45 | * @param e the thrown {@link BadRequestException} 46 | * @return A ResponseEntity with a ErrorMessage inside. 47 | */ 48 | @ExceptionHandler(BadRequestException.class) 49 | public ResponseEntity handleException(BadRequestException e) { 50 | return ResponseEntity 51 | .status(e.getStatus()) 52 | .body(e.getMessage()); 53 | } 54 | 55 | 56 | /** 57 | * Global Exception Handler to wrap exceptions into a readable JSON Object. 58 | * 59 | * @param e the thrown exception 60 | * @return ResponseEntity with readable data. 61 | */ 62 | @ExceptionHandler(Exception.class) 63 | public ResponseEntity handleException(Exception e) { 64 | if (e instanceof ResponseStatusException) { 65 | return ResponseEntity 66 | .status(((ResponseStatusException) e).getStatusCode()) 67 | .contentType(MediaType.APPLICATION_JSON) 68 | .body(new ProblemReportDto("co", "prob", "val", "det")); 69 | } else { 70 | log.error("Uncatched exception", e); 71 | return ResponseEntity 72 | .status(HttpStatus.INTERNAL_SERVER_ERROR) 73 | .contentType(MediaType.APPLICATION_JSON) 74 | .body(new ProblemReportDto("0x500", "Internal Server Error", "", "")); 75 | } 76 | } 77 | 78 | 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/eu/europa/ec/dgc/verifier/config/OpenApiConfig.java: -------------------------------------------------------------------------------- 1 | package eu.europa.ec.dgc.verifier.config; 2 | 3 | import io.swagger.v3.oas.models.OpenAPI; 4 | import io.swagger.v3.oas.models.info.Info; 5 | import io.swagger.v3.oas.models.info.License; 6 | import lombok.Generated; 7 | import lombok.RequiredArgsConstructor; 8 | import org.springframework.boot.info.BuildProperties; 9 | import org.springframework.context.annotation.Bean; 10 | import org.springframework.context.annotation.Configuration; 11 | 12 | @Generated 13 | @Configuration 14 | @RequiredArgsConstructor 15 | public class OpenApiConfig { 16 | 17 | private final BuildProperties buildProperties; 18 | 19 | /** 20 | * Configure the OpenApi bean with title and version. 21 | * 22 | * @return the OpenApi bean. 23 | */ 24 | @Bean 25 | public OpenAPI openApi() { 26 | return new OpenAPI() 27 | .info(new Info() 28 | .title("Digital Green Certificate Verifier Service") 29 | .description("The API defines how to exchange verification information for digital green certificates.") 30 | .version(buildProperties.getVersion()) 31 | .license(new License() 32 | .name("Apache 2.0") 33 | .url("https://www.apache.org/licenses/LICENSE-2.0"))); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/eu/europa/ec/dgc/verifier/config/SchedulerConfig.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * ---license-start 3 | * eu-digital-green-certificates / dgca-verifier-service 4 | * --- 5 | * Copyright (C) 2021 T-Systems International GmbH and all other contributors 6 | * --- 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * ---license-end 19 | */ 20 | 21 | package eu.europa.ec.dgc.verifier.config; 22 | 23 | import net.javacrumbs.shedlock.spring.annotation.EnableSchedulerLock; 24 | import org.springframework.context.annotation.Configuration; 25 | import org.springframework.context.annotation.Profile; 26 | import org.springframework.scheduling.annotation.EnableScheduling; 27 | 28 | @Configuration 29 | @Profile("!test") 30 | @EnableScheduling 31 | @EnableSchedulerLock(defaultLockAtMostFor = "PT30S") 32 | public class SchedulerConfig { 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/eu/europa/ec/dgc/verifier/config/ShedLockConfig.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * ---license-start 3 | * eu-digital-green-certificates / dgca-verifier-service 4 | * --- 5 | * Copyright (C) 2021 T-Systems International GmbH and all other contributors 6 | * --- 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * ---license-end 19 | */ 20 | 21 | package eu.europa.ec.dgc.verifier.config; 22 | 23 | import static net.javacrumbs.shedlock.provider.jdbctemplate.JdbcTemplateLockProvider.Configuration.builder; 24 | 25 | import javax.sql.DataSource; 26 | import net.javacrumbs.shedlock.core.LockProvider; 27 | import net.javacrumbs.shedlock.provider.jdbctemplate.JdbcTemplateLockProvider; 28 | import org.springframework.context.annotation.Bean; 29 | import org.springframework.context.annotation.Configuration; 30 | import org.springframework.jdbc.core.JdbcTemplate; 31 | 32 | @Configuration 33 | public class ShedLockConfig { 34 | 35 | /** 36 | * Creates a LockProvider for ShedLock. 37 | * 38 | * @param dataSource JPA datasource 39 | * @return LockProvider 40 | */ 41 | @Bean 42 | public LockProvider lockProvider(DataSource dataSource) { 43 | return new JdbcTemplateLockProvider(builder() 44 | .withTableName("shedlock") 45 | .withJdbcTemplate(new JdbcTemplate(dataSource)) 46 | .usingDbTime() 47 | .build() 48 | ); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/eu/europa/ec/dgc/verifier/dto/TrustedIssuerDto.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * ---license-start 3 | * WHO Digital Documentation Covid Certificate Gateway Service / ddcc-gateway 4 | * --- 5 | * Copyright (C) 2022 T-Systems International GmbH and all other contributors 6 | * --- 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * ---license-end 19 | */ 20 | 21 | package eu.europa.ec.dgc.verifier.dto; 22 | 23 | import java.time.ZonedDateTime; 24 | import lombok.AllArgsConstructor; 25 | import lombok.Data; 26 | import lombok.NoArgsConstructor; 27 | 28 | @Data 29 | @NoArgsConstructor 30 | @AllArgsConstructor 31 | public class TrustedIssuerDto { 32 | 33 | private String url; 34 | 35 | private UrlTypeDto type; 36 | 37 | private String country; 38 | 39 | private String thumbprint; 40 | 41 | private String sslPublicKey; 42 | 43 | private String keyStorageType; 44 | 45 | private String signature; 46 | 47 | private ZonedDateTime timestamp; 48 | 49 | private String name; 50 | 51 | public enum UrlTypeDto { 52 | HTTP, 53 | DID 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/eu/europa/ec/dgc/verifier/entity/InfoEntity.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * ---license-start 3 | * eu-digital-green-certificates / dgca-revocation-distribution-service 4 | * --- 5 | * Copyright (C) 2022 T-Systems International GmbH and all other contributors 6 | * --- 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * ---license-end 19 | */ 20 | 21 | package eu.europa.ec.dgc.verifier.entity; 22 | 23 | import jakarta.persistence.Column; 24 | import jakarta.persistence.Entity; 25 | import jakarta.persistence.Id; 26 | import jakarta.persistence.Table; 27 | import lombok.AllArgsConstructor; 28 | import lombok.Getter; 29 | import lombok.NoArgsConstructor; 30 | import lombok.Setter; 31 | 32 | @Getter 33 | @Setter 34 | @Entity 35 | @AllArgsConstructor 36 | @NoArgsConstructor 37 | @Table(name = "vs_info") 38 | public class InfoEntity { 39 | 40 | /** 41 | * The KID of the Key used to sign the CMS. 42 | */ 43 | @Id 44 | @Column(name = "identifier_key") 45 | private String identifierKey; 46 | 47 | /** 48 | * Type of Revocation Hashes. 49 | */ 50 | @Column(name = "property_value") 51 | private String value; 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/eu/europa/ec/dgc/verifier/entity/ShedlockEntity.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * ---license-start 3 | * eu-digital-green-certificates / dgca-verifier-service 4 | * --- 5 | * Copyright (C) 2021 T-Systems International GmbH and all other contributors 6 | * --- 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * ---license-end 19 | */ 20 | 21 | package eu.europa.ec.dgc.verifier.entity; 22 | 23 | import jakarta.persistence.Column; 24 | import jakarta.persistence.Entity; 25 | import jakarta.persistence.GeneratedValue; 26 | import jakarta.persistence.GenerationType; 27 | import jakarta.persistence.Id; 28 | import jakarta.persistence.Table; 29 | import java.util.Date; 30 | 31 | @Entity 32 | @Table(name = "shedlock") 33 | public class ShedlockEntity { 34 | 35 | @Id 36 | @GeneratedValue(strategy = GenerationType.IDENTITY) 37 | @Column(name = "id") 38 | private Long id; 39 | 40 | @Column(name = "name", length = 64, nullable = false, unique = true) 41 | private String name; 42 | 43 | @Column(name = "lock_until", nullable = false) 44 | private Date lockUntil; 45 | 46 | @Column(name = "locked_at", nullable = false) 47 | private Date lockedAt; 48 | 49 | @Column(name = "locked_by", nullable = false) 50 | private String lockedBy; 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/eu/europa/ec/dgc/verifier/entity/SignerInformationEntity.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * ---license-start 3 | * eu-digital-green-certificates / dgca-verifier-service 4 | * --- 5 | * Copyright (C) 2021 T-Systems International GmbH and all other contributors 6 | * --- 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * ---license-end 19 | */ 20 | 21 | package eu.europa.ec.dgc.verifier.entity; 22 | 23 | 24 | 25 | import jakarta.persistence.Column; 26 | import jakarta.persistence.Entity; 27 | import jakarta.persistence.GeneratedValue; 28 | import jakarta.persistence.GenerationType; 29 | import jakarta.persistence.Id; 30 | import jakarta.persistence.Table; 31 | import java.time.ZonedDateTime; 32 | import lombok.AllArgsConstructor; 33 | import lombok.Data; 34 | import lombok.Getter; 35 | import lombok.NoArgsConstructor; 36 | import lombok.Setter; 37 | 38 | @Data 39 | @Getter 40 | @Setter 41 | @Entity 42 | @Table(name = "signer_information") 43 | @AllArgsConstructor 44 | @NoArgsConstructor 45 | public class SignerInformationEntity { 46 | 47 | @Id 48 | @GeneratedValue(strategy = GenerationType.IDENTITY) 49 | @Column(name = "id") 50 | private Long id; 51 | 52 | /** 53 | * Unique Identifier of the cert. 54 | */ 55 | @Column(name = "kid", length = 50, nullable = false) 56 | private String kid; 57 | 58 | /** 59 | * Timestamp of the Record creation. 60 | */ 61 | @Column(name = "created_at", nullable = false) 62 | private ZonedDateTime createdAt = ZonedDateTime.now(); 63 | 64 | /** 65 | * Base64 encoded certificate raw data. 66 | */ 67 | @Column(name = "raw_data", nullable = false, length = 4096) 68 | String rawData; 69 | 70 | /** 71 | * The country code of the cert. 72 | */ 73 | @Column(name = "country") 74 | private String country; 75 | 76 | /** 77 | * The thumbprint of the cert. 78 | */ 79 | @Column(name = "thumbprint") 80 | private String thumbprint; 81 | 82 | /** 83 | * Timestamp of the last record update. 84 | */ 85 | @Column(name = "updated_at", nullable = false) 86 | private ZonedDateTime updatedAt = ZonedDateTime.now(); 87 | 88 | /** 89 | * Marks the record as deleted. 90 | */ 91 | @Column(name = "deleted") 92 | private boolean deleted = false; 93 | 94 | 95 | 96 | } 97 | -------------------------------------------------------------------------------- /src/main/java/eu/europa/ec/dgc/verifier/entity/TrustedIssuerEntity.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * ---license-start 3 | * eu-digital-green-certificates / dgca-verifier-service 4 | * --- 5 | * Copyright (C) 2021 T-Systems International GmbH and all other contributors 6 | * --- 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * ---license-end 19 | */ 20 | 21 | package eu.europa.ec.dgc.verifier.entity; 22 | 23 | import jakarta.persistence.Column; 24 | import jakarta.persistence.Entity; 25 | import jakarta.persistence.EnumType; 26 | import jakarta.persistence.Enumerated; 27 | import jakarta.persistence.GeneratedValue; 28 | import jakarta.persistence.GenerationType; 29 | import jakarta.persistence.Id; 30 | import jakarta.persistence.Table; 31 | import java.time.ZonedDateTime; 32 | import lombok.AllArgsConstructor; 33 | import lombok.Data; 34 | import lombok.Getter; 35 | import lombok.NoArgsConstructor; 36 | import lombok.Setter; 37 | 38 | @Data 39 | @Getter 40 | @Setter 41 | @Entity 42 | @Table(name = "trusted_issuer") 43 | @AllArgsConstructor 44 | @NoArgsConstructor 45 | public class TrustedIssuerEntity { 46 | 47 | 48 | @Id 49 | @GeneratedValue(strategy = GenerationType.IDENTITY) 50 | @Column(name = "id") 51 | private Long id; 52 | 53 | /** 54 | * The revoked hash. 55 | */ 56 | @Column(name = "etag", nullable = false, length = 36) 57 | private String etag; 58 | 59 | /** 60 | * Timestamp of the Record. 61 | */ 62 | @Column(name = "created_at", nullable = false) 63 | private ZonedDateTime createdAt = ZonedDateTime.now(); 64 | 65 | /** 66 | * ISO 3166 Alpha-2 Country Code 67 | * (plus code "EU" for administrative European Union entries). 68 | */ 69 | @Column(name = "country", nullable = false, length = 2) 70 | private String country; 71 | 72 | /** 73 | * URL of the service, can be HTTP(s) or DID URL. 74 | */ 75 | @Column(name = "url", nullable = false, length = 1024) 76 | private String url; 77 | 78 | /** 79 | * Name of the service. 80 | */ 81 | @Column(name = "name", nullable = false, length = 512) 82 | private String name; 83 | 84 | /** 85 | * Type of the URL (HTTP, DID). 86 | */ 87 | @Column(name = "url_type", nullable = false, length = 25) 88 | @Enumerated(EnumType.STRING) 89 | private UrlType urlType; 90 | 91 | /** 92 | * SHA-256 Thumbprint of the certificate (hex encoded). 93 | */ 94 | @Column(name = "thumbprint", length = 64) 95 | private String thumbprint; 96 | 97 | /** 98 | * SSL Certificate of the endpoint (if applicable). 99 | */ 100 | @Column(name = "ssl_public_key", length = 2048) 101 | private String sslPublicKey; 102 | 103 | /** 104 | * Type of Key Storage. E.g JWKS, DIDDocument etc. (If applicable) 105 | */ 106 | @Column(name = "key_storage_type", length = 128) 107 | private String keyStorageType; 108 | 109 | /** 110 | * Signature of the TrustAnchor. 111 | */ 112 | @Column(name = "signature", nullable = false, length = 6000) 113 | String signature; 114 | 115 | public enum UrlType { 116 | HTTP, 117 | DID 118 | } 119 | 120 | } 121 | -------------------------------------------------------------------------------- /src/main/java/eu/europa/ec/dgc/verifier/exception/BadRequestException.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * ---license-start 3 | * eu-digital-green-certificates / dgca-revocation-distribution-service 4 | * --- 5 | * Copyright (C) 2022 T-Systems International GmbH and all other contributors 6 | * --- 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * ---license-end 19 | */ 20 | 21 | package eu.europa.ec.dgc.verifier.exception; 22 | 23 | public class BadRequestException extends RuntimeException { 24 | public int getStatus() { 25 | return STATUS; 26 | } 27 | 28 | private static final int STATUS = 400; 29 | 30 | 31 | /** 32 | * Constructor for BadRequestException. 33 | * 34 | * @param message Massage of the exception. 35 | */ 36 | public BadRequestException(String message) { 37 | 38 | super(message); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/eu/europa/ec/dgc/verifier/mapper/IssuerMapper.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * ---license-start 3 | * WHO Digital Documentation Covid Certificate Gateway Service / ddcc-gateway-lib 4 | * --- 5 | * Copyright (C) 2022 T-Systems International GmbH and all other contributors 6 | * --- 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * ---license-end 19 | */ 20 | 21 | package eu.europa.ec.dgc.verifier.mapper; 22 | 23 | 24 | import eu.europa.ec.dgc.gateway.connector.model.TrustedIssuer; 25 | import eu.europa.ec.dgc.verifier.dto.TrustedIssuerDto; 26 | import eu.europa.ec.dgc.verifier.entity.TrustedIssuerEntity; 27 | import java.util.List; 28 | import org.mapstruct.Mapper; 29 | import org.mapstruct.Mapping; 30 | 31 | 32 | @Mapper(componentModel = "spring") 33 | public interface IssuerMapper { 34 | 35 | @Mapping(source = "type", target = "urlType") 36 | TrustedIssuerEntity trustedIssuerToTrustedIssuerEntity(TrustedIssuer trustedIssuer); 37 | 38 | 39 | List trustedIssuerToTrustedIssuerEntity(List trustedIssuer); 40 | 41 | @Mapping(source = "urlType", target = "type") 42 | @Mapping(source = "createdAt", target = "timestamp") 43 | TrustedIssuerDto trustedIssuerEntityToTrustedIssuerDto(TrustedIssuerEntity trustedIssuerEntity); 44 | 45 | @Mapping(source = "createdAt", target = "timestamp") 46 | List trustedIssuerEntityToTrustedIssuerDto(List trustedIssuerEntities); 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/eu/europa/ec/dgc/verifier/repository/InfoRepository.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * ---license-start 3 | * eu-digital-green-certificates / dgca-revocation-distribution-service 4 | * --- 5 | * Copyright (C) 2022 T-Systems International GmbH and all other contributors 6 | * --- 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * ---license-end 19 | */ 20 | 21 | package eu.europa.ec.dgc.verifier.repository; 22 | 23 | 24 | import eu.europa.ec.dgc.verifier.entity.InfoEntity; 25 | import org.springframework.data.jpa.repository.JpaRepository; 26 | 27 | public interface InfoRepository extends JpaRepository { 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/eu/europa/ec/dgc/verifier/repository/SignerInformationRepository.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * ---license-start 3 | * eu-digital-green-certificates / dgca-verifier-service 4 | * --- 5 | * Copyright (C) 2021 T-Systems International GmbH and all other contributors 6 | * --- 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * ---license-end 19 | */ 20 | 21 | package eu.europa.ec.dgc.verifier.repository; 22 | 23 | 24 | import eu.europa.ec.dgc.verifier.entity.SignerInformationEntity; 25 | import java.time.ZonedDateTime; 26 | import java.util.List; 27 | import java.util.Optional; 28 | import org.springframework.data.jpa.repository.JpaRepository; 29 | import org.springframework.data.jpa.repository.Modifying; 30 | import org.springframework.data.jpa.repository.Query; 31 | import org.springframework.data.repository.query.Param; 32 | 33 | 34 | public interface SignerInformationRepository extends JpaRepository { 35 | 36 | Optional findFirstByIdIsNotNullOrderByIdAsc(); 37 | 38 | Optional findFirstByIdGreaterThanOrderByIdAsc(Long id); 39 | 40 | List findAllByOrderByIdAsc(); 41 | 42 | @Modifying 43 | @Query("UPDATE SignerInformationEntity s SET s.deleted = true WHERE s.kid not in :kids") 44 | void setDeletedByKidsNotIn(@Param("kids") List kids); 45 | 46 | @Modifying 47 | @Query("UPDATE SignerInformationEntity s SET s.deleted = true") 48 | void setAllDeleted(); 49 | 50 | void deleteByKidNotIn(List kids); 51 | 52 | 53 | List findAllByDeletedOrderByIdAsc(boolean deleted); 54 | 55 | void deleteByKidIn(List kids); 56 | 57 | List findAllByUpdatedAtAfterOrderByIdAsc(ZonedDateTime ifModifiedDateTime); 58 | 59 | List findAllByKidIn(List kids); 60 | 61 | Optional findFirstByIdIsNotNullAndDeletedOrderByIdAsc(boolean deleted); 62 | 63 | Optional findFirstByIdGreaterThanAndDeletedOrderByIdAsc(Long resumeToken, boolean deleted); 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/eu/europa/ec/dgc/verifier/repository/TrustedIssuerRepository.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * ---license-start 3 | * eu-digital-green-certificates / dgca-revocation-distribution-service 4 | * --- 5 | * Copyright (C) 2022 T-Systems International GmbH and all other contributors 6 | * --- 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * ---license-end 19 | */ 20 | 21 | package eu.europa.ec.dgc.verifier.repository; 22 | 23 | 24 | import eu.europa.ec.dgc.verifier.entity.TrustedIssuerEntity; 25 | import java.util.List; 26 | import org.springframework.data.jpa.repository.JpaRepository; 27 | 28 | public interface TrustedIssuerRepository extends JpaRepository { 29 | 30 | void deleteAllByEtag(String etag); 31 | 32 | List findAllByEtag(String etag); 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/eu/europa/ec/dgc/verifier/restapi/controller/ContextController.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * ---license-start 3 | * eu-digital-green-certificates / dgca-verifier-service 4 | * --- 5 | * Copyright (C) 2021 T-Systems International GmbH and all other contributors 6 | * --- 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * ---license-end 19 | */ 20 | 21 | package eu.europa.ec.dgc.verifier.restapi.controller; 22 | 23 | import eu.europa.ec.dgc.verifier.config.DgcConfigProperties; 24 | import io.swagger.v3.oas.annotations.Operation; 25 | import io.swagger.v3.oas.annotations.media.Content; 26 | import io.swagger.v3.oas.annotations.media.ExampleObject; 27 | import io.swagger.v3.oas.annotations.media.Schema; 28 | import io.swagger.v3.oas.annotations.responses.ApiResponse; 29 | import java.io.IOException; 30 | import java.nio.charset.StandardCharsets; 31 | import lombok.RequiredArgsConstructor; 32 | import lombok.extern.slf4j.Slf4j; 33 | import org.apache.commons.io.IOUtils; 34 | import org.springframework.core.io.ClassPathResource; 35 | import org.springframework.core.io.Resource; 36 | import org.springframework.http.MediaType; 37 | import org.springframework.http.ResponseEntity; 38 | import org.springframework.web.bind.annotation.GetMapping; 39 | import org.springframework.web.bind.annotation.RequestMapping; 40 | import org.springframework.web.bind.annotation.RestController; 41 | 42 | @RestController 43 | @RequestMapping("/context") 44 | @Slf4j 45 | @RequiredArgsConstructor 46 | public class ContextController { 47 | 48 | private final DgcConfigProperties properties; 49 | 50 | /** 51 | * Http Method for getting the current context. 52 | */ 53 | @GetMapping(produces = MediaType.APPLICATION_JSON_VALUE) 54 | @Operation( 55 | summary = "Provide configuration information for the verifier app", 56 | tags = {"Configuration"}, 57 | responses = { 58 | @ApiResponse( 59 | responseCode = "200", 60 | description = "Returns the current context for the verifier app.", 61 | content = @Content( 62 | mediaType = MediaType.APPLICATION_JSON_VALUE, 63 | schema = @Schema(implementation = String.class), 64 | examples = {@ExampleObject(value = "{\"origin\":\"DE\",\"versions\":{\"default\":{\"privacyUrl\":" 65 | + "\"https://publications.europa.eu/en/web/about-us/legal-notices/eu-mobile-apps\"," 66 | + "\"context\":{\"url\":\"https://dgca-verifier-service.example.com/context\",\"pubKeys\":" 67 | + "[\"lKdU1EbQubxyDDm2q3N8KclZ2C94+3eI=\"," 68 | + "\"r/mIkG3eEpVdm+u/ko/cwxzOMo1bkA5E=\"]},\"endpoints\":{\"status\":{\"url\":" 69 | + "\"https://dgca-verifier-service.example.com/signercertificateStatus\",\"pubKeys\":" 70 | + "[\"lKdU1EbQubxyDDm2q3N8KclZ2C94+3eI=\"," 71 | + "\"r/mIkG3eEpVdm+u/ko/cwxzOMo1bkA5E=\"]},\"update\":{\"url\":" 72 | + "\"https://dgca-verifier-service.example.com/signercertificateUpdate\",\"pubKeys\":" 73 | + "[\"lKdU1EbQubxyDDm2q3N8KclZ2C94+3eI=\"," 74 | + "\"r/mIkG3eEpVdm+u/ko/cwxzOMo1bkA5E=\"]}}},\"0.1.0\":{\"outdated\":true}}}")})) 75 | } 76 | ) 77 | public ResponseEntity getContext() { 78 | try { 79 | 80 | String context = null; 81 | 82 | if (properties.getContext().isEmpty()) { 83 | Resource resource = new ClassPathResource("/static/context.json"); 84 | context = IOUtils.toString(resource.getInputStream(), StandardCharsets.UTF_8); 85 | } else { 86 | context = properties.getContext(); 87 | } 88 | 89 | return ResponseEntity.ok(context); 90 | } catch (IOException e) { 91 | log.error("Could not read context file"); 92 | } 93 | return ResponseEntity.ok(""); 94 | } 95 | 96 | } 97 | -------------------------------------------------------------------------------- /src/main/java/eu/europa/ec/dgc/verifier/restapi/controller/SignerInformationController.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * ---license-start 3 | * eu-digital-green-certificates / dgca-verifier-service 4 | * --- 5 | * Copyright (C) 2021 T-Systems International GmbH and all other contributors 6 | * --- 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * ---license-end 19 | */ 20 | 21 | package eu.europa.ec.dgc.verifier.restapi.controller; 22 | 23 | import eu.europa.ec.dgc.verifier.entity.SignerInformationEntity; 24 | import eu.europa.ec.dgc.verifier.exception.BadRequestException; 25 | import eu.europa.ec.dgc.verifier.restapi.dto.CertificatesLookupResponseItemDto; 26 | import eu.europa.ec.dgc.verifier.restapi.dto.DeltaListDto; 27 | import eu.europa.ec.dgc.verifier.service.SignerInformationService; 28 | import io.swagger.v3.oas.annotations.Operation; 29 | import io.swagger.v3.oas.annotations.Parameter; 30 | import io.swagger.v3.oas.annotations.enums.ParameterIn; 31 | import io.swagger.v3.oas.annotations.headers.Header; 32 | import io.swagger.v3.oas.annotations.media.ArraySchema; 33 | import io.swagger.v3.oas.annotations.media.Content; 34 | import io.swagger.v3.oas.annotations.media.ExampleObject; 35 | import io.swagger.v3.oas.annotations.media.Schema; 36 | import io.swagger.v3.oas.annotations.responses.ApiResponse; 37 | import jakarta.validation.Valid; 38 | import java.time.ZonedDateTime; 39 | import java.time.format.DateTimeFormatter; 40 | import java.time.format.DateTimeParseException; 41 | import java.util.List; 42 | import java.util.Map; 43 | import lombok.RequiredArgsConstructor; 44 | import lombok.extern.slf4j.Slf4j; 45 | import org.springframework.http.HttpHeaders; 46 | import org.springframework.http.MediaType; 47 | import org.springframework.http.ResponseEntity; 48 | import org.springframework.web.bind.annotation.GetMapping; 49 | import org.springframework.web.bind.annotation.PostMapping; 50 | import org.springframework.web.bind.annotation.RequestBody; 51 | import org.springframework.web.bind.annotation.RequestHeader; 52 | import org.springframework.web.bind.annotation.RequestMapping; 53 | import org.springframework.web.bind.annotation.RestController; 54 | 55 | 56 | @RestController 57 | @RequestMapping("/") 58 | @Slf4j 59 | @RequiredArgsConstructor 60 | public class SignerInformationController { 61 | 62 | private static final String X_RESUME_TOKEN_HEADER = "X-RESUME-TOKEN"; 63 | private static final String X_KID_HEADER = "X-KID"; 64 | 65 | private final SignerInformationService signerInformationService; 66 | 67 | 68 | /** 69 | * Http Method for getting signer certificate. 70 | */ 71 | @GetMapping(path = "/signercertificateUpdate", produces = MediaType.TEXT_PLAIN_VALUE) 72 | @Operation( 73 | summary = "Gets one signer certificate and a resume token.", 74 | description = "This method return one signer certificate and a corresponding resume token. In order to " 75 | + "download all available certificates, start calling this method without the resume token set. Then repeat" 76 | + " to call this method, with the resume token parameter set to the value of the last response. When you " 77 | + "receive a 204 response you have downloaded all available certificates.", 78 | tags = {"Signer Information" }, 79 | parameters = { 80 | @Parameter( 81 | in = ParameterIn.HEADER, 82 | name = "X-RESUME-TOKEN", 83 | description = "Defines where to resume the download of the certificates", 84 | schema = @Schema(implementation = Long.class)) 85 | }, 86 | responses = { 87 | @ApiResponse( 88 | responseCode = "200", 89 | description = "Returns one signer certificate and as header parameter a resume token and the kid. " 90 | + "There might be more certificates available to download. Repeat the request with the resume " 91 | + "token parameter set to the actual value, until you get a 204 response.", 92 | headers = { 93 | @Header( 94 | name = "X-RESUME-TOKEN", 95 | description = "Token can be used to resume the download of the certificates."), 96 | @Header( 97 | name = "X-KID", 98 | description = "The kid of the returned certificate.") 99 | }, 100 | content = @Content( 101 | mediaType = MediaType.TEXT_PLAIN_VALUE, 102 | schema = @Schema(implementation = String.class), 103 | examples = {@ExampleObject(value = 104 | "MIIBGzCBwqADAgECAgRggUObMAoGCCqGSM49BAMCMBYxFDASBgNVBAMMC2VkZ2Nf" 105 | + "ZGV2X2VjMB4XDTIxMDQyMjA5MzYyN1oXDTIyMDQyMjA5MzYyN1owFjEUMBIGA1UE" 106 | + "AwwLZWRnY19kZXZfZWMwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAAQVQc9JY190" 107 | + "s/Jn0CBSq/AWuxmqUzRVu+AsCe6gfbqk3s0e4jonzp5v/5IMW/9t7v5Fu2ITMmOT" 108 | + "VfKL1TuM+aixMAoGCCqGSM49BAMCA0gAMEUCIQCGWIk6ZET3afRxdpFVuXdrEYtF" 109 | + "iR1MGDx4HweZfspjSgIgBdCJsT746/FI3euIbzKDoeY65m+Qx2/4Cd/vOayNbuw=")})), 110 | @ApiResponse( 111 | responseCode = "204", 112 | description = "No Content available. All certificates already downloaded.", 113 | content = @Content(schema = @Schema(hidden = true))) 114 | } 115 | ) 116 | public ResponseEntity getSignerCertificateUpdate( 117 | @RequestHeader(value = X_RESUME_TOKEN_HEADER, required = false) Long resumeToken 118 | ) { 119 | HttpHeaders responseHeaders = new HttpHeaders(); 120 | SignerInformationEntity signerInformation = signerInformationService.getCertificate(resumeToken).orElse(null); 121 | 122 | if (signerInformation == null) { 123 | return ResponseEntity.noContent().build(); 124 | } 125 | 126 | responseHeaders.set(X_RESUME_TOKEN_HEADER, signerInformation.getId().toString()); 127 | responseHeaders.set(X_KID_HEADER, signerInformation.getKid()); 128 | 129 | return ResponseEntity.ok() 130 | .headers(responseHeaders) 131 | .body(signerInformation.getRawData()); 132 | } 133 | 134 | 135 | /** 136 | * Http Method for getting list of valid certificates ids. 137 | */ 138 | @GetMapping(path = "/signercertificateStatus", produces = MediaType.APPLICATION_JSON_VALUE) 139 | @Operation( 140 | summary = "Gets a list of kids from all valid certificates.", 141 | tags = {"Signer Information" }, 142 | description = "Gets a list of kids from all valid certificates. This list can be used to verify, that the " 143 | + "downloaded certificates are still valid. If a kid of a downloaded certificate is not part of the list, " 144 | + "the certificate is not valid any more.", 145 | responses = { 146 | @ApiResponse( 147 | responseCode = "200", 148 | description = "Returns a list of kids of all valid certificates.", 149 | content = @Content( 150 | mediaType = MediaType.APPLICATION_JSON_VALUE, 151 | array = @ArraySchema(schema = @Schema(implementation = String.class)), 152 | examples = {@ExampleObject(value = "[\"8xYtW2837bc=\",\"zoQi+KT68LM=\"]")})) 153 | }) 154 | public ResponseEntity> getSignerCertificateStatus() { 155 | 156 | return ResponseEntity.ok(signerInformationService.getListOfValidKids()); 157 | } 158 | 159 | 160 | /** 161 | * Http Method for getting delta list of certificates changes. 162 | */ 163 | @GetMapping(path = "/signercertificateStatus/delta", produces = MediaType.APPLICATION_JSON_VALUE) 164 | @Operation( 165 | summary = "Gets a list of kids from all valid certificates.", 166 | tags = {"Signer Information" }, 167 | description = "Gets a list of kids from all valid certificates. This list can be used to verify, that the " 168 | + "downloaded certificates are still valid. If a kid of a downloaded certificate is not part of the list, " 169 | + "the certificate is not valid any more.", 170 | parameters = { 171 | @Parameter( 172 | in = ParameterIn.HEADER, 173 | name = "If-Modified-Since", 174 | description = "Returns only the objects which are modified behind the given date.", 175 | required = false, 176 | schema = @Schema(implementation = String.class))}, 177 | responses = { 178 | @ApiResponse( 179 | responseCode = "200", 180 | description = "Returns a list of kids of all valid certificates.", 181 | content = @Content( 182 | mediaType = MediaType.APPLICATION_JSON_VALUE, 183 | schema = @Schema(implementation = DeltaListDto.class) 184 | )) 185 | }) 186 | public ResponseEntity getDeltaList( 187 | @RequestHeader(value = HttpHeaders.IF_MODIFIED_SINCE, required = false) String ifModifiedSince) { 188 | 189 | DeltaListDto result; 190 | 191 | if (ifModifiedSince != null) { 192 | ZonedDateTime ifModifiedDateTime = parseIfModifiedSinceHeader(ifModifiedSince); 193 | result = signerInformationService.getDeltaList(ifModifiedDateTime); 194 | } else { 195 | result = signerInformationService.getDeltaList(); 196 | } 197 | 198 | return ResponseEntity.ok(result); 199 | } 200 | 201 | private ZonedDateTime parseIfModifiedSinceHeader(String ifModifiedSince) throws BadRequestException { 202 | ZonedDateTime ifModifiedDateTime; 203 | try { 204 | ifModifiedDateTime = ZonedDateTime.parse(ifModifiedSince); 205 | } catch (DateTimeParseException e) { 206 | try { 207 | ifModifiedDateTime = ZonedDateTime.parse(ifModifiedSince, DateTimeFormatter.RFC_1123_DATE_TIME); 208 | } catch (DateTimeParseException ex) { 209 | throw new BadRequestException("Can not parse if-modified-since header"); 210 | } 211 | } 212 | return ifModifiedDateTime; 213 | } 214 | 215 | /** 216 | * Http Method for looking up certificate data. 217 | * 218 | * @param requestedCertList list of kids, for which the data should be returned 219 | * @return the requested certificate data. 220 | */ 221 | @PostMapping(path = "signercertificateUpdate", 222 | consumes = MediaType.APPLICATION_JSON_VALUE, 223 | produces = MediaType.APPLICATION_JSON_VALUE) 224 | @Operation( 225 | summary = "Returns the data for the requested certificates.", 226 | description = "Returns the certificate data for all kids in the request body.", 227 | tags = {"Signer Information" }, 228 | requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody( 229 | required = true, 230 | content = @Content(array = @ArraySchema( 231 | schema = @Schema(implementation = String.class, name = "kid"))) 232 | ), 233 | responses = { 234 | @ApiResponse( 235 | responseCode = "200", 236 | description = "Returns the certificate data.", 237 | content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, 238 | examples = {@ExampleObject(value = "{ \n “DE”: [“MII….”,”MII…”],\n “NL”: [“MII…”,”MII…”]\n}\n")})) 239 | } 240 | ) 241 | public ResponseEntity>> lookupCertificateData( 242 | @Valid @RequestBody(required = true) List requestedCertList) { 243 | 244 | return ResponseEntity.ok(signerInformationService.getCertificatesData(requestedCertList)); 245 | 246 | } 247 | 248 | 249 | } 250 | -------------------------------------------------------------------------------- /src/main/java/eu/europa/ec/dgc/verifier/restapi/controller/TrustedIssuerController.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * ---license-start 3 | * eu-digital-green-certificates / dgca-verifier-service 4 | * --- 5 | * Copyright (C) 2021 T-Systems International GmbH and all other contributors 6 | * --- 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * ---license-end 19 | */ 20 | 21 | package eu.europa.ec.dgc.verifier.restapi.controller; 22 | 23 | import eu.europa.ec.dgc.verifier.dto.TrustedIssuerDto; 24 | import eu.europa.ec.dgc.verifier.mapper.IssuerMapper; 25 | import eu.europa.ec.dgc.verifier.service.TrustedIssuerService; 26 | import io.swagger.v3.oas.annotations.Operation; 27 | import io.swagger.v3.oas.annotations.Parameter; 28 | import io.swagger.v3.oas.annotations.enums.ParameterIn; 29 | import io.swagger.v3.oas.annotations.headers.Header; 30 | import io.swagger.v3.oas.annotations.media.ArraySchema; 31 | import io.swagger.v3.oas.annotations.media.Content; 32 | import io.swagger.v3.oas.annotations.media.Schema; 33 | import io.swagger.v3.oas.annotations.responses.ApiResponse; 34 | import java.util.List; 35 | import lombok.RequiredArgsConstructor; 36 | import lombok.extern.slf4j.Slf4j; 37 | import org.springframework.http.HttpHeaders; 38 | import org.springframework.http.HttpStatus; 39 | import org.springframework.http.MediaType; 40 | import org.springframework.http.ResponseEntity; 41 | import org.springframework.web.bind.annotation.GetMapping; 42 | import org.springframework.web.bind.annotation.RequestHeader; 43 | import org.springframework.web.bind.annotation.RequestMapping; 44 | import org.springframework.web.bind.annotation.RestController; 45 | 46 | 47 | @RestController 48 | @RequestMapping("/") 49 | @Slf4j 50 | @RequiredArgsConstructor 51 | public class TrustedIssuerController { 52 | 53 | 54 | private final TrustedIssuerService trustedIssuerService; 55 | 56 | private final IssuerMapper issuerMapper; 57 | 58 | 59 | /** 60 | * Http Method for getting trusted issuers. 61 | */ 62 | @GetMapping(path = "/trustedissuers", produces = MediaType.APPLICATION_JSON_VALUE) 63 | @Operation( 64 | summary = "Gets one trusted issuers", 65 | description = "This method return a list of trusted issuers.", 66 | tags = {"Trusted Issuers"}, 67 | parameters = { 68 | @Parameter( 69 | in = ParameterIn.HEADER, 70 | name = "IF-NONE-MATCH", 71 | description = "When the eTag matches the current Tag, there is a 304 response.", 72 | required = false, 73 | schema = @Schema(implementation = String.class)) 74 | }, 75 | responses = { 76 | @ApiResponse( 77 | responseCode = "200", 78 | description = "Returns the the trusted issuers list.", 79 | headers = @Header(name = HttpHeaders.ETAG, description = "ETAG of the current data set"), 80 | content = @Content( 81 | mediaType = MediaType.APPLICATION_JSON_VALUE, 82 | array = @ArraySchema(schema = 83 | @Schema(implementation = TrustedIssuerDto.class)))), 84 | @ApiResponse( 85 | responseCode = "304", 86 | description = "Not modified.") 87 | } 88 | ) 89 | public ResponseEntity> getTrustedIssuers( 90 | @RequestHeader(value = HttpHeaders.IF_NONE_MATCH, defaultValue = "") String ifNoneMatch) { 91 | 92 | String currentEtag = trustedIssuerService.getEtag(); 93 | 94 | if (ifNoneMatch.equals(currentEtag)) { 95 | return ResponseEntity.status(HttpStatus.NOT_MODIFIED).build(); 96 | } 97 | 98 | return ResponseEntity.ok().eTag(currentEtag).body(issuerMapper.trustedIssuerEntityToTrustedIssuerDto( 99 | trustedIssuerService.getAllIssuers(currentEtag))); 100 | } 101 | 102 | } 103 | -------------------------------------------------------------------------------- /src/main/java/eu/europa/ec/dgc/verifier/restapi/dto/CertificatesLookupResponseItemDto.java: -------------------------------------------------------------------------------- 1 | package eu.europa.ec.dgc.verifier.restapi.dto; 2 | 3 | import io.swagger.v3.oas.annotations.media.Schema; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Getter; 6 | 7 | 8 | @Schema( 9 | name = "DeltaList", 10 | type = "object", 11 | example = "{\n" 12 | + "\"updated\": [\"33333d=\",\"333311=\",\"55554=\"],\n" 13 | + "\"deleted\":[\"3115adf=\"]\n" 14 | + "}" 15 | ) 16 | @Getter 17 | @AllArgsConstructor 18 | public class CertificatesLookupResponseItemDto { 19 | String kid; 20 | String rawData; 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/eu/europa/ec/dgc/verifier/restapi/dto/DeltaListDto.java: -------------------------------------------------------------------------------- 1 | package eu.europa.ec.dgc.verifier.restapi.dto; 2 | 3 | import io.swagger.v3.oas.annotations.media.Schema; 4 | import java.util.List; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | 9 | 10 | @Schema( 11 | name = "DeltaList", 12 | type = "object", 13 | example = "{\n" 14 | + "\"updated\": [\"33333d=\",\"333311=\",\"55554=\"],\n" 15 | + "\"deleted\":[\"3115adf=\"]\n" 16 | + "}" 17 | ) 18 | @Data 19 | @AllArgsConstructor 20 | @NoArgsConstructor 21 | public class DeltaListDto { 22 | List updated; 23 | List deleted; 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/eu/europa/ec/dgc/verifier/restapi/dto/KidDto.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * ---license-start 3 | * eu-digital-green-certificates / dgca-verifier-service 4 | * --- 5 | * Copyright (C) 2021 T-Systems International GmbH and all other contributors 6 | * --- 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * ---license-end 19 | */ 20 | 21 | package eu.europa.ec.dgc.verifier.restapi.dto; 22 | 23 | import io.swagger.v3.oas.annotations.media.Schema; 24 | import lombok.Value; 25 | 26 | @Schema( 27 | name = "kid", 28 | type = "string", 29 | example = "8xYtW2837fc=" 30 | ) 31 | 32 | @Value 33 | public class KidDto { 34 | String kid; 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/eu/europa/ec/dgc/verifier/restapi/dto/ProblemReportDto.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * ---license-start 3 | * eu-digital-green-certificates / dgca-verifier-service 4 | * --- 5 | * Copyright (C) 2021 T-Systems International GmbH and all other contributors 6 | * --- 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * ---license-end 19 | */ 20 | 21 | package eu.europa.ec.dgc.verifier.restapi.dto; 22 | 23 | import io.swagger.v3.oas.annotations.media.Schema; 24 | import lombok.AllArgsConstructor; 25 | import lombok.Data; 26 | 27 | @Schema( 28 | name = "ProblemReport", 29 | type = "object", 30 | example = "{\n" 31 | + "\"code\":\"0x001\",\n" 32 | + "\"problem\":\"[PROBLEM]\",\n" 33 | + "\"sent value\":\"[Sent Value]\",\n" 34 | + "\"details\":\"...\"\n" 35 | + "}" 36 | ) 37 | @Data 38 | @AllArgsConstructor 39 | public class ProblemReportDto { 40 | 41 | private String code; 42 | 43 | private String problem; 44 | 45 | private String sendValue; 46 | 47 | private String details; 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/eu/europa/ec/dgc/verifier/service/InfoService.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * ---license-start 3 | * eu-digital-green-certificates / dgca-revocation-distribution-service 4 | * --- 5 | * Copyright (C) 2022 T-Systems International GmbH and all other contributors 6 | * --- 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * ---license-end 19 | */ 20 | 21 | package eu.europa.ec.dgc.verifier.service; 22 | 23 | 24 | import eu.europa.ec.dgc.verifier.entity.InfoEntity; 25 | import eu.europa.ec.dgc.verifier.repository.InfoRepository; 26 | import java.util.Optional; 27 | import lombok.RequiredArgsConstructor; 28 | import lombok.extern.slf4j.Slf4j; 29 | import org.springframework.stereotype.Service; 30 | 31 | @Slf4j 32 | @RequiredArgsConstructor 33 | @Service 34 | public class InfoService { 35 | 36 | public static final String CURRENT_ETAG = "CURRENTETAG"; 37 | 38 | private final InfoRepository infoRepository; 39 | 40 | /** 41 | * Gets a value for the given key from the db. 42 | * 43 | * @param key the key, for which the value should be returned 44 | * @return the value or null if not found in db 45 | */ 46 | public String getValueForKey(String key) { 47 | Optional optionalValue = infoRepository.findById(key); 48 | 49 | return optionalValue.map(InfoEntity::getValue).orElse(null); 50 | } 51 | 52 | /** 53 | * Saves the value for a given key in the db. 54 | * 55 | * @param key key of the value to save. 56 | * @param value the value to save 57 | */ 58 | public void setValueForKey(String key, String value) { 59 | InfoEntity infoEntity = new InfoEntity(key, value); 60 | infoRepository.save(infoEntity); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/eu/europa/ec/dgc/verifier/service/SignerCertificateDownloadService.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * ---license-start 3 | * eu-digital-green-certificates / dgca-verifier-service 4 | * --- 5 | * Copyright (C) 2021 T-Systems International GmbH and all other contributors 6 | * --- 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * ---license-end 19 | */ 20 | 21 | package eu.europa.ec.dgc.verifier.service; 22 | 23 | public interface SignerCertificateDownloadService { 24 | 25 | /** 26 | * Synchronises the signer certificates with the gateway. 27 | */ 28 | void downloadCertificates(); 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/eu/europa/ec/dgc/verifier/service/SignerCertificateDownloadServiceImpl.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * ---license-start 3 | * eu-digital-green-certificates / dgca-verifier-service 4 | * --- 5 | * Copyright (C) 2021 T-Systems International GmbH and all other contributors 6 | * --- 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * ---license-end 19 | */ 20 | 21 | package eu.europa.ec.dgc.verifier.service; 22 | 23 | import eu.europa.ec.dgc.gateway.connector.DgcGatewayDownloadConnector; 24 | import eu.europa.ec.dgc.gateway.connector.model.TrustListItem; 25 | import java.util.List; 26 | import lombok.RequiredArgsConstructor; 27 | import lombok.extern.slf4j.Slf4j; 28 | import net.javacrumbs.shedlock.spring.annotation.SchedulerLock; 29 | import org.springframework.context.annotation.Profile; 30 | import org.springframework.scheduling.annotation.Scheduled; 31 | import org.springframework.stereotype.Component; 32 | 33 | /** 34 | * A service to download the signer certificates from the digital green certificate gateway. 35 | */ 36 | @Slf4j 37 | @RequiredArgsConstructor 38 | @Component 39 | @Profile("!btp") 40 | public class SignerCertificateDownloadServiceImpl implements SignerCertificateDownloadService { 41 | 42 | private final DgcGatewayDownloadConnector dgcGatewayConnector; 43 | private final SignerInformationService signerInformationService; 44 | 45 | @Override 46 | @Scheduled(fixedDelayString = "${dgc.certificatesDownloader.timeInterval}") 47 | @SchedulerLock(name = "SignerCertificateDownloadService_downloadCertificates", lockAtLeastFor = "PT0S", 48 | lockAtMostFor = "${dgc.certificatesDownloader.lockLimit}") 49 | public void downloadCertificates() { 50 | log.info("Certificates download started"); 51 | 52 | List trustedCerts = dgcGatewayConnector.getTrustedCertificates(); 53 | 54 | signerInformationService.updateTrustedCertsList(trustedCerts); 55 | 56 | log.info("Certificates download finished"); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/eu/europa/ec/dgc/verifier/service/SignerInformationService.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * ---license-start 3 | * eu-digital-green-certificates / dgca-verifier-service 4 | * --- 5 | * Copyright (C) 2021 T-Systems International GmbH and all other contributors 6 | * --- 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * ---license-end 19 | */ 20 | 21 | package eu.europa.ec.dgc.verifier.service; 22 | 23 | 24 | import eu.europa.ec.dgc.gateway.connector.model.TrustListItem; 25 | import eu.europa.ec.dgc.verifier.entity.SignerInformationEntity; 26 | import eu.europa.ec.dgc.verifier.repository.SignerInformationRepository; 27 | import eu.europa.ec.dgc.verifier.restapi.dto.CertificatesLookupResponseItemDto; 28 | import eu.europa.ec.dgc.verifier.restapi.dto.DeltaListDto; 29 | import java.time.ZonedDateTime; 30 | import java.util.ArrayList; 31 | import java.util.List; 32 | import java.util.Map; 33 | import java.util.Optional; 34 | import java.util.stream.Collectors; 35 | import lombok.RequiredArgsConstructor; 36 | import lombok.extern.slf4j.Slf4j; 37 | import org.springframework.stereotype.Component; 38 | import org.springframework.transaction.annotation.Transactional; 39 | 40 | 41 | @Slf4j 42 | @Component 43 | @RequiredArgsConstructor 44 | public class SignerInformationService { 45 | 46 | private final SignerInformationRepository signerInformationRepository; 47 | 48 | 49 | /** 50 | * Method to query the db for a certificate with a resume token. 51 | * 52 | * @param resumeToken defines which certificate should be returned. 53 | * @return Optional holding the certificate if found. 54 | */ 55 | public Optional getCertificate(Long resumeToken) { 56 | if (resumeToken == null) { 57 | return signerInformationRepository.findFirstByIdIsNotNullAndDeletedOrderByIdAsc(false); 58 | } else { 59 | return signerInformationRepository.findFirstByIdGreaterThanAndDeletedOrderByIdAsc(resumeToken, false); 60 | } 61 | } 62 | 63 | 64 | /** 65 | * Method to query the db for a list of kid from all certificates. 66 | * 67 | * @return A list of kids of all certificates found. If no certificate was found an empty list is returned. 68 | */ 69 | public List getListOfValidKids() { 70 | 71 | List certsList = signerInformationRepository.findAllByDeletedOrderByIdAsc(false); 72 | 73 | return certsList.stream().map(SignerInformationEntity::getKid).collect(Collectors.toList()); 74 | 75 | } 76 | 77 | 78 | /** 79 | * Method to synchronise the certificates in the db with the given List of trusted certificates. 80 | * 81 | * @param trustedCerts defines the list of trusted certificates. 82 | * 83 | */ 84 | @Transactional 85 | public void updateTrustedCertsList(List trustedCerts) { 86 | 87 | List trustedCertsKids = trustedCerts.stream().map(TrustListItem::getKid).collect(Collectors.toList()); 88 | List alreadyStoredCerts = getListOfValidKids(); 89 | List certsToDelete = new ArrayList<>(); 90 | 91 | 92 | if (trustedCertsKids.isEmpty()) { 93 | signerInformationRepository.setAllDeleted(); 94 | return; 95 | } else { 96 | signerInformationRepository.setDeletedByKidsNotIn(trustedCertsKids); 97 | } 98 | 99 | 100 | List signerInformationEntities = new ArrayList<>(); 101 | 102 | for (TrustListItem cert : trustedCerts) { 103 | if (!alreadyStoredCerts.contains(cert.getKid())) { 104 | signerInformationEntities.add(getSingerInformationEntity(cert)); 105 | certsToDelete.add(cert.getKid()); 106 | } 107 | } 108 | 109 | //Delete all certificates that got updated, so that they get a new id. 110 | signerInformationRepository.deleteByKidIn(certsToDelete); 111 | signerInformationRepository.saveAllAndFlush(signerInformationEntities); 112 | } 113 | 114 | 115 | private SignerInformationEntity getSingerInformationEntity(TrustListItem cert) { 116 | SignerInformationEntity signerEntity = new SignerInformationEntity(); 117 | signerEntity.setKid(cert.getKid()); 118 | signerEntity.setCreatedAt(cert.getTimestamp()); 119 | signerEntity.setCountry(cert.getCountry()); 120 | signerEntity.setThumbprint((cert.getThumbprint())); 121 | signerEntity.setRawData(cert.getRawData()); 122 | 123 | return signerEntity; 124 | } 125 | 126 | /** 127 | * Gets the deleted/updated state of the certificates. 128 | * @return state of the certificates represented by their kids 129 | */ 130 | public DeltaListDto getDeltaList() { 131 | 132 | List certs = 133 | signerInformationRepository.findAllByOrderByIdAsc(); 134 | 135 | Map> partitioned = 136 | certs.stream().collect(Collectors.partitioningBy(SignerInformationEntity::isDeleted, 137 | Collectors.mapping(SignerInformationEntity::getKid, Collectors.toList()))); 138 | 139 | return new DeltaListDto(partitioned.get(Boolean.FALSE),partitioned.get(Boolean.TRUE)); 140 | 141 | } 142 | 143 | /** 144 | * Gets the deleted/updated state of the certificates after the given value. 145 | * @return state of the certificates represented by their kids 146 | */ 147 | public DeltaListDto getDeltaList(ZonedDateTime ifModifiedDateTime) { 148 | 149 | List certs = 150 | signerInformationRepository.findAllByUpdatedAtAfterOrderByIdAsc(ifModifiedDateTime); 151 | 152 | Map> partitioned = 153 | certs.stream().collect(Collectors.partitioningBy(SignerInformationEntity::isDeleted, 154 | Collectors.mapping(SignerInformationEntity::getKid, Collectors.toList()))); 155 | 156 | return new DeltaListDto(partitioned.get(Boolean.FALSE),partitioned.get(Boolean.TRUE)); 157 | 158 | } 159 | 160 | /** 161 | * Gets the raw data of the certificates for a given kid list. 162 | * @param requestedCertList list of kids 163 | * @return raw data of certificates 164 | */ 165 | public Map> getCertificatesData(List requestedCertList) { 166 | 167 | List certs = 168 | signerInformationRepository.findAllByKidIn(requestedCertList); 169 | 170 | return certs.stream().collect(Collectors.groupingBy(SignerInformationEntity::getCountry, 171 | Collectors.mapping(this::map, Collectors.toList()))); 172 | } 173 | 174 | private CertificatesLookupResponseItemDto map(SignerInformationEntity entity) { 175 | return new CertificatesLookupResponseItemDto(entity.getKid(), entity.getRawData()); 176 | } 177 | 178 | } 179 | -------------------------------------------------------------------------------- /src/main/java/eu/europa/ec/dgc/verifier/service/TrustedIssuerDownloadService.java: -------------------------------------------------------------------------------- 1 | package eu.europa.ec.dgc.verifier.service; 2 | 3 | 4 | public interface TrustedIssuerDownloadService { 5 | 6 | /** 7 | * Synchronises the trusted issuers with the gateway. 8 | */ 9 | void downloadTrustedIssuers(); 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/eu/europa/ec/dgc/verifier/service/TrustedIssuerDownloadServiceImpl.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * ---license-start 3 | * eu-digital-green-certificates / dgca-verifier-service 4 | * --- 5 | * Copyright (C) 2021 T-Systems International GmbH and all other contributors 6 | * --- 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * ---license-end 19 | */ 20 | 21 | package eu.europa.ec.dgc.verifier.service; 22 | 23 | import eu.europa.ec.dgc.gateway.connector.DgcGatewayTrustedIssuerDownloadConnector; 24 | import eu.europa.ec.dgc.gateway.connector.model.TrustedIssuer; 25 | import java.util.List; 26 | import lombok.RequiredArgsConstructor; 27 | import lombok.extern.slf4j.Slf4j; 28 | import net.javacrumbs.shedlock.spring.annotation.SchedulerLock; 29 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; 30 | import org.springframework.context.annotation.Profile; 31 | import org.springframework.scheduling.annotation.Scheduled; 32 | import org.springframework.stereotype.Component; 33 | 34 | /** 35 | * A service to download the signer certificates from the digital green certificate gateway. 36 | */ 37 | @Slf4j 38 | @RequiredArgsConstructor 39 | @Component 40 | @Profile("!btp") 41 | @ConditionalOnProperty("dgc.trustedIssuerDownloader.enabled") 42 | public class TrustedIssuerDownloadServiceImpl implements TrustedIssuerDownloadService { 43 | 44 | private final DgcGatewayTrustedIssuerDownloadConnector downloadConnector; 45 | 46 | private final TrustedIssuerService trustedIssuerService; 47 | 48 | 49 | @Override 50 | @Scheduled(fixedDelayString = "${dgc.trustedIssuerDownloader.timeInterval}") 51 | @SchedulerLock(name = "TrustedIssuerDownloadService_downloadTrustedIssuers", lockAtLeastFor = "PT0S", 52 | lockAtMostFor = "${dgc.trustedIssuerDownloader.lockLimit}") 53 | public void downloadTrustedIssuers() { 54 | log.info("Trusted issuers download started"); 55 | 56 | List trustedIssuers = downloadConnector.getTrustedIssuers(); 57 | 58 | trustedIssuerService.updateTrustedIssuersList(trustedIssuers); 59 | 60 | log.info("Trusted issuers download finished. {} issuers downloaded.", trustedIssuers.size()); 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/eu/europa/ec/dgc/verifier/service/TrustedIssuerService.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * ---license-start 3 | * eu-digital-green-certificates / dgca-verifier-service 4 | * --- 5 | * Copyright (C) 2021 T-Systems International GmbH and all other contributors 6 | * --- 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * ---license-end 19 | */ 20 | 21 | package eu.europa.ec.dgc.verifier.service; 22 | 23 | 24 | import eu.europa.ec.dgc.gateway.connector.model.TrustedIssuer; 25 | import eu.europa.ec.dgc.verifier.entity.TrustedIssuerEntity; 26 | import eu.europa.ec.dgc.verifier.mapper.IssuerMapper; 27 | import eu.europa.ec.dgc.verifier.repository.TrustedIssuerRepository; 28 | import java.util.ArrayList; 29 | import java.util.List; 30 | import java.util.UUID; 31 | import lombok.RequiredArgsConstructor; 32 | import lombok.extern.slf4j.Slf4j; 33 | import org.springframework.stereotype.Component; 34 | import org.springframework.transaction.annotation.Transactional; 35 | 36 | @Slf4j 37 | @Component 38 | @RequiredArgsConstructor 39 | public class TrustedIssuerService { 40 | 41 | private final InfoService infoService; 42 | 43 | private final IssuerMapper issuerMapper; 44 | 45 | private final TrustedIssuerRepository trustedIssuerRepository; 46 | 47 | /** 48 | * Get the current etag. 49 | * @return the current etag 50 | */ 51 | 52 | public String getEtag() { 53 | String etag = infoService.getValueForKey(InfoService.CURRENT_ETAG); 54 | if (etag == null) { 55 | etag = ""; 56 | } 57 | return etag; 58 | } 59 | 60 | 61 | /** 62 | * Method to query the db for all trusted issuers. 63 | * 64 | * @return List holding the found trusted issuers. 65 | */ 66 | public List getAllIssuers(String etag) { 67 | return trustedIssuerRepository.findAllByEtag(etag); 68 | } 69 | 70 | /** 71 | * Method to synchronise the issuers in the db with the given List of trusted issuers. 72 | * 73 | * @param trustedIssuers defines the list of trusted issuers. 74 | * 75 | */ 76 | @Transactional 77 | public void updateTrustedIssuersList(List trustedIssuers) { 78 | String newEtag = UUID.randomUUID().toString(); 79 | 80 | List trustedIssuerEntities = new ArrayList<>(); 81 | 82 | 83 | for (TrustedIssuer trustedIssuer : trustedIssuers) { 84 | trustedIssuerEntities.add(getTrustedIssuerEntity(newEtag, trustedIssuer)); 85 | } 86 | 87 | trustedIssuerRepository.saveAll(trustedIssuerEntities); 88 | 89 | String oldEtag = getEtag(); 90 | infoService.setValueForKey(InfoService.CURRENT_ETAG, newEtag); 91 | 92 | cleanupData(oldEtag); 93 | 94 | } 95 | 96 | private TrustedIssuerEntity getTrustedIssuerEntity(String etag, TrustedIssuer trustedIssuer) { 97 | TrustedIssuerEntity entity = issuerMapper.trustedIssuerToTrustedIssuerEntity(trustedIssuer); 98 | entity.setEtag(etag); 99 | return entity; 100 | } 101 | 102 | private void cleanupData(String etag) { 103 | trustedIssuerRepository.deleteAllByEtag(etag); 104 | } 105 | 106 | } 107 | -------------------------------------------------------------------------------- /src/main/resources/application-cloud.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | h2: 3 | console: 4 | enabled: false 5 | datasource: 6 | driver-class-name: org.postgresql.Driver 7 | url: jdbc:postgresql://localhost:5432/postgres 8 | username: postgres 9 | password: postgres 10 | jpa: 11 | database-platform: org.hibernate.dialect.PostgreSQLDialect 12 | -------------------------------------------------------------------------------- /src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8080 3 | spring: 4 | application: 5 | name: dgca-verifier-service 6 | datasource: 7 | driver-class-name: org.h2.Driver 8 | url: jdbc:h2:mem:dgc;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=-1; 9 | username: sa 10 | password: '' 11 | jpa: 12 | database-platform: org.hibernate.dialect.H2Dialect 13 | hibernate: 14 | ddl-auto: validate 15 | liquibase: 16 | change-log: classpath:db/changelog.xml 17 | h2: 18 | console: 19 | enabled: true 20 | path: /h2-console 21 | task: 22 | scheduling: 23 | pool: 24 | size: 5 25 | management: 26 | endpoint: 27 | info: 28 | enabled: true 29 | health: 30 | enabled: true 31 | endpoints: 32 | enabled-by-default: false 33 | web: 34 | base-path: /management 35 | exposure: 36 | include: info,health 37 | info: 38 | name: ${spring.application.name} 39 | profiles: ${spring.profiles.active} 40 | springdoc: 41 | api-docs: 42 | path: /api/docs 43 | enabled: true 44 | swagger-ui: 45 | path: /swagger 46 | dgc: 47 | certificatesDownloader: 48 | timeInterval: 1800000 49 | lockLimit: 3600000 50 | trustedIssuerDownloader: 51 | enabled: true 52 | timeInterval: 1800000 53 | lockLimit: 3600000 54 | gateway: 55 | connector: 56 | enabled: true 57 | endpoint: ${DGC_GATEWAY_CONNECTOR_ENDPOINT} 58 | proxy: 59 | enabled: false 60 | max-cache-age: 300 61 | tls-trust-store: 62 | password: ${DGC_GATEWAY_CONNECTOR_TLSTRUSTSTORE_PASSWORD} 63 | path: ${DGC_GATEWAY_CONNECTOR_TLSTRUSTSTORE_PATH} 64 | tls-key-store: 65 | alias: ${DGC_GATEWAY_CONNECTOR_TLSKEYSTORE_ALIAS} 66 | password: ${DGC_GATEWAY_CONNECTOR_TLSKEYSTORE_PASSWORD} 67 | path: ${DGC_GATEWAY_CONNECTOR_TLSKEYSTORE_PATH} 68 | trust-anchor: 69 | alias: ${DGC_GATEWAY_CONNECTOR_TRUSTANCHOR_ALIAS} 70 | password: ${DGC_GATEWAY_CONNECTOR_TRUSTANCHOR_PASSWORD} 71 | path: ${DGC_GATEWAY_CONNECTOR_TRUSTANCHOR_PATH} 72 | 73 | -------------------------------------------------------------------------------- /src/main/resources/db/changelog.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/main/resources/db/changelog/alter-signer-information.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /src/main/resources/db/changelog/create-info-table.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/main/resources/db/changelog/create-trusted-issuer-table.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /src/main/resources/db/changelog/init-tables.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /src/main/resources/logback-spring.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/main/resources/static/context.json: -------------------------------------------------------------------------------- 1 | { 2 | "origin": "DE", 3 | "versions": { 4 | "default": { 5 | "privacyUrl": "https://publications.europa.eu/en/web/about-us/legal-notices/eu-mobile-apps", 6 | "context": { 7 | "url": "https://dgca-verifier-service.cfapps.eu10.hana.ondemand.com/context", 8 | "pubKeys": [ 9 | "lKdU1EbQubxyDDm2q3N8KclZ2C94Num3xXjG0pk+3eI=", 10 | "r/mIkG3eEpVdm+u/ko/cwxzOMo1bk4TyHIlByibiA5E=" 11 | ] 12 | }, 13 | "endpoints": { 14 | "status": { 15 | "url": "https://dgca-verifier-service.cfapps.eu10.hana.ondemand.com/signercertificateStatus", 16 | "pubKeys": [ 17 | "lKdU1EbQubxyDDm2q3N8KclZ2C94Num3xXjG0pk+3eI=", 18 | "r/mIkG3eEpVdm+u/ko/cwxzOMo1bk4TyHIlByibiA5E=" 19 | ] 20 | }, 21 | "update": { 22 | "url": "https://dgca-verifier-service.cfapps.eu10.hana.ondemand.com/signercertificateUpdate", 23 | "pubKeys": [ 24 | "lKdU1EbQubxyDDm2q3N8KclZ2C94Num3xXjG0pk+3eI=", 25 | "r/mIkG3eEpVdm+u/ko/cwxzOMo1bk4TyHIlByibiA5E=" 26 | ] 27 | }, 28 | "countryList": { 29 | "url": "https://dgca-businessrule-service.cfapps.eu10.hana.ondemand.com/countrylist", 30 | "pubKeys": [ 31 | "lKdU1EbQubxyDDm2q3N8KclZ2C94Num3xXjG0pk+3eI=", 32 | "r/mIkG3eEpVdm+u/ko/cwxzOMo1bk4TyHIlByibiA5E=" 33 | ] 34 | }, 35 | "rules": { 36 | "url": "https://dgca-businessrule-service.cfapps.eu10.hana.ondemand.com/rules", 37 | "pubKeys": [ 38 | "lKdU1EbQubxyDDm2q3N8KclZ2C94Num3xXjG0pk+3eI=", 39 | "r/mIkG3eEpVdm+u/ko/cwxzOMo1bk4TyHIlByibiA5E=" 40 | ] 41 | }, 42 | "valuesets": { 43 | "url": "https://dgca-businessrule-service.cfapps.eu10.hana.ondemand.com/valuesets", 44 | "pubKeys": [ 45 | "lKdU1EbQubxyDDm2q3N8KclZ2C94Num3xXjG0pk+3eI=", 46 | "r/mIkG3eEpVdm+u/ko/cwxzOMo1bk4TyHIlByibiA5E=" 47 | ] 48 | } 49 | } 50 | }, 51 | "0.1.0": { 52 | "outdated": true 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/test/java/eu/europa/ec/dgc/verifier/OpenApiTest.java: -------------------------------------------------------------------------------- 1 | package eu.europa.ec.dgc.verifier; 2 | 3 | import eu.europa.ec.dgc.gateway.connector.DgcGatewayDownloadConnector; 4 | import java.io.BufferedInputStream; 5 | import java.io.FileOutputStream; 6 | import java.net.URL; 7 | import lombok.extern.slf4j.Slf4j; 8 | import org.junit.jupiter.api.Assertions; 9 | import org.junit.jupiter.api.Test; 10 | import org.springframework.boot.test.context.SpringBootTest; 11 | import org.springframework.boot.test.mock.mockito.MockBean; 12 | 13 | @Slf4j 14 | @SpringBootTest( 15 | properties = { 16 | "server.port=8080", 17 | "springdoc.api-docs.enabled=true", 18 | "springdoc.api-docs.path=/openapi" 19 | }, 20 | webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT 21 | ) 22 | class OpenApiTest { 23 | 24 | @MockBean 25 | private DgcGatewayDownloadConnector dgcGatewayDownloadConnector; 26 | 27 | @Test 28 | void apiDocs() { 29 | try (BufferedInputStream in = new BufferedInputStream(new URL("http://localhost:8080/openapi").openStream()); 30 | FileOutputStream out = new FileOutputStream("target/openapi.json")) { 31 | byte[] buffer = new byte[1024]; 32 | int read; 33 | while ((read = in.read(buffer, 0, buffer.length)) != -1) { 34 | out.write(buffer, 0, read); 35 | } 36 | } catch (Exception e) { 37 | log.error("Failed to download openapi specification.", e); 38 | Assertions.fail(); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/test/java/eu/europa/ec/dgc/verifier/restapi/controller/ContextControllerIntegrationTest.java: -------------------------------------------------------------------------------- 1 | package eu.europa.ec.dgc.verifier.restapi.controller; 2 | 3 | import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; 4 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; 5 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; 6 | 7 | import java.io.IOException; 8 | import java.io.UnsupportedEncodingException; 9 | import java.nio.charset.StandardCharsets; 10 | 11 | import org.apache.commons.io.IOUtils; 12 | import org.junit.jupiter.api.Assertions; 13 | import org.junit.jupiter.api.Test; 14 | import org.springframework.beans.factory.annotation.Autowired; 15 | import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; 16 | import org.springframework.boot.test.context.SpringBootTest; 17 | import org.springframework.boot.test.mock.mockito.MockBean; 18 | import org.springframework.core.io.ClassPathResource; 19 | import org.springframework.core.io.Resource; 20 | import org.springframework.http.MediaType; 21 | import org.springframework.test.web.servlet.MockMvc; 22 | import org.springframework.test.web.servlet.MvcResult; 23 | 24 | import eu.europa.ec.dgc.gateway.connector.DgcGatewayDownloadConnector; 25 | 26 | @SpringBootTest 27 | @AutoConfigureMockMvc 28 | class ContextControllerIntegrationTest { 29 | 30 | @MockBean 31 | DgcGatewayDownloadConnector dgcGatewayDownloadConnector; 32 | 33 | @Autowired 34 | private MockMvc mockMvc; 35 | 36 | @Test 37 | void requestContext() throws Exception { 38 | mockMvc.perform(get("/context")) 39 | .andExpect(status().isOk()) 40 | .andExpect(content().contentType(MediaType.APPLICATION_JSON)) 41 | .andExpect(result -> assertContextStrEqualFile(result)); 42 | } 43 | 44 | 45 | private void assertContextStrEqualFile(MvcResult result) throws UnsupportedEncodingException { 46 | String resultContext = result.getResponse().getContentAsString(); 47 | Resource resource = new ClassPathResource("/static/context.json"); 48 | String fileContext = null; 49 | try { 50 | fileContext = IOUtils.toString(resource.getInputStream(), StandardCharsets.UTF_8); 51 | } catch (IOException e) { 52 | Assertions.fail(e); 53 | } 54 | Assertions.assertEquals(resultContext, fileContext); 55 | } 56 | 57 | } 58 | 59 | -------------------------------------------------------------------------------- /src/test/java/eu/europa/ec/dgc/verifier/restapi/controller/ContextControllerWithEnvironmentIntegrationTest.java: -------------------------------------------------------------------------------- 1 | package eu.europa.ec.dgc.verifier.restapi.controller; 2 | 3 | import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; 4 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; 5 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; 6 | 7 | import org.junit.jupiter.api.Test; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; 10 | import org.springframework.boot.test.context.SpringBootTest; 11 | import org.springframework.boot.test.mock.mockito.MockBean; 12 | import org.springframework.http.MediaType; 13 | import org.springframework.test.context.TestPropertySource; 14 | import org.springframework.test.web.servlet.MockMvc; 15 | 16 | import eu.europa.ec.dgc.gateway.connector.DgcGatewayDownloadConnector; 17 | 18 | @SpringBootTest 19 | @AutoConfigureMockMvc 20 | @TestPropertySource(properties = {"dgc.context={\"testContext\": true}"}) 21 | class ContextControllerWithEnvironmentIntegrationTest { 22 | 23 | @MockBean 24 | DgcGatewayDownloadConnector dgcGatewayDownloadConnector; 25 | 26 | @Autowired 27 | private MockMvc mockMvc; 28 | 29 | @Test 30 | void requestContext() throws Exception { 31 | mockMvc.perform(get("/context")) 32 | .andExpect(status().isOk()) 33 | .andExpect(content().contentType(MediaType.APPLICATION_JSON)) 34 | .andExpect(content().json("{\"testContext\": true}")); 35 | } 36 | 37 | 38 | 39 | 40 | } 41 | 42 | -------------------------------------------------------------------------------- /src/test/java/eu/europa/ec/dgc/verifier/restapi/controller/TrustedIssuerIntegrationTest.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * ---license-start 3 | * eu-digital-green-certificates / dgca-verifier-service 4 | * --- 5 | * Copyright (C) 2021 T-Systems International GmbH and all other contributors 6 | * --- 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * ---license-end 19 | */ 20 | 21 | package eu.europa.ec.dgc.verifier.restapi.controller; 22 | 23 | import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; 24 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; 25 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; 26 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; 27 | 28 | import org.junit.jupiter.api.BeforeEach; 29 | import org.junit.jupiter.api.Test; 30 | import org.springframework.beans.factory.annotation.Autowired; 31 | import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; 32 | import org.springframework.boot.test.context.SpringBootTest; 33 | import org.springframework.boot.test.mock.mockito.MockBean; 34 | import org.springframework.http.HttpHeaders; 35 | import org.springframework.test.web.servlet.MockMvc; 36 | 37 | import eu.europa.ec.dgc.gateway.connector.DgcGatewayDownloadConnector; 38 | import eu.europa.ec.dgc.verifier.repository.TrustedIssuerRepository; 39 | import eu.europa.ec.dgc.verifier.service.InfoService; 40 | import eu.europa.ec.dgc.verifier.testdata.TrustedIssuerTestHelper; 41 | 42 | @SpringBootTest 43 | @AutoConfigureMockMvc 44 | class TrustedIssuerIntegrationTest { 45 | 46 | @MockBean 47 | DgcGatewayDownloadConnector dgcGatewayDownloadConnector; 48 | 49 | @Autowired 50 | TrustedIssuerTestHelper trustedIssuerTestHelper; 51 | 52 | @Autowired 53 | TrustedIssuerRepository trustedIssuerRepository; 54 | 55 | @Autowired 56 | InfoService infoService; 57 | 58 | @Autowired 59 | private MockMvc mockMvc; 60 | 61 | @BeforeEach 62 | void clearRepositoryData() { 63 | 64 | trustedIssuerRepository.deleteAll(); 65 | infoService.setValueForKey(InfoService.CURRENT_ETAG,"TestEtag"); 66 | } 67 | 68 | @Test 69 | void requestTrustedIssuersIsEmpty() throws Exception { 70 | mockMvc.perform(get("/trustedissuers")) 71 | .andExpect(status().isOk()) 72 | .andExpect(content().json("[]")); 73 | 74 | } 75 | 76 | 77 | @Test 78 | void requestTrustedIssuers() throws Exception { 79 | trustedIssuerTestHelper.insertTrustedIssuer(trustedIssuerTestHelper.getIssuer(1)); 80 | 81 | 82 | mockMvc.perform(get("/trustedissuers")) 83 | .andExpect(status().isOk()) 84 | .andExpect(jsonPath("$[0].url").value("https://TestUrl.de")) 85 | .andExpect(jsonPath("$[0].type").value("HTTP")) 86 | .andExpect(jsonPath("$[0].country").value("DE")) 87 | .andExpect(jsonPath("$[0].thumbprint").value("thumbprint1")) 88 | .andExpect(jsonPath("$[0].sslPublicKey").value("PublicKey1")) 89 | .andExpect(jsonPath("$[0].keyStorageType").value("JWKS")) 90 | .andExpect(jsonPath("$[0].signature").value("Signature1")) 91 | .andExpect(jsonPath("$[0].name").value("example1.de")); 92 | 93 | } 94 | 95 | @Test 96 | void requestTrustedIssuersWithHeader() throws Exception { 97 | trustedIssuerTestHelper.insertTrustedIssuer(trustedIssuerTestHelper.getIssuer(1)); 98 | 99 | 100 | mockMvc.perform(get("/trustedissuers").header(HttpHeaders.IF_NONE_MATCH, "NoMatchEtag")) 101 | .andExpect(status().isOk()) 102 | .andExpect(jsonPath("$[0].url").value("https://TestUrl.de")) 103 | .andExpect(jsonPath("$[0].type").value("HTTP")) 104 | .andExpect(jsonPath("$[0].country").value("DE")) 105 | .andExpect(jsonPath("$[0].thumbprint").value("thumbprint1")) 106 | .andExpect(jsonPath("$[0].sslPublicKey").value("PublicKey1")) 107 | .andExpect(jsonPath("$[0].keyStorageType").value("JWKS")) 108 | .andExpect(jsonPath("$[0].signature").value("Signature1")) 109 | .andExpect(jsonPath("$[0].name").value("example1.de")); 110 | 111 | } 112 | 113 | @Test 114 | void requestTrustedIssuersWithHeaderMatchEtag() throws Exception { 115 | trustedIssuerTestHelper.insertTrustedIssuer(trustedIssuerTestHelper.getIssuer(1)); 116 | trustedIssuerTestHelper.insertTrustedIssuer(trustedIssuerTestHelper.getIssuer(2)); 117 | 118 | mockMvc.perform(get("/trustedissuers").header(HttpHeaders.IF_NONE_MATCH, "TestEtag")) 119 | .andExpect(status().isNotModified()); 120 | 121 | } 122 | 123 | 124 | 125 | 126 | 127 | 128 | } 129 | -------------------------------------------------------------------------------- /src/test/java/eu/europa/ec/dgc/verifier/service/InfoServiceTest.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * ---license-start 3 | * eu-digital-green-certificates / dgca-verifier-service 4 | * --- 5 | * Copyright (C) 2021 T-Systems International GmbH and all other contributors 6 | * --- 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * ---license-end 19 | */ 20 | 21 | package eu.europa.ec.dgc.verifier.service; 22 | 23 | 24 | import java.util.List; 25 | 26 | import org.junit.jupiter.api.Assertions; 27 | import org.junit.jupiter.api.BeforeEach; 28 | import org.junit.jupiter.api.Test; 29 | import org.springframework.beans.factory.annotation.Autowired; 30 | import org.springframework.boot.test.context.SpringBootTest; 31 | import org.springframework.boot.test.mock.mockito.MockBean; 32 | 33 | import eu.europa.ec.dgc.gateway.connector.DgcGatewayDownloadConnector; 34 | import eu.europa.ec.dgc.verifier.entity.InfoEntity; 35 | import eu.europa.ec.dgc.verifier.repository.InfoRepository; 36 | 37 | 38 | @SpringBootTest 39 | class InfoServiceTest { 40 | 41 | @MockBean 42 | DgcGatewayDownloadConnector dgcGatewayDownloadConnector; 43 | 44 | @Autowired 45 | InfoRepository infoRepository; 46 | 47 | @Autowired 48 | InfoService infoService; 49 | 50 | 51 | 52 | @BeforeEach 53 | void clearRepositoryData() { 54 | infoRepository.deleteAll(); 55 | } 56 | 57 | 58 | @Test 59 | void saveInfo() throws Exception { 60 | 61 | infoService.setValueForKey("TestKey", "TestValue"); 62 | 63 | List entities = infoRepository.findAll(); 64 | 65 | Assertions.assertEquals(1, entities.size()); 66 | Assertions.assertEquals("TestKey", entities.get(0).getIdentifierKey()); 67 | Assertions.assertEquals("TestValue", entities.get(0).getValue()); 68 | 69 | } 70 | 71 | @Test 72 | void getInfo() throws Exception { 73 | 74 | InfoEntity entity = new InfoEntity("TestKey", "TestValue"); 75 | infoRepository.save(entity); 76 | 77 | Assertions.assertEquals("TestValue", infoService.getValueForKey("TestKey")); 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /src/test/java/eu/europa/ec/dgc/verifier/service/SignerCertificateDownloadServiceImplTest.java: -------------------------------------------------------------------------------- 1 | package eu.europa.ec.dgc.verifier.service; 2 | 3 | import eu.europa.ec.dgc.gateway.connector.DgcGatewayDownloadConnector; 4 | import eu.europa.ec.dgc.gateway.connector.model.TrustListItem; 5 | import eu.europa.ec.dgc.verifier.entity.SignerInformationEntity; 6 | import eu.europa.ec.dgc.verifier.repository.SignerInformationRepository; 7 | import eu.europa.ec.dgc.verifier.testdata.SignerInformationTestHelper; 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | import org.junit.jupiter.api.Assertions; 11 | import org.junit.jupiter.api.Test; 12 | import org.mockito.Mockito; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.boot.test.context.SpringBootTest; 15 | import org.springframework.boot.test.mock.mockito.MockBean; 16 | 17 | 18 | @SpringBootTest 19 | class SignerCertificateDownloadServiceImplTest { 20 | 21 | @MockBean 22 | DgcGatewayDownloadConnector dgcGatewayDownloadConnector; 23 | 24 | @Autowired 25 | SignerCertificateDownloadServiceImpl signerCertificateDownloadService; 26 | 27 | @Autowired 28 | SignerInformationRepository signerInformationRepository; 29 | 30 | @Autowired 31 | SignerInformationTestHelper signerInformationTestHelper; 32 | 33 | @Test 34 | void downloadEmptyCertificatesList() { 35 | ArrayList trustList = new ArrayList<>(); 36 | Mockito.when(dgcGatewayDownloadConnector.getTrustedCertificates()).thenReturn(trustList); 37 | 38 | signerCertificateDownloadService.downloadCertificates(); 39 | 40 | List repositoryItems = signerInformationRepository.findAllByDeletedOrderByIdAsc(false); 41 | Assertions.assertEquals(0, repositoryItems.size()); 42 | } 43 | 44 | @Test 45 | void downloadCertificates() { 46 | ArrayList trustList = new ArrayList<>(); 47 | trustList.add(signerInformationTestHelper.createTrustListItem(SignerInformationTestHelper.TEST_CERT_1_STR)); 48 | Mockito.when(dgcGatewayDownloadConnector.getTrustedCertificates()).thenReturn(trustList); 49 | 50 | signerCertificateDownloadService.downloadCertificates(); 51 | 52 | List repositoryItems = signerInformationRepository.findAll(); 53 | Assertions.assertEquals(1, repositoryItems.size()); 54 | 55 | SignerInformationEntity repositoryItem = repositoryItems.get(0); 56 | Assertions.assertEquals(SignerInformationTestHelper.TEST_CERT_1_KID, repositoryItem.getKid()); 57 | Assertions.assertEquals(SignerInformationTestHelper.TEST_CERT_1_STR, repositoryItem.getRawData()); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/test/java/eu/europa/ec/dgc/verifier/service/SignerInformationServiceTest.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * ---license-start 3 | * eu-digital-green-certificates / dgca-verifier-service 4 | * --- 5 | * Copyright (C) 2021 T-Systems International GmbH and all other contributors 6 | * --- 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * ---license-end 19 | */ 20 | 21 | package eu.europa.ec.dgc.verifier.service; 22 | 23 | import com.google.code.beanmatchers.BeanMatchers; 24 | import eu.europa.ec.dgc.gateway.connector.DgcGatewayDownloadConnector; 25 | import eu.europa.ec.dgc.gateway.connector.model.TrustListItem; 26 | import eu.europa.ec.dgc.verifier.dto.TrustedIssuerDto; 27 | import eu.europa.ec.dgc.verifier.entity.SignerInformationEntity; 28 | import eu.europa.ec.dgc.verifier.repository.SignerInformationRepository; 29 | import eu.europa.ec.dgc.verifier.restapi.dto.DeltaListDto; 30 | import eu.europa.ec.dgc.verifier.testdata.SignerInformationTestHelper; 31 | import java.time.ZonedDateTime; 32 | import java.util.ArrayList; 33 | import java.util.List; 34 | import org.junit.jupiter.api.Assertions; 35 | import org.junit.jupiter.api.BeforeEach; 36 | import org.junit.jupiter.api.Test; 37 | import org.springframework.beans.factory.annotation.Autowired; 38 | import org.springframework.boot.test.context.SpringBootTest; 39 | import org.springframework.boot.test.mock.mockito.MockBean; 40 | 41 | import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanConstructor; 42 | import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanEquals; 43 | import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanHashCode; 44 | import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanToString; 45 | import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; 46 | import static org.hamcrest.MatcherAssert.assertThat; 47 | import static org.hamcrest.Matchers.allOf; 48 | 49 | 50 | @SpringBootTest 51 | class SignerInformationServiceTest { 52 | 53 | @MockBean 54 | DgcGatewayDownloadConnector dgcGatewayDownloadConnector; 55 | 56 | @Autowired 57 | SignerInformationRepository signerInformationRepository; 58 | 59 | @Autowired 60 | SignerInformationService signerInformationService; 61 | 62 | @Autowired 63 | SignerInformationTestHelper signerInformationTestHelper; 64 | 65 | @BeforeEach 66 | void clearRepositoryData() { 67 | signerInformationRepository.deleteAll(); 68 | } 69 | 70 | 71 | @Test 72 | void updateEmptyRepositoryWithEmptyCertList() { 73 | ArrayList trustList = new ArrayList<>(); 74 | 75 | signerInformationService.updateTrustedCertsList(trustList); 76 | 77 | List repositoryItems = signerInformationRepository.findAll(); 78 | 79 | Assertions.assertEquals(0, repositoryItems.size()); 80 | 81 | } 82 | 83 | @Test 84 | void updateEmptyRepositoryWithOneCert() { 85 | ArrayList trustList = new ArrayList<>(); 86 | trustList.add(signerInformationTestHelper.createTrustListItem(SignerInformationTestHelper.TEST_CERT_1_STR)); 87 | 88 | signerInformationService.updateTrustedCertsList(trustList); 89 | 90 | List repositoryItems = signerInformationRepository.findAll(); 91 | 92 | Assertions.assertEquals(1, repositoryItems.size()); 93 | 94 | SignerInformationEntity repositoryItem = repositoryItems.get(0); 95 | 96 | Assertions.assertEquals(SignerInformationTestHelper.TEST_CERT_1_KID, repositoryItem.getKid()); 97 | Assertions.assertEquals(SignerInformationTestHelper.TEST_CERT_1_STR, repositoryItem.getRawData()); 98 | 99 | } 100 | 101 | @Test 102 | void updateEmptyRepositoryWithCerts() { 103 | ArrayList trustList = new ArrayList<>(); 104 | trustList.add(signerInformationTestHelper.createTrustListItem(SignerInformationTestHelper.TEST_CERT_1_STR)); 105 | trustList.add(signerInformationTestHelper.createTrustListItem(SignerInformationTestHelper.TEST_CERT_2_STR)); 106 | trustList.add(signerInformationTestHelper.createTrustListItem(SignerInformationTestHelper.TEST_CERT_3_STR)); 107 | 108 | signerInformationService.updateTrustedCertsList(trustList); 109 | 110 | List repositoryItems = signerInformationRepository.findAll(); 111 | 112 | Assertions.assertEquals(3, repositoryItems.size()); 113 | 114 | SignerInformationEntity repositoryItem = repositoryItems.get(0); 115 | Assertions.assertEquals(SignerInformationTestHelper.TEST_CERT_1_KID, repositoryItem.getKid()); 116 | Assertions.assertEquals(SignerInformationTestHelper.TEST_CERT_1_STR, repositoryItem.getRawData()); 117 | repositoryItem = repositoryItems.get(1); 118 | Assertions.assertEquals(SignerInformationTestHelper.TEST_CERT_2_KID, repositoryItem.getKid()); 119 | Assertions.assertEquals(SignerInformationTestHelper.TEST_CERT_2_STR, repositoryItem.getRawData()); 120 | repositoryItem = repositoryItems.get(2); 121 | Assertions.assertEquals(SignerInformationTestHelper.TEST_CERT_3_KID, repositoryItem.getKid()); 122 | Assertions.assertEquals(SignerInformationTestHelper.TEST_CERT_3_STR, repositoryItem.getRawData()); 123 | 124 | } 125 | 126 | @Test 127 | void updateEmptyRepositoryWithSameCertsTwice() { 128 | ArrayList trustList = new ArrayList<>(); 129 | trustList.add(signerInformationTestHelper.createTrustListItem(SignerInformationTestHelper.TEST_CERT_1_STR)); 130 | trustList.add(signerInformationTestHelper.createTrustListItem(SignerInformationTestHelper.TEST_CERT_2_STR)); 131 | trustList.add(signerInformationTestHelper.createTrustListItem(SignerInformationTestHelper.TEST_CERT_3_STR)); 132 | 133 | signerInformationService.updateTrustedCertsList(trustList); 134 | 135 | List repositoryItems = signerInformationRepository.findAll(); 136 | 137 | Assertions.assertEquals(3, repositoryItems.size()); 138 | 139 | SignerInformationEntity repositoryItem0 = repositoryItems.get(0); 140 | SignerInformationEntity repositoryItem1 = repositoryItems.get(1); 141 | SignerInformationEntity repositoryItem2 = repositoryItems.get(2); 142 | 143 | signerInformationService.updateTrustedCertsList(trustList); 144 | 145 | repositoryItems = signerInformationRepository.findAll(); 146 | 147 | Assertions.assertEquals(3, repositoryItems.size()); 148 | 149 | SignerInformationEntity repositoryItem = repositoryItems.get(0); 150 | Assertions.assertEquals(repositoryItem0, repositoryItem); 151 | repositoryItem = repositoryItems.get(1); 152 | Assertions.assertEquals(repositoryItem1, repositoryItem); 153 | repositoryItem = repositoryItems.get(2); 154 | Assertions.assertEquals(repositoryItem2, repositoryItem); 155 | } 156 | 157 | @Test 158 | void updateRepositoryWithOneNewCertAndOneRevoked() { 159 | signerInformationTestHelper.insertCertString(SignerInformationTestHelper.TEST_CERT_1_STR); 160 | signerInformationTestHelper.insertCertString(SignerInformationTestHelper.TEST_CERT_2_STR); 161 | 162 | 163 | ArrayList trustList = new ArrayList<>(); 164 | trustList.add(signerInformationTestHelper.createTrustListItem(SignerInformationTestHelper.TEST_CERT_2_STR)); 165 | trustList.add(signerInformationTestHelper.createTrustListItem(SignerInformationTestHelper.TEST_CERT_3_STR)); 166 | 167 | signerInformationService.updateTrustedCertsList(trustList); 168 | 169 | List repositoryItems = signerInformationRepository.findAllByDeletedOrderByIdAsc(false); 170 | 171 | Assertions.assertEquals(2, repositoryItems.size()); 172 | 173 | SignerInformationEntity repositoryItem0 = repositoryItems.get(0); 174 | SignerInformationEntity repositoryItem1 = repositoryItems.get(1); 175 | 176 | Assertions.assertEquals(SignerInformationTestHelper.TEST_CERT_2_KID, repositoryItem0.getKid()); 177 | Assertions.assertEquals(SignerInformationTestHelper.TEST_CERT_2_STR, repositoryItem0.getRawData()); 178 | Assertions.assertEquals(SignerInformationTestHelper.TEST_CERT_3_KID, repositoryItem1.getKid()); 179 | Assertions.assertEquals(SignerInformationTestHelper.TEST_CERT_3_STR, repositoryItem1.getRawData()); 180 | 181 | } 182 | 183 | @Test 184 | void updateRepositoryWithEmptyCertList() { 185 | signerInformationTestHelper.insertCertString(SignerInformationTestHelper.TEST_CERT_1_STR); 186 | signerInformationTestHelper.insertCertString(SignerInformationTestHelper.TEST_CERT_2_STR); 187 | signerInformationTestHelper.insertCertString(SignerInformationTestHelper.TEST_CERT_3_STR); 188 | 189 | ArrayList trustList = new ArrayList<>(); 190 | 191 | signerInformationService.updateTrustedCertsList(trustList); 192 | 193 | List repositoryItems = signerInformationRepository.findAllByDeletedOrderByIdAsc(false); 194 | 195 | Assertions.assertEquals(0, repositoryItems.size()); 196 | 197 | } 198 | 199 | @Test 200 | void dataTypeTests() { 201 | 202 | assertThat(DeltaListDto.class, allOf(hasValidBeanConstructor(), hasValidBeanEquals(), 203 | hasValidGettersAndSetters(), hasValidBeanHashCode(), hasValidBeanToString())); 204 | List updated = new ArrayList<>(); 205 | updated.add("updated"); 206 | List deleted = new ArrayList<>(); 207 | deleted.add("deleted"); 208 | DeltaListDto deltaListDto = new DeltaListDto(updated, deleted); 209 | Assertions.assertEquals("updated",deltaListDto.getUpdated().get(0)); 210 | Assertions.assertEquals("deleted",deltaListDto.getDeleted().get(0)); 211 | deltaListDto.setDeleted(updated); 212 | deltaListDto.setUpdated(deleted); 213 | Assertions.assertEquals("deleted",deltaListDto.getUpdated().get(0)); 214 | Assertions.assertEquals("updated",deltaListDto.getDeleted().get(0)); 215 | 216 | 217 | TrustedIssuerDto issuer = new 218 | TrustedIssuerDto("url", TrustedIssuerDto.UrlTypeDto.HTTP,"DE","TP1","PK1", 219 | "JWKM","signature1", ZonedDateTime.now(),"name"); 220 | Assertions.assertEquals("url",issuer.getUrl()); 221 | issuer.setUrl("newUrl"); 222 | Assertions.assertEquals("newUrl",issuer.getUrl()); 223 | 224 | BeanMatchers.registerValueGenerator(ZonedDateTime::now, ZonedDateTime.class); 225 | 226 | assertThat(TrustedIssuerDto.class, allOf(hasValidBeanConstructor(), hasValidBeanEquals(), 227 | hasValidGettersAndSetters(), hasValidBeanHashCode(), hasValidBeanToString())); 228 | 229 | } 230 | 231 | } 232 | -------------------------------------------------------------------------------- /src/test/java/eu/europa/ec/dgc/verifier/service/TrustedIssuerDownloadServiceImplTest.java: -------------------------------------------------------------------------------- 1 | package eu.europa.ec.dgc.verifier.service; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.junit.jupiter.api.Assertions; 7 | import org.junit.jupiter.api.Test; 8 | import org.mockito.Mockito; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.boot.test.context.SpringBootTest; 11 | import org.springframework.boot.test.mock.mockito.MockBean; 12 | import org.springframework.test.context.TestPropertySource; 13 | 14 | import eu.europa.ec.dgc.gateway.connector.DgcGatewayDownloadConnector; 15 | import eu.europa.ec.dgc.gateway.connector.DgcGatewayTrustedIssuerDownloadConnector; 16 | import eu.europa.ec.dgc.gateway.connector.model.TrustedIssuer; 17 | import eu.europa.ec.dgc.verifier.entity.TrustedIssuerEntity; 18 | import eu.europa.ec.dgc.verifier.repository.TrustedIssuerRepository; 19 | import eu.europa.ec.dgc.verifier.testdata.TrustedIssuerTestHelper; 20 | 21 | 22 | @SpringBootTest 23 | @TestPropertySource(properties = {"dgc.trustedIssuerDownloader.enabled=true"}) 24 | class TrustedIssuerDownloadServiceImplTest { 25 | 26 | @MockBean 27 | DgcGatewayDownloadConnector dgcGatewayDownloadConnectorMock; 28 | 29 | @MockBean 30 | DgcGatewayTrustedIssuerDownloadConnector dgcGatewayDownloadConnector; 31 | 32 | 33 | @Autowired 34 | TrustedIssuerDownloadServiceImpl trustedIssuerDownloadService; 35 | 36 | @Autowired 37 | TrustedIssuerRepository trustedIssuerRepository; 38 | 39 | @Autowired 40 | TrustedIssuerTestHelper trustedIssuerTestHelper; 41 | 42 | @Test 43 | void downloadEmptyIssuerList() { 44 | ArrayList trustList = new ArrayList<>(); 45 | Mockito.when(dgcGatewayDownloadConnector.getTrustedIssuers()).thenReturn(trustList); 46 | 47 | trustedIssuerDownloadService.downloadTrustedIssuers(); 48 | 49 | List repositoryItems = trustedIssuerRepository.findAll(); 50 | Assertions.assertEquals(0, repositoryItems.size()); 51 | } 52 | 53 | @Test 54 | void downloadIssuers() { 55 | List trustedIssuers = trustedIssuerTestHelper.getTrustedIssuerList(); 56 | 57 | Mockito.when(dgcGatewayDownloadConnector.getTrustedIssuers()).thenReturn(trustedIssuers); 58 | 59 | trustedIssuerDownloadService.downloadTrustedIssuers(); 60 | 61 | List repositoryItems = trustedIssuerRepository.findAll(); 62 | Assertions.assertEquals(1, repositoryItems.size()); 63 | 64 | TrustedIssuer trustedIssuer = trustedIssuers.get(0); 65 | 66 | TrustedIssuerEntity repositoryItem = repositoryItems.get(0); 67 | Assertions.assertEquals(trustedIssuer.getCountry(), repositoryItem.getCountry()); 68 | Assertions.assertEquals(trustedIssuer.getKeyStorageType(), repositoryItem.getKeyStorageType()); 69 | Assertions.assertEquals(trustedIssuer.getName(), repositoryItem.getName()); 70 | Assertions.assertEquals(trustedIssuer.getSignature(), repositoryItem.getSignature()); 71 | Assertions.assertEquals(trustedIssuer.getThumbprint(), repositoryItem.getThumbprint()); 72 | Assertions.assertEquals(trustedIssuer.getSslPublicKey(), repositoryItem.getSslPublicKey()); 73 | Assertions.assertEquals(trustedIssuer.getUrl(), repositoryItem.getUrl()); 74 | Assertions.assertEquals(trustedIssuer.getType().toString(), repositoryItem.getUrlType().toString()); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/test/java/eu/europa/ec/dgc/verifier/testdata/SignerInformationTestHelper.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * ---license-start 3 | * eu-digital-green-certificates / dgca-verifier-service 4 | * --- 5 | * Copyright (C) 2021 T-Systems International GmbH and all other contributors 6 | * --- 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * ---license-end 19 | */ 20 | 21 | package eu.europa.ec.dgc.verifier.testdata; 22 | 23 | import eu.europa.ec.dgc.gateway.connector.model.TrustListItem; 24 | import eu.europa.ec.dgc.utils.CertificateUtils; 25 | import eu.europa.ec.dgc.verifier.entity.SignerInformationEntity; 26 | import eu.europa.ec.dgc.verifier.repository.SignerInformationRepository; 27 | import java.io.ByteArrayInputStream; 28 | import java.io.InputStream; 29 | import java.security.cert.CertificateException; 30 | import java.security.cert.CertificateFactory; 31 | import java.security.cert.X509Certificate; 32 | import java.time.ZonedDateTime; 33 | import java.util.Base64; 34 | import lombok.RequiredArgsConstructor; 35 | import org.springframework.stereotype.Service; 36 | 37 | @Service 38 | @RequiredArgsConstructor 39 | public class SignerInformationTestHelper { 40 | 41 | public static final String TEST_CERT_1_STR = 42 | "MIICrDCCAZSgAwIBAgIEYH+7ujANBgkqhkiG9w0BAQsFADAYMRYwFAYDVQQDDA1l" 43 | + "ZGdjX2Rldl90ZXN0MB4XDTIxMDQyMTA1NDQyNloXDTIyMDQyMTA1NDQyNlowGDEW" 44 | + "MBQGA1UEAwwNZWRnY19kZXZfdGVzdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC" 45 | + "AQoCggEBAOAlpphOE0TH2m+jU6prmP1W6N0ajaExs5X+sxxG58hIGnZchxFkLkeY" 46 | + "SZqyC2bPQtPiYIDgVFcPJPgfRO4r5ex3W7OxQCFS0TJmYhRkLiVQHQDNHeXFmOpu" 47 | + "834x2ErPJ8AK2D9KhVyFKl5OX1euU25IXzXs67vQf30eStArvWFlZGX4E+JUy8yI" 48 | + "wrR6WLRe+kgtBdFmJZJywbnnffg/5WT+TEcky8ugBlsEcyTxI5rt6iW5ptNUphui" 49 | + "8ZGaE2KtjcnZVaPCvn1IjEv6sdWS/DNDlFySuJ6LQD1OnKsjCXrNVZFVZS5ae9sn" 50 | + "Pu4Y/gapzdgeSDioRk6BWwZ02E9BE+8CAwEAATANBgkqhkiG9w0BAQsFAAOCAQEA" 51 | + "pE8H9uGtB6DuDL3LEqGslyJKyc6EBqJ+4hDlFtPe+13xEDomJsNwq1Uk3p9F1aHg" 52 | + "qqXc1MjJfDWn0l7ZDGh02tfi+EgHyV2vrfqZwXm6vuK/P7fzdb5blLJpKt0NoMCz" 53 | + "Y+lHhkCxcRGX1R8QOGuuGtnepDrtyeTuoQqsh0mdcMuFgKuTr3c3kKpoQwBWquG/" 54 | + "eZ0PhKSkqXy5aEaFAzdXBLq/dh4zn8FVx+STSpKK1WNmoqjtL7EEFcNgxLTjWJFj" 55 | + "usTEZL0Yxa4Ot4Gb6+VK7P34olH7pFcBFYfh6DyOESV9uglrE4kdOQ7+x+yS5zR/" 56 | + "UTeEfM4mW4I2QIEreUN8Jg=="; 57 | 58 | public static final String TEST_CERT_1_KID = "8xYtW2837ac="; 59 | 60 | public static final String TEST_CERT_2_STR = 61 | "MIIBGzCBwqADAgECAgRggUObMAoGCCqGSM49BAMCMBYxFDASBgNVBAMMC2VkZ2Nf" 62 | + "ZGV2X2VjMB4XDTIxMDQyMjA5MzYyN1oXDTIyMDQyMjA5MzYyN1owFjEUMBIGA1UE" 63 | + "AwwLZWRnY19kZXZfZWMwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAAQVQc9JY190" 64 | + "s/Jn0CBSq/AWuxmqUzRVu+AsCe6gfbqk3s0e4jonzp5v/5IMW/9t7v5Fu2ITMmOT" 65 | + "VfKL1TuM+aixMAoGCCqGSM49BAMCA0gAMEUCIQCGWIk6ZET3afRxdpFVuXdrEYtF" 66 | + "iR1MGDx4HweZfspjSgIgBdCJsT746/FI3euIbzKDoeY65m+Qx2/4Cd/vOayNbuw="; 67 | 68 | public static final String TEST_CERT_2_KID = "EzVuT0kOpJc="; 69 | 70 | public static final String TEST_CERT_3_STR = 71 | "MIIDqDCCAhCgAwIBAgIEYIFDEjANBgkqhkiG9w0BAQsFADAWMRQwEgYDVQQDDAtl" 72 | + "ZGdjX2Rldl9kZTAeFw0yMTA0MjIwOTM0MTBaFw0yMjA0MjIwOTM0MTBaMBYxFDAS" 73 | + "BgNVBAMMC2VkZ2NfZGV2X2RlMIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKC" 74 | + "AYEAt1aoSm/JB7qth70XBPR4avb1wcKHpBLFBDZIZnHzKYWvIy6JIXgd342tK825" 75 | + "0jOJ5UC1SVJdtAckWEkV5HYQ3qJ7qr6booEQzK64lLSk6oimjOnnIOFWEIrPPqW+" 76 | + "nQFOyw96opf6ISiyVvUipJVFuQC2RE3Ci/yKGBO7LeMQi2FDw+edo4/HtsmJlkEz" 77 | + "8JxnCniwjTRCnRGNAs7YXMlrwcCcyIarDtxbdbcwm/6WpuOnj8MzTAAUXQ+SeFOq" 78 | + "MlvUosKxL34nJ7liHySu6uuGCopFSvuRh3yIuwAqeufGVKBfoiJkrtsn+AB/Q/kP" 79 | + "XpPR7Dk2NybbJX3g+dh2ok08zpbVcYBRrtITXPZIQvLuZXMd1CUnNz0aOWNAxT6P" 80 | + "v4R4ROavuQcjJR785mspCovqXCy8SpD4JHs+HxYqE7RTWzd3j4HmPf7NuWMnlH04" 81 | + "J2h10V/EffHu65+wQ4s9dMCRLttOBScV6EAgRLoCt11tvc8XUxzI0yq17YntZDr2" 82 | + "1SjJAgMBAAEwDQYJKoZIhvcNAQELBQADggGBABIWLWx/RQ3WQoHXmbLhkTTtM2b3" 83 | + "Q/TZCXz5ZB89l/CrTeLQ+hy5pYv5HUTz00JnikyxbfVwsNhfVRMYm0NVJf6WWqHB" 84 | + "OIk9MKAxksJ49QFHdL2sW4Vm5XhGy2FDaEgtx58q3koNHY9e5FyOcEZcXo2+eXKO" 85 | + "bOsj80RJV5aj53SWY3Si+sq9iJMGYghskaEs/rnWn65ullbUKuC1+vkOV3qfFPKo" 86 | + "CxeHlmGzdokRzbVKtXjDqb/edRX6I4k7laZ0+irFQqftvkaMHVEf13nXTIgQ9rpp" 87 | + "+JQ0Y2pWSLPnWf/dah/D0/NmwI6E6V5+9U6i73RcalGw97gfyorMkYFFE8ByLdfp" 88 | + "n76oTgJaXN/CQDLm2yzOX/ynt4t0ycqcVYrzewiKY2Fpnhao4U00vrh+0lwdUFr3" 89 | + "jpOMeNg/2UDYhpWwWiT1ik+D6PSfKQ7Amuph6VcYEy/grQxNxPWcghoZSVKdXhOz" 90 | + "6ggdK/eFNlO1aYj/DLxV3ZWcrAYk6dS4rnn8Ow=="; 91 | 92 | public static final String TEST_CERT_3_KID = "zoQi+KTb8LM="; 93 | 94 | private final SignerInformationRepository signerInformationRepository; 95 | private final CertificateUtils certificateUtils; 96 | 97 | private X509Certificate convertStringToX509Cert(String certificate) throws CertificateException { 98 | InputStream targetStream = new ByteArrayInputStream(Base64.getDecoder().decode(certificate)); 99 | return (X509Certificate) CertificateFactory 100 | .getInstance("X509") 101 | .generateCertificate(targetStream); 102 | } 103 | 104 | public Long insertCertString(String certStr) { 105 | String kid; 106 | try { 107 | kid = certificateUtils.getCertKid(convertStringToX509Cert(certStr)); 108 | }catch (CertificateException e) { 109 | kid = "kid_"+ ZonedDateTime.now(); 110 | } 111 | 112 | SignerInformationEntity cert = new SignerInformationEntity( 113 | null, 114 | kid, 115 | ZonedDateTime.now(), 116 | certStr, 117 | "de", 118 | "thumbprint", 119 | ZonedDateTime.now(), 120 | false 121 | ); 122 | 123 | signerInformationRepository.save(cert); 124 | 125 | return cert.getId(); 126 | } 127 | 128 | public Long insertCertString(String certStr, String country, 129 | String thumbprint, ZonedDateTime date, boolean deleted) { 130 | String kid; 131 | try { 132 | kid = certificateUtils.getCertKid(convertStringToX509Cert(certStr)); 133 | }catch (CertificateException e) { 134 | kid = "kid_"+ ZonedDateTime.now(); 135 | } 136 | 137 | SignerInformationEntity cert = new SignerInformationEntity( 138 | null, 139 | kid, 140 | ZonedDateTime.now(), 141 | certStr, 142 | country, 143 | thumbprint, 144 | date, 145 | deleted 146 | ); 147 | 148 | signerInformationRepository.save(cert); 149 | 150 | return cert.getId(); 151 | } 152 | 153 | public TrustListItem createTrustListItem(String certStr) { 154 | String kid; 155 | try { 156 | kid = certificateUtils.getCertKid(convertStringToX509Cert(certStr)); 157 | }catch (CertificateException e) { 158 | kid = "kid_"+ ZonedDateTime.now(); 159 | } 160 | 161 | TrustListItem item = new TrustListItem(); 162 | item.setKid(kid); 163 | item.setTimestamp(ZonedDateTime.now()); 164 | item.setRawData(certStr); 165 | 166 | return item; 167 | } 168 | } 169 | -------------------------------------------------------------------------------- /src/test/java/eu/europa/ec/dgc/verifier/testdata/TrustedIssuerTestHelper.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * ---license-start 3 | * eu-digital-green-certificates / dgca-verifier-service 4 | * --- 5 | * Copyright (C) 2021 T-Systems International GmbH and all other contributors 6 | * --- 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * ---license-end 19 | */ 20 | 21 | package eu.europa.ec.dgc.verifier.testdata; 22 | 23 | import java.time.ZonedDateTime; 24 | import java.util.ArrayList; 25 | import java.util.List; 26 | 27 | import org.springframework.beans.factory.annotation.Autowired; 28 | import org.springframework.stereotype.Service; 29 | 30 | import eu.europa.ec.dgc.gateway.connector.model.TrustedIssuer; 31 | import eu.europa.ec.dgc.verifier.entity.TrustedIssuerEntity; 32 | import eu.europa.ec.dgc.verifier.repository.TrustedIssuerRepository; 33 | import lombok.RequiredArgsConstructor; 34 | 35 | @Service 36 | @RequiredArgsConstructor 37 | public class TrustedIssuerTestHelper { 38 | 39 | @Autowired 40 | TrustedIssuerRepository trustedIssuerRepository; 41 | 42 | 43 | public TrustedIssuerEntity getIssuer(int number) { 44 | TrustedIssuerEntity issuer = new TrustedIssuerEntity(); 45 | 46 | switch (number) { 47 | case 1: 48 | issuer.setEtag("TestEtag"); 49 | issuer.setCreatedAt(ZonedDateTime.parse("2022-04-04T02:21:00Z")); 50 | issuer.setCountry("DE"); 51 | issuer.setUrl("https://TestUrl.de"); 52 | issuer.setName("example1.de"); 53 | issuer.setUrlType(TrustedIssuerEntity.UrlType.HTTP); 54 | issuer.setThumbprint("thumbprint1"); 55 | issuer.setSslPublicKey("PublicKey1"); 56 | issuer.setKeyStorageType("JWKS"); 57 | issuer.setSignature("Signature1"); 58 | return issuer; 59 | 60 | case 2: 61 | issuer.setEtag("TestEtag"); 62 | issuer.setCreatedAt(ZonedDateTime.parse("2022-04-03T03:33:00Z")); 63 | issuer.setCountry("DE"); 64 | issuer.setUrl("https://TestUrl2.de"); 65 | issuer.setName("example2.de"); 66 | issuer.setUrlType(TrustedIssuerEntity.UrlType.HTTP); 67 | issuer.setThumbprint("thumbprint2"); 68 | issuer.setSslPublicKey("PublicKey2"); 69 | issuer.setKeyStorageType("JWKS"); 70 | issuer.setSignature("Signature2"); 71 | break; 72 | default: 73 | issuer.setEtag("TestEtag"); 74 | issuer.setCreatedAt(ZonedDateTime.parse("2022-04-03T03:33:00Z")); 75 | issuer.setCountry("DE"); 76 | issuer.setUrl("https://TestUrlDefault.de"); 77 | issuer.setName("exampleDefault.de"); 78 | issuer.setUrlType(TrustedIssuerEntity.UrlType.HTTP); 79 | issuer.setThumbprint("thumbprintDefault"); 80 | issuer.setSslPublicKey("PublicKeyDefault"); 81 | issuer.setKeyStorageType("JWKS"); 82 | issuer.setSignature("SignatureDefault"); 83 | break; 84 | } 85 | 86 | return issuer; 87 | 88 | } 89 | 90 | 91 | public void insertTrustedIssuer(TrustedIssuerEntity issuer) { 92 | trustedIssuerRepository.save(issuer); 93 | } 94 | 95 | 96 | public List getTrustedIssuerList() { 97 | List list = new ArrayList<>(); 98 | 99 | TrustedIssuer issuer = new TrustedIssuer(); 100 | issuer.setCountry("DE"); 101 | issuer.setUrl("https://ministry-of-health.country-de.de/.well-known/jwks.json"); 102 | issuer.setType(TrustedIssuer.UrlType.HTTP); 103 | issuer.setThumbprint("8e5b84a5c807f8661e470453119830f2ec27971fce4a3420bb744bad66e5bf4c"); 104 | issuer.setSslPublicKey("MHcCAQEEICdvyZFxcPenETpnkmMf8m7te73UE6olhUB72OpIuGRpoAoGCCqGSM49AwEHoUQDQgAE7ni62sNPT7" 105 | + "02PoVkwd8+oCJMkDjht8gcFVGSgYNmjUFDXjKuLK/IVl87xQ5G8zNTbIMllwD1JJZB9LElhFb3JA=="); 106 | issuer.setKeyStorageType("JWKS"); 107 | issuer.setSignature("MIAGCSqGSIb3DQEHAqCAMIACAQExDTALBglghkgBZQMEAgEwgAYJKoZIhvcNAQcBAACggDCCBX0wggNloAMCAQICF" 108 | + "CfArZMSPZ2iPmF85n5LHsj4D5XgMA0GCSqGSIb3DQEBCwUAME4xCzAJBgNVBAYTAkVVMRcwFQYDVQQIDA5FdXJvcGVhbiBVbmlvbjEU" 109 | + "MBIGA1UECgwLVHJ1c3RBbmNob3IxEDAOBgNVBAsMB1RTVCBFTlYwHhcNMjEwNDIyMDgxNTIyWhcNMzEwNDIwMDgxNTIyWjBOMQswCQY" 110 | + "DVQQGEwJFVTEXMBUGA1UECAwORXVyb3BlYW4gVW5pb24xFDASBgNVBAoMC1RydXN0QW5jaG9yMRAwDgYDVQQLDAdUU1QgRU5WMIICIj" 111 | + "ANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA13sh56S2sRAwnS4TCKci0UHGFC1/GxptcaAow2jznzRaJyz7k6oghedDzibFZREen" 112 | + "g3cO+pw4XpNO8SiWK8w8fipE9TOkbWBNP8cij/yWj+jfyZvVCPY8eXyS5okzS2PNN2lPswdiB5m5BkuXcm8I8d0fgi4bTzT3lwtxlRo" 113 | + "JZo6LVMFjI/sB3LTYsMiL/OnYozpQWf7Cd6wLJI3c9IiQWFH40dGFFwtdQifDWPjOj9iwMASeCarqtOpNhpkn1ZxCDmqPj1mPqreLdq" 114 | + "2RCbzrdvuFRs8KsIrjzJFCcBACPzQeP0jFijPhMa9p8BLSwCrlZOz7OEASPqWDstOqBazTUYBvcwGnP2ZcBuXKUS+lN9V+r37J4ANb/" 115 | + "OpM+iZuPUURxf7OxPa+0INauy6OD8018OleL4svS+8tQadT4G9Nbr/2JqFfqat0FVhaZxQHEyLgQdt70wX1BOctgbCKlGQKBuLMyvyT" 116 | + "wUJ6Qd0IKxmzFbOVfe+AWHb+V+x8oBpAo+vhS6OCaFuB8dIma1pgf6JP6kfmBERvm8n7158q92ZfGebzhSDhbsuB6Gaj0Ew5qJ/kdzQ" 117 | + "rZP5QywHZQ8mEum7JR8rygPEEXDRhdtn3CHIDWEt0we+hGU2GchHOrZwMenQKMdxWnNr5/4M6WobefnOk+t2t4aF1ceWd8nXvK2j1l8" 118 | + "CAwEAAaNTMFEwHQYDVR0OBBYEFK9nb1NMVv4ZzXG7A2alSueXrLBQMB8GA1UdIwQYMBaAFK9nb1NMVv4ZzXG7A2alSueXrLBQMA8GA1" 119 | + "UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQADggIBAEujCHeHgcqBFeKvt9bAsEDB1QH19+kcd2TdW87GWlA+sYPM3ARwSy5E7JbYj" 120 | + "yk0pZ/XbDi6qC+CE8OgOyWQaj9CELEZCktXZsdGvOs9dKJd5yf97CLDT9EMp2284Ek67VWp5wqqa1+B6xGTg5r8a0OCNrCR04siQNoQ" 121 | + "3pq669hQfhmg5iR0sz4JZrgUL6LIukrd5b/kDvaP37xh8gUrYLX5ApdQFuX41FiP/zcwC4/LG4llsAfYw2lh9ZhXqj3VW8SCayYeJ/O" 122 | + "ExQLM8sHCxJ5NMHoXEvlOjoz+X3/Jib7GHIb0z70EaA8BN6KQ8YPcm+U6sgrjsj501WNAz2GA7ji5Iv/Pet5HGZsYNsDYZSWspe5hbc" 123 | + "Buc271sVbofLkIXxS8l1mVyhJYj4G+X2DWU3RDoQE+XN8wUdYXcrnKlpp8BKQTOxjofp5xnymCq5GXO50+K1C/tqHjCP1aiir2V1Sb1" 124 | + "SumgFoJ10bJXCaqCtUX1/7U7f9lGLirAhgN26s4T13hp+8X1D2hMxfo0w/w90fvtcxfSxutoMwwyU917JtPO/8TA+rE07MbnS0SVsYI" 125 | + "Pg+CVPBHV2jSa1ZVSSsVhJSteG6Hs971ci3kgo4rN/ukosBycylzjBLXBnWfWYAoMb3YoNs1jQJnSyll+N2WxX7vHkKwPrh7OpI9yh+" 126 | + "IEOnYAAAxggMoMIIDJAIBATBmME4xCzAJBgNVBAYTAkVVMRcwFQYDVQQIDA5FdXJvcGVhbiBVbmlvbjEUMBIGA1UECgwLVHJ1c3RBbm" 127 | + "Nob3IxEDAOBgNVBAsMB1RTVCBFTlYCFCfArZMSPZ2iPmF85n5LHsj4D5XgMAsGCWCGSAFlAwQCAaCBljAYBgkqhkiG9w0BCQMxCwYJK" 128 | + "oZIhvcNAQcBMBwGCSqGSIb3DQEJBTEPFw0yMjAzMjUxMTE3MzRaMCsGCSqGSIb3DQEJNDEeMBwwCwYJYIZIAWUDBAIBoQ0GCSqGSIb3" 129 | + "DQEBCwUAMC8GCSqGSIb3DQEJBDEiBCDRX6mP3IuhUUd3UlbOhbuPYgXXjxeGv+F6IlfEC1aeRTANBgkqhkiG9w0BAQsFAASCAgC23Mz" 130 | + "bNZgXilk+NjuGPfbqQM2veffsKdA0Ln89ODg7Bjtjc0UKTpIQj/o8K9xR/xLkANxM+jLr1v4ya7CUwG9fCde0lqxozSl/j4+P+9Ir82" 131 | + "yTDO7AgT0tNpYI+Pa1NzIlRNgqiTVfEg+AmaKLHkg/SJaDa3KxMslkaeQrUwGqaWBLbaMjQFzk/S92s+uRl00At04peXClb87ml6qlO" 132 | + "BEipjzpcmz/pJPXctBJ38rLSaWyId+Gi+2z5xyClP3N5xUBumVNJZQvkE21cxggUw9CF7m7TPl6O3+6pbkW5ZLrDPOYvGMVH2XYkIJN" 133 | + "AsxEnJSOIEhCAF2PWaKQ5A2ioHOpEvO7Ao2XHxHYZviH66dibxz1tZKe+lxdn65wChfHimvgmu3qyEVjAW3DcHBK8Vs4vB5xdBcx9Q8" 134 | + "1tES/w/Q5ML4rIXKHv6aWlg5cpLuxY6q/T39AxxHnn7CZfIhj+A7kFQGQzy98qRj/qUDgTGF2VoEVX5hDRpkINZhStsW5pTVWtppLVc" 135 | + "CLn7L67FKp8pj8z1S5XY/5akbflY0NPy/a9u71aVHPA+O3RaOlNKG9ZzIKBjApdoDuEEabhwmUmqxbtPhKOSklhv0qOJ1rvuMZLCOha" 136 | + "S1u3C1KyLok+6WI0oSr+hnLwzR69j9Mcfrq98HjvYpmZgSgOKaRe4XsKIBpNQAAAAAAAA=="); 137 | 138 | issuer.setTimestamp(ZonedDateTime.parse("2022-03-25T12:14:49+01:00")); 139 | issuer.setName("example-de"); 140 | issuer.setDomain("domain"); 141 | issuer.setUuid("b446e0e1-ff8b-45a0-8da0-303caa533ae5"); 142 | 143 | list.add(issuer); 144 | return list; 145 | } 146 | 147 | 148 | } 149 | -------------------------------------------------------------------------------- /src/test/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8080 3 | 4 | spring: 5 | application: 6 | name: dgca-verifier-service 7 | datasource: 8 | driver-class-name: org.h2.Driver 9 | url: jdbc:h2:mem:dgc;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=-1; 10 | username: sa 11 | password: '' 12 | jpa: 13 | database-platform: org.hibernate.dialect.H2Dialect 14 | hibernate: 15 | ddl-auto: create-drop 16 | liquibase: 17 | change-log: classpath:db/changelog.xml 18 | h2: 19 | console: 20 | enabled: true 21 | path: /h2-console 22 | profiles: 23 | active: 24 | - test 25 | main: 26 | allow-bean-definition-overriding: true 27 | dgc: 28 | synchroniseCertificates: 29 | timeInterval: 60000 30 | lockLimit: 1800000 31 | trustedIssuerDownloader: 32 | enabled: false 33 | timeInterval: 60000 34 | lockLimit: 1800000 35 | gateway: 36 | connector: 37 | enabled: false 38 | springdoc: 39 | api-docs: 40 | path: /api/docs 41 | swagger-ui: 42 | path: /swagger 43 | 44 | -------------------------------------------------------------------------------- /templates/file-header.txt: -------------------------------------------------------------------------------- 1 | /*- 2 | * ---license-start 3 | * eu-digital-green-certificates / dgca-verifier-service 4 | * --- 5 | * Copyright (C) 2021 T-Systems International GmbH and all other contributors 6 | * --- 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * ---license-end 19 | */ 20 | --------------------------------------------------------------------------------