Domain Security in Jasper Using Attribute Service Mechanism

Posted on by By admin, in Business Intelligence, Jaspersoft, Open Source Business Intelligence | 0

Domain Security in Jasper using attributeService Mechanism

attributeService – attributeService gets hierarchical attributes for user. From Jasper V6.0 , we can set attributes on User level , Tenant or Organization and on Server level. In addition to the attributes assigned on Userlevel, a user can inherit attributes from its Tenant or Server level.

Below is the method using which we can get the attributes defined on any of the level(User,Tenant,Server)

attributesService.getAttribute(‘AttrName’,Level[, condition]))
AttrName – This defines the attribute’s name.
Level –
Level can be null,User,Tenant,Server . This can tell on which level jasper will have to check for attributes. If its value is null , it means it will give attributes defined in each level.
Condition –
this is optional . If we have set it to true , and attribute is not present then it will give us the error message in UI.
If its value is set as false , then even if the attribute is not present it will not through the error rather filterExpression will not prformed.

NOTE Using attributeService , we can get the filter on the roles .

To retrieve information on Roles , we will have to use- authentication.getPrincipal() .
For example –

<principalExpression>
  authentication.getPrincipal().getRoles().any{ it.getRoleName() 
    in ['ROLE_SUPERUSER','ROLE_ADMINISTRATOR'] }
</principalExpression>

Lets take an example –
Database – Foodmart
Tables – product,product_class,store,sales_fact_1998.

I have created a domain by using the above tables in jasper .You can refer the screenshots below –
a. select tables –














b. Define Joins between the tables















c. Display Tab –




















d. Click on OK → Submit .

e. Now I have created 1 user and set attribute.














Here product_family is the attribute name
and Drink is the attribute value.

f. Later I created a Domain Security file and uploaded it.














g. Later I fired the below query in the database and get the result –

So I assumed that when I will create an adhoc view using
Test_User_Drink user then I will get the data only for product family as “Drink” because I have set attribute “product_family“ value as “Drink”.

And when I created Adhoc view I got the result as expected . See below the screenshot –
















Reference –
http://community.jaspersoft.com/documentation/tibco-jasperreports-server-security-guide/v630/creating-domain-security-file

logo

Best Open Source Business Intelligence Software Helical Insight is Here

logo

A Business Intelligence Framework

Thanks,
Rupam Bhardwaj

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments