BackPrevious Page Next PageNext

Security Context Support

Configuring JReport products

Security Context APIs

Using Security Context

Security Context Support refers to a new set of functionalities that JReport products provide to support Unify NXJ Security Context. Other than using the security system of JReport, Security Context Support allows Unify NXJ developers to write code that obtains user profile information from the security database. Security Context Support may be useful for any developer who uses Java EE Security.

Configuring JReport products

Configuring JReport Designer

By default, JReport Designer uses its own security system. If you want to enable the Security Context Support, you will first need to configure the config.xml file in <designer_install_root>\bin.

  1. Add the elements <SecurityContextFactory value=""/> and <DeployWizardFactory value=""/> as the child of the element <Option>.
  2. Implement classes to the attribute values. For example, part of the config.xml file might be as follows:
    <Option>
        …
    
    
        <SecurityContextFactory value="com.utify.JRSecurityContextFactoryImpl"/> 
        <DeployWizardFactory value="com.utify.JRDeployWizardFactoryImpl"/> 
    </Option>
  3. Add the root path of the implementing class packages to the ADDCLASSPATH variable of setenv.bat in <install_root>\bin.

Security Context interfaces in JReport Server are different from those of JReport Designer, and you will have to implement the Server interfaces separately.

Configuring JReport Server

  1. Before you can use the Security Context feature, first configure the server.properties file in <server_install_root>\bin.

    Open the server.properites file, and then modify (add if it doesn't exist) the value of the property com.jinfonet.securityContextFactory to be that of your SecurityContextFactory implementing class package and name as follows:

    com.jinfonet.securityContextFactory=mypackage.myclass

    Note: Alternatively, you can add the parameter –D com.jinfonet.securityContextFactory = mypackage.myclass to the file JRServer.bat with which you start your JReport Server.

  2. Add the root path of the implementing class packages to the class path of the file JRServer.bat.

Security Context APIs

JReport provides a set of APIs to support the Security Context feature.

JRSecurityContextFactory

JRSecurityUserDataSource

JRSecurityHierarchicalDataSource

SecurityContextFactory

SecurityContext

Using Security Context

Using in viewing report

When you view a report that requires the security context to run, JReport Designer will use the implemented JRSecurityContextFactory to instantiate the SecurityContext instance which will be used to execute the report.

Using in the Formula Editor

The Formula Editor now allows you to pass the Security Context to a user-defined formula (UDF) function.

You can call getSecurityContext() in your formula, which will pass the returning object to your UDF function. The method getSecurityContext() returns a DbSecurityContext type object, which provides the method get() to get the Security Context instance transfer from Server or Designer.

DbSecurityContext is a new data type for the SecurityContext object, since the data type of all the variables used in UDF functions should be DbValue.

The following is an example.

Import userClass from "UserFunction";
userClass.getData(getSecurityContext(), @country, …);

Using in the Deployment Wizard

JReport provides you with two API methods which allow you to bring out your own publishing tool.

DeploymentWizard

DeploymentWizardFactory

Below are the working principles:

BackPrevious Page Next PageNext