Skip to content
Snippets Groups Projects
Commit 7c3e23e5 authored by Sasha Ilieva's avatar Sasha Ilieva
Browse files

Merge branch 'master' into 553-filter-interactions

parents a8e51975 3c39f5e6
Branches
Tags
1 merge request!53Ability to search and filter Inbox(Emails and Documents)
This commit is part of merge request !53. Comments created here will be created in the context of that merge request.
......@@ -1194,8 +1194,12 @@ const connection = Penpal.connectToParent({
certificatePEM: certificateOneTime
} = keys;
passportChain.reverse();
passportChain.push(passportCertificate);
passportChain.reverse();
const pdfContentType = "application/pdf";
if (documentContentType !== pdfContentType) {
......@@ -1271,6 +1275,84 @@ const connection = Penpal.connectToParent({
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.reverse();
passportChain.push(passportCertificate);
passportChain.push(certificateOneTime);
passportChain.reverse();
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) => {
const authenticationPublicKey = localStorage.getItem(
"authenticatedIdentity"
......
......@@ -124,8 +124,28 @@ function generateKeys(algorithms) {
return crypto.generateKey(algorithm.algorithm, true, algorithm.usages);
}
function fixPkijsRDN() {
pkijs.RelativeDistinguishedNames.prototype.toSchema = function () {
//region Decode stored TBS value
if (this.valueBeforeDecode.byteLength === 0) // No stored encoded array, create "from scratch"
{
return (new asn1js.Sequence({
value: Array.from(this.typesAndValues, element => new asn1js.Set({value: [element.toSchema()]}))
}));
}
const asn1 = asn1js.fromBER(this.valueBeforeDecode);
//endregion
//region Construct and return new ASN.1 schema for this object
return asn1.result;
//endregion
};
}
//*********************************************************************************
function createCertificate(certData, issuerData = null) {
if (typeof certData === "undefined") {
return Promise.reject("No Certificate data provided");
}
......@@ -1252,3 +1272,6 @@ export const verifySMIME = (smimeString, rootCaPem) => {
}, 50);
});
};
//Initialization block
fixPkijsRDN();
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment