summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2014-04-12 04:11:50 +0000
committerTed Trask <ttrask01@yahoo.com>2014-04-12 04:11:50 +0000
commitb7413b39ead7974611f0a749240ac5383d011442 (patch)
tree8d85857b158f3cda6f143b5e872aa195fd7f9aa5
parent6354a6d5d2a9f645bca8901edb116d6103b81d01 (diff)
downloadacf-openssl-b7413b39ead7974611f0a749240ac5383d011442.tar.bz2
acf-openssl-b7413b39ead7974611f0a749240ac5383d011442.tar.xz
Changes to use new htmlviewfunctions functions
-rw-r--r--openssl-checkenvironment-html.lsp8
-rw-r--r--openssl-model.lua10
-rw-r--r--openssl-putcacert-html.lsp9
-rw-r--r--openssl-read-html.lsp114
-rw-r--r--openssl-status-html.lsp52
-rw-r--r--openssl-viewcert-html.lsp6
-rw-r--r--openssl-viewrequest-html.lsp6
7 files changed, 118 insertions, 87 deletions
diff --git a/openssl-checkenvironment-html.lsp b/openssl-checkenvironment-html.lsp
index 3475bbc..ae54a17 100644
--- a/openssl-checkenvironment-html.lsp
+++ b/openssl-checkenvironment-html.lsp
@@ -1,15 +1,15 @@
-<% local form, viewlibrary, page_info = ... %>
+<% local form, viewlibrary, page_info, session = ... %>
<% htmlviewfunctions = require("htmlviewfunctions") %>
<% html = require("acf.html") %>
-<h1><%= html.html_escape(form.label) %></h1>
<%
+local header_level = htmlviewfunctions.displaysectionstart(form, page_info)
if form.value.status.errtxt then
- form.action = page_info.script .. page_info.prefix .. page_info.controller .. "/" .. page_info.action
- htmlviewfunctions.displayformstart(form)
+ htmlviewfunctions.displayformstart(form, page_info)
end
htmlviewfunctions.displayitem(form.value.status)
if form.value.status.errtxt then
htmlviewfunctions.displayformend(form)
end
+htmlviewfunctions.displaysectionend(header_level)
%>
diff --git a/openssl-model.lua b/openssl-model.lua
index 1df9b13..f5ab354 100644
--- a/openssl-model.lua
+++ b/openssl-model.lua
@@ -299,7 +299,7 @@ mymodule.getstatus = function()
end
end
local environment = mymodule.checkenvironment()
- return cfe({ type="group", value={version=version, conffile=conffile, environment=environment, cacert=cacert, cacertcontents=cacertcontents, cakey=cakey}, label="openssl status" })
+ return cfe({ type="group", value={version=version, conffile=conffile, environment=environment, cacert=cacert, cacertcontents=cacertcontents, cakey=cakey}, label="OpenSSL status" })
end
mymodule.set_umask = function()
@@ -463,7 +463,7 @@ mymodule.viewrequest = function(request)
local reqpath = requestdir .. request
local cmdresult = modelfunctions.run_executable({"openssl", "req", "-in", reqpath..".csr", "-text", "-noout"})
local a,b,c = string.match(request, "([^%.]*)%.([^%.]*)%.([^%.]*)")
- local request = cfe({ type="table", value={name=name, user=a, certtype=b, commonName=c, value=cmdresult}, label="Request" })
+ local request = cfe({ type="table", value={name=name, user=a, certtype=b, commonName=c, value=cmdresult}, label="Request Details" })
return request
end
@@ -586,7 +586,7 @@ end
mymodule.viewcert = function(cert)
local cmdresult = modelfunctions.run_executable({"openssl", "x509", "-in", certdir..cert..".crt", "-noout", "-text"})
local a,b,c,d = string.match(cert, "([^%.]*)%.([^%.]*)%.([^%.]*).([^%.]*)")
- return cfe({ type="table", value={name=name, user=a, certtype=b, commonName=c, serial=d, value=cmdresult}, label="Certificate" })
+ return cfe({ type="table", value={name=name, user=a, certtype=b, commonName=c, serial=d, value=cmdresult}, label="Certificate Details" })
end
mymodule.getcert = function(cert)
@@ -728,8 +728,8 @@ mymodule.getca = function(certtype)
end
mymodule.getnewputca = function()
- local ca = cfe({ type="raw", value=0, label="CA Certificate", descr='File must be a password protected ".pfx" file' })
- local password = cfe({ label="Certificate Password" })
+ local ca = cfe({ type="raw", value=0, label="CA Certificate", descr='File must be a password protected ".pfx" file', seq=1 })
+ local password = cfe({ type="password", label="Certificate Password", seq=2 })
return cfe({ type="group", value={ca=ca, password=password} })
end
diff --git a/openssl-putcacert-html.lsp b/openssl-putcacert-html.lsp
index 1d178fe..35d39b6 100644
--- a/openssl-putcacert-html.lsp
+++ b/openssl-putcacert-html.lsp
@@ -1,13 +1,8 @@
-<% local form, viewlibrary, page_info = ... %>
+<% local form, viewlibrary, page_info, session = ... %>
<% htmlviewfunctions = require("htmlviewfunctions") %>
-<% html = require("acf.html") %>
-<h1><%= html.html_escape(form.label) %></h1>
<%
- form.action = page_info.script .. page_info.prefix .. page_info.controller .. "/" .. page_info.action
form.enctype = "multipart/form-data"
form.value.ca.type="file"
- form.value.password.type="password"
- local order = {"ca", "password"}
- htmlviewfunctions.displayform(form, order)
+ htmlviewfunctions.displayitem(form, page_info)
%>
diff --git a/openssl-read-html.lsp b/openssl-read-html.lsp
index a3dd4b3..3f4693a 100644
--- a/openssl-read-html.lsp
+++ b/openssl-read-html.lsp
@@ -24,7 +24,13 @@
<% htmlviewfunctions.displaycommandresults({"approve", "deleterequest", "deletemyrequest", "renewcert", "requestrenewcert", "revoke", "deletecert"}, session) %>
-<h1>Pending certificate requests<% if view.value.user then%> for <%= html.html_escape(view.value.user.value) %><% end %></h1>
+<%
+local label = ""
+if view.value.user then
+ label = label.." for "..html.html_escape(view.value.user.value)
+end
+local header_level = htmlviewfunctions.displaysectionstart(cfe({label="Pending certificate requests"..label}), page_info)
+%>
<% if not view.value.pending or #view.value.pending.value == 0 then %>
<p>No certificates pending</p>
<% else %>
@@ -38,20 +44,24 @@
</tr>
</thead>
<tbody>
+ <% local req = cfe({ type="hidden", value="" }) %>
<% for i,request in ipairs(view.value.pending.value) do %>
<tr>
<td>
- <% if viewlibrary.check_permission("viewrequest") then
- io.write(html.link{value="viewrequest?request="..request.name, label="View "})
- end %>
- <% if viewlibrary.check_permission("approve") then
- io.write(html.link{value="approve?submit=true&request="..request.name, label="Approve "})
- end %>
- <% if viewlibrary.check_permission("deleterequest") then
- io.write(html.link{value="deleterequest?submit=true&request="..request.name, label="Delete "})
+ <%
+ req.value = request.name
+ if viewlibrary.check_permission("viewrequest") then
+ htmlviewfunctions.displayitem(cfe({type="link", value={request=req}, label="", option="View", action="viewrequest"}), page_info, -1)
+ end
+ if viewlibrary.check_permission("approve") then
+ htmlviewfunctions.displayitem(cfe({type="form", value={request=req}, label="", option="Approve", action="approve"}), page_info, -1)
+ end
+ if viewlibrary.check_permission("deleterequest") then
+ htmlviewfunctions.displayitem(cfe({type="form", value={request=req}, label="", option="Delete", action="deleterequest"}), page_info, -1)
elseif viewlibrary.check_permission("deletemyrequest") then
- io.write(html.link{value="deletemyrequest?submit=true&request="..request.name, label="Delete "})
- end %>
+ htmlviewfunctions.displayitem(cfe({type="form", value={request=req}, label="", option="Delete", action="deletemyrequest"}), page_info, -1)
+ end
+ %>
</td>
<td><%= html.html_escape(request.user) %></td>
<td><%= html.html_escape(request.certtype) %></td>
@@ -61,6 +71,9 @@
</tbody>
</table>
<% end %>
+<% htmlviewfunctions.displaysectionend(header_level) %>
+
+<% viewtype = cfe({type="hidden", value="stream"}) %>
<% local reverserevoked = {}
local approved = {}
@@ -80,7 +93,7 @@ else
approved = view.value.approved.value
end %>
-<h1>Approved certificate requests<% if view.value.user then%> for <%= html.html_escape(view.value.user.value) %><% end %></h1>
+<% htmlviewfunctions.displaysectionstart(cfe({label="Approved certificate requests"..label}), page_info, header_level) %>
<% if #approved == 0 then %>
<p>No certificates approved</p>
<% else %>
@@ -96,26 +109,30 @@ end %>
</tr>
</thead>
<tbody>
+ <% local crt = cfe({ type="hidden", value="" }) %>
<% for i,cert in ipairs(approved) do %>
<tr <% if cert.daysremaining < 14 then %>class='error'<% end %>>
<td>
- <% if viewlibrary.check_permission("viewcert") then %>
- <%= html.link{value="viewcert?cert="..cert.name, label="View "} %>
- <% end %>
- <% if viewlibrary.check_permission("getcert") then %>
- <%= html.link{value="getcert?viewtype=stream&cert="..cert.name, label="Download "} %>
- <% end %>
- <% if viewlibrary.check_permission("renewcert") then %>
- <%= html.link{value="renewcert?submit=true&cert="..cert.name, label="Renew "} %>
- <% elseif viewlibrary.check_permission("requestrenewcert") then %>
- <%= html.link{value="requestrenewcert?submit=true&cert="..cert.name, label="Renew "} %>
- <% end %>
- <% if viewlibrary.check_permission("revoke") then %>
- <%= html.link{value="revoke?submit=true&cert="..cert.name, label="Revoke "} %>
- <% end %>
- <% if viewlibrary.check_permission("deletecert") then %>
- <%= html.link{value="deletecert?submit=true&cert="..cert.name, label="Delete "} %>
- <% end %>
+ <%
+ crt.value = cert.name
+ if viewlibrary.check_permission("viewcert") then
+ htmlviewfunctions.displayitem(cfe({type="link", value={cert=crt}, label="", option="View", action="viewcert"}), page_info, -1)
+ end
+ if viewlibrary.check_permission("getcert") then
+ htmlviewfunctions.displayitem(cfe({type="link", value={cert=crt, viewtype=viewtype}, label="", option="Download", action="getcert"}), page_info, -1)
+ end
+ if viewlibrary.check_permission("renewcert") then
+ htmlviewfunctions.displayitem(cfe({type="form", value={cert=crt}, label="", option="Renew", action="renewcert"}), page_info, -1)
+ elseif viewlibrary.check_permission("requestrenewcert") then
+ htmlviewfunctions.displayitem(cfe({type="form", value={cert=crt}, label="", option="Renew", action="requestrenewcert"}), page_info, -1)
+ end
+ if viewlibrary.check_permission("revoke") then
+ htmlviewfunctions.displayitem(cfe({type="form", value={cert=crt}, label="", option="Revoke", action="revoke"}), page_info, -1)
+ end
+ if viewlibrary.check_permission("deletecert") then
+ htmlviewfunctions.displayitem(cfe({type="form", value={cert=crt}, label="", option="Delete", action="deletecert"}), page_info, -1)
+ end
+ %>
</td>
<td><%= html.html_escape(cert.user) %></td>
<td><%= html.html_escape(cert.certtype) %></td>
@@ -127,8 +144,9 @@ end %>
<tbody>
</table>
<% end %>
+<% htmlviewfunctions.displaysectionend(header_level) %>
-<h1>Revoked certificates<% if view.value.user then%> for <%= html.html_escape(view.value.user.value) %><% end %></h1>
+<% htmlviewfunctions.displaysectionstart(cfe({label="Revoked certificates"..label}), page_info, header_level) %>
<% if #revoked == 0 then %>
<p>No certificates revoked</p>
<% else %>
@@ -143,18 +161,22 @@ end %>
</tr>
</thead>
<tbody>
+ <% local crt = cfe({ type="hidden", value="" }) %>
<% for i,cert in ipairs(revoked) do %>
<tr>
<td>
- <% if viewlibrary.check_permission("viewcert") then %>
- <%= html.link{value="viewcert?cert="..cert.name, label="View "} %>
- <% end %>
- <% --[[ if viewlibrary.check_permission("getcert") then %>
- <%= html.link{value="getcert?viewtype=stream&cert="..cert.name, label="Download "} %>
- <% end --]] %>
- <% if viewlibrary.check_permission("deletecert") then %>
- <%= html.link{value="deletecert?submit=true&cert="..cert.name, label="Delete "} %>
- <% end %>
+ <%
+ crt.value = cert.name
+ if viewlibrary.check_permission("viewcert") then
+ htmlviewfunctions.displayitem(cfe({type="link", value={cert=crt}, label="", option="View", action="viewcert"}), page_info, -1)
+ end
+ --[[ if viewlibrary.check_permission("getcert") then
+ htmlviewfunctions.displayitem(cfe({type="link", value={cert=crt, viewtype=viewtype}, label="", option="Download", action="getcert"}), page_info, -1)
+ end --]]
+ if viewlibrary.check_permission("deletecert") then
+ htmlviewfunctions.displayitem(cfe({type="form", value={cert=crt}, label="", option="Delete", action="deletecert"}), page_info, -1)
+ end
+ %>
</td>
<td><%= html.html_escape(cert.user) %></td>
<td><%= html.html_escape(cert.certtype) %></td>
@@ -165,9 +187,13 @@ end %>
</tbody>
</table>
<% end %>
+<% htmlviewfunctions.displaysectionend(header_level) %>
-<% if viewlibrary.check_permission("getrevoked") then %>
-<h1>Get revoked list (crl)</h1>
-<%= html.link{value="getrevoked?viewtype=stream&crltype=PEM", label="Download PEM "} %><BR>
-<%= html.link{value="getrevoked?viewtype=stream&crltype=DER", label="Download DER "} %><BR>
-<% end %>
+<%
+if viewlibrary.check_permission("getrevoked") then
+ htmlviewfunctions.displaysectionstart(cfe({label="Get revoked list (crl)"}), page_info, header_level)
+ htmlviewfunctions.displayitem(cfe({type="link", value={crltype=cfe({type="hidden", value="PEM"}), viewtype=viewtype}, label="", option="Download PEM", action="getrevoked"}), page_info, -1)
+ htmlviewfunctions.displayitem(cfe({type="link", value={crltype=cfe({type="hidden", value="DER"}), viewtype=viewtype}, label="", option="Download DER", action="getrevoked"}), page_info, -1)
+ htmlviewfunctions.displaysectionend(header_level)
+end
+%>
diff --git a/openssl-status-html.lsp b/openssl-status-html.lsp
index cb02df8..796d63a 100644
--- a/openssl-status-html.lsp
+++ b/openssl-status-html.lsp
@@ -5,32 +5,33 @@
<% htmlviewfunctions.displaycommandresults({"checkenvironment", "putcacert", "generatecacert"}, session, true) %>
<% htmlviewfunctions.displaycommandresults({"install"}, session) %>
-<h1>System Info</h1>
<%
+local header_level = htmlviewfunctions.displaysectionstart(view, page_info)
+
htmlviewfunctions.displayitem(view.value.version)
if view.value.version and view.value.version.errtxt and viewlibrary.check_permission("apk-tools/apk/install") then
+ local install = cfe({ type="form", value={}, label="Install package", option="Install", action=page_info.script.."/apk-tools/apk/install" })
+ install.value.package = cfe({ type="hidden", value=view.value.version.name })
+ htmlviewfunctions.displayitem(install, page_info, 0) -- header_level 0 means display inline without header
+end
+
+htmlviewfunctions.displayitem(view.value.conffile)
+htmlviewfunctions.displayitem(view.value.environment)
+htmlviewfunctions.displayitem(view.value.cacert)
+htmlviewfunctions.displayitem(view.value.cakey)
%>
- <div class='item'><p class='left'>Install package</p>
- <div class='right'>
- <form action="<%= html.html_escape(page_info.script .. "/apk-tools/apk/install") %>" method="post">
- <input type='hidden' name='package' value='<%= html.html_escape(view.value.version.name) %>'>
- <input class='submit' type='submit' name='submit' value='Install'></form>
- </div></div><!-- end .item -->
-<% end %>
-<% htmlviewfunctions.displayitem(view.value.conffile) %>
-<% htmlviewfunctions.displayitem(view.value.environment) %>
-<% htmlviewfunctions.displayitem(view.value.cacert) %>
-<% htmlviewfunctions.displayitem(view.value.cakey) %>
-<% if not view.value.version.errtxt and not view.value.conffile.errtxt then
+<%
+if not view.value.version.errtxt and not view.value.conffile.errtxt then
if view.value.environment.errtxt then
if viewlibrary and viewlibrary.dispatch_component and viewlibrary.check_permission("checkenvironment") then
viewlibrary.dispatch_component("checkenvironment")
end
- elseif not view.value.cacert.errtxt and not view.value.cakey.errtxt then %>
-<h1>CA Certificate contents</h1>
-<pre><%= html.html_escape(view.value.cacertcontents.value) %></pre>
- <% elseif viewlibrary and viewlibrary.dispatch_component then
+ elseif not view.value.cacert.errtxt and not view.value.cakey.errtxt then
+ htmlviewfunctions.displaysectionstart(view.value.cacertcontents, page_info, header_level)
+ print("<pre>"..html.html_escape(view.value.cacertcontents.value).."</pre>")
+ htmlviewfunctions.displaysectionend(header_level)
+ elseif viewlibrary and viewlibrary.dispatch_component then
if viewlibrary.check_permission("putcacert") then
viewlibrary.dispatch_component("putcacert")
end
@@ -38,9 +39,14 @@ if view.value.version and view.value.version.errtxt and viewlibrary.check_permis
viewlibrary.dispatch_component("generatecacert")
end
end
-end %>
-<% if viewlibrary.check_permission("downloadcacert") then %>
-<h1>Download CA Cert</h1>
-<%= html.link{value="downloadcacert?viewtype=stream&certtype=pem", label="Download PEM"} %><br/>
-<%= html.link{value="downloadcacert?viewtype=stream&certtype=der", label="Download DER"} %><br/>
-<% end %>
+end
+%>
+
+<%
+if viewlibrary.check_permission("downloadcacert") then
+ htmlviewfunctions.displaysectionstart(cfe({label="Download CA Cert"}), page_info, header_level)
+ htmlviewfunctions.displayitem(cfe({type="link", value={certtype=cfe({type="hidden", value="pem"}), viewtype=cfe({type="hidden", value="stream"})}, label="", option="Download PEM", action="downloadcacert"}), page_info, -1)
+ htmlviewfunctions.displayitem(cfe({type="link", value={certtype=cfe({type="hidden", value="der"}), viewtype=cfe({type="hidden", value="stream"})}, label="", option="Download DER", action="downloadcacert"}), page_info, -1)
+ htmlviewfunctions.displaysectionend(header_level)
+end
+%>
diff --git a/openssl-viewcert-html.lsp b/openssl-viewcert-html.lsp
index dcfb7d6..0774c4e 100644
--- a/openssl-viewcert-html.lsp
+++ b/openssl-viewcert-html.lsp
@@ -1,5 +1,7 @@
-<% local view, viewlibrary = ... %>
+<% local view, viewlibrary, page_info, session = ... %>
+<% htmlviewfunctions = require("htmlviewfunctions") %>
<% html = require("acf.html") %>
-<h1>Certificate Details</h1>
+<% local header_level = htmlviewfunctions.displaysectionstart(view, page_info) %>
<pre><%= html.html_escape(view.value.value) %></pre>
+<% htmlviewfunctions.displaysectionend(header_level) %>
diff --git a/openssl-viewrequest-html.lsp b/openssl-viewrequest-html.lsp
index a4e6440..0774c4e 100644
--- a/openssl-viewrequest-html.lsp
+++ b/openssl-viewrequest-html.lsp
@@ -1,5 +1,7 @@
-<% local view, viewlibrary = ... %>
+<% local view, viewlibrary, page_info, session = ... %>
+<% htmlviewfunctions = require("htmlviewfunctions") %>
<% html = require("acf.html") %>
-<h1>Request Details</h1>
+<% local header_level = htmlviewfunctions.displaysectionstart(view, page_info) %>
<pre><%= html.html_escape(view.value.value) %></pre>
+<% htmlviewfunctions.displaysectionend(header_level) %>