hi everyone,
I have one small site web in PHP that allow users authenticate and give them access to the reports. I want to increase the security and for that i create a key in the site web that it's unique for any user and i put it in a cookie for it is possible to access it in BIRT.
In the BIRT's report i have this code in the beforeFactory script:
importPackage( Packages.javax.servlet.http );
var request = reportContext.getHttpServletRequest();
var cookies = request.getCookies();
var cookiestring="";
var tm = new Date();
hour = tm.getUTCHours().toString();
prev_hour = (tm.getUTCHours()-1).toString();
//if the hour is one digit, we need to add a leading 0 because this is also used in PHP
if (hour.length==1) {hour='0'+hour};
if (prev_hour.length==1) {prev_hour='0'+prev_hour};
//search for the correct cookie, being OUR_REPORT
for (i=0; i< cookies.length; i++)
{
if(cookies[i].getName().equals("OUR_REPORT")){
cookiestring=cookies[i].getValue();
}
}
//read the url values
var request = reportContext.getHttpServletRequest();
user=request.getParameter("user");
repname=request.getParameter("__report");
urlstring=(String)(repname+user+hour);
prev_urlstring=(String)(repname+user+prev_hour);
//set the flag to allow the report components to hide if flag=1 (= no access)
if (cookiestring!=urlstring)
{
if (cookiestring!=prev_urlstring) {flag=1;}
reportContext.setGlobalVariable('access_flag', flag);
}
this script compare the key that i put in the site web with the same key but in this moment it is generated in the BIRT's script, if they are differents on put the global variable flag = 1. Here is my problem. I don't know how to use the globla variables. In this case i generated access_flag variable in the data explorer variables and the variable flag in the initialize script and then i use the access flag variables for the visibility conditions of the report's elements.
This don't go , what is the problem?
PD: sorry about my english, i'm not so good in English
Page 1 of 1
Use of session's varibles in BIRT
Page 1 of 1




MultiQuote
