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
eadcd1c2
Commit
eadcd1c2
authored
2 years ago
by
Jean-Laurent DUZANT
Browse files
Options
Downloads
Patches
Plain Diff
FEAT #20284 TIME 0:20 [FAST] : use uploadOTP
parent
8a867263
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/workflow/controllers/FastOTPController.php
+27
-124
27 additions, 124 deletions
src/app/workflow/controllers/FastOTPController.php
with
27 additions
and
124 deletions
src/app/workflow/controllers/FastOTPController.php
+
27
−
124
View file @
eadcd1c2
...
@@ -20,6 +20,7 @@ use ExternalSignatoryBook\models\ExternalSignatoryBookModel;
...
@@ -20,6 +20,7 @@ use ExternalSignatoryBook\models\ExternalSignatoryBookModel;
use
SrcCore\models\AuthenticationModel
;
use
SrcCore\models\AuthenticationModel
;
use
Respect\Validation\Validator
;
use
Respect\Validation\Validator
;
use
SrcCore\models\ValidatorModel
;
use
SrcCore\models\ValidatorModel
;
use
Configuration\models\ConfigurationModel
;
...
@@ -52,48 +53,7 @@ class FastOTPController
...
@@ -52,48 +53,7 @@ class FastOTPController
if
(
!
empty
(
$check
[
'errors'
]))
{
if
(
!
empty
(
$check
[
'errors'
]))
{
return
[
'errors'
=>
$check
[
'errors'
]];
return
[
'errors'
=>
$check
[
'errors'
]];
}
}
$multipartBody
=
[
'doc'
=>
[
'isFile'
=>
true
,
'filename'
=>
"
{
$args
[
'name'
]
}
.pdf"
,
'content'
=>
base64_decode
(
$args
[
'encodedDocument'
])
],
'circuit'
=>
json_encode
([
'type'
=>
'BUREAUTIQUE_PDF'
,
'steps'
=>
[
[
'step'
=>
'OTPSignature'
,
'members'
=>
[
$workflowExternalInformations
[
'email'
]]
]
]
]),
'comment'
=>
"
{
$args
[
'name'
]
}
:
{
$args
[
'description'
]
}
"
];
$uploadResponse
=
FastOTPController
::
onDemndUpload
([
'connection_data'
=>
$externalSB
[
'connection_data'
],
'multipartBody'
=>
$multipartBody
]);
if
(
!
empty
(
$uploadResponse
[
'errors'
]))
{
FastOTPController
::
updateErrorInfo
([
'workflowId'
=>
$args
[
'workflowId'
],
'informations'
=>
[
'errors'
=>
$uploadResponse
[
'userFriendlyMessage'
]]
]);
return
[
'errors'
=>
$uploadResponse
[
'errors'
]];
}
$fastDocumentId
=
$uploadResponse
[
'response'
];
$workflowExternalInformations
[
'informations'
][
'fastDocumentId'
]
=
$fastDocumentId
;
WorkflowExternalInformationModel
::
update
([
'set'
=>
[
'informations'
=>
json_encode
(
$workflowExternalInformations
)
],
'where'
=>
[
'workflow_id = ?'
],
'data'
=>
[
$args
[
'workflowId'
]]
]);
$otpXml
=
FastOTPController
::
generateOtpXml
([
$otpXml
=
FastOTPController
::
generateOtpXml
([
'prettyPrint'
=>
true
,
'prettyPrint'
=>
true
,
...
@@ -109,44 +69,40 @@ class FastOTPController
...
@@ -109,44 +69,40 @@ class FastOTPController
return
[
'errors'
=>
$otpXml
[
'errors'
]];
return
[
'errors'
=>
$otpXml
[
'errors'
]];
}
}
$today
=
new
\DateTimeImmutable
();
$multipartBody
=
[
$multipartBody
=
[
'otpinformation'
=>
[
'document'
=>
[
'isFile'
=>
true
,
'filename'
=>
"
{
$args
[
'name'
]
}
_
{
$today
->
format
(
'd-m-Y_H-i-s'
)
}
.pdf"
,
'content'
=>
base64_decode
(
$args
[
'encodedDocument'
])
],
'meta'
=>
[
'isFile'
=>
true
,
'isFile'
=>
true
,
'filename'
=>
$otpXml
[
'filename'
],
'filename'
=>
$otpXml
[
'filename'
],
'content'
=>
$otpXml
[
'content'
]
'content'
=>
$otpXml
[
'content'
]
]
],
'referrer'
=>
ConfigurationModel
::
getApplicationUrl
()
.
"rest/documents/
{
$args
[
'documentId'
]
}
/workflows/
{
$args
[
'workflowId'
]
}
/fastRedirectionUrl"
];
];
$
metaDataR
esponse
=
FastOTPController
::
defineDocumentMetadata
([
$
r
esponse
=
FastOTPController
::
uploadOTP
([
'connection_data'
=>
$externalSB
[
'connection_data'
],
'connection_data'
=>
$externalSB
[
'connection_data'
],
'multipartBody'
=>
$multipartBody
,
'multipartBody'
=>
$multipartBody
'fastDocumentId'
=>
$fastDocumentId
]);
if
(
!
empty
(
$metaDataResponse
[
'errors'
]))
{
FastOTPController
::
updateErrorInfo
([
'workflowId'
=>
$args
[
'workflowId'
],
'informations'
=>
[
'errors'
=>
$metaDataResponse
[
'userFriendlyMessage'
]]
]);
return
[
'errors'
=>
$metaDataResponse
[
'errors'
]];
}
$smsUrlResponse
=
FastOTPController
::
getSmsUrl
([
'connection_data'
=>
$externalSB
[
'connection_data'
],
'fastDocumentId'
=>
$fastDocumentId
]);
]);
if
(
!
empty
(
$
smsUrlR
esponse
[
'errors'
]))
{
if
(
!
empty
(
$
r
esponse
[
'errors'
]))
{
FastOTPController
::
updateErrorInfo
([
FastOTPController
::
updateErrorInfo
([
'workflowId'
=>
$args
[
'workflowId'
],
'workflowId'
=>
$args
[
'workflowId'
],
'informations'
=>
[
'errors'
=>
$
smsUrlR
esponse
[
'errors'
]]
'informations'
=>
[
'errors'
=>
$
r
esponse
[
'errors'
]]
]);
]);
return
[
'errors'
=>
$
smsUrlR
esponse
[
'errors'
]];
return
[
'errors'
=>
$
r
esponse
[
'errors'
]];
}
}
$workflowExternalInformations
[
'informations'
][
'fast
Url
'
]
=
$
smsUrlR
esponse
[
'response'
][
'
url
'
];
$workflowExternalInformations
[
'informations'
][
'fast
DocId
'
]
=
$
r
esponse
[
'response'
][
'
id
'
];
$workflowExternalInformations
[
'informations'
][
'fastUrl'
]
=
$response
[
'response'
][
'url'
];
$informations
=
json_encode
(
$workflowExternalInformations
[
'informations'
]);
$informations
=
json_encode
(
$workflowExternalInformations
[
'informations'
]);
WorkflowExternalInformationModel
::
update
([
'set'
=>
[
'informations'
=>
$informations
],
'where'
=>
[
'workflow_id = ?'
],
'data'
=>
[
$args
[
'workflowId'
]]]);
WorkflowExternalInformationModel
::
update
([
'set'
=>
[
'informations'
=>
$informations
],
'where'
=>
[
'workflow_id = ?'
],
'data'
=>
[
$args
[
'workflowId'
]]]);
return
true
;
return
true
;
}
}
...
@@ -179,7 +135,7 @@ class FastOTPController
...
@@ -179,7 +135,7 @@ class FastOTPController
WorkflowExternalInformationModel
::
update
([
WorkflowExternalInformationModel
::
update
([
'set'
=>
[
'set'
=>
[
'informations'
=>
json_encode
(
$args
[
'
workflowId
'
])
'informations'
=>
json_encode
(
$args
[
'
informations
'
])
],
],
'where'
=>
[
'workflow_id = ?'
],
'where'
=>
[
'workflow_id = ?'
],
'data'
=>
[
$args
[
'workflowId'
]]
'data'
=>
[
$args
[
'workflowId'
]]
...
@@ -187,14 +143,14 @@ class FastOTPController
...
@@ -187,14 +143,14 @@ class FastOTPController
return
true
;
return
true
;
}
}
public
static
function
onDemndU
pload
(
array
$args
)
public
static
function
u
pload
OTP
(
array
$args
)
{
{
ValidatorModel
::
notEmpty
(
$args
,
[
'connection_data'
,
'multipartBody'
]);
ValidatorModel
::
notEmpty
(
$args
,
[
'connection_data'
,
'multipartBody'
]);
ValidatorModel
::
arrayType
(
$args
,
[
'connection_data'
,
'multipartBody'
]);
ValidatorModel
::
arrayType
(
$args
,
[
'connection_data'
,
'multipartBody'
]);
$curlReturn
=
CurlModel
::
exec
([
$curlReturn
=
CurlModel
::
exec
([
'method'
=>
'POST'
,
'method'
=>
'POST'
,
'url'
=>
$args
[
'connection_data'
][
'apiUri'
]
.
"/documents/
ondemand/"
.
$args
[
'connection_data'
][
'apiKey'
]
.
"
/upload"
,
'url'
=>
$args
[
'connection_data'
][
'apiUri'
]
.
"/documents/
v2/otp/
{
$args
[
'connection_data'
][
'apiKey'
]
}
/signature-otp
/upload"
,
'options'
=>
[
'options'
=>
[
CURLOPT_SSLCERT
=>
$args
[
'connection_data'
][
'certPath'
],
CURLOPT_SSLCERT
=>
$args
[
'connection_data'
][
'certPath'
],
CURLOPT_SSLCERTPASSWD
=>
AuthenticationModel
::
decrypt
([
'cryptedPassword'
=>
$args
[
'connection_data'
][
'certPass'
]]),
CURLOPT_SSLCERTPASSWD
=>
AuthenticationModel
::
decrypt
([
'cryptedPassword'
=>
$args
[
'connection_data'
][
'certPass'
]]),
...
@@ -203,13 +159,13 @@ class FastOTPController
...
@@ -203,13 +159,13 @@ class FastOTPController
'multipartBody'
=>
$args
[
'multipartBody'
]
'multipartBody'
=>
$args
[
'multipartBody'
]
]);
]);
if
(
$curlReturn
[
'code'
]
!=
200
||
!
is_int
(
$curlReturn
[
'response'
]))
{
if
(
$curlReturn
[
'code'
]
!=
200
||
!
empty
(
$curlReturn
[
'response'
]
[
'errorCode'
]
))
{
if
(
!
empty
(
$curlReturn
[
'resonse'
][
'userFriendlyMessage'
]))
{
if
(
!
empty
(
$curlReturn
[
'resonse'
][
'userFriendlyMessage'
])
&&
$curlReturn
[
'resonse'
][
'userFriendlyMessage'
]
!=
'Erreur'
)
{
return
[
'errors'
=>
FastOTPController
::
OTP_ERROR
.
$curlReturn
[
'response'
][
'userFriendlyMessage'
]];
return
[
'errors'
=>
FastOTPController
::
OTP_ERROR
.
$curlReturn
[
'response'
][
'userFriendlyMessage'
]];
}
else
{
return
[
'errors'
=>
FastOTPController
::
OTP_ERROR
.
$curlReturn
[
'response'
][
'developerMessage'
]];
}
}
return
[
'errors'
=>
FastOTPController
::
OTP_ERROR
.
$curlReturn
[
'response'
][
'developerMessage'
]];
}
}
return
[
'response'
=>
$curlReturn
[
'response'
]];
return
[
'response'
=>
$curlReturn
[
'response'
]];
}
}
...
@@ -240,57 +196,4 @@ class FastOTPController
...
@@ -240,57 +196,4 @@ class FastOTPController
return
[
'filename'
=>
$args
[
'filename'
],
'content'
=>
$xmlData
];
return
[
'filename'
=>
$args
[
'filename'
],
'content'
=>
$xmlData
];
}
}
public
static
function
defineDocumentMetadata
(
array
$args
)
{
ValidatorModel
::
notEmpty
(
$args
,
[
'connection_data'
,
'multipartBody'
,
'fastDocumentId'
]);
ValidatorModel
::
arrayType
(
$args
,
[
'connection_data'
,
'multipartBody'
]);
ValidatorModel
::
intVal
(
$args
,
[
'fastDocumentId'
]);
$curlReturn
=
CurlModel
::
exec
([
'method'
=>
'PUT'
,
'url'
=>
$args
[
'connection_data'
][
'apiUri'
]
.
"/documents/v2/otp/"
.
$args
[
'fastDocumentId'
]
.
"/metadata/define"
,
'options'
=>
[
CURLOPT_SSLCERT
=>
$args
[
'connection_data'
][
'certPath'
],
CURLOPT_SSLCERTPASSWD
=>
AuthenticationModel
::
decrypt
([
'cryptedPassword'
=>
$args
[
'connection_data'
][
'certPass'
]]),
CURLOPT_SSLCERTTYPE
=>
$args
[
'connection_data'
][
'certType'
]
],
'multipartBody'
=>
$args
[
'multipartBody'
]
]);
if
(
$curlReturn
[
'code'
]
!=
200
)
{
if
(
!
empty
(
$curlReturn
[
'resonse'
][
'userFriendlyMessage'
]))
{
return
[
'errors'
=>
FastOTPController
::
OTP_ERROR
.
$curlReturn
[
'response'
][
'userFriendlyMessage'
]];
}
return
[
'errors'
=>
FastOTPController
::
OTP_ERROR
.
$curlReturn
[
'response'
][
'developerMessage'
]];
}
return
[
'response'
=>
true
];
}
public
static
function
getSmsUrl
(
array
$args
)
{
ValidatorModel
::
notEmpty
(
$args
,
[
'connection_data'
,
'fastDocumentId'
]);
ValidatorModel
::
arrayType
(
$args
,
[
'connection_data'
]);
ValidatorModel
::
intVal
(
$args
,
[
'fastDocumentId'
]);
$curlReturn
=
CurlModel
::
exec
([
'method'
=>
'GET'
,
'url'
=>
$args
[
'connection_data'
][
'apiUri'
]
.
"/documents/v2/otp/url"
,
'options'
=>
[
CURLOPT_SSLCERT
=>
$args
[
'connection_data'
][
'certPath'
],
CURLOPT_SSLCERTPASSWD
=>
AuthenticationModel
::
decrypt
([
'cryptedPassword'
=>
$args
[
'connection_data'
][
'certPass'
]]),
CURLOPT_SSLCERTTYPE
=>
$args
[
'connection_data'
][
'certType'
]
],
'queryParams'
=>
[
'id'
=>
$args
[
'fastDocumentId'
]
]
]);
if
(
$curlReturn
[
'code'
]
!=
200
)
{
if
(
!
empty
(
$curlReturn
[
'resonse'
][
'userFriendlyMessage'
]))
{
return
[
'errors'
=>
FastOTPController
::
OTP_ERROR
.
$curlReturn
[
'response'
][
'userFriendlyMessage'
]];
}
return
[
'errors'
=>
FastOTPController
::
OTP_ERROR
.
$curlReturn
[
'response'
][
'developerMessage'
]];
}
return
[
'response'
=>
$curlReturn
[
'response'
]];
}
}
}
\ No newline at end of file
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