ramandeep1980 Posted October 11, 2009 Share Posted October 11, 2009 Hi Everyone,I will appreciate any help in process of authentication.Can we somehow dynamically select one out of 3 WHERE clause depending upon authentication thru Loggedinusername and roles in use.Depending upon the value in loggedinusername and role from Jiuser and jirole respectively. Can we select a where clause which is already written.I need this for row level security on reports.I dnt want to put multiple WHERE clause in the query for report because it will slow down the reports.so i am looking to put these WHERE clause somewhere in the server or report from where they can be selected depending upon the user name and role they r in.Regards,RamanPost Edited by ramandeep1980 at 10/11/2009 23:16 Link to comment Share on other sites More sharing options...
swood Posted October 13, 2009 Share Posted October 13, 2009 Sounds like you want to do something like this http://jasperforge.org/plugins/espforum/view.php?group_id=112&forumid=102&topicid=64901 ShermanJaspersoft Link to comment Share on other sites More sharing options...
ramandeep1980 Posted October 13, 2009 Author Share Posted October 13, 2009 Hi Sherman,Thank you for replying.Not exactly, thats not what im looking for.What i am looking for is that i prepare 3 different types of WHERE clauses with diferent number of parameters in them A.Where col_1= $P{x} B.Where col_1= $P{x}AND col_2 =$P{y} C. Where col_1= $P{x}AND col_2 =$P{y}AND col_3 = $P{z} Now on the bases of the Role user is in, I wanna select one of the above 3 values of WHERE- A,B or C Andi dnt want to put these values in report query.So where can i put them and call them as per the requirement. Regards,Raman Link to comment Share on other sites More sharing options...
swood Posted October 17, 2009 Share Posted October 17, 2009 In your report JRXML, define the X, Y, Z parameters and input controls for them in JasperServer. Then have a parameter with a default expression that generates the string you want to put in the where clause based on a test of the user's roles, like: (In Groovy)<parameter name="queryExpression" class="java.lang.String"> <defaultExpression> if (${LoggedInUser}.roles.any{ it.roleName in ['ROLE_X'] }) { 'col_1 = \'' + $P{X} + '\'' } else if ( another test ) { 'col_1 = \'' + $P{X} + \'' and col_2 = \'' + $P{Y} + '\'' } </defaultExpression> </parameter>...<queryString>...where $P!{queryExpression}</queryString> If you want to do that in Java, have a complicated (test) ? string : ((test2) ? string :...)) or you could use a scriptlet. ShermanJaspersoft Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now