|
|
|
@ -39,7 +39,51 @@ $(function () {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function handleEmbeddedResult(data) {
|
|
|
|
|
console.log("I haven't implemented this yet")
|
|
|
|
|
var fileReader = new FileReader();
|
|
|
|
|
|
|
|
|
|
fileReader.onload = function() {
|
|
|
|
|
var text = this.result;
|
|
|
|
|
if (keyFileContent === null) {
|
|
|
|
|
saveText(text, 'server-embedded.conf');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var match = /<key>/.exec(text);
|
|
|
|
|
matchOffset = match.index + 6;
|
|
|
|
|
text = text.substring(0, matchOffset) + keyFileContent + text.substring(matchOffset);
|
|
|
|
|
|
|
|
|
|
if (decryptKeyCheckbox.prop('checked') === true) {
|
|
|
|
|
var keyPassword = password.val();
|
|
|
|
|
text = decryptKey(text, keyPassword);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
saveText(text, 'server-embedded.conf');
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
fileReader.readAsText(data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function decryptKey(text, keyPassword) {
|
|
|
|
|
var match = /<key>/.exec(text);
|
|
|
|
|
|
|
|
|
|
var keyStartOffset = match.index + 6;
|
|
|
|
|
|
|
|
|
|
match = /<\/key>/.exec(text);
|
|
|
|
|
|
|
|
|
|
var keyEndOffset = match.index;
|
|
|
|
|
|
|
|
|
|
var keyContent = text.substring(keyStartOffset, keyEndOffset);
|
|
|
|
|
|
|
|
|
|
var decryptedKey = 'DECRYPTED_KEY';
|
|
|
|
|
|
|
|
|
|
// actual decryption happens here
|
|
|
|
|
|
|
|
|
|
return text.substring(0, keyStartOffset) + decryptedKey + text.substring(keyEndOffset);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function saveText(text, fileName) {
|
|
|
|
|
var blob = new Blob([text], {type: 'text/plain'});
|
|
|
|
|
var blobUrl = URL.createObjectURL(blob);
|
|
|
|
|
saveBlobUrl(blobUrl, fileName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var downloadElement = document.createElement("a");
|
|
|
|
@ -54,15 +98,12 @@ $(function () {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function submitCertificateForm(event) {
|
|
|
|
|
console.log('submitCert');
|
|
|
|
|
var url = getCertificateForm.attr('action'),
|
|
|
|
|
method = getCertificateForm.attr('method'),
|
|
|
|
|
data = getCertificateForm.serialize(),
|
|
|
|
|
dataType = 'application/zip',
|
|
|
|
|
handler = handleZipResult;
|
|
|
|
|
|
|
|
|
|
if (embedConfiguration.checked) {
|
|
|
|
|
dataType = 'text/plain';
|
|
|
|
|
if (embedConfiguration.prop('checked') === true) {
|
|
|
|
|
handler = handleEmbeddedResult;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|