Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MaarchParapheur
Manage
Activity
Members
Plan
Redmine
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maarch
MaarchParapheur
Commits
c9efeb09
Commit
c9efeb09
authored
2 years ago
by
Jean-Laurent DUZANT
Browse files
Options
Downloads
Patches
Plain Diff
FIX #20175 TIME 0:45 document can be signed by any signature method depending of workflow
parent
3d489af4
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/app/document/controllers/DocumentController.php
+27
-24
27 additions, 24 deletions
src/app/document/controllers/DocumentController.php
with
27 additions
and
24 deletions
src/app/document/controllers/DocumentController.php
+
27
−
24
View file @
c9efeb09
...
@@ -460,6 +460,7 @@ class DocumentController
...
@@ -460,6 +460,7 @@ class DocumentController
$hasEidas
=
false
;
$hasEidas
=
false
;
$hasMetaSignSignature
=
false
;
$hasElectronicSignature
=
false
;
$hasElectronicSignature
=
false
;
foreach
(
$body
[
'workflow'
]
as
$key
=>
$workflow
)
{
foreach
(
$body
[
'workflow'
]
as
$key
=>
$workflow
)
{
$processingUser
=
null
;
$processingUser
=
null
;
...
@@ -516,17 +517,22 @@ class DocumentController
...
@@ -516,17 +517,22 @@ class DocumentController
}
}
}
}
}
}
if
(
in_array
(
$workflow
[
'signatureMode'
],
[
'eidas'
,
'eidas_metasign'
,
'rgs_2stars_timestamped'
,
'inca_card_eidas'
]))
{
if
(
in_array
(
$workflow
[
'signatureMode'
],
[
'eidas'
,
'rgs_2stars_timestamped'
,
'inca_card_eidas'
]))
{
$hasEidas
=
true
;
$hasEidas
=
true
;
}
}
if
(
$workflow
[
'signatureMode'
]
==
'eidas_metasign'
&&
$workflow
[
'mode'
]
==
'sign'
)
{
$hasMetaSignSignature
=
true
;
}
if
(
$workflow
[
'signatureMode'
]
!=
'stamp'
&&
$workflow
[
'mode'
]
==
'sign'
)
{
if
(
$workflow
[
'signatureMode'
]
!=
'stamp'
&&
$workflow
[
'mode'
]
==
'sign'
)
{
$hasElectronicSignature
=
true
;
$hasElectronicSignature
=
true
;
}
}
}
}
$libDir
=
CoreConfigModel
::
getLibrariesDirectory
();
$libDir
=
CoreConfigModel
::
getLibrariesDirectory
();
$loadedXml
=
CoreConfigModel
::
getConfig
();
$loadedXml
=
CoreConfigModel
::
getConfig
();
if
(
$loadedXml
->
docaposteSignature
->
enable
==
'true'
&&
$hasEidas
&&
(
empty
(
$libDir
)
||
!
is_file
(
$libDir
.
'SetaPDF-Signer/library/SetaPDF/Autoload.php'
)))
{
if
((
$loadedXml
->
docaposteSignature
->
enable
==
'true'
||
$loadedXml
->
metaSignSignature
->
enable
==
'true'
)
&&
(
$hasEidas
||
$hasMetaSignSignature
)
&&
(
empty
(
$libDir
)
||
!
is_file
(
$libDir
.
'SetaPDF-Signer/library/SetaPDF/Autoload.php'
)))
{
return
$response
->
withStatus
(
500
)
->
withJson
([
'errors'
=>
'SetaPDF-Signer library is not installed'
,
'lang'
=>
'setAPdfSignerError'
]);
return
$response
->
withStatus
(
500
)
->
withJson
([
'errors'
=>
'SetaPDF-Signer library is not installed'
,
'lang'
=>
'setAPdfSignerError'
]);
}
}
...
@@ -763,14 +769,18 @@ class DocumentController
...
@@ -763,14 +769,18 @@ class DocumentController
'orderBy'
=>
[
'"order" asc'
]
'orderBy'
=>
[
'"order" asc'
]
]);
]);
$workflowSignatureMode
=
array_column
(
$workflow
,
'signature_mode'
);
if
(
$loadedXml
->
docaposteSignature
->
enable
==
'true'
&&
$hasEidas
)
{
if
(
$loadedXml
->
docaposteSignature
->
enable
==
'true'
&&
$hasEidas
&&
!
in_array
(
'eidas_metasign'
,
$workflowSignatureMode
))
{
$result
=
DigitalSignatureController
::
createTransaction
([
'documentId'
=>
$id
,
'workflow'
=>
$workflow
,
'encodedDocument'
=>
$encodedDocument
[
'encodedDocument'
]]);
$result
=
DigitalSignatureController
::
createTransaction
([
'documentId'
=>
$id
,
'workflow'
=>
$workflow
,
'encodedDocument'
=>
$encodedDocument
[
'encodedDocument'
]]);
if
(
!
empty
(
$result
[
'errors'
]))
{
if
(
!
empty
(
$result
[
'errors'
]))
{
return
$response
->
withStatus
(
500
)
->
withJson
([
'errors'
=>
$result
[
'errors'
]]);
return
$response
->
withStatus
(
500
)
->
withJson
([
'errors'
=>
$result
[
'errors'
]]);
}
}
}
}
if
(
$loadedXml
->
metaSignSignature
->
enable
==
'true'
&&
$hasMetaSignSignature
)
{
$metaSignInit
=
MetaSignSignatureController
::
init
();
if
(
!
empty
(
$metaSignInit
[
'errors'
]))
{
return
$response
->
withStatus
(
$metaSignInit
[
'code'
])
->
withJson
([
'errors'
=>
$metaSignInit
[
'errors'
]]);
}
}
if
(
empty
(
$body
[
'workflow'
][
0
][
'userId'
]))
{
if
(
empty
(
$body
[
'workflow'
][
0
][
'userId'
]))
{
if
(
$body
[
'workflow'
][
0
][
'externalInformations'
][
'type'
]
==
'yousign'
)
{
if
(
$body
[
'workflow'
][
0
][
'externalInformations'
][
'type'
]
==
'yousign'
)
{
...
@@ -815,7 +825,7 @@ class DocumentController
...
@@ -815,7 +825,7 @@ class DocumentController
}
}
require_once
(
$libDir
.
'SetaPDF-Signer/library/SetaPDF/Autoload.php'
);
require_once
(
$libDir
.
'SetaPDF-Signer/library/SetaPDF/Autoload.php'
);
if
(
DocumentController
::
ACTIONS
[
$args
[
'actionId'
]]
==
'VAL'
&&
$workflow
[
'signature_mode'
]
!=
'eidas'
)
{
if
(
DocumentController
::
ACTIONS
[
$args
[
'actionId'
]]
==
'VAL'
&&
!
in_array
(
$workflow
[
'signature_mode'
]
,
[
'eidas'
,
'eidas_metasign'
])
)
{
$url
=
UrlController
::
getCoreUrl
();
$url
=
UrlController
::
getCoreUrl
();
if
(
strpos
(
$url
,
'https://'
)
!==
0
)
{
if
(
strpos
(
$url
,
'https://'
)
!==
0
)
{
return
$response
->
withStatus
(
400
)
->
withJson
([
'errors'
=>
'Url is not secured (https needed)'
,
'lang'
=>
'securedUrlNeeded'
]);
return
$response
->
withStatus
(
400
)
->
withJson
([
'errors'
=>
'Url is not secured (https needed)'
,
'lang'
=>
'securedUrlNeeded'
]);
...
@@ -823,19 +833,11 @@ class DocumentController
...
@@ -823,19 +833,11 @@ class DocumentController
}
}
}
}
if
(
in_array
(
$workflow
[
'signature_mode'
],
[
'eidas'
,
'inca_card_eidas'
]))
{
if
(
in_array
(
$workflow
[
'signature_mode'
],
[
'eidas'
,
'inca_card_eidas'
])
&&
$loadedXml
->
docaposteSignature
->
enable
!=
'true'
)
{
if
(
$loadedXml
->
docaposteSignature
->
enable
!=
'true'
)
{
return
$response
->
withStatus
(
400
)
->
withJson
([
'errors'
=>
'docaposteSignature is disabled'
,
'lang'
=>
'docaposteSignatureDisabled'
]);
return
$response
->
withStatus
(
400
)
->
withJson
([
'errors'
=>
'docaposteSignature is disabled'
,
'lang'
=>
'docaposteSignatureDisabled'
]);
}
}
if
(
$workflow
[
'signature_mode'
]
==
'eidas_metasign'
&&
$loadedXml
->
metaSignSignature
->
enable
!=
'true'
)
{
}
elseif
(
$workflow
[
'signature_mode'
]
==
'eidas_metasign'
)
{
return
$response
->
withStatus
(
400
)
->
withJson
([
'errors'
=>
'metaSignSignature is disabled'
,
'lang'
=>
'metaSignSignatureDisabled'
]);
if
(
$loadedXml
->
metaSignSignature
->
enable
!=
'true'
)
{
return
$response
->
withStatus
(
400
)
->
withJson
([
'errors'
=>
'metaSignSignature is disabled'
,
'lang'
=>
'metaSignSignatureDisabled'
]);
}
$metaSignInit
=
MetaSignSignatureController
::
init
();
if
(
!
empty
(
$metaSignInit
[
'errors'
]))
{
return
$response
->
withStatus
(
$metaSignInit
[
'code'
])
->
withJson
([
'errors'
=>
$metaSignInit
[
'errors'
]]);
}
}
}
$body
=
$request
->
getParsedBody
();
$body
=
$request
->
getParsedBody
();
...
@@ -1112,7 +1114,7 @@ class DocumentController
...
@@ -1112,7 +1114,7 @@ class DocumentController
$signPosX
=
(
$signature
[
'positionX'
]
*
$format
[
'width'
])
/
100
;
$signPosX
=
(
$signature
[
'positionX'
]
*
$format
[
'width'
])
/
100
;
$signPosY
=
(
$signature
[
'positionY'
]
*
$format
[
'height'
])
/
100
;
$signPosY
=
(
$signature
[
'positionY'
]
*
$format
[
'height'
])
/
100
;
}
}
if
(
$loadedXml
->
docaposteSignature
->
enable
==
'true'
&&
in_array
(
$workflow
[
'signature_mode'
],
[
'eidas'
,
'inca_card_eidas'
])
)
{
if
(
$loadedXml
->
docaposteSignature
->
enable
==
'true'
)
{
$return
=
DigitalSignatureController
::
signHashes
([
$return
=
DigitalSignatureController
::
signHashes
([
'signatureId'
=>
$workflow
[
'digital_signature_id'
],
'signatureId'
=>
$workflow
[
'digital_signature_id'
],
'documentId'
=>
$args
[
'id'
],
'documentId'
=>
$args
[
'id'
],
...
@@ -1125,7 +1127,7 @@ class DocumentController
...
@@ -1125,7 +1127,7 @@ class DocumentController
],
],
'isLastSignature'
=>
!
isset
(
$body
[
'signatures'
][
$key
+
1
])
'isLastSignature'
=>
!
isset
(
$body
[
'signatures'
][
$key
+
1
])
]);
]);
}
else
if
(
$loadedXml
->
metaSignSignature
->
enable
==
'true'
&&
$workflow
[
'signature_mode'
]
==
'eidas_metasign'
)
{
}
else
if
(
$loadedXml
->
metaSignSignature
->
enable
==
'true'
)
{
$return
=
MetaSignSignatureController
::
signDocument
([
$return
=
MetaSignSignatureController
::
signDocument
([
'documentId'
=>
(
int
)
$args
[
'id'
],
'documentId'
=>
(
int
)
$args
[
'id'
],
'signatureInfo'
=>
[
'signatureInfo'
=>
[
...
@@ -1146,18 +1148,19 @@ class DocumentController
...
@@ -1146,18 +1148,19 @@ class DocumentController
}
}
}
}
}
}
if
(
!
$imageSignature
&&
$loadedXml
->
docaposteSignature
->
enable
==
'true'
&&
in_array
(
$workflow
[
'signature_mode'
],
[
'eidas'
,
'inca_card_eidas'
])
)
{
if
(
!
$imageSignature
&&
$loadedXml
->
docaposteSignature
->
enable
==
'true'
)
{
$return
=
DigitalSignatureController
::
signHashes
([
'signatureId'
=>
$workflow
[
'digital_signature_id'
],
'documentId'
=>
$args
[
'id'
],
'isLastSignature'
=>
true
]);
$return
=
DigitalSignatureController
::
signHashes
([
'signatureId'
=>
$workflow
[
'digital_signature_id'
],
'documentId'
=>
$args
[
'id'
],
'isLastSignature'
=>
true
]);
if
(
!
empty
(
$return
[
'errors'
]))
{
if
(
!
empty
(
$return
[
'errors'
]))
{
return
$response
->
withStatus
(
400
)
->
withJson
(
$return
);
return
$response
->
withStatus
(
400
)
->
withJson
(
$return
);
}
}
}
else
if
(
!
$imageSignature
&&
$loadedXml
->
metaSignSignature
->
enable
==
'true'
&&
$workflow
[
'signature_mode'
]
==
'eidas_metasign'
)
{
}
if
(
!
$imageSignature
&&
$loadedXml
->
metaSignSignature
->
enable
==
'true'
)
{
$return
=
MetaSignSignatureController
::
signDocument
([
'documentId'
=>
(
int
)
$args
[
'id'
],
'isLastSignature'
=>
true
]);
$return
=
MetaSignSignatureController
::
signDocument
([
'documentId'
=>
(
int
)
$args
[
'id'
],
'isLastSignature'
=>
true
]);
if
(
!
empty
(
$return
[
'errors'
]))
{
if
(
!
empty
(
$return
[
'errors'
]))
{
return
$response
->
withStatus
(
$return
[
'code'
])
->
withJson
([
'errors'
=>
$return
[
'errors'
]]);
return
$response
->
withStatus
(
$return
[
'code'
])
->
withJson
([
'errors'
=>
$return
[
'errors'
]]);
}
}
}
}
}
elseif
(
DocumentController
::
ACTIONS
[
$args
[
'actionId'
]]
==
'REF'
&&
$workflow
[
'mode'
]
==
'sign'
&&
$loadedXml
->
docaposteSignature
->
enable
==
'true'
&&
in_array
(
$workflow
[
'signature_mode'
],
[
'eidas'
,
'inca_card_eidas'
])
)
{
}
elseif
(
DocumentController
::
ACTIONS
[
$args
[
'actionId'
]]
==
'REF'
&&
$workflow
[
'mode'
]
==
'sign'
&&
$loadedXml
->
docaposteSignature
->
enable
==
'true'
)
{
$return
=
DigitalSignatureController
::
abort
([
'signatureId'
=>
$workflow
[
'digital_signature_id'
],
'documentId'
=>
$args
[
'id'
]]);
$return
=
DigitalSignatureController
::
abort
([
'signatureId'
=>
$workflow
[
'digital_signature_id'
],
'documentId'
=>
$args
[
'id'
]]);
if
(
!
empty
(
$return
[
'errors'
]))
{
if
(
!
empty
(
$return
[
'errors'
]))
{
return
$response
->
withStatus
(
400
)
->
withJson
(
$return
);
return
$response
->
withStatus
(
400
)
->
withJson
(
$return
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment