构建一个web方式的局域网签名
2006-12-15 10:46
337 查看
当需要大量签名的工作,同时又多用户使用,但又想把签名证书进行一定限制时,下面就实现了这样一个简单的方案。
需要一台IIS server, 共享一个文件夹(读写)。
在IIS 上创建一个asp.net web站点:
页面上添加一个按钮就可以了,后台代码如下:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Diagnostics;
using System.Timers;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
void processSign(string cmd, string showstr)
{
//利用CMD来执行已经写好的sign的bat处理文件
Process p = new Process();
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.WorkingDirectory = @"C:doxtechsign";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = true;
p.Start();
//记录签名者IP地址 和 签名的一些信息(这里仅仅反馈给用户显示),如果保存至文件就可以进行管理了。
string cIP = Request.ServerVariables["REMOTE_ADDR"];
p.StandardInput.WriteLine(cmd + " " + cIP);
p.StandardInput.WriteLine("exit");
string info = "Your IP: " + cIP + "<br> Using Signature is " + showstr + "<br><br>";
string starstr = p.StandardOutput.ReadToEnd();
string[] sc = new string[] { " " };
string[] showmsg = starstr.Split(sc, StringSplitOptions.RemoveEmptyEntries);
System.DateTime currentTime = new System.DateTime();
currentTime = System.DateTime.Now;
string Labelstr = "Sign Time: " + currentTime.ToString("g") + "<br>" + info;
if (showmsg.Length <= 4)
{
Labelstr += ("Not Found Files! <br>");
Label1.Text = Labelstr;
return;
}
else
{
for (int i = 3; i < showmsg.Length - 1; i++)
{
Labelstr += showmsg[i];
Labelstr += "<br>";
}
Label1.Text = Labelstr + "<br>";
}
}
protected void Button2_Click(object sender, EventArgs e)
{
processSign("Sign2K3.bat", "File -> Windows Mobile 2003");
}
}
Sign2K3.bat 文件:
@echo off
dir Files | find /i "mui" >signname.tmp
dir Files | find /i "dll" >>signname.tmp
dir Files | find /i "cab" >>signname.tmp
dir Files | find /i "exe" >>signname.tmp
dir Files | find /i "hme" >>signname.tmp
for /f "tokens=4" %%a in (signname.tmp) do signcode /spc DOXTechsign.cer /v DOXTechsign.pvk /a sha1 Files%%a
del signname.tmp
goto done
:usage
echo S
echo filename: all mui,dll,exe files in the files floder
:done
这样就构建完成了。
1.当需要签名是在客户端上打开网页。2. 把需要签名的文件放置在共享的文件里。 3. 点击页面上的按钮。
在这里,只是并没有深入考虑安全性和广域网,也忽略多用户同时进行处理。简单安全性可以使用IIS提供安全设置来控制指定用户密码登入此网页,限制IP等。广域网的实施那就要实现页面上传文件至服务器,签名后下载至客户端。
需要一台IIS server, 共享一个文件夹(读写)。
在IIS 上创建一个asp.net web站点:
页面上添加一个按钮就可以了,后台代码如下:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Diagnostics;
using System.Timers;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
void processSign(string cmd, string showstr)
{
//利用CMD来执行已经写好的sign的bat处理文件
Process p = new Process();
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.WorkingDirectory = @"C:doxtechsign";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = true;
p.Start();
//记录签名者IP地址 和 签名的一些信息(这里仅仅反馈给用户显示),如果保存至文件就可以进行管理了。
string cIP = Request.ServerVariables["REMOTE_ADDR"];
p.StandardInput.WriteLine(cmd + " " + cIP);
p.StandardInput.WriteLine("exit");
string info = "Your IP: " + cIP + "<br> Using Signature is " + showstr + "<br><br>";
string starstr = p.StandardOutput.ReadToEnd();
string[] sc = new string[] { " " };
string[] showmsg = starstr.Split(sc, StringSplitOptions.RemoveEmptyEntries);
System.DateTime currentTime = new System.DateTime();
currentTime = System.DateTime.Now;
string Labelstr = "Sign Time: " + currentTime.ToString("g") + "<br>" + info;
if (showmsg.Length <= 4)
{
Labelstr += ("Not Found Files! <br>");
Label1.Text = Labelstr;
return;
}
else
{
for (int i = 3; i < showmsg.Length - 1; i++)
{
Labelstr += showmsg[i];
Labelstr += "<br>";
}
Label1.Text = Labelstr + "<br>";
}
}
protected void Button2_Click(object sender, EventArgs e)
{
processSign("Sign2K3.bat", "File -> Windows Mobile 2003");
}
}
Sign2K3.bat 文件:
@echo off
dir Files | find /i "mui" >signname.tmp
dir Files | find /i "dll" >>signname.tmp
dir Files | find /i "cab" >>signname.tmp
dir Files | find /i "exe" >>signname.tmp
dir Files | find /i "hme" >>signname.tmp
for /f "tokens=4" %%a in (signname.tmp) do signcode /spc DOXTechsign.cer /v DOXTechsign.pvk /a sha1 Files%%a
del signname.tmp
goto done
:usage
echo S
echo filename: all mui,dll,exe files in the files floder
:done
这样就构建完成了。
1.当需要签名是在客户端上打开网页。2. 把需要签名的文件放置在共享的文件里。 3. 点击页面上的按钮。
在这里,只是并没有深入考虑安全性和广域网,也忽略多用户同时进行处理。简单安全性可以使用IIS提供安全设置来控制指定用户密码登入此网页,限制IP等。广域网的实施那就要实现页面上传文件至服务器,签名后下载至客户端。
相关文章推荐
- 用STS和Maven的方式创建一个JavaWeb项目
- Virtura box 构建一个简单局域网并联入外网
- 20_Android中apk安装器,通过WebView来load进一个页面,Android通知,程序退出自动杀死进程,通过输入包名的方式杀死进程
- 使用 XMPP 构建一个基于 web 的通知工具
- 如何构建一个中型的 web 应用(全栈技术)
- Data Web Services:访问 IBM 数据库服务器的新方式 —— 构建 Web 服务
- jetbrick-webmvc 支持多种方式返回一个JSON (xml, html, js类似)
- Android构建一个通用的WebView(二):自定义的错误页面、缓存数据,离线浏览
- 使用JSF, Spring, Hibernate构建一个实际的web应用(转载)
- 用Maven如何构建一个基于Hibernate Annotation的web项目?
- 构建一个简单的基于MVC模式的JavaWeb
- 构建一个 Twitter Web 应用程序
- 关于【apache- tomcat- 5.5.15/conf /Catalina/localhost配置虚拟目录】时的一些问题。(配置web项目的方式不止一种,虚拟目录就是一个)
- 构建更加安全的 Web 应用程序-一个新的保护框架可帮助您防止操作和数据篡改
- 局域网WEB方式实现TTS实时语音合成
- 为您的Web项目构建一个简单的JSON控制器
- webpack 入门(一个简单打包配置构建)
- 从零开始构建支持TLS1.2的Web服务器Linux版(六)选装-Redis(src安装方式)
- 使用 XMPP 构建一个基于 web 的通知工具——转
- NetBeans Visual Web Pack 5.5以可视方式快速构建基于标准的 Web 应用程序。