Skip to content

Commit

Permalink
Update project to latest tag sacerws-6.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
parerworker committed Jan 24, 2025
1 parent 72e1f83 commit 9e8de1a
Show file tree
Hide file tree
Showing 11 changed files with 255 additions and 28 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@

## 6.2.0 (20-01-2025)

### Novità: 1
- [#34697](https://parermine.regione.emilia-romagna.it/issues/34697) Aggiornamento libreria DSS 6.0

## 6.1.0 (09-12-2024)

### Bugfix: 1
Expand Down
12 changes: 3 additions & 9 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
## 6.1.0 (09-12-2024)
## 6.2.0 (20-01-2025)

### Bugfix: 1
- [#33853](https://parermine.regione.emilia-romagna.it/issues/33853) WS aggiornamento metadati UD: correzione del messaggio di controllo del profilo normativo nella response

### Novità: 4
- [#34196](https://parermine.regione.emilia-romagna.it/issues/34196) Nuova gestione per rapprentazione completa su base dati del seriale del certificato (CA, CRL e OCSP)
- [#34076](https://parermine.regione.emilia-romagna.it/issues/34076) Log del processo di conservazione delle unità documentarie
- [#33489](https://parermine.regione.emilia-romagna.it/issues/33489) Aggiornamento librerie obsolete 2024
- [#33128](https://parermine.regione.emilia-romagna.it/issues/33128) Aggiornamento alle ultimi versioni librerie jakarata-ee8 per jboss 7.4
### Novità: 1
- [#34697](https://parermine.regione.emilia-romagna.it/issues/34697) Aggiornamento libreria DSS 6.0
11 changes: 9 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<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>
<artifactId>sacerws</artifactId>
<version>6.1.1-SNAPSHOT</version>
<version>6.2.0</version>
<packaging>pom</packaging>
<name>sacerws</name>
<description>Progetto SACERWS</description>
Expand All @@ -18,14 +18,15 @@
<sacer.xmlmodule.version>2.12.0</sacer.xmlmodule.version>
<!-- spagofat bom -->
<spagofat.version>6.16.0</spagofat.version>
<verificafirma-eidas-beans.version>1.10.0</verificafirma-eidas-beans.version>
<verificafirma-eidas-beans.version>1.11.0</verificafirma-eidas-beans.version>
<verificafirma-crypto-beans.version>1.6.0</verificafirma-crypto-beans.version>
<parer-retry.version>2.2.0</parer-retry.version>
<idp-jaas-rdbms.version>0.0.9</idp-jaas-rdbms.version>
<!-- third party lib -->
<software.amazon.awssdk.version>2.27.7</software.amazon.awssdk.version>
<netty.version>4.1.112.Final</netty.version>
<xadisk.version>1.2.2.5</xadisk.version>
<jakarta.xml-bind.version>3.0.1</jakarta.xml-bind.version>
</properties>

<distributionManagement>
Expand Down Expand Up @@ -76,6 +77,12 @@
<artifactId>verificafirma-eidas-beans</artifactId>
<version>${verificafirma-eidas-beans.version}</version>
</dependency>
<!-- DSS from 6.x - Jakarta XML-BIND (3.x needed)-->
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>${jakarta.xml-bind.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion sacerws-ear/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<artifactId>sacerws</artifactId>
<groupId>it.eng.parer</groupId>
<version>6.1.1-SNAPSHOT</version>
<version>6.2.0</version>
</parent>

<artifactId>sacerws-ear</artifactId>
Expand Down
9 changes: 8 additions & 1 deletion sacerws-ejb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>sacerws</artifactId>
<groupId>it.eng.parer</groupId>
<version>6.1.1-SNAPSHOT</version>
<version>6.2.0</version>
</parent>

<artifactId>sacerws-ejb</artifactId>
Expand Down Expand Up @@ -193,6 +193,13 @@
<groupId>it.eng.parer</groupId>
<artifactId>verificafirma-eidas-beans</artifactId>
</dependency>
<!-- DSS- Jakarta 3.x runtime needed-->
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-osgi</artifactId>
<version>${jakarta.xml-bind.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>it.eng.parer</groupId>
<artifactId>spagofat-timer-wrapper-common</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package it.eng.parer.firma.converter;

import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

import org.springframework.http.converter.HttpMessageConversionException;
import org.springframework.http.converter.xml.AbstractXmlHttpMessageConverter;

import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.JAXBException;
import jakarta.xml.bind.Marshaller;
import jakarta.xml.bind.Unmarshaller;

public abstract class EidasAbstractJaxb3HttpMessageConverter<T> extends AbstractXmlHttpMessageConverter<T> {

private final ConcurrentMap<Class<?>, JAXBContext> jaxbContexts = new ConcurrentHashMap<>(64);

protected final Marshaller createMarshaller(Class<?> clazz) {
try {
JAXBContext jaxbContext = getJaxbContext(clazz);
Marshaller marshaller = jaxbContext.createMarshaller();
customizeMarshaller(marshaller);
return marshaller;
} catch (JAXBException ex) {
throw new HttpMessageConversionException(
"Could not create Marshaller for class [" + clazz + "]: " + ex.getMessage(), ex);
}
}

protected void customizeMarshaller(Marshaller marshaller) {
}

protected final Unmarshaller createUnmarshaller(Class<?> clazz) {
try {
JAXBContext jaxbContext = getJaxbContext(clazz);
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
customizeUnmarshaller(unmarshaller);
return unmarshaller;
} catch (JAXBException ex) {
throw new HttpMessageConversionException(
"Could not create Unmarshaller for class [" + clazz + "]: " + ex.getMessage(), ex);
}
}

protected void customizeUnmarshaller(Unmarshaller unmarshaller) {
}

protected final JAXBContext getJaxbContext(Class<?> clazz) {
return this.jaxbContexts.computeIfAbsent(clazz, key -> {
try {
return JAXBContext.newInstance(clazz);
} catch (JAXBException ex) {
throw new HttpMessageConversionException(
"Could not create JAXBContext for class [" + clazz + "]: " + ex.getMessage(), ex);
}
});
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
package it.eng.parer.firma.converter;

import java.io.IOException;
import java.io.StringReader;

import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.sax.SAXSource;
import javax.xml.transform.stream.StreamSource;

import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConversionException;
import org.springframework.http.converter.HttpMessageNotWritableException;
import org.springframework.lang.Nullable;
import org.springframework.util.ClassUtils;
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;

import jakarta.xml.bind.JAXBElement;
import jakarta.xml.bind.JAXBException;
import jakarta.xml.bind.MarshalException;
import jakarta.xml.bind.Marshaller;
import jakarta.xml.bind.PropertyException;
import jakarta.xml.bind.UnmarshalException;
import jakarta.xml.bind.Unmarshaller;
import jakarta.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlType;

public class EidasJaxb3HttpMessageConverter extends EidasAbstractJaxb3HttpMessageConverter<Object> {

private boolean supportDtd = false;

private boolean processExternalEntities = false;

public void setSupportDtd(boolean supportDtd) {
this.supportDtd = supportDtd;
}

public boolean isSupportDtd() {
return this.supportDtd;
}

public void setProcessExternalEntities(boolean processExternalEntities) {
this.processExternalEntities = processExternalEntities;
if (processExternalEntities) {
setSupportDtd(true);
}
}

public boolean isProcessExternalEntities() {
return this.processExternalEntities;
}

@Override
public boolean canRead(Class<?> clazz, MediaType mediaType) {
return (clazz.isAnnotationPresent(XmlRootElement.class) || clazz.isAnnotationPresent(XmlType.class))
&& canRead(mediaType);
}

@Override
public boolean canWrite(Class<?> clazz, MediaType mediaType) {
return (AnnotationUtils.findAnnotation(clazz, XmlRootElement.class) != null && canWrite(mediaType));
}

@Override
protected boolean supports(Class<?> clazz) {
// should not be called, since we override canRead/Write
throw new UnsupportedOperationException();
}

@Override
protected Object readFromSource(Class<?> clazz, HttpHeaders headers, Source source) throws Exception {
try {
source = processSource(source);
Unmarshaller unmarshaller = createUnmarshaller(clazz);
if (clazz.isAnnotationPresent(XmlRootElement.class)) {
return unmarshaller.unmarshal(source);
} else {
JAXBElement<?> jaxbElement = unmarshaller.unmarshal(source, clazz);
return jaxbElement.getValue();
}
} catch (NullPointerException ex) {
if (!isSupportDtd()) {
throw new IllegalStateException("NPE while unmarshalling. "
+ "This can happen due to the presence of DTD declarations which are disabled.", ex);
}
throw ex;
} catch (UnmarshalException ex) {
throw ex;
} catch (JAXBException ex) {
throw new HttpMessageConversionException("Invalid JAXB setup: " + ex.getMessage(), ex);
}
}

@SuppressWarnings("deprecation") // on JDK 9
protected Source processSource(Source source) {
if (source instanceof StreamSource) {
StreamSource streamSource = (StreamSource) source;
InputSource inputSource = new InputSource(streamSource.getInputStream());
try {
XMLReader xmlReader = org.xml.sax.helpers.XMLReaderFactory.createXMLReader();
xmlReader.setFeature("http://apache.org/xml/features/disallow-doctype-decl", !isSupportDtd());
String featureName = "http://xml.org/sax/features/external-general-entities";
xmlReader.setFeature(featureName, isProcessExternalEntities());
if (!isProcessExternalEntities()) {
xmlReader.setEntityResolver(NO_OP_ENTITY_RESOLVER);
}
return new SAXSource(xmlReader, inputSource);
} catch (SAXException ex) {
logger.warn("Processing of external entities could not be disabled", ex);
return source;
}
} else {
return source;
}
}

@Override
protected void writeToResult(Object o, HttpHeaders headers, Result result) throws IOException {
try {
Class<?> clazz = ClassUtils.getUserClass(o);
Marshaller marshaller = createMarshaller(clazz);
setCharset(headers.getContentType(), marshaller);
marshaller.marshal(o, result);
} catch (MarshalException ex) {
throw new HttpMessageNotWritableException("Could not marshal [" + o + "]: " + ex.getMessage(), ex);
} catch (JAXBException ex) {
throw new HttpMessageConversionException("Invalid JAXB setup: " + ex.getMessage(), ex);
}
}

private void setCharset(@Nullable MediaType contentType, Marshaller marshaller) throws PropertyException {
if (contentType != null && contentType.getCharset() != null) {
marshaller.setProperty(Marshaller.JAXB_ENCODING, contentType.getCharset().name());
}
}

private static final EntityResolver NO_OP_ENTITY_RESOLVER = (publicId,
systemId) -> new InputSource(new StringReader(""));

}
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@
import org.springframework.web.client.RestTemplate;

import it.eng.parer.eidas.model.EidasDataToValidateMetadata;
import it.eng.parer.eidas.model.EidasWSReportsDTOTree;
import it.eng.parer.eidas.model.EidasValidationResponse;
import it.eng.parer.eidas.model.EidasWSReportsDTOTree;
import it.eng.parer.entity.constraint.DecServizioVerificaCompDoc.CdServizioVerificaCompDoc;
import it.eng.parer.firma.converter.EidasJaxb3HttpMessageConverter;
import it.eng.parer.firma.exception.VerificaFirmaConnectionException;
import it.eng.parer.firma.exception.VerificaFirmaGenericInvokeException;
import it.eng.parer.firma.exception.VerificaFirmaWrapperGenericException;
Expand Down Expand Up @@ -175,6 +176,8 @@ private EidasValidationResponse verificaEidasJson(EidasDataToValidateMetadata dt
throws VerificaFirmaConnectionException, VerificaFirmaGenericInvokeException {

RestTemplate restTemplate = buildRestTemplateWithRetry();
// add converter (jakarta.xml.* compliant) -> (non più necessario al passaggio da javax.* a jakarta.*)
restTemplate.getMessageConverters().add(new EidasJaxb3HttpMessageConverter());

String preferredUrl = restInvoker.preferredEndpoint();
String urlEidas = preferredUrl + FIRMA_API_PATH;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@

import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.bind.JAXBIntrospector;
import javax.xml.bind.Marshaller;
import javax.xml.namespace.QName;

import org.apache.commons.compress.archivers.zip.X5455_ExtendedTimestamp;
Expand Down Expand Up @@ -69,6 +64,11 @@
import it.eng.parer.ws.utils.CostantiDB;
import it.eng.parer.ws.utils.MessaggiWSBundle;
import it.eng.parer.ws.utils.MessaggiWSFormat;
import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.JAXBElement;
import jakarta.xml.bind.JAXBException;
import jakarta.xml.bind.JAXBIntrospector;
import jakarta.xml.bind.Marshaller;

/*
* EJB di supporto per la gestione del report di verifica firma in formato ZIP.
Expand Down
23 changes: 15 additions & 8 deletions sacerws-jpa/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>it.eng.parer</groupId>
<artifactId>sacerws</artifactId>
<version>6.1.1-SNAPSHOT</version>
<version>6.2.0</version>
</parent>
<artifactId>sacerws-jpa</artifactId>
<name>sacerws-jpa</name>
Expand Down Expand Up @@ -77,10 +77,17 @@
<artifactId>hibernate-jpamodelgen</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>

<!-- jboss-jaxb-api_2.3_spec -->
<dependency>
<groupId>org.jboss.spec.javax.xml.bind</groupId>
<artifactId>jboss-jaxb-api_2.3_spec</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<resources>
Expand All @@ -90,15 +97,15 @@
</resource>
</resources>
<plugins>
<!-- metamodel generator -->
<!-- metamodel generator -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<!-- disabilito la generazione automatica dei metamodel, la voglio gestire puntualmente -->
<!-- disabilito la generazione automatica dei metamodel, la voglio gestire puntualmente -->
<compilerArgument>-proc:none</compilerArgument>
</configuration>
</plugin>
<!-- configurazione del metamodel generator -->
<!-- configurazione del metamodel generator -->
<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
Expand Down
Loading

0 comments on commit 9e8de1a

Please sign in to comment.