/
Index.cshtml
66 lines (55 loc) · 2.67 KB
/
Index.cshtml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
@using PkiSuiteAspNetMvcSample.Models.Rest
@model SignatureModel
<h2 class="ls-title">XML Signature with REST PKI</h2>
<form id="signForm" method="POST">
@* Render the token in a hidden input field. *@
@Html.HiddenFor(m => m.Token)
<div class="form-group">
<label>File to sign</label>
<p>You are signing this <b>entire</b> <a href='~/Content/SampleDocument.xml'>sample XML</a>.</p>
</div>
@*
Render a select (combo box) to list the user's certificates. For now it will be empty, we'll populate
it later on (see signature-form.js).
*@
<div class="form-group">
<label for="certificateSelect">Choose a certificate</label>
<select id="certificateSelect" class="form-control"></select>
</div>
@*
Action buttons. Notice that the "Sign File" button is NOT a submit button. When the user clicks the
button, we must first use the Web PKI component to perform the client-side computation necessary and
only when that computation is finished we'll submit the form programmatically
(see signature-form.js).
*@
<button id="signButton" type="button" class="btn btn-primary">Sign File</button>
<button id="refreshButton" type="button" class="btn btn-outline-primary">Refresh Certificates</button>
</form>
@section Scripts {
@*
The file below contains the JS lib for accessing the Web PKI component. For more information, see:
https://webpki.lacunasoftware.com/#/Documentation
*@
<script type="text/javascript" src="https://cdn.lacunasoftware.com/libs/web-pki/lacuna-web-pki-2.14.3.min.js"
integrity="sha256-P92LF1ePw0qwnmbefDpDiMcr8rmwFkcxVX+utanmlek="
crossorigin="anonymous"></script>
@*
The file below contains the logic for calling the Web PKI component. It is only an example, feel
free to alter it to meet your application's needs. You can also bring the code into the javascript
block below if you prefer.
*@
<script src="@Url.Content("~/Content/js/signature-form.js")"></script>
<script>
$(document).ready(function () {
// Once the page is ready, we call the init() function on the javascript code
// (see signature-form.js)
signatureForm.init({
token: '@Model.Token', // The token acquired from REST PKI.
form: $('#signForm'), // The form that should be submitted when the operation is completed.
certificateSelect: $('#certificateSelect'), // The <select> element (combo box) to list the certificates.
refreshButton: $('#refreshButton'), // The "refresh" button.
signButton: $('#signButton') // The button that initiates the operation.
});
});
</script>
}