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

Restrain user to access only reports


rljp

Recommended Posts

Hello all!

     I have a single user that will access all my reports through direct URL, my problem is that I want to allow this user to only view the reports, I mean, I don’t want to allow him to view the JasperServer home page or my folders or anything else. I don’t even need a list of available reports, since I’ll access them through a direct URL generated by another program.
     How can I do that?

Thanks a lot!



Post Edited by rljp at 12/14/2009 19:23
Link to comment
Share on other sites

  • Replies 7
  • Created
  • Last Reply

Top Posters In This Topic

Hello,

What I did is to create a report which queries the metadatabase of jasperserver (mysql) and lists only the reports by their designation (=label) as hyperlinks.

Then I associated this report as the home page for the user's Role.

After that, I complicated by filtering the reports according to the jasperserver "rights" on the reports and folders containing the reports. So I can have different views of the available reports for the users.

I did that one year ago and since it works fine

HTH

Gaby

Link to comment
Share on other sites

You certainly need to change the home page like Gaby indicates. Given you don't want the user to access anything,  this could be blank or just some friendly "you can't do anything" message.

 

You will need to change the template WEB-INF/decorators/main.jsp does not show the menu for ROLE_URL_ONLY (say) and give the user that role.

 

Sherman

Jaspersoft

Link to comment
Share on other sites

Hello everyone, thanks for the help!

     I’m sorry to bother you all if these questions, but I don’t have any experience in this. I tried to change the home page of a user, but I couldn’t get it right.
     I changed the following setting in the file /WEB-INF/jasperserver-servlet.xml, at the "loginController" bean:

<property name="homePageByRole">
   <list>
      <value>ROLE_ADMINISTRATOR|redirect:/flow.html?_flowId=repositoryExplorerFlow</value>
      <value>ROLE_USER|redirect:http://www.google.com/</value>
   </list>
</property>

     But my ROLE_USER home page remains the same. What I’m doing wrong?
     I also tried to have a look at the WEB-INF/decorators/main.jsp, but I didn’t find where I can set the menu to be showed or not.
     Can anyone PLEASE take some time and explain this to me?

Thanks a lot…

Link to comment
Share on other sites

cant you 'just' hide the menu bars?
and then change the home page for the role ROLE_USER?

the first option ive read about and thus should be possible, the second one i've actually done:

-open jasperserver-servlet-pro.xml
-change
<value>ROLE_USER|redirect:/flow.html?_flowId=homeFlow</value>
to
<value>ROLE_USER|redirect:/flow.html?_flowId=listReportsFlow</value>

(or any role for that matter)

 

 

EDIT:

wow i must be blind @ 9:42 in the morning :D

have you restarted the JasperServer afther the configuration change? are you sure you arent logging in as ROLE_ADMIN or any other?

good luck :)



Post Edited by sjongenelen at 12/23/2009 08:32

 

EDIT2:

whaha still blind, you are talking about the 'jasperserver-servlet.xml' and im talking about 'jasperserver-servlet-pro.xml'

perhaps you didnt edit the right XML? Im using JasperServer pro btw



Post Edited by sjongenelen at 12/23/2009 08:34
Link to comment
Share on other sites

Just another idea - use the Webservices:

Instead of letting the users access JasperServer directly you can use the SOAP Implementation provided.

Version a) Checkout the php samples provided with JS, they are great and easily customizable. - do this in case you want to provide more than a few reports to the user and let the user browse around according to his rights.

Version b) checkout: http://gist.github.com/26205   - do this in case you want to provide just one or two reports

hth regards georg

PS: ad b) as the link seems to be broken I'll attach the php code below.


Post Edited by gkuehnberger at 01/04/2010 00:51

Code:
<?php/** * PHP client for requesting reports from JasperServer via SOAP. * * USAGE: * *  $jasper_url = "http://jasper.example.com/jasperserver/services/repository"; *  $jasper_username = "jasperadmin"; *  $jasper_password = "topsecret"; * * *  $client = new JasperClient($jasper_url, $jasper_username, $jasper_password); * *  $report_unit = "/my_report"; *  $report_format = "PDF"; *  $report_params = array('foo' => 'bar', 'fruit' => 'apple'); * *  $result = $client->requestReport($report_unit, $report_format,$report_params); * *  header('Content-type: application/pdf'); *  echo $result; */class JasperClient {  private $url;  private $username;  private $password;  public function __construct($url, $username, $password) {    $this->url = $url;    $this->username = $username;    $this->password = $password;  }  public function requestReport($report, $format, $params) {    $params_xml = "";    foreach ($params as $name => $value) {      $params_xml .= "<parameter name="$name"><![CDATA[$value]]></parameter>n";    }    $request = "      <request operationName="runReport" locale="en">        <argument name="RUN_OUTPUT_FORMAT">$format</argument>        <resourceDescriptor name="" wsType=""        uriString="$report"        isNew="false">        <label>null</label>        $params_xml        </resourceDescriptor>      </request>    ";    $client = new SoapClient(null, array(        'location'  => $this->url,        'uri'       => 'urn:',        'login'     => $this->username,        'password'  => $this->password,        'trace'    => 1,        'exception'=> 1,        'soap_version'  => SOAP_1_1,        'style'    => SOAP_RPC,        'use'      => SOAP_LITERAL      ));    $pdf = null;    try {      $result = $client->__soapCall('runReport', array(        new SoapParam($request,"requestXmlString")      ));      $pdf = $this->parseReponseWithReportData(        $client->__getLastResponseHeaders(),        $client->__getLastResponse());    } catch(SoapFault $exception) {      $responseHeaders = $client->__getLastResponseHeaders();      if ($exception->faultstring == "looks like we got no XML document" &&          strpos($responseHeaders, "Content-Type: multipart/related;") !== false) {        $pdf = $this->parseReponseWithReportData($responseHeaders, $client->__getLastResponse());      } else {        throw $exception;      }    }    if ($pdf)      return $pdf;    else      throw new Exception("Jasper did not return PDF data. Instead got: n$result");  }  protected function parseReponseWithReportData($responseHeaders, $responseBody) {    preg_match('/boundary="(.*?)"/', $responseHeaders, $matches);    $boundary = $matches[1];    $parts = explode($boundary, $responseBody);    $pdf = null;    foreach($parts as $part) {      if (strpos($part, "Content-Type: application/pdf") !== false) {        $pdf = substr($part, strpos($part, '%PDF-'));        break;      }    }    return $pdf;  }}?>

Post Edited by gkuehnberger at 01/04/2010 00:52
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...