Custom Java interceptors allow users to create and execute custom Java classes contained in .jar files, following a specific development model.
To create custom Java interceptors, you must have a .jar file in your machine and upload it to the Manager. On this page, we explain how to configure the Manager settings and offer examples of .jar files to assist you.
To create a custom interceptor on the Manager, you must first upload the .jar file of your project to our Platform.
For a .jar file to be considered valid, it should have these characteristics:
@ApiSuiteInterceptor;@InterceptorMethod;TIPA common mistake is selecting folders such as
binortargetin addition tosrcto compile the source code into the .jar file, which can lead to error because it creates invalid references to other files. You only need to reference thesrcfolder.
This is the dependency you need to use:
Download dependency (api-interceptor-java-spec-4.6.1.0.zip)
If you are using an older version of the Manager, you might need to download this dependency file (feel free to get in touch with our support team if you need assistance):
Download dependency (older version)
Different in v4In versions 4.13, 4.14 and 4.15, use the
api-interceptor-java-spec3.0.1 dependency:Download the v4 dependency (api-interceptor-java-spec-3.0.1.zip)
See below some examples of custom Java interceptors:
TIPYou can check this page to see a more detailed example of how to create and upload a custom Java interceptor to the API Platform.
Here you can get JavaDocs to assist you:
JavaDocs - Custom Java Interceptor
New interceptors are created on the Interceptors menu page, through the + button on the bottom right corner.

To create a Java interceptor, click or hover the cursor over the + button and select the option Create Custom Java.

To configure the interceptor, you must fill in some attributes, as shown in the image below.

After entering the data, click Save. The system will then perform an analysis to validate the file uploaded. If it is valid, the system will save it. Otherwise, the message "Invalid JAR file" will be displayed.
Existing Java interceptors will be displayed on cards separated by tags. Interceptors which have not been assigned any tags will be listed under the Uncategorized grouping and with a tag signalling that they are custom Java interceptors.

To use the interceptor, drag it into the desired flow. Custom interceptors might be added both to the request and the response flows.
A modal window will open up displaying the name of the Java interceptor and the list containing the classes and methods that can be used to intercept calls.

You can specify parameters to be used inside Java interceptors. To do so, you need to add the keys/values and interpret these parameters inside the method that will intercept the call.
CAUTIONIf you edit a custom interceptor you must remove all instances of this interceptor that had been inserted in API flows before your modifications. That is because changes made to an interceptor will not be reflected upon interceptor instances in API flows.
Upon receiving a request, the system performs a validation analysis of the .jar file code looking for potentially malicious functions that may somehow compromise the interceptor. If the system finds any potential security breach, the interceptor won't run and a security exception will be triggered.
We use cookies to enhance your experience on our site. By continuing to browse, you agree to our use of cookies.Learn more