Controlling Export Options per Role/User?

0
Heyas,

is there a way to control the export (as PDF, CSV, XLS) on a Role/User base in JasperServer?
Basically, i want to give some Users the possibility to export the data in a raw format (XLS or CSV), while others are only allowed to see the PDF/Image.

Additional: The rendered image of a report differs from the "preview" from iReport. It seems, that some graphical elements are not being rendered properly (sometimes a text is only half shown, sometimes a background elemental box is rendered in white only).
Is there something to take care of?

thanks
DocJones's picture
102
Joined: Nov 21 2007 - 8:26pm
Last seen: 1 year 11 months ago

13 Answers:

0
For the first question about selectively showing the export options, you will have to change the DefaultJasperView.jsp to check for roles with the Acegi authz:authorize tag and display or not display the export options. There is an example of using authz:authorize in WEB-INF/decorators/main.jsp

On the difference between iReport and JasperServer: if you have report elements that overlap in some way, they will not be displayed in HTML, due to the limitations of HTML, but are displayed in PDF, RTF etc. This is usually the problem.


Sherman
JasperSoft
Post edited by: swood, at: 2007/11/25 19:49
swood's picture
2620
Joined: Jun 21 2006 - 12:48pm
Last seen: 9 years 1 week ago
0
Heyas,

reffering to that code snippet from DefaultJasperViewer.jsp, dont you?

Code:
<c:if test="${!emptyReport}"><br />
		  <input type="hidden" name="output"/><br />
		  <c:forEach items="${configuredExporters}" var="configuredExporter"><br />
...output td element<br />
</c:forEach><br />
</c:if><br />
</td></tr></tbody></table><br />
<br />
How can i find out about the configuredExporter values? I think i need to check every configuredExporter against a seperate ROLE like:<br />
<br />
<table align="center" border="0" cellpadding="3" cellspacing="1" width="90%"><tbody><tr><td><b>Code:</b></td></tr><tr><td><pre><c:if test="${!emptyReport}"><br />
		  <input type="hidden" name="output"/><br />
		  <c:forEach items="${configuredExporters}" var="configuredExporter"><br />
<br />
<c:if test="${configuredExporters=="Excel"}"><br />
<authz:authorize ifNotGranted="ROLE_EXPORT_EXCEL"><br />
...output td element<br />
</authz:authorize><br />
</c:if><br />
<br />
</c:forEach><br />
</c:if><br />
</td></tr></tbody></table><br />
<br />
or is there an easier way? <br />
<br />
thanks!
DocJones's picture
102
Joined: Nov 21 2007 - 8:26pm
Last seen: 1 year 11 months ago
0
You can find the list of configured exporters in WEB-INF/flows/viewReportBeans.xml (see the exporterConfigMap bean). If you derive the role names from the exporter keys, you would not need to write repetitive code in DefaultJasperViewer.jsp.

Note that hiding the export icons does not actually prevent an ill intentioned (and technical) user to fire a request that produces output that he should not be able to produce. A complete solution would require the authorization to be checked on the server; such a solution would be of course more elaborate.

Regards,
Lucian
lucianc's picture
7439
Joined: Jul 17 2006 - 1:10am
Last seen: 2 days 5 hours ago
0
Heyas,

i am doing
Code:
<authz:authorize ifAnyGranted="${configuredExporter.key}"></td></tr></tbody></table><br />
<br />
key names are "pdf", "xls", "rtf" and "csv". However, if i define a role with that name and assign a user to it, it wont work. <br />
Any tips on this? <br />
<br />
2nd question: is it possible to do a concatenation to make the role names begin with "ROLE_EXPORT_(pdf|xls|rtf|csv)"? i am not (yet) skilled enough to do it on my own... :(<br />
<br />
thanks & regards
DocJones's picture
102
Joined: Nov 21 2007 - 8:26pm
Last seen: 1 year 11 months ago
0
Heyas,

i am doing
Code:
<authz:authorize ifAnyGranted="${configuredExporter.key}"></td></tr></tbody></table><br />
<br />
key names are "pdf", "xls", "rtf" and "csv". However, if i define a role with that name and assign a user to it, it wont work. <br />
Any tips on this? <br />
<br />
2nd question: is it possible to do a concatenation to make the role names begin with "ROLE_EXPORT_(pdf|xls|rtf|csv)"? i am not (yet) skilled enough to do it on my own... :(<br />
<br />
thanks & regards
DocJones's picture
102
Joined: Nov 21 2007 - 8:26pm
Last seen: 1 year 11 months ago
0
DocJones wrote:
However, if i define a role with that name and assign a user to it, it wont work.
Any tips on this?


Did you try to login/logout?

2nd question: is it possible to do a concatenation to make the role names begin with "ROLE_EXPORT_(pdf|xls|rtf|csv)"?


Use
Code:
<authz:authorize ifAnyGranted="ROLE_EXPORT_${configuredExporter.key}"></td></tr></tbody></table><br />
<br />
HTH,<br />
Lucian
lucianc's picture
7439
Joined: Jul 17 2006 - 1:10am
Last seen: 2 days 5 hours ago
0
:silly:

Yay! Logging out/in worked. And the concatenation, too..

*two thumbs up*
DocJones's picture
102
Joined: Nov 21 2007 - 8:26pm
Last seen: 1 year 11 months ago
0

I inserted same piece of code

 

<authz:authorize ifAnyGranted="ROLE_EXPORT_${configuredExporter.key}">
 
...output td element
 
</authz:authorize>

and I tried to logout/login, but I always get exporter icons displayed.

I have several users, only one of them have role ROLE_EXPORT_pdf and ROLE_EXPORT_xls, but everyone can see that icons. I tried to restart tomcat server also, but nothing helped.

I am using JasperServer 3.7.0 Release Candidate.

Can someone help?



Post Edited by danysabo at 12/30/2009 19:04
danysabo's picture
Joined: Nov 11 2009 - 4:29am
Last seen: 11 years 11 months ago
0

What JSP did you change?

 

Sherman

Jaspersoft

swood's picture
2620
Joined: Jun 21 2006 - 12:48pm
Last seen: 9 years 1 week ago
0

I changed DefaultJasperViewer.jsp file (inside jsp folder), same file as mentioned above.

danysabo's picture
Joined: Nov 11 2009 - 4:29am
Last seen: 11 years 11 months ago
0

danysabo
Wrote:

I inserted same piece of code

 

<authz:authorize ifAnyGranted="ROLE_EXPORT_${configuredExporter.key}">
 
...output td element
 
</authz:authorize>

and I tried to logout/login, but I always get exporter icons displayed.

I have several users, only one of them have role ROLE_EXPORT_pdf and ROLE_EXPORT_xls, but everyone can see that icons. I tried to restart tomcat server also, but nothing helped.

I am using JasperServer 3.7.0 Release Candidate.

Can someone help?



Post Edited by danysabo at 12/30/2009 19:04

You might need to add a taglib directive in the JSP.

Regards,

Lucian

Code:
<%@ taglib uri="http://www.springframework.org/security/tags" prefix="authz"%></td></tr></tbody></table>
lucianc's picture
7439
Joined: Jul 17 2006 - 1:10am
Last seen: 2 days 5 hours ago
0

Thanks Lucian, it helped!

danysabo's picture
Joined: Nov 11 2009 - 4:29am
Last seen: 11 years 11 months ago
0

same problem...

my code:

 <authz:authorize ifNotGranted="ROLE_TEST">
              <td width="1" valign="top"><a href="javascript:exportReport('${configuredExporter.key}'<c:if test="${not empty exportFilename}">, '<c:url value="flow.html/flowFile/${exportFilename}"/>'</c:if>)" title="<spring:message code='${configuredExporter.value.descriptionKey}'/>"><img src="${pageContext.request.contextPath}${configuredExporter.value.iconSrc}" border="0" alt="<spring:message code='${configuredExporter.value.descriptionKey}'/>"/></a></td>
              <td width="1">&nbsp;&nbsp;</td>
          </authz:authorize>

even if the user dont have the role ROLE_TEST he see's the exporters....

Greetz

Kerstin

kthormann's picture
Joined: Jan 13 2010 - 12:54am
Last seen: 8 years 9 months ago
Feedback