summaryrefslogtreecommitdiffstats
path: root/openssl-html.lsp
blob: 97b4a972d1fed4fda5b13f905c10f2153a2cd477 (plain)
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<? local view, viewlibrary, pageinfo, session = ... ?>

<? --[[ DEBUG INFORMATION
io.write(html.cfe_unpack(view))
--]] ?>

<link rel="stylesheet" type="text/css" href="/js/style.css">
<script type="text/javascript" src="/js/jquery-latest.js"></script>
<script type="text/javascript" src="/js/jquery.tablesorter.min.js"></script>
<script type="text/javascript">
	$(document).ready(function() {
		$("#pending").tablesorter({headers: {0:{sorter: false}}});
		$("#approved").tablesorter({headers: {0:{sorter: false}, 5:{sorter:'usLongDate'}}});
		$("#revoked").tablesorter({headers: {0:{sorter: false}, 5:{sorter:'usLongDate'}}});
	});
</script>

<? if view.value.cmdresult then ?>
<H1>Command Result</H1>
<DL>
<?= string.gsub(view.value.cmdresult.value, "\n", "<BR>") ?>
</DL>
<? end ?>

<H1>Pending certificate requests<? if view.value.user then?> for <?= view.value.user.value ?><? end ?></H1>
<? if not view.value.pending or #view.value.pending.value == 0 then ?>
	No certificates pending
<? else ?>
<table id="pending" class="tablesorter">
<thead>
	<tr>
		<th>Action</th>
		<th>User</th>
		<th>Cert Type</th>
		<th>Common Name</th>
	</tr>
</thead>
<tbody>
	<? for i,request in ipairs(view.value.pending.value) do ?>
		<tr>
		<td>
		<? if session.permissions.openssl.viewrequest then
			io.write(html.link{value="viewrequest?request="..request.name, label="View "})
		end ?>
		<? if session.permissions.openssl.approve then
			io.write(html.link{value="approve?request="..request.name, label="Approve "})
		end ?>
		<? if session.permissions.openssl.deleterequest then
			io.write(html.link{value="deleterequest?request="..request.name, label="Delete "})
		elseif session.permissions.openssl.deletemyrequest then
			io.write(html.link{value="deletemyrequest?request="..request.name, label="Delete "})
		end ?>
		</td>
		<td><?= request.user ?></td>
		<td><?= request.certtype ?></td>
		<td><?= request.commonName ?></td>
		</tr>
	<? end ?>
</tbody>
</table>
<? end ?>

<? local reverserevoked = {}
local approved = {}
local revoked = {}
if view.value.revoked and #view.value.revoked.value > 0 then
	for i,serial in ipairs(view.value.revoked.value) do
		reverserevoked[serial] = i
	end
	for i,cert in ipairs(view.value.approved.value) do
		if reverserevoked[cert.serial] then
			revoked[#revoked + 1] = cert
		else
			approved[#approved + 1] = cert
		end
	end
else
	approved = view.value.approved.value
end ?>
	
<H1>Approved certificate requests<? if view.value.user then?> for <?= view.value.user.value ?><? end ?></H1>
<? if #approved == 0 then ?>
	No certificates approved
<? else ?>
<table id="approved" class="tablesorter">
<thead>
	<tr>
		<th>Action</th>
		<th>User</th>
		<th>Cert Type</th>
		<th>Common Name</th>
		<th>Serial Num</th>
		<th>End Date</th>
	</tr>
</thead>
<tbody>
	<? for i,cert in ipairs(approved) do ?>
		<tr <? if cert.daysremaining < 14 then ?>class='error'<? end ?>>
		<td>
		<? if session.permissions.openssl.viewcert then ?>
			<?= html.link{value="viewcert?cert="..cert.name, label="View "} ?>
		<? end ?>
		<? if session.permissions.openssl.getcert then ?>
			<?= html.link{value="getcert?cert="..cert.name, label="Download "} ?>
		<? end ?>
		<? --[[ if session.permissions.openssl.renewcert then ?>
			<?= html.link{value="renewcert?cert="..cert.name, label="Renew "} ?>
		<? elseif session.permissions.openssl.requestrenewcert then ?>
			<?= html.link{value="requestrenewcert?cert="..cert.name, label="Renew "} ?>
		<? end --]] ?>
		<? if session.permissions.openssl.revoke then ?>
			<?= html.link{value="revoke?cert="..cert.name, label="Revoke "} ?>
		<? end ?>
		<? if session.permissions.openssl.deletecert then ?>
			<?= html.link{value="deletecert?cert="..cert.name, label="Delete "} ?>
		<? end ?>
		</td>
		<td><?= cert.user ?></td>
		<td><?= cert.certtype ?></td>
		<td><?= cert.commonName ?></td>
		<td><?= tostring(tonumber('0x'..cert.serial)) ?></td>
		<td><?= cert.enddate ?></td>
		</tr>
	<? end ?>
<tbody>
</table>
<? end ?>

<H1>Revoked certificates<? if view.value.user then?> for <?= view.value.user.value ?><? end ?></H1>
<? if #revoked == 0 then ?>
	No certificates revoked
<? else ?>
<table id="revoked" class="tablesorter">
<thead>
	<tr>
		<th>Action</th>
		<th>User</th>
		<th>Cert Type</th>
		<th>Common Name</th>
		<th>Serial Num</th>
	</tr>
</thead>
<tbody>
	<? for i,cert in ipairs(revoked) do ?>
		<tr>
		<td>
		<? if session.permissions.openssl.viewcert then ?>
			<?= html.link{value="viewcert?cert="..cert.name, label="View "} ?>
		<? end ?>
		<? --[[ if session.permissions.openssl.getcert then ?>
			<?= html.link{value="getcert?cert="..cert.name, label="Download "} ?>
		<? end --]] ?>
		<? if session.permissions.openssl.deletecert then ?>
			<?= html.link{value="deletecert?cert="..cert.name, label="Delete "} ?>
		<? end ?>
		</td>
		<td><?= cert.user ?></td>
		<td><?= cert.certtype ?></td>
		<td><?= cert.commonName ?></td>
		<td><?= tostring(tonumber('0x'..cert.serial)) ?></td>
		</tr>
	<? end ?>
</tbody>
</table>
<? end ?>

<? if session.permissions.openssl.getrevoked then ?>
<H1>Get revoked list (crl)</H1>
<?= html.link{value="getrevoked?crltype=PEM", label="Download PEM "} ?><BR>
<?= html.link{value="getrevoked?crltype=DER", label="Download DER "} ?><BR>
<?= html.link{value="getrevoked", label="Import to Firefox"} ?><BR>

<? end ?>