Row Level Security - Domain level

0

 

Hello,
 
I am new to Jaspersoft & am trying to try implement row level security at a domain level. 
 
I have a very simple domain (one user table with a user_id column). This user_id references the ID of the users already present in Jaspersoft. (Basically, I want the logged in user to see his details in the report). When I just defined the domain without any security, domain was created fine, I could create views & reports.
 
But when I attach the security file, the domain is throwing up errors.
 
This is the error I get - 
 
The Domain data source /Test_Domain is invalid. exception parsing filter string 'public_test.user_id == authentication.getPrincipal().getId()'
 
This is the security file - 
 
<securityDefinition xmlns="http://www.jaspersoft.com/2007/SL/XMLSchema" version="1.0" itemGroupDefaultAccess="granted"><resourceAccessGrants>
<resourceAccessGrantList id="public_test_List" label="ListLabel" resourceId="public_test">
<resourceAccessGrants>
<resourceAccessGrant id="public_test_row_access_grant_1">
<principalExpression>
<![CDATA[authentication.getPrincipal().getId() > 0 ]]> 
</principalExpression>
<filterExpression>
public_test.user_id == authentication.getPrincipal().getId()
</filterExpression>
</resourceAccessGrant>
</resourceAccessGrants>
        </resourceAccessGrantList> 
</resourceAccessGrants>
</securityDefinition>
 
 
Any thoughts on what I am doing wrong. I am on Jaspersoft 4.7
 
Any help is appreciated.
 
Thanks
 
A
 
akothari's picture
Joined: Nov 6 2012 - 1:55pm
Last seen: 4 years 6 months ago

2 Answers:

0

Hi,

The filter expression is an expression in DomEL expression language.

To access authentication object, you need to use groovy call, i.e. the expression should look like :

<filterExpression>
public_test.user_id == groovy('authentication.getPrincipal().getId()')
</filterExpression>
 
Note that principal expression is already in the groovy scope.
 
Andrew S.
andrews's picture
10
Joined: Aug 6 2008 - 5:36pm
Last seen: 1 year 3 months ago
This comment was blocked because Project Honeypot indicates it came from a suspicious IP address.
akothari - 9 years 2 months ago
0

Thanks Andrew.

When I added the groovy code, I get the following error

The Domain data source /Test_Domain is invalid.
exception parsing filter string 'public_test.user_id == groovy('authentication.getPrincipal().getId()')'

akothari's picture
Joined: Nov 6 2012 - 1:55pm
Last seen: 4 years 6 months ago
Feedback
randomness