OBSOLETE!!!: ENI (3) Generating java classes from multiple schemas
0. Introduction (NOTE This is obsolete. see https://dantesquews.blogspot.com/2019/07/eni-1-eni-document-or-spanish.html)
The purpose of this post is to convert a XAdES internally detached signed document to an ENI document.The signed document contains content and signature, but ENI document has also metadata. But the schema of a XAdES document is not the same as the ENI.
I am using Gexflow from Teralco, and the metadata are stored in a database.
So it is necessary a conversion.
Several schemas are needed:
- documentoEni.xsd
- contenidoDocumentoEni.xsd
- metadatosDocumentoEni.xsd
- firmasEni.xsd
- xmldsig-core-schema.xsd
- XAdES.xsd
1. Configuring the maven project
Here is the pom.xml file with the needed resources:
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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 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 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>org.ximodante</groupId> <artifactId>Alfresco01</artifactId> <version>0.0.1-SNAPSHOT</version> <name>Alfresco01</name> <description>Alfresco01</description> <properties> <cxf.version>3.3.2</cxf.version> <!-- 3.2.6 antes --> <!-- jax.version>2.3.0</jax.version--> <!-- 2.3.0 antes --> <jaxb-imp.version>2.3.2</jaxb-imp.version> <jaxb-core.version>2.3.0.1</jaxb-core.version> <lombok.version>1.18.8</lombok.version> <!-- 1.18.4 antes --> <jackson.version>2.9.9</jackson.version> <!-- 2.9.6 antes --> <h2.version>1.4.196</h2.version> <hibernate.version>5.4.3.Final</hibernate.version> <!-- antes 5.2.16.Final --> <poi.version>4.0.1</poi.version> <failOnMissingWebXml>false</failOnMissingWebXml> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <!-- Java version--> <java.version>10</java.version> </properties> <dependencies> <!-- https://mvnrepository.com/artifact/org.apache.chemistry.opencmis/chemistry-opencmis-client-impl --> <dependency> <groupId>org.apache.chemistry.opencmis</groupId> <artifactId>chemistry-opencmis-client-impl</artifactId> <version>1.1.0</version> </dependency> <!-- https://mvnrepository.com/artifact/commons-io/commons-io --> <dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> <version>2.6</version> </dependency> <!-- https://mvnrepository.com/artifact/org.projectlombok/lombok --> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>${lombok.version}</version> <scope>provided</scope> </dependency> <!-- https://mvnrepository.com/artifact/org.postgresql/postgresql --> <dependency> <groupId>org.postgresql</groupId> <artifactId>postgresql</artifactId> <version>42.2.6</version> <!-- antes 42.1.4--> </dependency> <!-- JPA 2.1 Provider --> <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core --> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <version>${hibernate.version}</version> </dependency> <!-- 2018-03-26 Jackson Dataformat XML --> <dependency> <groupId>com.fasterxml.jackson.dataformat</groupId> <artifactId>jackson-dataformat-xml</artifactId> <version>${jackson.version}</version> </dependency> <!--See https://github.com/FasterXML/jackson-dataformat-xml for details --> <dependency> <groupId>com.fasterxml.woodstox</groupId> <artifactId>woodstox-core</artifactId> <version>5.1.0</version> </dependency> <!-- Apache commons string utils .. --> <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 --> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> <version>3.7</version> </dependency> <!-- Apache commons bean utils--> <!-- https://mvnrepository.com/artifact/commons-beanutils/commons-beanutils --> <dependency> <groupId>commons-beanutils</groupId> <artifactId>commons-beanutils</artifactId> <version>1.9.3</version> </dependency> <!--BEGIN Java 9 references to JEE not included in JDK9--> <!-- see http://openjdk.java.net/jeps/320--> <!-- https://mvnrepository.com/artifact/com.sun.xml.bind/jaxb-impl --> <dependency> <groupId>com.sun.xml.bind</groupId> <artifactId>jaxb-impl</artifactId> <!-- version>${jax.version}</version --> <version>${jaxb-imp.version}</version> </dependency> <!-- https://mvnrepository.com/artifact/com.sun.xml.bind/jaxb-core --> <dependency> <groupId>com.sun.xml.bind</groupId> <artifactId>jaxb-core</artifactId> <!-- <version>${jax.version}</version> --> <version>${jaxb-core.version}</version> </dependency> <!-- PROVES --> <!-- https://mvnrepository.com/artifact/com.sun.xml.bind/jaxb-xjc --> <dependency> <groupId>com.sun.xml.bind</groupId> <artifactId>jaxb-xjc</artifactId> <version>2.3.2</version> </dependency> <!-- https://mvnrepository.com/artifact/org.eclipse.persistence/org.eclipse.persistence.moxy --> <dependency> <groupId>org.eclipse.persistence</groupId> <artifactId>org.eclipse.persistence.moxy</artifactId> <version>2.7.4</version> </dependency> <!-- FI PROVES --> <dependency> <groupId>com.sun.activation</groupId> <artifactId>javax.activation</artifactId> <version>1.2.0</version> </dependency> <dependency> <groupId>com.sun.xml.ws</groupId> <artifactId>jaxws-ri</artifactId> <!-- version>${jax.version}</version --> <version>${jaxb-imp.version}</version> <type>pom</type> </dependency> <dependency> <groupId>com.sun.xml.bind</groupId> <artifactId>jaxb-ri</artifactId> <!-- version>${jax.version}</version --> <version>${jaxb-imp.version}</version> <type>pom</type> </dependency> <!-- End of Dependencies required for JAVA 9!!!! --> <!-- WS DEPENDENCIES --> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-frontend-jaxws</artifactId> <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-transports-http</artifactId> <version>${cxf.version}</version> </dependency> <!-- Jetty is needed if you're are not using the CXFServlet --> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-transports-http-jetty</artifactId> <version>${cxf.version}</version> </dependency> </dependencies> </project> |
The most important dependencies are related to "fasterxml" (lines 70-81) and "jaxb" (lines 103-119)
2. Generating java classes from the schemas with Eclipse
Eclipse is used.
Let's copy these files to the resources folder.
We are using only documentoEni.xsd, xmldsig-core-schema.xsd and XAdES.xsd for generating the java classes.
Right-click on one of them and select "Generate" then "JAXB Classes", select a folder for the output. Use a different folder for each schema although some classes are repeated.
I have used 3 packages to store the generated classes. I have also made a copy as these classes should be edited
Comments
Post a Comment