1
|
|
2
|
// Component representing an instance in certificate listing
|
3
|
Vue.component("certificate-item",{
|
4
|
// certificate = certificate to be displayed by the list item
|
5
|
props: ["certificate"],
|
6
|
template: "<tr>"+
|
7
|
"<td class='align-middle'>{{ certificate.CN }}</td>"+
|
8
|
"<td class='align-middle'>{{ certificate.notBefore }}</td>"+
|
9
|
"<td class='align-middle'>{{ certificate.notAfter }}</td>"+
|
10
|
"<td class='align-middle'>" +
|
11
|
" <div v-if='certificate.usage.CA'>CA</div>" +
|
12
|
" <div v-if='certificate.usage.authentication'>authentication</div>" +
|
13
|
" <div v-if='certificate.usage.digitalSignature'>digital signature</div>" +
|
14
|
" <div v-if='certificate.usage.SSL'>SSL/TLS</div>" +
|
15
|
"</td>"+
|
16
|
"<td class='align-middle'><button v-on:click='onCertificateDownload()'>Download certificate</button></td>"+
|
17
|
"<td class='align-middle'><button v-on:click='onCertificateChainDownload()'>Download chain of trust</button></td>"+
|
18
|
"<td class='align-middle'><button v-on:click='onCertificateRootDownload()'>Download chain root</button></td>"+
|
19
|
"</tr>",
|
20
|
methods: {
|
21
|
// Get the certificate PEM data from the server and downloads it to users computer
|
22
|
onCertificateDownload: function () {
|
23
|
var id = this.certificate.id;
|
24
|
axios.get(API_URL + "certificates/" + id)
|
25
|
.then(function (response) {
|
26
|
if(response.data["success"]) {
|
27
|
download(id + ".crt", response.data["data"])
|
28
|
}
|
29
|
else
|
30
|
console.log("Error occurred while downloading the certificate") // TODO more action may be required
|
31
|
})
|
32
|
.catch(function (error) {
|
33
|
console.log(error);
|
34
|
});
|
35
|
},
|
36
|
// Get the certificate's chain of trust in PEM format from the server and downloads it to users computer
|
37
|
onCertificateChainDownload: function () {
|
38
|
var id = this.certificate.id;
|
39
|
axios.get(API_URL + "certificates/" + id + "/chain")
|
40
|
.then(function (response) {
|
41
|
if(response.data["success"]) {
|
42
|
download(id + "_chain.crt", response.data["data"])
|
43
|
}
|
44
|
else
|
45
|
console.log("Error occurred while downloading the certificate's chain of trust") // TODO more action may be required
|
46
|
})
|
47
|
.catch(function (error) {
|
48
|
console.log(error);
|
49
|
});
|
50
|
},
|
51
|
// Get the certificate's root CA as PEM data from the server and downloads it to users computer
|
52
|
onCertificateRootDownload: function () {
|
53
|
var id = this.certificate.id;
|
54
|
axios.get(API_URL + "certificates/" + id + "/root")
|
55
|
.then(function (response) {
|
56
|
if(response.data["success"]) {
|
57
|
download(id + "_root.crt", response.data["data"])
|
58
|
}
|
59
|
else
|
60
|
console.log("Error occurred while downloading the certificate's root CA") // TODO more action may be required
|
61
|
})
|
62
|
.catch(function (error) {
|
63
|
console.log(error);
|
64
|
});
|
65
|
}
|
66
|
}
|
67
|
});
|
68
|
|
69
|
// Component representing an item in select of available CAs
|
70
|
Vue.component("ca-select-item", {
|
71
|
// Certificate authority to be represented by the option
|
72
|
props: ["ca"],
|
73
|
template: "<option v-bind:value='ca.id'>{{ ca.CN }}</option>"
|
74
|
});
|