### Security Context APIs

JReport provides a set of APIs to support the Security Context feature, including JReport Designer API and JReport Server API.

#### JReport Designer API

##### JRSecurityContextFactory

Package: jet.acl.api

Usage: This interface is used to help the user to create an instance of SecurityContext.

Method: getSecurityContext(javax.swing.JFrame frame, java.util.Vector roles)

Parameters:

- frame - The parent window.
- roles - The role list defined by RLS (record-level security).

Returns: The SecurityContext object.

##### JRSecurityUserDataSource

Package: jet.datasource

Usage: A JRSecurityUserDataSource provides data to JReport for generating reports. The JRSecurityUserDataSource class is developed by users of JReport. It can provide data from a flat file, non-relational database, or application data.

The data returned by this class is in ResultSet object, so users will need to create a ResultSet instance. Then, JReport will use the instance to fetch the data. Users can also create their own ResultSet class.

Method: getResultSet(SecurityContext sc, java.lang.String param)

Method description: Gets the data in ResultSet according to parameters.

Parameters:

- sc - A SecurityContext object, which is implemented by the user.
- param - The parameter that is to be used for UDS.

Returns: The ResultSet object.

##### JRSecurityHierarchicalDataSource

Package: jet.datasource

Usage: A JRSecurityHierarchicalDataSource provides data to JReport for generating reports. The JRSecurityHierarchicalDataSource class is developed by users of JReport. It can provide data from a flat file, non-relational database, or application data.

The data returned by this class is in JRHierarchicalDataset object, so users will need to create a JRHierarchicalDataset instance. Then, JReport will use the instance to fetch the data. Users can also create their own JRHierarchicalDataset class.

Method: getHierarchicalDataset(SecurityContext sc, java.lang.String param)

Method description: Gets the data in JRSecurityHierarchicalDataset according to the security context and parameters

Parameters:

- sc - A SecurityContext object, which is implemented by the user.
- param - The parameter that is to be used for HDS.

Returns: The JRHierarchicalDataset object.

#### JReport Server API

##### SecurityContextFactory

Package: jet.server.api

Usage: SecurityContextFactory is an interface that is used to help you implement security context.

Method: getSecurityContext(java.lang.String realmName, java.lang.String userName, java.lang.String resource, int versionNumber)

Method description: Returns the SecurityContext of a specified resource.

Parameters:

- realmName - The realm name of the current active realm of the server.
- userName - The user name, for a schedule task it is submitter, for an advance run task, it is login user.
- resource - The resource of the server. Now, it is only limited to report resource in the server. For example, `/SampleReports/CustomerAnalysis.cls`
- versionNumber - The version number of the resource.

Returns: The SecurityContext of the specified resource.

##### SecurityContext

Package: jet.server.api

Usage: SecurityContext is an interface that is used to help you implement security context.

Methods:

- getEmail() - Returns the e-mail address of the user.
- getRoles() - Returns the roles the user belongs to.
- getSalutation() - Returns the salutation of the user (for example, Mr., Mrs., and so on).
- getUserName() - Returns the user name.