Since JasperReports Server works only with users that are defined internally, once the user has been authenticated and their external user details have been set, you need to have the internal database reflect that user state, and create the necessary organizations, user, roles, and attributes. To do this, implement ExternalDataSynchronizer.
To create custom code to run on the server after the user has been authenticated, you can add a custom processor and add it to the processors list for the externalUserProcessors property. To create a custom processor, extend the AbstractExternalSetupProcessor or MTAbstractExternalProcessor class, which provides access to all of the JasperReports Server services, such as the repository and user manager. For example, to create a folder, you must use the Hibernate access service. See the description of Java APIs in the chapter “JasperReports Server APIs” in the JasperReports Server Ultimate Guide for more information on the available JasperReports Server services.
All the sample files in the <js-install>/samples/externalAuth-sample-config directory implement the externalUserProcessors property. Files that map users and roles implement an ExternalUserSetupProcessor bean; files that map external tenants to internal JasperReports Server organizations implement an TenantSetupProcessor bean. These processors are described in detail in the sections for each authentication mechanism, for example, Mapping the User Roles and Mapping the User Organization. In addition, the sample file sample-applicationContext-externalAuth-template[-mt].xml shows how to implement an externalUserFolderProcessor that automatically creates a user folder which is accessible only to the authenticated user.
The following example shows how to add two processors, externalUserSetupProcessor and externalUserFolderProcessor, to the externalUserProcessors property of the ExternalDataSynchronizer bean:
<bean id="externalDataSynchronizer"[/code] class="com.jaspersoft.jasperserver.api.security.externalAuth.ExternalDataSynchronizerImpl">[/code] <property name="externalUserProcessors">[/code] <list>[/code] <ref local="externalUserSetupProcessor"/>[/code] <ref local="externalUserFolderProcessor"/>[/code] </list>[/code] </property>[/code] </bean>[/code] |
The following example shows how to configure an externalUserFolderProcessor bean in the applicationContext-externalAuth-template[-mt].xml configuration file:
<bean id="externalUserFolderProcessor"[/code] class="com.jaspersoft.jasperserver.api.security.externalAuth.processors.[/code] ExternalUserFolderProcessor"[/code] parent="abstractExternalProcessor">[/code] <property name="repositoryService" ref="${bean.unsecureRepositoryService}"/>[/code] </bean>[/code] |
To write a processor, use the JasperReports Server Java APIs, which are services instantiated by the Spring 3.1 Framework; these APIs are documented in the JasperReports Server Ultimate Guide. You can use these services to add custom processing after JasperReports Server receives the userDetails.
To use the following services, extend AbstractExternalUserProcessor:
• | RepositoryService |
• | UserAuthorityService |
• | TenantService |
• | ProfileAttributeService |
• | ObjectPermissionService |
To use the following service, extend MTAbstractExternalProcessor:
• | multiTenancyService |
For more information on the Spring Framework used for the Java APIs, refer to Spring’s reference documentation at http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/html.
Recommended Comments
There are no comments to display.