bi报表系统FineReport7.1.1
大小:148.2M 适用平台:windows/linux
前提准备报表工程:如直接使用内置Jetty服务器中的报表工程WebReport,端口为8075;用户系统:如用户工程PFDemo发布于IIS服务器,端口为80,可省;报表工程已经配置了身份验证,并实现了单点登录,如其中存在用户A/123、B/123。
载入FR提供的BouncyCastle.Crypto.dll及Com.FineReport.dll数字签名库下载FR提供的BouncyCastle.Crypto.dll及Com.FineReport.dll数字签名库;在用户.net系统中载入这两个数字签名库。
用户系统中添加一个web接口给报表工程提供公钥用户系统中提供一个web接口,如创建一个getKey.aspx,可以通过http://localhost/getKey.aspx来获取公钥,代码如下:<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="getKey.aspx.cs" Inherits="PFDemo.getKey" %>
在页面Page_Load事件中调用我方提供的dll的接口,返回公钥信息,对应的后台cs代码getKey.aspx.cs为:using System;using System.Collections.Generic;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using Com.FineReport.net;namespace PFDemo{ public partial class getKey : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { try { // 获得公钥的两个参数,传回 String modulus = FRPrivilegeFilterHelper.getPublicKeyModulus(); String exponent = FRPrivilegeFilterHelper.getPublicKeyExponent(); Response.Write(modulus + "&" + exponent); } catch (Exception e1) { Response.Write("error"); } return; } } }}
报表工程中获取用户系统的公钥登陆FR管理平台http://localhost:8075/WebReport/ReportServer?op=fr_platform,选择权限配置>详细权限配置;数字签名密钥地址为http://localhost/getKey.aspx,点击提交:
用户系统发送报表请求加入数字签名信息如最上图中登陆后的主界面为index.aspx,代码如下:<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="index.aspx.cs" Inherits="PFDemo._Default" %>
在report.aspx中利用FR数字签名库提供的接口,对需要访问的报表路径、报表浏览形式(op)、当前用户名与当前系统时间进行数字签名,得到签名信息,并将签名信息加入请求中转发给报表工程,代码如下:<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Report.aspx.cs" Inherits="PFDemo.Report" %>
对应的后台cs代码Report.aspx.cs为:using System;using System.Collections.Generic;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using Com.FineReport.net;namespace PFDemo{ public partial class Report : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { String reportPath = Request.QueryString["report"]; String username = (String)Session["username"]; // 获取当前用户名 String op = "page"; // 默认分页预览时,null即可 long curtime = FRPrivilegeFilterHelper.getCurTime4JavaPlatform(); // 获取与java平台同步的当前时间的毫秒数 String signInfo = FRPrivilegeFilterHelper.sign(reportPath, op, username, curtime); // 将上述获得的四个要素传入,获得相关的数字签名信息 String path = "http://localhost:8075/WebReport/ReportServer?reportlet=" + reportPath + "&op=" + op + "&" + FRPrivilegeFilterHelper.FR_DIGITALSIGNATURE_CURRENT_TIME + "=" + curtime + "&" + FRPrivilegeFilterHelper.FR_DIGITALSIGNATURE_INFO + "=" + signInfo; // 模拟拼接url,其实就是原有正常请求之后添加上签名的当前时间,和签名信息 Response.Redirect(path, true); } } }}报表工程得到报表请求后进行验证,对reportlet参数值、op参数值、报表系统中当前用户名、发送来的系统时间进行数字签名验证是否正确。且若用户系统发送来的签名时系统时间,与当前时间差超过90秒,将视为超时。如果都验证通过,则可以访问报表,否则提示没有权限查看。