ICAP Support in Quarkiverse Antivirus
— Quarkus, Extension, Antivirus — 2 min read
We're thrilled to announce a significant enhancement to the Quarkiverse Antivirus extension: it now supports the Internet Content Adaptation Protocol (ICAP)! This new feature has been made possible thanks to the powerful Toolarium ICAP Client, enabling seamless integration with ICAP-compliant antivirus solutions.
What Is ICAP?
The Internet Content Adaptation Protocol (ICAP) is a lightweight HTTP-like protocol designed to offload content adaptation tasks, such as antivirus scanning or content filtering, to dedicated servers. By leveraging ICAP, organizations can:
- Improve scalability by centralizing content scanning.
- Ensure consistency in malware detection and policy enforcement.
- Enhance performance by offloading resource-intensive scanning from application servers.
Why Add ICAP Support?
Modern enterprises often rely on ICAP servers to integrate robust antivirus scanning capabilities across their systems. By supporting ICAP, the Quarkiverse Antivirus extension empowers Quarkus developers to:
- Connect to any ICAP-compliant antivirus solution seamlessly.
- Perform real-time file or content scanning as part of their applications.
- Meet stringent security and compliance requirements efficiently.
Introducing the Toolarium ICAP Client
The Toolarium ICAP Client is an open-source Java library designed for effortless integration with ICAP servers. With its lightweight footprint and intuitive API, the Toolarium ICAP Client has been instrumental in enabling ICAP support in the Quarkiverse Antivirus extension. It offers:
- Ease of use: Simple APIs for sending and receiving ICAP requests.
- Flexibility: Support for various ICAP operations like file scanning and content modification.
- Reliability: A robust and actively maintained codebase.
How to Use the New ICAP Feature
Here's a quick overview of how you can leverage ICAP in your Quarkus application using the updated Antivirus extension:
-
Add the Quarkiverse Antivirus Extension Include the extension in your Quarkus project:
1./mvnw quarkus:add-extension -Dextensions="io.quarkiverse.antivirus" -
Configure ICAP Server Details Specify your ICAP server settings in the
application.properties
file:1quarkus.antivirus.icap.host=icap.example.com2quarkus.antivirus.icap.port=13443quarkus.antivirus.icap.service=avscan -
Integrate Scanning in Your Application Use the provided API to scan files or content within your Quarkus application:
1@Inject2Antivirus antivirus;3@PUT4@Consumes(MediaType.MULTIPART_FORM_DATA)5@Produces(MediaType.TEXT_PLAIN)6@Path("/upload")7public Response upload(@MultipartForm @Valid final UploadRequest fileUploadRequest) {8 final String fileName = fileUploadRequest.getFileName();9 final InputStream data = fileUploadRequest.getData();10 try {11 // copy the stream to make it resettable12 final ByteArrayInputStream inputStream = new ByteArrayInputStream(13 IOUtils.toBufferedInputStream(data).readAllBytes());14 // scan the file and check the results15 List<AntivirusScanResult> results = antivirus.scan(fileName, inputStream);16 for (AntivirusScanResult result : results) {17 if (result.getStatus() != Response.Status.OK.getStatusCode()) {18 throw new WebApplicationException(result.getMessage(), result.getStatus());19 }20 }21 // write the file out to disk22 final File tempFile = File.createTempFile("fileName", "tmp");23 IOUtils.copy(inputStream, new FileOutputStream(tempFile));24 } catch (IOException e) {25 throw new BadRequestException(e);26 }27 return Response.ok().build();28}