1 |
d72b12cf
|
Jan Pašek
|
Vue.use(VueLoading);
|
2 |
|
|
Vue.component('loading', VueLoading)
|
3 |
5885e489
|
Jan Pašek
|
|
4 |
7a423499
|
Jan Pašek
|
|
5 |
d72b12cf
|
Jan Pašek
|
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 |
|
|
issuedCertificates: [],
|
13 |
|
|
certificate: {
|
14 |
|
|
subject: {
|
15 |
|
|
C: "",
|
16 |
|
|
ST: "",
|
17 |
|
|
L: "",
|
18 |
|
|
CN: "",
|
19 |
|
|
O: "",
|
20 |
|
|
OU: "",
|
21 |
|
|
emailAddress: "",
|
22 |
7a423499
|
Jan Pašek
|
},
|
23 |
d72b12cf
|
Jan Pašek
|
notBefore: "",
|
24 |
|
|
notAfter: "",
|
25 |
|
|
usage: {
|
26 |
|
|
CA: false,
|
27 |
|
|
authentication: false,
|
28 |
|
|
digitalSignature: false,
|
29 |
|
|
SSL: false,
|
30 |
5f211e7b
|
Jan Pašek
|
},
|
31 |
d72b12cf
|
Jan Pašek
|
CA: null,
|
32 |
7a423499
|
Jan Pašek
|
},
|
33 |
d72b12cf
|
Jan Pašek
|
errorMessage: "",
|
34 |
|
|
successMessage: "",
|
35 |
|
|
},
|
36 |
|
|
computed: {
|
37 |
|
|
startDate: function () {
|
38 |
|
|
return this.certificate.notBefore.substr(0, 16);
|
39 |
7a423499
|
Jan Pašek
|
},
|
40 |
d72b12cf
|
Jan Pašek
|
endDate: function () {
|
41 |
|
|
return this.certificate.notAfter.substr(0, 16);
|
42 |
|
|
},
|
43 |
|
|
issuerURL: function () {
|
44 |
|
|
return "/static/certificate.html?id=" + this.certificate.CA;
|
45 |
|
|
},
|
46 |
|
|
crlEndpoint: function () {
|
47 |
|
|
return "/api/crl/" + this.certificate.CA;
|
48 |
|
|
},
|
49 |
|
|
ocspEndpoint: function () {
|
50 |
|
|
return "/api/ocsp/" + this.certificate.CA;
|
51 |
7a423499
|
Jan Pašek
|
}
|
52 |
d72b12cf
|
Jan Pašek
|
},
|
53 |
|
|
watch: {},
|
54 |
|
|
methods: {
|
55 |
|
|
onCertificateDownload: function () {
|
56 |
|
|
onCertificateDownload(this.id);
|
57 |
|
|
},
|
58 |
|
|
onRootDownload: function () {
|
59 |
|
|
onCertificateRootDownload(this.id);
|
60 |
|
|
},
|
61 |
|
|
onChainDownload: function () {
|
62 |
|
|
onCertificateChainDownload(this.id);
|
63 |
|
|
},
|
64 |
|
|
onPublicKeyDownload: function () {
|
65 |
|
|
onPublicKeyDownload(this.id);
|
66 |
|
|
},
|
67 |
|
|
onPrivateKeyDownload: function () {
|
68 |
|
|
onPrivateKeyDownload(this.id);
|
69 |
|
|
},
|
70 |
|
|
onRevoke: function () {
|
71 |
|
|
document.body.scrollTop = 0;
|
72 |
|
|
document.documentElement.scrollTop = 0;
|
73 |
|
|
axios.patch(API_URL + "certificates/" + this.id, {
|
74 |
|
|
status: "revoked",
|
75 |
|
|
reason: this.revocationReason
|
76 |
|
|
})
|
77 |
7a423499
|
Jan Pašek
|
.then(function (response) {
|
78 |
5885e489
|
Jan Pašek
|
if (response.data["success"]) {
|
79 |
d72b12cf
|
Jan Pašek
|
certificateDetailsApp.successMessage = "Certificate revocation successful.";
|
80 |
|
|
} else {
|
81 |
|
|
certificateDetailsApp.errorMessage = "Certificate cannot be revoked - " + response.data["data"] + "!";
|
82 |
5885e489
|
Jan Pašek
|
}
|
83 |
d72b12cf
|
Jan Pašek
|
})
|
84 |
|
|
.catch(function (error) {
|
85 |
|
|
certificateDetailsApp.errorMessage = "An error occurred while revoking certificate";
|
86 |
|
|
});
|
87 |
|
|
},
|
88 |
|
|
onDelete: function () {
|
89 |
|
|
document.body.scrollTop = 0;
|
90 |
|
|
document.documentElement.scrollTop = 0;
|
91 |
|
|
axios.delete(API_URL + "certificates/" + this.id)
|
92 |
|
|
.then(function (response) {
|
93 |
|
|
if (response.data["success"]) {
|
94 |
|
|
window.location.href = "/static/index.html?success=Certificate+successfully+deleted";
|
95 |
|
|
} else {
|
96 |
|
|
certificateDetailsApp.errorMessage = "Certificate cannot be deleted - " + response.data["data"] + "!";
|
97 |
5885e489
|
Jan Pašek
|
}
|
98 |
7a423499
|
Jan Pašek
|
})
|
99 |
|
|
.catch(function (error) {
|
100 |
d72b12cf
|
Jan Pašek
|
certificateDetailsApp.errorMessage = "An error occurred while deleting certificate";
|
101 |
7a423499
|
Jan Pašek
|
});
|
102 |
d72b12cf
|
Jan Pašek
|
},
|
103 |
|
|
loadIssuedCertificates: function () {
|
104 |
|
|
|
105 |
|
|
}
|
106 |
|
|
},
|
107 |
|
|
mounted: function () {
|
108 |
|
|
// get details of the selected certificate
|
109 |
|
|
const params = window.location.search;
|
110 |
|
|
if (params !== "") {
|
111 |
|
|
// get requested ID
|
112 |
|
|
const urlParams = new URLSearchParams(params);
|
113 |
|
|
if (urlParams.get("id") != null) {
|
114 |
|
|
const id = urlParams.get("id");
|
115 |
|
|
this.id = id;
|
116 |
|
|
// query certificate details
|
117 |
|
|
axios.get(API_URL + "certificates/" + id + "/details")
|
118 |
|
|
.then(function (response) {
|
119 |
|
|
if (response.data["success"]) {
|
120 |
|
|
// display certificate
|
121 |
|
|
certificateDetailsApp.certificate = response.data["data"];
|
122 |
|
|
axios.get(API_URL + "certificates", {
|
123 |
|
|
params: {
|
124 |
|
|
filtering: {
|
125 |
|
|
issuedby: parseInt(certificateDetailsApp.id)
|
126 |
|
|
}
|
127 |
|
|
}
|
128 |
|
|
})
|
129 |
|
|
.then(function (response) {
|
130 |
|
|
if (response.data["success"]) {
|
131 |
|
|
response.data["data"].forEach(item => {
|
132 |
|
|
if (item.id != certificateDetailsApp.id) certificateDetailsApp.issuedCertificates.push(item)
|
133 |
|
|
})
|
134 |
|
|
} else {
|
135 |
|
|
certificateDetailsApp.issuedCertificates = [];
|
136 |
|
|
}
|
137 |
|
|
})
|
138 |
|
|
.catch(function (error) {
|
139 |
|
|
console.log(error);
|
140 |
|
|
});
|
141 |
|
|
certificateDetailsApp.loading = false;
|
142 |
|
|
certificateDetailsApp.error = false;
|
143 |
|
|
} else {
|
144 |
|
|
// certificate does not exists
|
145 |
|
|
console.error("Required certificate does not exists");
|
146 |
|
|
certificateDetailsApp.loading = false;
|
147 |
|
|
certificateDetailsApp.error = true;
|
148 |
|
|
}
|
149 |
|
|
})
|
150 |
|
|
.catch(function (error) {
|
151 |
|
|
// server error
|
152 |
|
|
console.error(error);
|
153 |
|
|
certificateDetailsApp.loading = false;
|
154 |
|
|
certificateDetailsApp.error = true;
|
155 |
|
|
});
|
156 |
|
|
} else {
|
157 |
|
|
// id was not provided as a URL parameter
|
158 |
|
|
console.error("URL does not contain 'id' parameter")
|
159 |
|
|
certificateDetailsApp.loading = false;
|
160 |
|
|
certificateDetailsApp.error = true;
|
161 |
|
|
}
|
162 |
7a423499
|
Jan Pašek
|
} else {
|
163 |
5885e489
|
Jan Pašek
|
console.error("URL does not contain 'id' parameter")
|
164 |
|
|
certificateDetailsApp.loading = false;
|
165 |
|
|
certificateDetailsApp.error = true;
|
166 |
7a423499
|
Jan Pašek
|
}
|
167 |
5885e489
|
Jan Pašek
|
}
|
168 |
d72b12cf
|
Jan Pašek
|
});
|
169 |
|
|
|