Skip to content

Commit

Permalink
Merge pull request #454 from EsupPortail/test
Browse files Browse the repository at this point in the history
Test
  • Loading branch information
dlemaignent authored Sep 23, 2024
2 parents 49f863f + 111fbbb commit 1a12fd8
Show file tree
Hide file tree
Showing 54 changed files with 718 additions and 332 deletions.
31 changes: 21 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.3.3</version>
<version>3.3.4</version>
<relativePath />
</parent>
<groupId>org.esupportail</groupId>
<artifactId>esup-signature</artifactId>
<version>1.29.17</version>
<version>1.30.0-SNAPSHOT</version>
<name>esup-signature</name>
<properties>
<startClass>org.esupportail.esupsignature.EsupSignatureApplication</startClass>
<java.version>17</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<dss.framework.version>6.0</dss.framework.version>
<dss.framework.version>6.1</dss.framework.version>
<dss.framework.safeVersion>5.4.3</dss.framework.safeVersion>
<skipDockerCompose>true</skipDockerCompose>
<skipSurefire>false</skipSurefire>
Expand Down Expand Up @@ -160,9 +160,9 @@
<version>0.59</version>
</dependency>
<dependency>
<groupId>org.webjars.bower</groupId>
<artifactId>google-code-prettify</artifactId>
<version>1.0.5</version>
<groupId>org.webjars</groupId>
<artifactId>prettify</artifactId>
<version>4-Mar-2013-1</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
Expand All @@ -183,7 +183,7 @@
<dependency>
<groupId>org.webjars.npm</groupId>
<artifactId>pdfjs-dist</artifactId>
<version>4.4.168</version>
<version>4.6.82</version>
</dependency>
<dependency>
<groupId>org.webjars.npm</groupId>
Expand Down Expand Up @@ -236,9 +236,9 @@
<version>3.2.5</version>
</dependency>
<dependency>
<groupId>org.webjars.bowergithub.ajaxorg</groupId>
<groupId>org.webjars.npm</groupId>
<artifactId>ace-builds</artifactId>
<version>1.4.13</version>
<version>1.35.3</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
Expand Down Expand Up @@ -303,6 +303,11 @@
<artifactId>dss-model</artifactId>
<version>${dss.framework.version}</version>
</dependency>
<dependency>
<groupId>eu.europa.ec.joinup.sd-dss</groupId>
<artifactId>dss-validation</artifactId>
<version>${dss.framework.version}</version>
</dependency>
<dependency>
<groupId>eu.europa.ec.joinup.sd-dss</groupId>
<artifactId>dss-spi</artifactId>
Expand Down Expand Up @@ -438,6 +443,12 @@
<groupId>eu.europa.ec.joinup.sd-dss</groupId>
<artifactId>dss-pades-pdfbox</artifactId>
<version>${dss.framework.version}</version>
<exclusions>
<exclusion>
<artifactId>pdfbox</artifactId>
<groupId>org.apache.pdfbox</groupId>
</exclusion>
</exclusions>
</dependency>

<!-- SEDA dependencies -->
Expand Down Expand Up @@ -565,7 +576,7 @@
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
<version>2.0.31</version>
<version>2.0.32</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,16 @@
import eu.europa.esig.dss.service.ocsp.OnlineOCSPSource;
import eu.europa.esig.dss.service.tsp.OnlineTSPSource;
import eu.europa.esig.dss.service.x509.aia.JdbcCacheAIASource;
import eu.europa.esig.dss.spi.client.http.DSSCacheFileLoader;
import eu.europa.esig.dss.spi.client.http.DSSFileLoader;
import eu.europa.esig.dss.spi.client.http.IgnoreDataLoader;
import eu.europa.esig.dss.spi.client.jdbc.JdbcCacheConnector;
import eu.europa.esig.dss.spi.policy.SignaturePolicyProvider;
import eu.europa.esig.dss.spi.tsl.TrustedListsCertificateSource;
import eu.europa.esig.dss.spi.validation.CertificateVerifier;
import eu.europa.esig.dss.spi.validation.CommonCertificateVerifier;
import eu.europa.esig.dss.spi.validation.OCSPFirstRevocationDataLoadingStrategyFactory;
import eu.europa.esig.dss.spi.validation.RevocationDataVerifier;
import eu.europa.esig.dss.spi.x509.KeyStoreCertificateSource;
import eu.europa.esig.dss.spi.x509.aia.AIASource;
import eu.europa.esig.dss.spi.x509.aia.DefaultAIASource;
Expand All @@ -42,9 +48,6 @@
import eu.europa.esig.dss.tsl.function.OfficialJournalSchemeInformationURI;
import eu.europa.esig.dss.tsl.job.TLValidationJob;
import eu.europa.esig.dss.tsl.source.LOTLSource;
import eu.europa.esig.dss.validation.CertificateVerifier;
import eu.europa.esig.dss.validation.CommonCertificateVerifier;
import eu.europa.esig.dss.validation.SignaturePolicyProvider;
import eu.europa.esig.dss.xades.signature.XAdESService;
import eu.europa.esig.dss.xml.common.DocumentBuilderFactoryBuilder;
import eu.europa.esig.dss.xml.common.SchemaFactoryBuilder;
Expand Down Expand Up @@ -263,7 +266,7 @@ public CacheCleaner cacheCleaner(DSSFileLoader offlineLoader) {
CacheCleaner cacheCleaner = new CacheCleaner();
cacheCleaner.setCleanMemory(true);
cacheCleaner.setCleanFileSystem(true);
cacheCleaner.setDSSFileLoader(offlineLoader);
cacheCleaner.setDSSFileLoader((DSSCacheFileLoader) offlineLoader);

return cacheCleaner;
}
Expand All @@ -290,13 +293,20 @@ public LOTLSource europeanLOTL(KeyStoreCertificateSource ojContentKeyStore) {
}

@Bean
public CertificateVerifier certificateVerifier(JdbcCacheOCSPSource jdbcCacheOCSPSource, JdbcCacheCRLSource jdbcCacheCRLSource, JdbcCacheAIASource jdbcCacheAIASource, TrustedListsCertificateSource trustedListSource) {
public RevocationDataVerifier revocationDataVerifier() {
return RevocationDataVerifier.createDefaultRevocationDataVerifier();
}

@Bean
public CertificateVerifier certificateVerifier(JdbcCacheOCSPSource jdbcCacheOCSPSource, JdbcCacheCRLSource jdbcCacheCRLSource, JdbcCacheAIASource jdbcCacheAIASource, TrustedListsCertificateSource trustedListSource, RevocationDataVerifier revocationDataVerifier) {
CommonCertificateVerifier certificateVerifier = new CommonCertificateVerifier();
certificateVerifier.setCrlSource(jdbcCacheCRLSource);
certificateVerifier.setOcspSource(jdbcCacheOCSPSource);
certificateVerifier.setAIASource(jdbcCacheAIASource);
certificateVerifier.setTrustedCertSources(trustedListSource);
certificateVerifier.setRevocationDataVerifier(revocationDataVerifier);
certificateVerifier.setAlertOnMissingRevocationData(new ExceptionOnStatusAlert());
certificateVerifier.setRevocationDataLoadingStrategyFactory(new OCSPFirstRevocationDataLoadingStrategyFactory());
certificateVerifier.setCheckRevocationForUntrustedChains(dssProperties.getCheckRevocationForUntrustedChains());
return certificateVerifier;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package org.esupportail.esupsignature.dss.service;

import eu.europa.esig.dss.model.identifier.Identifier;
import eu.europa.esig.dss.spi.tsl.LOTLInfo;
import eu.europa.esig.dss.spi.tsl.ParsingInfoRecord;
import eu.europa.esig.dss.spi.tsl.TLInfo;
import eu.europa.esig.dss.spi.tsl.TLValidationJobSummary;
import eu.europa.esig.dss.model.tsl.LOTLInfo;
import eu.europa.esig.dss.model.tsl.ParsingInfoRecord;
import eu.europa.esig.dss.model.tsl.TLInfo;
import eu.europa.esig.dss.model.tsl.TLValidationJobSummary;
import eu.europa.esig.dss.spi.x509.CommonTrustedCertificateSource;
import eu.europa.esig.dss.spi.x509.KeyStoreCertificateSource;
import eu.europa.esig.dss.tsl.job.TLValidationJob;
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/org/esupportail/esupsignature/entity/Workflow.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public class Workflow {
@Column(columnDefinition = "TEXT")
private String message;

private String mailFrom;

private Integer counter;

@Temporal(TemporalType.TIMESTAMP)
Expand Down Expand Up @@ -85,6 +87,8 @@ public class Workflow {

private Boolean sealAtEnd = false;

private String signRequestParamsDetectionPattern;

@Transient
private String messageToDisplay;

Expand Down Expand Up @@ -128,6 +132,14 @@ public void setMessage(String message) {
this.message = message;
}

public String getMailFrom() {
return mailFrom;
}

public void setMailFrom(String mailFrom) {
this.mailFrom = mailFrom;
}

public Integer getCounter() {
return counter;
}
Expand Down Expand Up @@ -333,4 +345,12 @@ public Boolean getForbidDownloadsBeforeEnd() {
public void setForbidDownloadsBeforeEnd(Boolean forbidDownloadsBeforeEnd) {
this.forbidDownloadsBeforeEnd = forbidDownloadsBeforeEnd;
}

public String getSignRequestParamsDetectionPattern() {
return signRequestParamsDetectionPattern;
}

public void setSignRequestParamsDetectionPattern(String signRequestParamsDetectionPattern) {
this.signRequestParamsDetectionPattern = signRequestParamsDetectionPattern;
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package org.esupportail.esupsignature.repository;

import org.esupportail.esupsignature.entity.Otp;
import org.esupportail.esupsignature.entity.enums.SignRequestStatus;
import org.springframework.data.repository.CrudRepository;

import java.util.List;

public interface OtpRepository extends CrudRepository<Otp, Long> {

Otp findByUrlId(String url);
List<Otp> findBySignBookStatus(SignRequestStatus status);

}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,49 @@ and size(sb.signRequests) > 0
""")
Page<SignBook> findByRecipientAndCreateByEppnIndexed(User user, String workflowFilter, String docTitleFilter, User creatorFilter, Date startDateFilter, Date endDateFilter, Pageable pageable);

@Query("""
select distinct sb from SignBook sb
left join sb.team team
left join sb.signRequests sr
left join sr.recipientHasSigned rhs
left join sb.liveWorkflow lw
left join lw.liveWorkflowSteps lws
left join lws.recipients r
left join r.user u
where (:workflowFilter is null or sb.workflowName = :workflowFilter)
and (:docTitleFilter is null or sb.subject = :docTitleFilter)
and (:recipientUser is null or key(rhs).user = :recipientUser or :recipientUser in (u))
and (:creatorFilter is null or sb.createBy = :creatorFilter)
and size(sb.signRequests) > 0
and (sb.createDate between :startDateFilter and :endDateFilter)
""")
Page<SignBook> findByWorkflowName(User recipientUser, String workflowFilter, String docTitleFilter, User creatorFilter, Date startDateFilter, Date endDateFilter, Pageable pageable);

@Query("""
select distinct sb.subject from SignBook sb
where (:workflowFilter is null or sb.workflowName = :workflowFilter)
""")
List<String> findByWorkflowNameSubjects(String workflowFilter);

@Query("""
select distinct sb.createBy from SignBook sb
where (:workflowFilter is null or sb.workflowName = :workflowFilter)
""")
List<User> findByWorkflowNameCreators(String workflowFilter);

@Query("""
select distinct u from SignBook sb
left join sb.team team
left join sb.signRequests sr
left join sr.recipientHasSigned rhs
left join sb.liveWorkflow lw
left join lw.liveWorkflowSteps lws
left join lws.recipients r
left join r.user u
where (:workflowFilter is null or sb.workflowName = :workflowFilter) and u is not null
""")
List<User> findByWorkflowNameRecipientsUsers(String workflowFilter);

@Query("""
select distinct sb from SignBook sb
left join sb.team team
Expand Down Expand Up @@ -236,6 +279,5 @@ where sr.id in (select l.signRequestId from Log as l where l.eppn = :eppn and l.
Page<SignBook> findOnShareByEppn(String eppn, User recipientUser, String workflowFilter, String docTitleFilter, User creatorFilter, Date startDateFilter, Date endDateFilter, Pageable pageable);

List<SignBook> findByCreateByEppn(String userEppn);

}

Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public byte[] generateFile(Data data, InputStream inputStream) throws IOExceptio
if(inputStream != null && inputStream.available() > 0) {
return pdfService.fill(inputStream, data.getDatas(), false, true);
} else if(form.getDocument() != null) {
return pdfService.fill(pdfService.removeSignField(form.getDocument().getInputStream()), data.getDatas(), false, true);
return pdfService.fill(pdfService.removeSignField(form.getDocument().getInputStream(), data.getForm().getWorkflow()), data.getDatas(), false, true);
} else {
logger.error("no pdf model");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.pdfbox.cos.COSDictionary;
import org.apache.pdfbox.cos.COSName;
import org.apache.pdfbox.cos.COSObject;
import org.apache.pdfbox.cos.COSString;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.interactive.action.PDAction;
Expand Down Expand Up @@ -315,8 +317,10 @@ private List<Field> getFields(InputStream inputStream, Workflow workflow) throws
PDAnnotationAdditionalActions pdAnnotationAdditionalActions = pdAnnotationWidget.getActions();
if (pdAnnotationAdditionalActions != null && pdAnnotationAdditionalActions.getCOSObject().size() > 0) {
if (pdAnnotationAdditionalActions.getCOSObject().getCOSObject(COSName.K) != null) {
COSString cosString = (COSString) pdAnnotationAdditionalActions.getCOSObject().getCOSObject(COSName.K).getItem(COSName.JS);
type = cosString.toString();
COSObject cosObject = pdAnnotationAdditionalActions.getCOSObject().getCOSObject(COSName.K);
if(cosObject.getObject() instanceof COSDictionary cosDictionary) {
type = ((COSString) cosDictionary.getDictionaryObject(COSName.JS)).toString();
}
}
}
if (type == null || type.equals("text")) {
Expand Down Expand Up @@ -466,7 +470,7 @@ public Set<Form> getManagerForms(String userEppn) {
@Transactional
public void updateSignRequestParams(Long formId, InputStream inputStream) {
Form form = getById(formId);
List<SignRequestParams> findedSignRequestParams = signRequestParamsService.scanSignatureFields(inputStream, 0);
List<SignRequestParams> findedSignRequestParams = signRequestParamsService.scanSignatureFields(inputStream, 0, form.getWorkflow());
if(!findedSignRequestParams.isEmpty()) {
form.getSignRequestParams().clear();
int i = 0;
Expand Down
Loading

0 comments on commit 1a12fd8

Please sign in to comment.