1
|
Vue.use(VueLoading);
|
2
|
Vue.component('loading', VueLoading)
|
3
|
|
4
|
|
5
|
var certificateDetailsApp = new Vue({
|
6
|
el: "#certificate-detailed-view-content",
|
7
|
data: {
|
8
|
loading: true,
|
9
|
error: false,
|
10
|
id: null,
|
11
|
revocationReason: "unspecified",
|
12
|
certificate: {
|
13
|
subject: {
|
14
|
C: "",
|
15
|
ST: "",
|
16
|
L: "",
|
17
|
CN: "",
|
18
|
O: "",
|
19
|
OU: "",
|
20
|
emailAddress: "",
|
21
|
},
|
22
|
notBefore: "",
|
23
|
notAfter: "",
|
24
|
usage: {
|
25
|
CA: false,
|
26
|
authentication: false,
|
27
|
digitalSignature: false,
|
28
|
SSL: false,
|
29
|
},
|
30
|
CA: null,
|
31
|
},
|
32
|
errorMessage: "",
|
33
|
successMessage: "",
|
34
|
},
|
35
|
computed: {
|
36
|
startDate: function () {
|
37
|
return this.certificate.notBefore.substr(0, 16);
|
38
|
},
|
39
|
endDate: function () {
|
40
|
return this.certificate.notAfter.substr(0, 16);
|
41
|
},
|
42
|
issuerURL: function () {
|
43
|
return "/static/certificate.html?id=" + this.certificate.CA;
|
44
|
},
|
45
|
crlEndpoint: function () {
|
46
|
return "/api/crl/" + this.certificate.CA;
|
47
|
},
|
48
|
ocspEndpoint: function () {
|
49
|
return "/api/ocsp/" + this.certificate.CA;
|
50
|
}
|
51
|
},
|
52
|
watch: {
|
53
|
|
54
|
},
|
55
|
methods: {
|
56
|
onCertificateDownload: function () {
|
57
|
onCertificateDownload(this.id);
|
58
|
},
|
59
|
onRootDownload: function () {
|
60
|
onCertificateRootDownload(this.id);
|
61
|
},
|
62
|
onChainDownload: function () {
|
63
|
onCertificateChainDownload(this.id);
|
64
|
},
|
65
|
onPublicKeyDownload: function () {
|
66
|
onPublicKeyDownload(this.id);
|
67
|
},
|
68
|
onPrivateKeyDownload: function () {
|
69
|
onPrivateKeyDownload(this.id);
|
70
|
},
|
71
|
onRevoke: function () {
|
72
|
document.body.scrollTop = 0;
|
73
|
document.documentElement.scrollTop = 0;
|
74
|
axios.patch(API_URL + "certificates/"+this.id, {
|
75
|
status: "revoked",
|
76
|
reason: this.revocationReason
|
77
|
})
|
78
|
.then(function (response) {
|
79
|
if(response.data["success"]) {
|
80
|
certificateDetailsApp.successMessage = "Certificate revocation successful.";
|
81
|
}
|
82
|
else {
|
83
|
certificateDetailsApp.errorMessage = "Certificate cannot be revoked - "+response.data["data"]+"!";
|
84
|
}
|
85
|
})
|
86
|
.catch(function (error) {
|
87
|
certificateDetailsApp.errorMessage = "An error occurred while revoking certificate";
|
88
|
});
|
89
|
},
|
90
|
onDelete: function () {
|
91
|
|
92
|
}
|
93
|
}
|
94
|
});
|
95
|
|
96
|
// get details of the selected certificate
|
97
|
const params = window.location.search;
|
98
|
if (params !== "") {
|
99
|
// get requested ID
|
100
|
const urlParams = new URLSearchParams(params);
|
101
|
if (urlParams.get("id") != null) {
|
102
|
const id = urlParams.get("id");
|
103
|
certificateDetailsApp.id = id;
|
104
|
// query certificate detailes
|
105
|
axios.get(API_URL + "certificates/"+id+"/details")
|
106
|
.then(function (response) {
|
107
|
if (response.data["success"]) {
|
108
|
// display certificate
|
109
|
certificateDetailsApp.certificate = response.data["data"];
|
110
|
certificateDetailsApp.loading = false;
|
111
|
certificateDetailsApp.error = false;
|
112
|
}
|
113
|
else {
|
114
|
// certificate does not exists
|
115
|
console.error("Required certificate does not exists");
|
116
|
certificateDetailsApp.loading = false;
|
117
|
certificateDetailsApp.error = true;
|
118
|
}
|
119
|
})
|
120
|
.catch(function (error) {
|
121
|
// server error
|
122
|
console.error(error);
|
123
|
certificateDetailsApp.loading = false;
|
124
|
certificateDetailsApp.error = true;
|
125
|
});
|
126
|
} else {
|
127
|
// id was not provided as a URL parameter
|
128
|
console.error("URL does not contain 'id' parameter")
|
129
|
certificateDetailsApp.loading = false;
|
130
|
certificateDetailsApp.error = true;
|
131
|
}
|
132
|
} else {
|
133
|
console.error("URL does not contain 'id' parameter")
|
134
|
certificateDetailsApp.loading = false;
|
135
|
certificateDetailsApp.error = true;
|
136
|
}
|