Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What are the authentication methods supported to access data source URLs? #508

Open
tuspatil1 opened this issue Jan 27, 2025 · 4 comments
Open

Comments

@tuspatil1
Copy link

tuspatil1 commented Jan 27, 2025

Hi Team,

We have jasperreports-6.21.3 community edition deployed in our environment & we uses JRXmlDataSource() to access the data source URLs, we would like to understand the authentication methods available for securely accessing data source URLs, such as OAuth, Bearer Token, or Digest Authentication.
Could you please provide information on the authentication methods supported by Jasper Studio and the corresponding Jasper APIs?

[Note: We have recently purchased te commercial edition jasperreport-9.0.0 & integration work is in progress]

Thanks,
Tushar

@teodord
Copy link
Collaborator

teodord commented Jan 28, 2025

The JasperReports Library CE only has built-in support for Basic Authentication for data adapters.
As a customer of Jaspersoft, you woud probably be assisted with other types of connecting to remote sources of data for the reports.

@teodord
Copy link
Collaborator

teodord commented Feb 3, 2025

Just to add more information here about data adapters which retrieve file data (JSON, XML, Excel, CSV, etc) from remote URLs:

They rely on pluggable implementations of the DataFileService and DataFileConnection interfaces, which can be added as extensions to the JRL core engine.
You can look at our default implementation of these two interfaces that provide basic authentication functionality and see how these could be used as examples when implementing more sophisticated authentication methods such as those using tokens and/or request headers:

https://github.com/TIBCOSoftware/jasperreports/blob/master/ext/data-adapters-http/src/main/java/net/sf/jasperreports/dataadapters/http/HttpDataService.java

https://github.com/TIBCOSoftware/jasperreports/blob/master/ext/data-adapters-http/src/main/java/net/sf/jasperreports/dataadapters/http/HttpDataConnection.java

In our standard HTTP basic authentication, we pass username and password. But in a custom implementation of your own, you could pass tokens in request headers or others stuff.

@teodord
Copy link
Collaborator

teodord commented Feb 3, 2025

It's been a while since I last looked at HTTP data adapters, so I took a fresh look and I can tell you that if your method of authentication relies on passing certain headers to the HTTP request (tokens or something), then what you need is probably already possible:

If you create a JSON or XML data adapter file in Jaspersoft Studio, to retrieve JSON or XML data from a remote URL, you'll see that the wizard proposes you to set static request headers or GET or POST parameters.
Once you type in a remote URL starting with http:// or https:// the Options button opens a dialog that allows you to introduce such HTTP request specific information.

Image

Image

In addition to this static information that can be stored in the data adapter file itself, request headers can have dynamic values that come from report parameters. This is achieved by marking report parameter definitions inside the JRXML with this configuration property that would cause their value to be injected in the request as request header values:

https://jasperreports.sourceforge.net/config.reference.html#net.sf.jasperreports.http.data.header

I assume that the authentication requiring some UI login screen happens somewhere inside your application, prior to the report execution and thus you obtain a token or something that you than can use to authenticate the data retrieval request.
So you can pass that token as report parameter value and thus use it as data adapter HTTP request header value.

@dadza
Copy link
Collaborator

dadza commented Feb 3, 2025

Also see the the sample reference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants