Symantec 防毒掃描引擎是一款企業級的防毒解決方案,支援與多種運行環境整合。本文記錄如何在 J2EE 專案中呼叫該引擎,提供完整的實作步驟與範例代碼,供開發人員參考。
前往 Symantec 官網下載試用版軟體與授權檔:
Symantec Scan Engine 試用下載
https://ip:8004/ → System → License → Install) 或直接複製至 C:\Program Files\Common Files\Symantec Shared\Licenses 目錄注意: Web Console 僅支援 HTTPS 連線。
掃描伺服器預設使用 ICAP 協定通訊,URL 格式為 icap://[IP]:[Port]/avscan。
專案需引入 virusscan-0.1.jar(檔名 virus-scan-connect.zip),該套件封裝了與 Scan Server 互動的邏輯。
public static void main(String[] args) {
// 掃描伺服器 ICAP URL
String scanServerUrl = "icap://10.225.69.89:1344/avscan";
VirusScanManager vsm = new VirusScanManager(scanServerUrl);
String testFile = "./test/eicar.com.txt";
InputStream in = null;
try {
// 使用 EICAR 測試病毒碼或讀取本地檔案
in = new FileInputStream(testFile);
} catch (Exception e) {
e.printStackTrace();
}
// 執行掃描:檔案名、MIME 類型、輸入流
vsm.processScanVirus("eicarTestFile.txt", "plain/text", in);
}
VirusScanManager 建構子傳入 ICAP 端點。processScanVirus 方法參數依序為:邏輯檔名、Content-Type、檔案輸入流。透過簡單的 Jar 套件與 ICAP 協定,即可在 J2EE 應用中快速整合企業級防毒掃描能力,保障檔案上傳與資料交換的安全性。