Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Use of session's varibles in BIRT
cheli
hi everyone,<br />
<br />
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. <br />
<br />
In the BIRT's report i have this code in the beforeFactory script: <br />
<br />
importPackage( Packages.javax.servlet.http );<br />
<br />
var request = reportContext.getHttpServletRequest();<br />
var cookies = request.getCookies();<br />
var cookiestring="";<br />
var tm = new Date();<br />
hour = tm.getUTCHours().toString();<br />
prev_hour = (tm.getUTCHours()-1).toString();<br />
<br />
//if the hour is one digit, we need to add a leading 0 because this is also used in PHP<br />
if (hour.length==1) {hour='0'+hour};<br />
if (prev_hour.length==1) {prev_hour='0'+prev_hour};<br />
<br />
<br />
//search for the correct cookie, being OUR_REPORT<br />
for (i=0; i< cookies.length; i++)<br />
{<br />
if(cookies
.getName().equals("OUR_REPORT")){<br />
cookiestring=cookies
.getValue();<br />
}<br />
}<br />
<br />
//read the url values<br />
var request = reportContext.getHttpServletRequest();<br />
user=request.getParameter("user");<br />
repname=request.getParameter("__report");<br />
urlstring=(String)(repname+user+hour);<br />
prev_urlstring=(String)(repname+user+prev_hour);<br />
<br />
<br />
//set the flag to allow the report components to hide if flag=1 (= no access)<br />
if (cookiestring!=urlstring)<br />
{<br />
if (cookiestring!=prev_urlstring) {flag=1;}<br />
reportContext.setGlobalVariable('access_flag', flag);<br />
}<br />
<br />
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.<br />
This don't go , what is the problem?<br />
<br />
PD: sorry about my english, i'm not so good in English
Find more posts tagged with
Comments
averma
Hi cheli,
I would recommend using reportContext.setPersistentGlobalVariable() and reportContext.getPersistentGlobalVariable() methods. This allows variables to be persisted across generation and presentation (rendering).
Ashwini