-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update project to latest tag sacerws-6.2.0
- Loading branch information
1 parent
72e1f83
commit 9e8de1a
Showing
11 changed files
with
255 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...jb/src/main/java/it/eng/parer/firma/converter/EidasAbstractJaxb3HttpMessageConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
}); | ||
} | ||
|
||
} |
145 changes: 145 additions & 0 deletions
145
sacerws-ejb/src/main/java/it/eng/parer/firma/converter/EidasJaxb3HttpMessageConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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("")); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.