Jump to content
We've recently updated our Privacy Statement, available here ×

Controlling Export Options per Role/User?


DocJones

Recommended Posts

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

Link to comment
Share on other sites

  • Replies 13
  • Created
  • Last Reply

Top Posters In This Topic

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

Link to comment
Share on other sites

  • 2 weeks later...

Heyas,

 

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

 

Code:
<c:if test="${!emptyReport}">
<input type="hidden" name="output"/>
<c:forEach items="${configuredExporters}" var="configuredExporter">
...output td element
</c:forEach>
</c:if>

 

How can i find out about the configuredExporter values? I think i need to check every configuredExporter against a seperate ROLE like:

 

Code:
[code]<c:if test="${!emptyReport}">
<input type="hidden" name="output"/>
<c:forEach items="${configuredExporters}" var="configuredExporter">

<c:if test="${configuredExporters=="Excel"}">
<authz:authorize ifNotGranted="ROLE_EXPORT_EXCEL">
...output td element
</authz:authorize>
</c:if>

</c:forEach>
</c:if>

 

or is there an easier way?

 

thanks!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Heyas,

 

i am doing

Code:
<authz:authorize ifAnyGranted="${configuredExporter.key}">

 

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.

Any tips on this?

 

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... :(

 

thanks & regards

Link to comment
Share on other sites

Heyas,

 

i am doing

Code:
<authz:authorize ifAnyGranted="${configuredExporter.key}">

 

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.

Any tips on this?

 

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... :(

 

thanks & regards

Link to comment
Share on other sites

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}">

 

HTH,

Lucian

Link to comment
Share on other sites

  • 2 years later...

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
Link to comment
Share on other sites

danysabo
Wrote:

I inserted same piece of code

 

 

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"%>
Link to comment
Share on other sites

  • 2 weeks later...
  • 9 months later...

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">  </td>          </authz:authorize>

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

 

Greetz

Kerstin

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...