系统集成方案(一).NET集成方案

NET系统集成有本身独立的登陆验证方式。好比,跟报表集成时,不须要再使用报表内置的登陆界面,只须要将报表默认的参数用户名fr_username和密码fr_password发送给报表系统,触发一下报表验证方式就能够实现单点登陆了,如下用FineReport的.NET跨域单点登陆案例简单介绍一下。javascript

系统自己有独立的登陆验证方式以下图:html

 

1.触发报表验证方法java

报表集成时不须要再一次进行登陆验证,只需在项目里面的登陆验证页面内触发一下报表方法,以下js方法:跨域

function doSubmit() {    
         var username =document.getElementById("username").value;  //此处是用来提取用户名和密码
         var password =document.getElementById("userPwd").value;
        var scr = document.createElement("iframe");      //建立iframe  
         var dt=new Date();
        scr.src = "/WebReport/ReportServer?op=fs_load&cmd=sso&username=" + username + "&password=" + password+"&time="+dt.toString();   //将报表验证用户名密码的地址指向此iframe  
        document.getElementsByTagName("head")[0].appendChild(scr);   //将iframe标签嵌入到head中  
    }

注:此处的单点登陆是登陆报表管理平台,而不是FineReport的数据决策系统,若是须要与数据决策系统作单点登陆,需将浏览器

scr.src = " http://localhost:8075/WebReport/ReportServer?op=fs_load&cmd=sso&username=" + username + "&password=" + password;
改为

scr.src = " http://localhost:8075/WebReport/ReportServer?op=fs_load&cmd=sso&username=" + username + "&password=" + password;
2.实现过程

点击项目里面的登陆按钮,跳到后台进行项目里面的验证,此报表的验证方式须要在页面前台内调用javascript的方式触发,这边相似定义了两个onclick事件,而.net不能同时触发两个onclick事件,因此先要触发完一个onclick事件后再触发另外一个,考虑报表没有验证完.net项目就跳转的话,致使报表没有验证成功,因此点击登陆按钮首先触发报表验证方法,其次再到.net后台进行验证。服务器

3. 触发.net前台session

触发前台报表验证方法,新建一个登陆按钮,设置按钮OnClientClick属性为:OnClientClick="doSubmit();return false;",即触发前台doSubmit()方法,doSubmit()方法,首先把获取的用户名和密码的值,发送到报表系统,报表服务将带着这两个参数访问认证地址进行认证。而项目自己有个登陆按钮是触发的项目后台的方法,咱们这边首先触发报表前台再经过js的方式触发后台的那个登陆按钮,因此这边须要把以前的登陆按钮设置隐藏,属性为Style="display: none;"。app

4. 触发.net后台工具

报表验证完再触发.net项目后台登陆验证的方法,经过登陆按钮ID为Button1,使用document.getElementById("Button1").click();触发登陆按钮,可是每一个浏览器执行的方式不一样,因此这边须要判断一下,代码以下:加密

if (scr.attachEvent){       //判断是否为ie浏览器  
               scr.attachEvent("onload", function(){                    //若是为ie浏览器则页面加载完成后当即执行  
                   var f = document.getElementById("Button1");  
                   f.click();  
               });  
            } else {  
               scr.onload = function(){              //其余浏览器则从新加载onload事件  
                    var f = document.getElementById("Button1");  
                    f.click();  
               };  
         }
下面以简单的登陆验证页面login.aspx为例head中调用javascript

示例

一、登陆前台页面

以简单的登陆验证页面login.aspx为例,head中调用javascript触发报表方法:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="login.aspx.cs" Inherits="login" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>无标题页</title>
  <script type="text/javascript" language="javascript">  
       function doSubmit() {    
         var username =document.getElementById("username").value;  //此处是用来提取用户名和密码
         var password =document.getElementById("userPwd").value;
        var scr = document.createElement("iframe");      //建立iframe  
         var dt=new Date();
        scr.src = "/WebReport/ReportServer?op=fs_load&cmd=sso&username=" + username + "&password=" + password+"&time="+dt.toString();   //将报表验证用户名密码的地址指向此iframe  
        if (scr.attachEvent){       //判断是否为ie浏览器  
               scr.attachEvent("onload", function(){                    //若是为ie浏览器则页面加载完成后当即执行  
                   var f = document.getElementById("Button1");  
                   f.click();  
               });  
            } else {  
               scr.onload = function(){              //其余浏览器则从新加载onload事件  
                    var f = document.getElementById("Button1");  
                    f.click();  
               };  
         }  
        document.getElementsByTagName("head")[0].appendChild(scr);   //将iframe标签嵌入到head中  
    } 
  </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:TextBox ID="username" runat="server" Style="z-index: 100; left: 156px; position: absolute;
            top: 42px"></asp:TextBox>
        <asp:TextBox ID="userPwd" runat="server" Style="z-index: 101; left: 157px; position: absolute;
            top: 91px"></asp:TextBox>
        <asp:Label ID="Label1" runat="server" Height="22px" Style="z-index: 102; left: 76px;
            position: absolute; top: 46px" Text="用户名:" Width="77px"></asp:Label>
        <asp:Label ID="Label2" runat="server" Style="z-index: 103; left: 80px; position: absolute;
            top: 88px" Text="密码:" Width="64px"></asp:Label>
        <asp:Button ID="Button1" runat="server"  Style="z-index: 104; display:none;
            left: 84px; position: absolute; top: 132px" Text="登陆" Width="66px" />
        <asp:Button ID="Button2" runat="server" OnClientClick="doSubmit();return false;"
            Style="z-index: 106; left: 178px; position: absolute; top: 133px" Text="登陆" Width="100px" />
    
    </div>
    </form>
</body>
</html>

前台和后台验证成功以后,单点登陆页面就设计完成了。

报表工具是经过url传用户名和密码进行验证,传到报表服务器是以session的方式保存,防止被人中途拦截会致使系统泄密,能够对登陆进来的密码进行加密,或者使用https证书,让请求在传输过程当中加密,配置方法也很简单。这种方式还存在一个证书合法性问题,用本身生成的证书,客户端在访问报表中浏览器会显示证书非法警告,因此须要去购买合法证书。目前国内最便宜的证书一年是一千多元。

二、平台设置

通常状况下报表集成到.net系统,首先登陆访问.net的项目,因此自定义登陆页面访问地址能够不须要设置,若是没有登陆到.ne项目,先访问咱们的报表了,而这时访问报表的登陆页面是报表内置的登陆界面,需使用自动登陆页面地址为您系统的登陆地址,操做以下:

打开http://localhost/WebReport/ReportServer?op=fr_platform,FR管理平台,选择权限配置>登陆设置,自定义登陆页面访问地址上,输入本身的登陆页面路径http://localhost/FRtest/login.aspx,以下图所示: