Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 7a423499

Přidáno uživatelem Jan Pašek před asi 4 roky(ů)

Re #8583 - Details page subject data

Zobrazit rozdíly:

static/certificate.html
12 12
            <h1 class="ml-2 d-inline-block">Certificate Detailed View</h1>
13 13
            <span class="ml-2 mb-2">
14 14
                <div>
15
                    <a class="btn btn-success ml-2 mb-3" href="">Download Certificate</a>
16
                    <a class="btn btn-success ml-2 mb-3" href="">Download Root Certificate</a>
17
                    <a class="btn btn-success ml-2 mb-3" href="">Download Chain of Trust</a>
15
                    <a class="btn btn-success ml-2 mb-3" v-on:click="onCertificateDownload()">Download Certificate</a>
16
                    <a class="btn btn-success ml-2 mb-3" v-on:click="onRootDownload()">Download Root Certificate</a>
17
                    <a class="btn btn-success ml-2 mb-3" v-on:click="onChainDownload()">Download Chain of Trust</a>
18 18
                </div>
19 19
                <div>
20
                    <a class="btn btn-warning ml-2 mb-2" href="">Revoke certificate</a>
21
                    <a class="btn btn-danger ml-2 mb-2" href="">Delete certificate</a>
20
                    <a class="btn btn-warning ml-2 mb-2" v-on:click="onRevoke()">Revoke certificate</a>
21
                    <a class="btn btn-danger ml-2 mb-2" v-on:click="onDelete()">Delete certificate</a>
22 22
                </div>
23 23
            </span>
24 24
        </div>
......
36 36
                        <div class="form-group">
37 37
                            <td><label for="validity_start">Validity start:</label></td>
38 38
                            <td class="pl-3">
39
                                <input value="" type="date" id="validity_start" name="validity_start" class="form-control" disabled>
39
                                <input :value="startDate" type="text" id="validity_start" name="validity_start" class="form-control" disabled>
40 40
                            </td>
41 41
                        </div>
42 42
                    </tr>
......
44 44
                        <div class="form-group">
45 45
                            <td><label for="validity_end">Validity end:</label></td>
46 46
                            <td class="pl-3">
47
                                <input value="" type="date" id="validity_end" name="validity_end" class="form-control" disabled>
47
                                <input :value="endDate" type="text" id="validity_end" name="validity_end" class="form-control" disabled>
48 48
                            </td>
49 49
                        </div>
50 50
                    </tr>
......
55 55
                        <div class="form-group">
56 56
                            <td><label for="subject_C">Country Code:</label></td>
57 57
                            <td class="pl-3">
58
                                <input value="" type="text" id="subject_C" name="subject_C" class="form-control" disabled>
58
                                <input :value="certificate.subject.C" type="text" id="subject_C" name="subject_C" class="form-control" disabled>
59 59
                            </td>
60 60
                        </div>
61 61
                    </tr>
......
63 63
                        <div class="form-group">
64 64
                            <td><label for="subject_ST">Province/State:</label></td>
65 65
                            <td class="pl-3">
66
                                <input value="" type="text" id="subject_ST" name="subject_ST" class="form-control" disabled>
66
                                <input :value="certificate.subject.ST" type="text" id="subject_ST" name="subject_ST" class="form-control" disabled>
67 67
                            </td>
68 68
                        </div>
69 69
                    </tr>
......
71 71
                        <div class="form-group">
72 72
                            <td><label for="subject_L">Locality:</label></td>
73 73
                            <td class="pl-3">
74
                                <input value="" type="text" id="subject_L" name="subject_L" class="form-control" disabled>
74
                                <input :value="certificate.subject.L" type="text" id="subject_L" name="subject_L" class="form-control" disabled>
75 75
                            </td>
76 76
                        </div>
77 77
                    </tr>
......
79 79
                        <div class="form-group">
80 80
                            <td><label for="subject_CN">Common Name:</label></td>
81 81
                            <td class="pl-3">
82
                                <input value="" type="text" id="subject_CN" name="subject_CN" class="form-control" disabled>
82
                                <input :value="certificate.subject.CN" type="text" id="subject_CN" name="subject_CN" class="form-control" disabled>
83 83
                            </td>
84 84
                        </div>
85 85
                    </tr>
......
87 87
                        <div class="form-group">
88 88
                            <td><label for="subject_O">Organization:</label></td>
89 89
                            <td class="pl-3">
90
                                <input value="" type="text" id="subject_O" name="subject_O" class="form-control" disabled>
90
                                <input :value="certificate.subject.O" type="text" id="subject_O" name="subject_O" class="form-control" disabled>
91 91
                            </td>
92 92
                        </div>
93 93
                    </tr>
......
95 95
                        <div class="form-group">
96 96
                            <td><label for="subject_OU">Organization Unit:</label></td>
97 97
                            <td class="pl-3">
98
                                <input value="" type="text" id="subject_OU" name="subject_OU" class="form-control" disabled>
98
                                <input :value="certificate.subject.OU" type="text" id="subject_OU" name="subject_OU" class="form-control" disabled>
99 99
                            </td>
100 100
                        </div>
101 101
                    </tr>
......
103 103
                        <div class="form-group">
104 104
                            <td><label for="subject_emailAddress">Email Address:</label></td>
105 105
                            <td class="pl-3">
106
                                <input value="" type="text" id="subject_emailAddress" name="subject_emailAddress" class="form-control" disabled>
106
                                <input :value="certificate.subject.emailAddress" type="text" id="subject_emailAddress" name="subject_emailAddress" class="form-control" disabled>
107 107
                            </td>
108 108
                        </div>
109 109
                    </tr>
110 110
                    <tr>
111 111
                        <td>Usage:</td>
112 112
                        <td class="form-check">
113
                            <input class="form-check-input" v-model="certificateData.usage.CA" type="checkbox" id="isCA" name="isCA" value="CA" disabled>
113
                            <input class="form-check-input" v-model="certificate.usage.CA" type="checkbox" id="isCA" name="isCA" value="CA" disabled>
114 114
                            <label class="form-check-label" for="isCA">CA</label><br>
115 115

  
116
                            <input class="form-check-input" v-model="certificateData.usage.digitalSignature" type="checkbox" id="isDigitalSignature" name="isDigitalSignature" value="DigitalSignature" disabled>
116
                            <input class="form-check-input" v-model="certificate.usage.digitalSignature" type="checkbox" id="isDigitalSignature" name="isDigitalSignature" value="DigitalSignature" disabled>
117 117
                            <label class="form-check-label" for="isDigitalSignature">Digital Signature</label><br>
118 118

  
119
                            <input class="form-check-input" v-model="certificateData.usage.authentication" type="checkbox" id="isAuthentication" name="isAuthentication" value="Authentication" disabled>
119
                            <input class="form-check-input" v-model="certificate.usage.authentication" type="checkbox" id="isAuthentication" name="isAuthentication" value="Authentication" disabled>
120 120
                            <label class="form-check-label" for="isAuthentication">Authentication</label><br>
121 121

  
122
                            <input class="form-check-input" v-model="certificateData.usage.SSL" type="checkbox" id="isSSL_TLS" name="isSSL_TLS" value="SSL_TLS" disabled>
122
                            <input class="form-check-input" v-model="certificate.usage.SSL" type="checkbox" id="isSSL_TLS" name="isSSL_TLS" value="SSL_TLS" disabled>
123 123
                            <label class="form-check-label" for="isSSL_TLS">SSL/TLS</label><br>
124 124
                        </td>
125 125
                    </tr>
126 126
                </table>
127 127
                <div class="text-center">
128
                    <a class="btn btn-success m-1" href="">Download Public Key</a>
129
                    <a class="btn btn-success m-1" href="">Download Private Key</a>
128
                    <a class="btn btn-success m-1" v-on:click="onPublicKeyDownload()">Download Public Key</a>
129
                    <a class="btn btn-success m-1" v-on:click="onPrivateKeyDownload()">Download Private Key</a>
130 130
                </div>
131 131
            </div>
132 132
            <div class="col-xl-7 table-responsive">
static/js/certificate.js
1

  
2
    var certificateDetailsApp = new Vue({
3
        el: "#certificate-detailed-view-content",
4
        data: {
5
            certificate: {
6
                subject: {
7
                    C: "",
8
                    ST: "",
9
                    L: "",
10
                    CN: "",
11
                    O: "",
12
                    OU: "",
13
                    emailAddress: "",
14
                },
15
                notBefore: "",
16
                notAfter: "",
17
                usage: {
18
                    CA: false,
19
                    authentication: false,
20
                    digitalSignature: false,
21
                    SSL: false,
22
                },
23
                CA: null,
24
            },
25
        },
26
        computed: {
27
            startDate: function () {
28
                return this.certificate.notBefore.substr(0, 16);
29
            },
30
            endDate: function () {
31
                return this.certificate.notAfter.substr(0, 16);
32
            }
33
        },
34
        watch: {
35

  
36
        },
37
        methods: {
38
            onCertificateDownload: function () {
39

  
40
            },
41
            onRootDownload: function () {
42

  
43
            },
44
            onChainDownload: function () {
45

  
46
            },
47
            onPublicKeyDownload: function () {
48

  
49
            },
50
            onPrivateKeyDownload: function () {
51

  
52
            },
53
            onRevoke: function () {
54

  
55
            },
56
            onDelete: function () {
57

  
58
            }
59
        }
60
    });
61

  
62
    // get details of the selected certificate
63
    const params = window.location.search;
64
    if (params !== "") {
65
        const urlParams = new URLSearchParams(params);
66
        if (urlParams.get("id") != null) {
67
            const id = urlParams.get("id");
68
            axios.get(API_URL + "certificates/"+id+"/details")
69
                .then(function (response) {
70
                    if (response.data["success"])
71
                        certificateDetailsApp.certificate = response.data["data"];
72
                })
73
                .catch(function (error) {
74
                    alert("There should be some error reaction");
75
                    // TODO error reaction -> display fault window
76
                });
77
        } else {
78
            alert("There should be some error reaction");
79
            // TODO error reaction -> display fault window
80
        }
81
    } else {
82
        alert("There should be some error reaction");
83
        // TODO error reaction -> display fault window
84
    }
static/js/components.js
28 28
    methods: {
29 29
        // Get the certificate PEM data from the server and downloads it to users computer
30 30
        onCertificateDownload: function () {
31
            var id = this.certificate.id;
32
            axios.get(API_URL + "certificates/" + id)
33
                .then(function (response) {
34
                    if(response.data["success"]) {
35
                        download(id + ".pem", response.data["data"])
36
                    }
37
                    else
38
                        console.log("Error occurred while downloading the certificate") // TODO more action may be required
39
                })
40
                .catch(function (error) {
41
                    console.log(error);
42
                });
31
            onCertificateDownload(this.certificate.id)
43 32
        },
44
        // Get the certificate's chain of trust in PEM format from the server and downloads it to users computer
45
        onCertificateChainDownload: function () {
46
            var id = this.certificate.id;
47
            axios.get(API_URL + "certificates/" + id + "/chain")
48
                .then(function (response) {
49
                    if(response.data["success"]) {
50
                        download(id + "_chain.pem", response.data["data"])
51
                    }
52
                    else
53
                        console.log("Error occurred while downloading the certificate's chain of trust") // TODO more action may be required
54
                })
55
                .catch(function (error) {
56
                    console.log(error);
57
                });
58
        },
59
        // Get the certificate's root CA as PEM data from the server and downloads it to users computer
60
        onCertificateRootDownload: function () {
61
            var id = this.certificate.id;
62
            axios.get(API_URL + "certificates/" + id + "/root")
63
                .then(function (response) {
64
                    if(response.data["success"]) {
65
                        download(id + "_root.pem", response.data["data"])
66
                    }
67
                    else
68
                        console.log("Error occurred while downloading the certificate's root CA") // TODO more action may be required
69
                })
70
                .catch(function (error) {
71
                    console.log(error);
72
                });
73
        }
74 33
    }
75 34
});
76 35

  
static/js/index.js
13 13
                const urlParams = new URLSearchParams(params);
14 14
                if (urlParams.get("success") != null) this.successMessage = urlParams.get("success");
15 15

  
16
                // the following code is necessary to dismiss the alert when the page is reloaded
16 17
                const nextURL = '/static/index.html';
17 18
                const nextTitle = 'X.509 Certificate Management';
18 19
                const nextState = { additionalInformation: 'Updated the URL with JS' };
static/js/utilities.js
25 25
    var local = new Date(this);
26 26
    local.setMinutes(this.getMinutes() - this.getTimezoneOffset());
27 27
    return local.toJSON().slice(0,10);
28
});
28
});
29

  
30
// Get the certificate PEM data from the server and downloads it to users computer
31
function onCertificateDownload(id) {
32
    axios.get(API_URL + "certificates/" + id)
33
        .then(function (response) {
34
            if (response.data["success"]) {
35
                download(id + ".pem", response.data["data"])
36
            } else
37
                console.log("Error occurred while downloading the certificate") // TODO more action may be required
38
        })
39
        .catch(function (error) {
40
            console.log(error);
41
        });
42
}
43

  
44
// Get the certificate's chain of trust in PEM format from the server and downloads it to users computer
45
function onCertificateChainDownload(id) {
46
    axios.get(API_URL + "certificates/" + id + "/chain")
47
        .then(function (response) {
48
            if(response.data["success"]) {
49
                download(id + "_chain.pem", response.data["data"])
50
            }
51
            else
52
                console.log("Error occurred while downloading the certificate's chain of trust") // TODO more action may be required
53
        })
54
        .catch(function (error) {
55
            console.log(error);
56
        });
57
}
58

  
59
// Get the certificate's root CA as PEM data from the server and downloads it to users computer
60
function onCertificateRootDownload(id) {
61
    axios.get(API_URL + "certificates/" + id + "/root")
62
        .then(function (response) {
63
            if(response.data["success"]) {
64
                download(id + "_root.pem", response.data["data"])
65
            }
66
            else
67
                console.log("Error occurred while downloading the certificate's root CA") // TODO more action may be required
68
        })
69
        .catch(function (error) {
70
            console.log(error);
71
        });
72
}

Také k dispozici: Unified diff