Skip to content
Snippets Groups Projects
Commit 37f906aa authored by Gospodin Bodurov's avatar Gospodin Bodurov
Browse files

Add java signing service

parent ec688929
No related branches found
No related tags found
1 merge request!57Ssj 1 signing service java initial
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
# unused-packages = true # unused-packages = true
[[constraint]] [[constraint]]
branch = "master" branch = "SSJ-1-signing-service-java-initial"
name = "code.vereign.com/code/restful-api" name = "code.vereign.com/code/restful-api"
[prune] [prune]
......
...@@ -1271,6 +1271,80 @@ const connection = Penpal.connectToParent({ ...@@ -1271,6 +1271,80 @@ const connection = Penpal.connectToParent({
return encodeResponse("200", "", "Document signed"); return encodeResponse("200", "", "Document signed");
}, },
signDocumentJava: async (passportUUID, documentUUID, documentContentType) => {
const authenticationPublicKey = localStorage.getItem(
"authenticatedIdentity"
);
if (
!authenticationPublicKey ||
!window.loadedIdentities[authenticationPublicKey] ||
!extendPinCodeTtl(authenticationPublicKey)
) {
return encodeResponse("400", "", "Identity not authenticated");
}
const certResponse = await getCertificateForPassport(passportUUID, true);
if (certResponse.code !== "200") {
return encodeResponse("400", "", certResponse.status);
}
const {
x509Certificate: passportCertificate,
privateKey: passportPrivateKey,
chain: passportChain
} = certResponse.data;
const keys = await createOneTimePassportCertificate(
makeid() + "-" + passportUUID,
null,
passportPrivateKey,
passportCertificate
);
const {
privateKeyPEM: privateKeyOneTime,
certificatePEM: certificateOneTime
} = keys;
passportChain.push(passportCertificate);
passportChain.push(certificateOneTime);
const pdfContentType = "application/pdf";
if (documentContentType !== pdfContentType) {
const convResponse = await executeRestfulFunction(
"private",
window.viamApi,
window.viamApi.documentConvertDocumentByUUID,
null,
documentUUID,
documentContentType,
pdfContentType
);
if (convResponse.code !== "200") {
return encodeResponse("400", "", convResponse.status);
}
}
const signResponse = await executeRestfulFunction(
"private",
window.viamApi,
window.viamApi.documentSignDocumentJavaService,
null,
privateKeyOneTime,
passportChain,
passportUUID,
documentUUID,
pdfContentType
);
if (signResponse.code !== "200") {
return encodeResponse("400", "", signResponse.status);
}
return encodeResponse("200", "", "Document signed");
},
documentCreateDocument: async (passportUUID, path, contentType, title) => { documentCreateDocument: async (passportUUID, path, contentType, title) => {
const authenticationPublicKey = localStorage.getItem( const authenticationPublicKey = localStorage.getItem(
"authenticatedIdentity" "authenticatedIdentity"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment