Antivirus extensibility
A sponsor might use any Antivirus Server other than ClamAV. In such situations, the sponsor must write an implementation code for the respective Antivirus Server, and call the implementation code in the Agent code for integrating with IBM PEM. This topic explains how to set up the Agent container to call the implementation code.
Before you begin
- Set up an Agent container that is running the scanAgent.
- Create the implementation code.
Procedure
- Create a java project in any IDE.
- Download the agent.zip file that contains all the required classes.
- Extract and add all the classes to the java project.
-
Create a main class. For example,
TestAVScanner.java.The sample code snippet ofTestAVScanner.javamain class is as follows:
Here,package com.ibm.vch.antivirus.scan.framework; import java.io.IOException; import java.io.InputStream; import com.ibm.vch.identity.antivirus.framework.AntiVirusException; import com.ibm.vch.identity.antivirus.framework.ScanResult; public class TestAVScanner implements AntivirusScanHandler { @Override public ScanResult antivirusScanTask(InputStream data) throws AntiVirusException, IOException { return TestScanner.scanFile(data); } }InputStreamis where the data is sent to scan for viruses.TestScanner.scanFileis the function that has the business logic to scan the file and display the results.
The sample code snippet forTestScanner.javais as follows:package com.ibm.vch.antivirus.scan.framework; import java.io.IOException; import java.io.InputStream; import com.ibm.vch.identity.antivirus.framework.AntiVirusException; import com.ibm.vch.identity.antivirus.framework.ScanResult; public class TestScanner { public static ScanResult scanFile(InputStream is) throws AntiVirusException, IOException { return new TestAVProvider().scan(is); } } -
Validate whether your implementation code is compatible with the IBM PEM
Agent code. To validate, ensure that the
TestAVProvider.javaclass returns the following values:- CLEAN - The file that is scanned does not contain any virus.
- INFECTED - The file that is scanned contains viruses.
- ERROR - The file initiated for virus scan failed.
The
TestScanner.scanFile(InputStream)method is provided for reference in theTESTScanner.javaclass that callsTestAVProvider.java.The sample code snippet ofTestAVProvider.javaclass is as follows:package com.ibm.vch.antivirus.scan.framework; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import com.ibm.vch.identity.antivirus.framework.ScanResult; import com.ibm.vch.identity.antivirus.framework.ScanResult.ScanResultStatus; public class TestAVProvider { private ScanResult sc; public ScanResult scan(InputStream is) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(is)); StringBuilder out = new StringBuilder(); String line; while ((line = reader.readLine()) != null) { out.append(line); } String str = out.toString(); System.out.println(str); if (<The file initiated for virus scan failed>) { sc = new ScanResult(ScanResultStatus.ERROR); } else if (<The file that is scanned does not contain any virus>) { sc = new ScanResult(ScanResultStatus.CLEAN); } else if (<The file that is scanned contains viruses>) { sc = new ScanResult(ScanResultStatus.INFECTED); } return sc; } } -
In the
Setup.cfgfile, configure the following property:agent.scan_extensibility_classand set the value to"com.ibm.vch.antivirus.scan.framework.TestAVScanner" -
Extract the jar file from the IDE project, for example,
agent_plugin.jar. -
Verify that you have extracted the files of
MountFiles.zip. -
Copy the
agent_plugin.jarfile to the lib folder.