Skip to content

Commit

Permalink
Merge branch 'test' of gitlab.univ-rouen.fr:si/esup-signature into test
Browse files Browse the repository at this point in the history
  • Loading branch information
dlemaignent committed Sep 2, 2024
2 parents 6867bc6 + 49bd64a commit 5089da5
Show file tree
Hide file tree
Showing 9 changed files with 205 additions and 182 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public LiveWorkflowStep createLiveWorkflowStep(SignBook signBook, WorkflowStep w
LiveWorkflowStep liveWorkflowStep = new LiveWorkflowStep();
liveWorkflowStep.setWorkflowStep(workflowStep);
liveWorkflowStep.setRepeatable(Objects.requireNonNullElse(step.getRepeatable(), false));
liveWorkflowStep.setMultiSign(Objects.requireNonNullElse(step.getMultiSign(), false));
liveWorkflowStep.setMultiSign(Objects.requireNonNullElse(step.getMultiSign(), true));
liveWorkflowStep.setAutoSign(Objects.requireNonNullElse(step.getAutoSign(), false));
liveWorkflowStep.setAllSignToComplete(Objects.requireNonNullElse(step.getAllSignToComplete(), false));
if(step.getSignType() == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,15 +264,18 @@ public StepStatus sign(SignRequest signRequest, String password, String signWith
if(signRequestParamses.isEmpty() && visual) {
throw new EsupSignatureRuntimeException("Il manque une signature !");
}
int nbSign = 0;
if (toSignDocuments.size() == 1 && toSignDocuments.get(0).getContentType().equals("application/pdf") && visual) {
for(SignRequestParams signRequestParams : signRequestParamses) {
signedInputStream = pdfService.stampImage(signedInputStream, signRequest, signRequestParams, 1, signerUser, date, userService.getRoles(userEppn).contains("ROLE_OTP"), false);
if(signRequestParams.getSignImageNumber() < 0) {
if(signRequestParams.getSignImageNumber() < 0 && signRequest.getParentSignBook().getLiveWorkflow().getCurrentStep().getMultiSign()) {
signedInputStream = pdfService.stampImage(signedInputStream, signRequest, signRequestParams, 1, signerUser, date, userService.getRoles(userEppn).contains("ROLE_OTP"), false);
lastSignLogs.add(updateStatus(signRequest.getId(), signRequest.getStatus(), "Ajout d'un élément", null, "SUCCESS", signRequestParams.getSignPageNumber(), signRequestParams.getxPos(), signRequestParams.getyPos(), signRequest.getParentSignBook().getLiveWorkflow().getCurrentStepNumber(), userEppn, authUserEppn));
auditTrailService.addAuditStep(signRequest.getToken(), userEppn, "Ajout d'un élément", "Pas de timestamp", date, isViewed, signRequestParams.getSignPageNumber(), signRequestParams.getxPos(), signRequestParams.getyPos());
} else {
} else if(signRequestParams.getSignImageNumber() >= 0 && (signRequest.getParentSignBook().getLiveWorkflow().getCurrentStep().getMultiSign() || nbSign == 0)) {
signedInputStream = pdfService.stampImage(signedInputStream, signRequest, signRequestParams, 1, signerUser, date, userService.getRoles(userEppn).contains("ROLE_OTP"), false);
lastSignLogs.add(updateStatus(signRequest.getId(), signRequest.getStatus(), "Apposition de la signature", null, "SUCCESS", signRequestParams.getSignPageNumber(), signRequestParams.getxPos(), signRequestParams.getyPos(), signRequest.getParentSignBook().getLiveWorkflow().getCurrentStepNumber(), userEppn, authUserEppn));
auditTrailService.addAuditStep(signRequest.getToken(), userEppn, "Signature simple", "Pas de timestamp", date, isViewed, signRequestParams.getSignPageNumber(), signRequestParams.getxPos(), signRequestParams.getyPos());
nbSign++;
}
}
} else {
Expand Down Expand Up @@ -939,8 +942,11 @@ public void getToSignFileResponseWithCode(Long signRequestId, HttpServletRespons


@Transactional
public void getSignedFileAndReportResponse(Long signRequestId, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
public void getSignedFileAndReportResponse(Long signRequestId, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, boolean force) throws Exception {
SignRequest signRequest = getById(signRequestId);
if(!force && signRequest.getParentSignBook().getLiveWorkflow().getWorkflow() != null && BooleanUtils.isTrue(signRequest.getParentSignBook().getLiveWorkflow().getWorkflow().getForbidDownloadsBeforeEnd()) && !signRequest.getStatus().equals(SignRequestStatus.completed)) {
throw new EsupSignatureException("Téléchargement interdit avant la fin du circuit");
}
webUtilsService.copyFileStreamToHttpResponse(signRequest.getTitle() + "-avec_rapport", "application/zip; charset=utf-8", "attachment", new ByteArrayInputStream(getZipWithDocAndReport(signRequest, httpServletRequest, httpServletResponse)), httpServletResponse);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public ResponseEntity<String> deleteSignBook(@PathVariable Long id,
public ResponseEntity<Void> getLastFileFromSignRequest(@PathVariable("id") Long id,
@ModelAttribute("xApiKey") @Parameter(hidden = true) String xApiKey, HttpServletResponse httpServletResponse) {
try {
signRequestService.getToSignFileResponse(id, "attachment", httpServletResponse);
signRequestService.getToSignFileResponse(id, "form-data", httpServletResponse);
return ResponseEntity.ok().build();
} catch (Exception e) {
logger.error(e.getMessage(), e);
Expand All @@ -237,7 +237,7 @@ public ResponseEntity<Void> getLastFileFromSignRequest(@PathVariable("id") Long
public ResponseEntity<Void> getLastFileAndReport(@PathVariable("id") Long id,
@ModelAttribute("xApiKey") @Parameter(hidden = true) String xApiKey, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) {
try {
signRequestService.getSignedFileAndReportResponse(id, httpServletRequest, httpServletResponse);
signRequestService.getSignedFileAndReportResponse(id, httpServletRequest, httpServletResponse, true);
return ResponseEntity.ok().build();
} catch (Exception e) {
logger.error(e.getMessage(), e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public ResponseEntity<Void> getLastFileFromSignRequestPdf(@ModelAttribute("userE
@GetMapping(value = "/get-last-file-report/{id}")
public ResponseEntity<Void> getLastFileReport(@ModelAttribute("userEppn") String userEppn, @ModelAttribute("authUserEppn") String authUserEppn, @PathVariable("id") Long id, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) {
try {
signRequestService.getSignedFileAndReportResponse(id, httpServletRequest, httpServletResponse);
signRequestService.getSignedFileAndReportResponse(id, httpServletRequest, httpServletResponse, false);
return ResponseEntity.ok().build();
} catch (Exception e) {
logger.error("get file error", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import {EventFactory} from "../../utils/EventFactory.js?version=@version@";

export class SignPosition extends EventFactory {

constructor(signType, currentSignRequestParamses, signImageNumber, signImages, userName, authUserName, signable, forceResetSignPos, isOtp, phone, csrf) {
constructor(signType, currentSignRequestParamses, currentStepMultiSign, signImageNumber, signImages, userName, authUserName, signable, forceResetSignPos, isOtp, phone, csrf) {
super();
console.info("Starting sign positioning tools");
this.userName = userName;
this.authUserName = authUserName;
this.pdf = $("#pdf");
this.signImages = signImages;
this.currentStepMultiSign = currentStepMultiSign;
this.isOtp = isOtp;
this.phone = phone;
this.csrf = csrf;
Expand Down Expand Up @@ -110,6 +111,10 @@ export class SignPosition extends EventFactory {
id = 999999;
this.signRequestParamses.set(id, new SignRequestParams(null, id, this.currentScale, page, this.userName, this.authUserName, false, false, false, false, false, false, false, signImageNumber, this.scrollTop, this.csrf, this.signType));
} else if(signImageNumber >= 0) {
if(this.currentStepMultiSign === false && this.signRequestParamses.size > 0) {
alert("Impossible d'ajouter plusieurs signatures sur cette étape");
return;
}
if(JSON.parse(sessionStorage.getItem("favoriteSignRequestParams")) != null) {
favoriteSignRequestParams = JSON.parse(sessionStorage.getItem("favoriteSignRequestParams"));
if(currentSignRequestParams != null) {
Expand All @@ -119,10 +124,18 @@ export class SignPosition extends EventFactory {
}
this.signRequestParamses.set(id, new SignRequestParams(favoriteSignRequestParams, id, this.currentScale, page, this.userName, this.authUserName, restore, true, this.signType === "visa", this.signType === "certSign" || this.signType === "nexuSign", this.isOtp, this.phone, false, this.signImages, this.scrollTop));
} else {
if(this.currentStepMultiSign === false) {
alert("Impossible d'ajouter des annotations sur cette étape");
return;
}
this.signRequestParamses.set(id, new SignRequestParams(favoriteSignRequestParams, id, this.currentScale, page, this.userName, this.authUserName, false, false, false, this.signType === "certSign" || this.signType === "nexuSign", this.isOtp, this.phone, false, null, this.scrollTop));
}
this.signRequestParamses.get(id).changeSignImage(signImageNumber);
} else {
if(this.currentStepMultiSign === false) {
alert("Impossible d'ajouter des annotations sur cette étape");
return;
}
this.signRequestParamses.set(id, new SignRequestParams(null, id, this.currentScale, page, this.userName, this.authUserName, restore, signImageNumber != null && signImageNumber >= 0, false, this.signType === "certSign" || this.signType === "nexuSign", this.isOtp, this.phone, false, null, this.scrollTop));
}
this.signRequestParamses.get(id).addEventListener("unlock", e => this.lockSigns());
Expand Down Expand Up @@ -157,8 +170,10 @@ export class SignPosition extends EventFactory {

addText(page) {
let signRequestParams = this.addSign(page, false, null);
signRequestParams.turnToText();
signRequestParams.cross.css("background-image", "");
signRequestParams.changeSignSize(null);
if(signRequestParams != null) {
signRequestParams.turnToText();
signRequestParams.cross.css("background-image", "");
signRequestParams.changeSignSize(null);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class SignUi {
this.formId = formId;
this.dataId = dataId;
this.currentSignType = currentSignType;
this.workspace = new WorkspacePdf(isPdf, id, dataId, formId, currentSignRequestParamses, signImageNumber, currentSignType, signable, editable, postits, currentStepNumber, currentStepMultiSign, workflow, signImages, userName, authUserName, currentSignType, fields, stepRepeatable, status, this.csrf, action, notSigned, attachmentAlert, attachmentRequire, isOtp, restore, phone);
this.workspace = new WorkspacePdf(isPdf, id, dataId, formId, currentSignRequestParamses, signImageNumber, currentSignType, signable, editable, postits, currentStepNumber, currentStepMultiSign, workflow, signImages, userName, authUserName, fields, stepRepeatable, status, this.csrf, action, notSigned, attachmentAlert, attachmentRequire, isOtp, restore, phone);
this.signRequestUrlParams = "";
this.signComment = $('#signComment');
this.signModal = $('#signModal');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {UserUi} from '../users/UserUi.js?version=@version@';

export class WorkspacePdf {

constructor(isPdf, id, dataId, formId, currentSignRequestParamses, signImageNumber, currentSignType, signable, editable, postits, currentStepNumber, currentStepMultiSign, workflow, signImages, userName, authUserName, signType, fields, stepRepeatable, status, csrf, action, notSigned, attachmentAlert, attachmentRequire, isOtp, restore, phone) {
constructor(isPdf, id, dataId, formId, currentSignRequestParamses, signImageNumber, currentSignType, signable, editable, postits, currentStepNumber, currentStepMultiSign, workflow, signImages, userName, authUserName, fields, stepRepeatable, status, csrf, action, notSigned, attachmentAlert, attachmentRequire, isOtp, restore, phone) {
console.info("Starting workspace UI");
this.ready = false;
this.formInitialized = false;
Expand All @@ -17,14 +17,13 @@ export class WorkspacePdf {
this.dataId = dataId;
this.formId = formId;
this.signImageNumber = signImageNumber;
this.currentSignType = currentSignType;
this.restore = restore;
this.postits = postits;
this.notSigned = notSigned;
this.signable = signable;
this.editable = editable;
this.signRequestId = id;
this.signType = signType;
this.currentSignType = currentSignType;
this.stepRepeatable = stepRepeatable;
this.status = status;
this.csrf = csrf;
Expand All @@ -51,8 +50,9 @@ export class WorkspacePdf {
}
}
this.signPosition = new SignPosition(
signType,
currentSignType,
currentSignRequestParamses,
currentStepMultiSign,
signImageNumber,
signImages,
userName, authUserName, signable, this.forcePageNum, this.isOtp, this.phone, this.csrf);
Expand All @@ -71,7 +71,7 @@ export class WorkspacePdf {
this.workspace = $("#workspace");
this.secondTools = $("#second-tools");
this.addSignButton = $("#addSignButton")
if (signType === "form" || (formId == null && !workflow) || currentSignRequestParamses.length === 0) {
if (currentSignType === "form" || (formId == null && !workflow) || currentSignRequestParamses.length === 0) {
if(this.wsTabs.length) {
this.autocollapse();
let self = this;
Expand Down Expand Up @@ -209,7 +209,7 @@ export class WorkspacePdf {
signSpaceDiv = $("#signSpace_" + i);
signSpaceDiv.on("click", e => this.addSign(i));
if(currentSignRequestParams.ready == null || !currentSignRequestParams.ready) {
if(this.signType !== "visa") {
if(this.currentSignType !== "visa") {
signSpaceDiv.html("Cliquez ici pour insérer votre signature");
} else {
signSpaceDiv.html("Cliquez ici pour insérer votre visa");
Expand Down Expand Up @@ -247,7 +247,7 @@ export class WorkspacePdf {
this.signImageNumber = localStorage.getItem('signNumber');
}
this.signPosition.addSign(targetPageNumber, this.restore, this.signImageNumber, forceSignNumber);
if((this.signType === "nexuSign" || this.signType === "certSign") && !this.notSigned) {
if((this.currentSignType === "nexuSign" || this.currentSignType === "certSign") && !this.notSigned) {
$("#addSignButton").attr("disabled", true);
}
}
Expand Down Expand Up @@ -830,7 +830,7 @@ export class WorkspacePdf {
$('#signButtons').removeClass('d-none');
$('#signModeButton').toggleClass('btn-outline-success');

if(this.signType !== 'hiddenVisa') {
if(this.currentSignType !== 'hiddenVisa') {
let signTools = $('#sign-tools');
signTools.removeClass("d-none");
signTools.addClass("d-flex");
Expand Down
Loading

0 comments on commit 5089da5

Please sign in to comment.