Hide logout option for externally authenticated users in JasperReport Server

Hide logout option for externally authenticated users in Jasper Report Server

  • An external user is a user outside of an organization who does not directly login to Jasper Reports Server.
  • JasperReports Server does not store the passwords of external users, and is not impacted by changes to user passwords or user password policies on the external authority only the login name is stored in an external user account.
  • In JasperReports Server if you want to hide logout option for externally authenticated users, following are the steps to achieve it :



Used Jasper Report Server Version : 6.4.0

  1. Goto to path : \WEB-INF\decorators\
  2. Open the decorator.jsp file
  3. Comment below code :
  4.         <authz:authorize ifNotGranted="ROLE_ANONYMOUS">
            <li id="main_logOut" class="last" role="menuitem">
            <a id="main_logOut_link" tabindex="-1">
            <spring:message code="menu.logout"/>
            </a>
            </li>
            </authz:authorize>
         


  5. Add below code before commented code which check for externally authenticated user and hides the logout option for it :

  6. <c:set var="isExternallyDefinedUser" value="<%= ((com.jaspersoft.jasperserver.api.metadata.user.domain.User)SecurityContextHolder.getContext().getAuthentication().getPrincipal()).isExternallyDefined()%>"/>
    
    <c:if test="${!isExternallyDefinedUser}">
    
    <authz:authorize ifNotGranted="ROLE_ANONYMOUS">
    
    <li id="main_logOut" class="last" role="menuitem">
    
    <a id="main_logOut_link" tabindex="-1">
    
    <spring:message code="menu.logout"/>
    
    </a>
    
    </li>
    
    </authz:authorize>
    
    </c:if>
    


  7. Save decorator.jsp file

To test hide logout option for externally authenticated user :

  1. Custom authentication
  2. Manually update “externallydefined” flag in database and test.

We can test hide logout option for externally authenticated user by second mentioned way :

  1. Connect to Jasperserver postgres database.
  2. Check users present in jasperserver by executing below query :

Select * from jiuser;

  1. You will get all users details which are present in jasper server , check the id of user to which you want to make it as externally defined user.
  2. Let us assume if you want to make testuser as externally defined user and its id is 65874 then to make is as externally defined user execute below query which set the “externallydefined” flag/value to “t”.

Verify the set flag value by executing Select * from jiuser;

  1. Now restart the jasperserver and its repository(postgres).
  2. Login to jasper server with superuser access through browser.
  3. Goto->Mange->Users and select testuser.
  4. Click on Login as User button.



Picture1

9.You will directly logged with testuser which don’t having the logout option .

 

Picture2

 

Thanks,

Sayali Mahale | Helical IT Solutions

Report’s sections controlled by input control

Report’s sections controlled by input control

Requirement: In this blog, I am going to discuss how we can enable/disable the different sections of the jasper report through input control.

Solution overview: In main report I am using two subreports which will be linked to input controls through print when expression. Let us discuss in detail how we can achieve this.

Detailed Solution:

  1. Create main report in jasperstudio. Here I am considering you know how to create report in jasper.
  2. Again create two subreports in main report and linked to already existing reports.
  3. After done with steps 1 & 2,create parameter in main report as “reportsection”:blog-1
  4. In ‘print when expression’ of subreports, type the expression as shown in screenshot below:blog-2 
  5. Similarly, update the ‘print when expression’ of subreport2.
  6. Create input control on server:

    a.Type: Multi select list of values.

    b. Name the input control as “Report Section” and parameter name should be same as in report parameter. Here it is “reportsection”.

      c. In tab “Edit list of Values”, provide the name and value.Value will contain the name of   subreport file name.e.g,

  •       subreport name: sample1.jrxml,
  •       subreport name: sample2.jrxml
  •       Name: “Sample 1”and Value: “sample1”
  •       Name: “Sample 2”and Value: “sample2”
    b3

b5

b5

  1. Link the input control with main report on jasperserver.

  7. On executing report you’ ll be able to show and hide the subreport sections of the report on click of input control. Refer the screenshots below:b7

b8

b9

Hope it helps!!

Thanks,

Nisha Sahu

Gantt chart through Widget Pro Component in Jaspersoft

Gantt chart through Widget Pro Component in Jaspersoft

Widgets Pro elements are rendered as Flash objects that are embedded in the HTML and PDF output. When a report containing Widgets Pro element is exported in a format other than HTML or PDF, the space used by the element remains blank.To view Maps, Charts, and Widgets Pro elements in HTML output, make sure Flash is installed and enabled on your browser.To view Maps, Charts, and Widgets Pro elements in PDF output, be sure to use a Flash-enabled PDF viewer such as Adobe Reader 9.

 Prerequisite:

  1. Jasperstudio pro 6.0 (any available)
  2.  Jasperserver 6.2(This blog is specific to this version)
  • At the tab Window>Preferences>Jaspersoft Studio>Properties add a new property with Property Name “com.jaspersoft.jasperreports.fusion.widgets.render.type” and Value “html5″[ incase the report doesn’t showup]. Set above property to avoid the error message which will appear after some minutes in Preview tab after running  the report containing the widget pro component.
  • In the jasperserver properties file at location: <Jaspersoft>\jasperreports-server-6.2.0\apache-tomcat\webapps\jasperserver-pro\WEB-INF\classes\jasperreports.properties. Change the render.type as flash for gantt chart widget to render in your jasperserver.

1

Note: You don’t need to set this property in jasperserver:6.3.0

Steps Involved in Created the gantt chart using widget pro option in jasperstudio:

  • Create Blank report.
  • Drag the gantt chart option from Componentspro->widgets pro-> Gantt chart.2

 

  • In main report query write the query which is going to have all the necessary data needed to be populated In the gantt chart.
  • The Gantt Chart is the most complex widget or chart, with its data defined by up to four different datasets. The following figure shows the main components of a Gantt chart:

 

Category Set: Its going to be the different categories under which the task data is going to be populated. E.g We can categorise the time period in different months.

 

Process set: Process Set consists of different values on y axis which simply means different subjects or areas for which the data in form of task is going to be visualized in the chart.

Process is unique to its type. E.g P1, P2, P3, P4…. etc

 

Task Set: There can be more than one task in every process. Thus different  tasks come under the each process, as the per the available data. E.g P1.T1, P1.T2, P2.T1, P3.T3, P3.T2 etc. Unlike process the task can be same in different process.
Refer the document on ireport widget pro for the basics of gantt chart.

 

  • Configuring the properties of widget pro:
    As shown in the figure below add different categories in the category set of the gantt chart.

4

  • Configure the dataset in the gantt chart as shown in the data given below:

    5

 

Note: Don’t forget to add the process id for each task added.

  • Configure the tasks in the chart as shown in the given screenshot:

6

  • Save the report and publish on server. You”ll be able to get the desired gantt chart.

 

Thankyou
Nisha Sahu

 

 

 

Jasper Server External Database Authentication

                                                                 JasperServer External Database Authentication

Jasper Report Server can be configured to perform authentication and authorization using external table.

Purpose
This kind of authentication can be used when an application is using any other database to store users, roles and organization data, and if it wants jasper server to sync-up data and create same users, roles and organization information what it has stored in database. It also can be used to set up environment for SSO.
We need to configure jasper server to use this authentication process.

Steps to configure Jasper server

STEP-1
Copy <JS_INSTALL>/samples/externalAuth-sample-config/sample-applicationContext-externalAuth-db.xml to /WEB-INF directory.

STEP-2
Rename copied file to applicationContext-externalAuth-db-mt.xml.
Now, edit and configure beans of applicationContext-externalAuth-db-mt.xml.

STEP-3
Find below mentioned bean tag and configure according to your requirement. This tag is used for database parameters. Here, I am using mysql for external database authentication.

<bean id=”externalDataSource” class=”org.springframework.jdbc.datasource.DriverManagerDataSource”>

        <property name=”driverClassName” value=”com.mysql.jdbc.Driver”/>

        <property name=”url” value=”jdbc:mysql://localhost:3306/jasper_external”/>

        <property name=”username” value=”user”/>

        <property name=”password” value=”****”/>

NOTE: For testing purpose, you can create same database structure as jasper server use for authentication.

STEP-4
Find “externalUserTenantDetailsService” bean tag and configure: E.g.

<bean id=”externalUserTenantDetailsService”    class=”com.jaspersoft.jasperserver.multipleTenancy.security.externalAuth.db.MTExternalJDBCUserDetailsService”>

        <property name=”dataSource” ref=”externalDataSource”/>

        <property name=”usersByUsernameAndTenantNameQuery” value=”SELECT u.username, u.password, t.org_name FROM h_users u LEFT JOIN organization t ON u.org_id = t.id WHERE username =?”/>

        <property name=”authoritiesByUsernameQuery” value=”SELECT u.username, r.role_name FROM h_users u, user_role ur, role r WHERE u.id = ur.user_id and ur.role_id=r.id and u.username = ?”/>

        <property name=”multiTenancyConfiguration”><ref bean=”multiTenancyConfiguration”/></property>

    </bean>

NOTE: You can change table name, column names but sequence of column should not be changed in written query. Here, you can see I am using h_users table (custom table) instead jiuser (which is used by jasperserver) and column names are also different e.g. role_name.
This bean is responsible for queries which will be executed by jasperserver to use authentication.

STEP-5
Retrieving roles from database:
Configure “mtExternalUserSetupProcessor” bean to map the external information to roles in jasperserver.
• defaultInternalRoles property – A list of internal roles assigned to the external user by default.
• organizationRoleMap property – A list of key/value pairs that maps external role names to internal ones.

For commercial JasperReports Server deployments, you need to choose the level at which the role is assigned:

• To map to an internal role at the organization level, append |* to the name of the internal role, for example, ROLE_EXTERNAL_USER|*. Roles mapped at the organization level do not have administrative privileges.
• To map to an internal role at the system (null) level, do not modify the internal role name, for example, ROLE_EXTERNAL_ADMINISTRATOR. Roles at the system level are usually reserved for special users such as the system administrator and allow access to the repository folder of all other organizations.

The following example shows how to configure organizationrolemap:


<property name=”organizationRoleMap”>
    <map>                <entry>                                <key>                                                <value>ROLE_ADMIN</value>

                                </key>

                                <value>ROLE_ADMINISTRATOR|*</value>

                </entry>

</map>

</property>

STEP-6
Restart Jasper server.

 

Thanks

Sharad

I-Report Bands

                                                                                                        I-Report Bands

 

A jasper report is composed by a set of sections named as “bands”.  Every band contains few properties such as height. Band height should be greater than 0, otherwise it will never be visible to user.  The band height can grow if elements inside it are stretched.

Default Bands in Report:

Title Band

Printedonly one time and it’s the first band. It can be printed on a separate page. You can print report title in this band.

 

Page Header

Printed on each page.

 

Column Header

It prints on each page if page contains detail band. If page splits it prints on each page. You can use this to crate manual table and put column name in this band.

 

Detail

It prints for each record in the source.

 

Column Footer

It is same as column header band, but it prints in footer instead of header.

 

Page Footer

Same as Page header, but it is footer section.

 

Summary

It prints only once at the end of the report. It can be printed on separate page also.

 

Background

It can be used to define a page background. You can also use image in this band.

 

The position of bands cannot be modified. For each band, you can modify only band height.

This is the sequence of bands in any jasper report (Fig 1.0). You can hide/unhide bands according to your needs.

If you click on any band, you can see the properties of that band in your right hand side panels (Fig 2.0). (If properties panel is not visible, Click on menu Window > Properties.

 

FIg 1.0

FIg 1.0

Fig 2.0

Fig 2.0

 

 

 

 

Thanks

Sharad Sinha

Deploy jar file in jasperserver without restarting service

Option 1 – If you want to use your Jar in a several reports.

You should “Add Jar” (as it called in iReport repository manager) to some folder in the Jasper Server folder tree. Then “Add reference” to this resource in Resources section of you specific report.

Option 2 – You need a jar in a specific report.

Use “Add Jar” option in a resources section of specific report.

Worked perfectly on JasperServer 4.7

 

Naveen Dasari

Helical IT Solutions

Jasper Report Localization Example

Jasper Report Localization Example

Applying localization on jasper reports and jasper input controls. This blog post helps you understand how localization can be achieved , what can be localized and its limitations.

What can be localized?

Localization can be done on data which is static in nature i.e data which is not coming from database. Below are the few items where it can be achieved.

  1. Input controls.
  2. Report title.
  3. Legends.

How to localize reports?

Create a property file and enter input control name – value pairs, report title name.. etc. This is a one time activity and this file to be saved with extension .properties. EX: “file_name.properties”

Before creating property file, I recommend users to analyze what all can be localized on jasper report like input control names and its value, report title, legends, table component headers etc.

Step 1: Create property file as I shown below for both English and Spanish.

Step 1

Step 2: Edit your Input Control and modify the value of [“Prompt Text” / Name of Input Control] to “$R{inputcontrol_id}”.

Step 2Step 3: Remove all the name and values from Edit List of values and modify as I shown in below picture.

Step 3

Step 4: Update your JRXML by providing Resource Bundle. Resource Bundle is nothing but the file name of your property file which is created at Step-1 and is a property of report and publish your report.

Step 4

Where and How to upload properties file in Jasperserver?

Property file can be upload in 2 ways. One way from iReport and other way via JasperServer. I prefer to upload property file from JasperServer rather from iReport. Please follow my steps.

Step 1: Edit your report and navigate to “Controls & Resources” tab and click on “Add Resource”.

Step 5

Step 2: Browse property file and navigates to next page where you need to give Resource Name and Resource ID.

Step 6NOTE: Resource Name and Resource ID both should match with the file name of your properties. Please find the screen shot.

By this time you might have get a doubt how spanish language can be achieved. No worries the solution is very simple. For spanish you need to save your filename as “localization_es.properties” and then upload the same file in Jasperserver. Please follow my screen shot.

Step 7Remember: Each time when you update your property file, it has to be uploaded to server.

Localization Limitations:

– Localization cannot be achieved on Input controls for type

  • Single select query
  • Multi select query
  • Single select query (Radio)
  • Multi select query (Radio)

– Localization cannot be done on the data which is dynamic in nature.