diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0401cd78..541735a6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,67 +1,57 @@ name: Build and deploy - on: [push] + jobs: build: - runs-on: ubuntu-latest strategy: matrix: - java: [ '8', '11' ] - - name: build java ${{ matrix.java }} + java: [ '8', '17' ] + name: Build on Java ${{ matrix.java }} + runs-on: ubuntu-latest + env: + MAVEN_ARGS: --show-version --no-transfer-progress steps: - uses: actions/checkout@v3 - - uses: actions/setup-java@v3.6.0 + - uses: actions/setup-java@v3 with: distribution: temurin java-version: ${{ matrix.java }} cache: "maven" - name: Build with Maven - run: mvn -B clean verify --no-transfer-progress --show-version + run: mvn verify + - makeversion: - if: github.ref != 'refs/heads/main' + publishing_parameters: needs: build + name: Publishing parameters runs-on: ubuntu-latest - name: Create version outputs: + is_release: ${{ steps.version.outputs.is_release }} version: ${{ steps.version.outputs.version }} steps: - - name: Decide on build version + - name: Determine version id: version run: | if [[ $GITHUB_REF == *"tags"* ]]; then - TAG=${GITHUB_REF#refs/tags/} + is_release=true + version=${GITHUB_REF#refs/tags/} else - TAG=${GITHUB_REF#refs/heads/}-SNAPSHOT + is_release=false + version=${GITHUB_REF#refs/heads/}-SNAPSHOT fi - echo ::set-output name=version::${TAG//\//-} - deploy_snapshot: - if: startsWith(github.ref, 'refs/heads/') - needs: makeversion - runs-on: ubuntu-latest + echo "is_release=${is_release//\//-}" >> $GITHUB_OUTPUT + echo "version=${version//\//-}" >> $GITHUB_OUTPUT - name: Deploy snapshot - steps: - - uses: actions/checkout@v1 - - uses: digipost/action-maven-publish@1.3.2 - with: - sonatype_secrets: ${{ secrets.sonatype_secrets }} - release_version: ${{ needs.makeversion.outputs.version }} - perform_release: false - release: - if: startsWith(github.ref, 'refs/tags/') + publish: + needs: publishing_parameters + name: Publish ${{ needs.publishing_parameters.outputs.version }} runs-on: ubuntu-latest - needs: makeversion - name: Release to Sonatype steps: - - name: Check out Git repository - uses: actions/checkout@v1 - - name: Release to Central Repository - uses: digipost/action-maven-publish@1.3.2 + - uses: actions/checkout@v3 + - uses: digipost/action-maven-publish@v1 with: sonatype_secrets: ${{ secrets.sonatype_secrets }} - release_version: ${{ needs.makeversion.outputs.version }} - perform_release: true + release_version: ${{ needs.publishing_parameters.outputs.version }} + perform_release: ${{ needs.publishing_parameters.outputs.is_release }} diff --git a/.mvn/maven.config b/.mvn/maven.config index 0db77b80..8c7b1295 100644 --- a/.mvn/maven.config +++ b/.mvn/maven.config @@ -1 +1 @@ --P build-sources-and-javadoc +-P build-sources-and-javadoc,dependency-analyze,check-license-header,include-NOTICE diff --git a/NOTICE b/NOTICE index 2e6d1596..fbf59c21 100644 --- a/NOTICE +++ b/NOTICE @@ -8,9 +8,12 @@ Licensed under Apache 2 - http://www.apache.org/licenses/LICENSE-2.0.html This software includes third party software subject to the following licenses: - Jakarta Activation API jar under EDL 1.0 - Jakarta XML Binding API under Eclipse Distribution License - v 1.0 + Digipost JAXB Resolver - com.sun.xml.bind under The Apache Software License, Version 2.0 + JavaBeans Activation Framework API jar under CDDL/GPLv2+CE + jaxb-api under CDDL 1.1 or GPL2 w/ CPE JAXB2 Basics - Runtime under BSD-Style License + Old JAXB Core under CDDL+GPL License + Old JAXB Runtime under Eclipse Distribution License - v 1.0 Posten signering - API JAXB Classes under The Apache Software License, Version 2.0 Posten signering - API Schema under The Apache Software License, Version 2.0 Posten signering - API Specification under The Apache Software License, Version 2.0 diff --git a/jaxb/NOTICE b/jaxb/NOTICE index 61ad5bce..d1ea46fd 100644 --- a/jaxb/NOTICE +++ b/jaxb/NOTICE @@ -8,9 +8,12 @@ Licensed under Apache 2 - http://www.apache.org/licenses/LICENSE-2.0.html This software includes third party software subject to the following licenses: - Jakarta Activation API jar under EDL 1.0 - Jakarta XML Binding API under Eclipse Distribution License - v 1.0 + Digipost JAXB Resolver - com.sun.xml.bind under The Apache Software License, Version 2.0 + JavaBeans Activation Framework API jar under CDDL/GPLv2+CE + jaxb-api under CDDL 1.1 or GPL2 w/ CPE JAXB2 Basics - Runtime under BSD-Style License + Old JAXB Core under CDDL+GPL License + Old JAXB Runtime under Eclipse Distribution License - v 1.0 Posten signering - API JAXB Classes under The Apache Software License, Version 2.0 diff --git a/jaxb/pom.xml b/jaxb/pom.xml index d7223256..dbe78a48 100644 --- a/jaxb/pom.xml +++ b/jaxb/pom.xml @@ -1,4 +1,21 @@ + 4.0.0 @@ -14,7 +31,6 @@ ${project.basedir}/target/generated-resources/xsd - set_with_-Dproject.previousVersion=X.Y @@ -26,20 +42,25 @@ pom import + + no.digipost + jaxb-resolver-com.sun.xml.bind-bom + 1.0 + pom + import + - jakarta.xml.bind - jakarta.xml.bind-api - 2.3.3 + javax.xml.bind + jaxb-api - org.glassfish.jaxb - jaxb-runtime - 2.3.8 - test + no.digipost + jaxb-resolver-com.sun.xml.bind + runtime org.jvnet.jaxb2_commons @@ -111,6 +132,12 @@ 2.0.6 test + + no.digipost + jul-to-slf4j-junit-extension + 1.0 + test + @@ -125,59 +152,16 @@ maven-javadoc-plugin 3.5.0 - no.digipost.signature.api.xml.* false all,-missing,-html - - org.jasig.maven - maven-notice-plugin - - ${project.basedir}/../src/notice/NOTICE.template - - - - com.github.siom79.japicmp - japicmp-maven-plugin - 0.17.1 - - - - ${project.groupId} - ${project.artifactId} - ${project.previousVersion} - - - - - ${project.build.directory}/${project.build.finalName}.${project.packaging} - - - - true - true - - no.digipost.signature - - - - maven-dependency-plugin - - - analyze-only - - - true - true - - unpack-xsd-resources initialize diff --git a/jaxb/src/main/java/no/digipost/signature/jaxb/JaxbMarshaller.java b/jaxb/src/main/java/no/digipost/signature/jaxb/JaxbMarshaller.java index dfcabe6b..06a24a33 100644 --- a/jaxb/src/main/java/no/digipost/signature/jaxb/JaxbMarshaller.java +++ b/jaxb/src/main/java/no/digipost/signature/jaxb/JaxbMarshaller.java @@ -16,6 +16,7 @@ package no.digipost.signature.jaxb; import no.digipost.signature.xsd.SignatureApiSchemas; +import org.w3c.dom.Document; import org.xml.sax.InputSource; import org.xml.sax.XMLReader; @@ -27,6 +28,7 @@ import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; import javax.xml.transform.Source; +import javax.xml.transform.dom.DOMResult; import javax.xml.transform.sax.SAXSource; import javax.xml.validation.Schema; import javax.xml.validation.SchemaFactory; @@ -191,11 +193,17 @@ public byte[] marshalToBytes(Object object) { return marshalToResult(object, ByteArrayOutputStream::toByteArray); } - @FunctionalInterface - private interface ThrowingFunction { - R apply(T t) throws Exception; + public Document marshalToDomDocument(Object object) { + DOMResult domResult = new DOMResult(); + doWithMarshaller(object, (o, marshaller) -> marshaller.marshal(o, domResult)); + return (Document) domResult.getNode(); } + public void marshal(Object object, OutputStream outputStream) { + doWithMarshaller(object, (o, marshaller) -> marshaller.marshal(o, outputStream)); + } + + private R marshalToResult(Object object, ThrowingFunction outputStreamMapper) { try (ByteArrayOutputStream xmlOutputStream = new ByteArrayOutputStream(128)) { marshal(object, xmlOutputStream); @@ -207,29 +215,43 @@ private R marshalToResult(Object object, ThrowingFunction { + R apply(T t) throws Exception; + } - public void marshal(Object object, OutputStream outputStream) { + @FunctionalInterface + private interface ThrowingBiConsumer { + void accept(T t, S s) throws Exception; + } + + private void doWithMarshaller(T object, ThrowingBiConsumer operation) { try { Marshaller marshaller = jaxbContext.createMarshaller(); schema.ifPresent(marshaller::setSchema); - marshaller.marshal(object, outputStream); + operation.accept(object, marshaller); } catch (Exception e) { throw SignatureMarshalException.failedMarshal(object, e); } } + public T unmarshal(InputStream inputStream, Class type) { + return unmarshal(unmarshaller -> unmarshaller.unmarshal(inputStream), type); + } + + public T unmarshal(byte[] bytes, Class type) { + return unmarshal(new ByteArrayInputStream(bytes), type); + } + + private T unmarshal(ThrowingFunction operation, Class type) { try { Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); schema.ifPresent(unmarshaller::setSchema); - return type.cast(unmarshaller.unmarshal(inputStream)); + return type.cast(operation.apply(unmarshaller)); } catch (Exception e) { throw SignatureMarshalException.failedUnmarshal(type, e); } } - public T unmarshal(byte[] bytes, Class type) { - return unmarshal(new ByteArrayInputStream(bytes), type); - } - } diff --git a/jaxb/src/main/java/no/digipost/signature/jaxb/SignatureMarshalling.java b/jaxb/src/main/java/no/digipost/signature/jaxb/SignatureMarshalling.java index 1a7d77eb..49dfb6ab 100644 --- a/jaxb/src/main/java/no/digipost/signature/jaxb/SignatureMarshalling.java +++ b/jaxb/src/main/java/no/digipost/signature/jaxb/SignatureMarshalling.java @@ -40,7 +40,6 @@ /** * Different sets of classes to be bound by a {@link javax.xml.bind.JAXBContext JAXB context} in order to * create marshallers and unmarshallers. All the sets are immutable. - *

*/ public final class SignatureMarshalling { diff --git a/jaxb/src/test/resources/junit-platform.properties b/jaxb/src/test/resources/junit-platform.properties new file mode 100644 index 00000000..adc88348 --- /dev/null +++ b/jaxb/src/test/resources/junit-platform.properties @@ -0,0 +1,17 @@ +# +# Copyright (C) Posten Norge AS +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# 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 for the specific language governing permissions and +# limitations under the License. +# + +junit.jupiter.extensions.autodetection.enabled=true diff --git a/jaxb/src/test/resources/simplelogger.properties b/jaxb/src/test/resources/simplelogger.properties index 8b202875..dd174bdf 100644 --- a/jaxb/src/test/resources/simplelogger.properties +++ b/jaxb/src/test/resources/simplelogger.properties @@ -14,4 +14,4 @@ # limitations under the License. # -org.slf4j.simpleLogger.defaultLogLevel=warn \ No newline at end of file +org.slf4j.simpleLogger.defaultLogLevel=warn diff --git a/pom.xml b/pom.xml index abf002bf..308a1fa8 100644 --- a/pom.xml +++ b/pom.xml @@ -1,4 +1,21 @@ + 4.0.0 @@ -6,7 +23,7 @@ no.digipost digipost-open-super-pom - 8 + 12 Posten signering - API Specification @@ -56,13 +73,15 @@ 3.2.1 - - 3.6.3 - commons-logging - com.sun.xml.bind + + jakarta.xml.bind true @@ -74,111 +93,52 @@ 3.0.0-M9 - org.jasig.maven - maven-notice-plugin - 1.1.0 - - true - - test - - ${project.basedir}/src/notice/NOTICE.template - - - - org.glassfish.jaxb - jaxb-runtime - 2.3.8 - - - jakarta.xml.bind - jakarta.xml.bind-api - 2.3.3 - - + maven-jar-plugin + 3.3.0 + + + maven-install-plugin + 3.1.0 + + + maven-deploy-plugin + 3.1.0 + + + org.codehaus.mojo + versions-maven-plugin + 2.15.0 com.mycila license-maven-plugin - 4.1 + 4.2.rc3 - true - true - true - - XML_STYLE - -

src/license-header.txt
- **/pom.xml src/validation/*.* xsd/thirdparty/*.* - xsd/catalog.xml examples/**/* - NOTICE - **/LICENSE - src/notice/NOTICE.template - src/notice/license-mappings.xml - jaxb/*.xjb - integrasjon/** - docs/** - .github/**/*.yml - .java-version - .mvn/maven.config
- maven-jar-plugin - 3.3.0 - - - maven-install-plugin - 3.1.0 - - - maven-deploy-plugin - 3.1.0 - - - org.codehaus.mojo - versions-maven-plugin - 2.15.0 + com.github.siom79.japicmp + japicmp-maven-plugin + 0.17.2 + + + + no.digipost.signature + + +
- - - org.jasig.maven - maven-notice-plugin - - - check-NOTICE-file - verify - - check - - - - - - com.mycila - license-maven-plugin - - - check-license-header - test - - check - - - - -
diff --git a/schema/pom.xml b/schema/pom.xml index 9ba886f1..71b9debe 100644 --- a/schema/pom.xml +++ b/schema/pom.xml @@ -1,4 +1,21 @@ + 4.0.0 @@ -61,13 +78,6 @@ - - org.jasig.maven - maven-notice-plugin - - ${project.basedir}/../src/notice/NOTICE.template - - diff --git a/schema/xsd/catalog.xml b/schema/xsd/catalog.xml index 79400b72..079a2928 100644 --- a/schema/xsd/catalog.xml +++ b/schema/xsd/catalog.xml @@ -1,4 +1,21 @@ + diff --git a/src/notice/NOTICE.template b/src/NOTICE.template similarity index 100% rename from src/notice/NOTICE.template rename to src/NOTICE.template