Pages

Thursday, November 12, 2015

Java code to access  clamdav  server  with out logger class



Purpose  : There   are  clamdav  scan classes availble in internet but most of them are using logger .


If your application already has logger ( like WCC server ) then you can't use it  in application server
.I removed logger and created new zip file




To install clamdav  & test file Refer below blog post



1. Download clamdev.zip


URL : https://www.dropbox.com/s/es0u3lxktyd5n1a/clamdev.zip?dl=0

Source : https://www.dropbox.com/s/tfm26qxafbqdiw2/source.zip?dl=0




2. create classpath file :

CLASSPATH=$CLASSPATH:`pwd`/clamdev.zip:.

3. create new java class to access scan.java and result.java

Example :


import java.io.*;

public class newscan
{

public newscan()
{
}

public static void main(String args[])
{
ClamScan clamscan = new ClamScan("10.184.36.14", 3310, 200);
try
{
ScanResult scanresult = clamscan.scan(new FileInputStream(args[0]));
System.out.println(scanresult.getStatus());
}
catch(FileNotFoundException filenotfoundexception)
{
filenotfoundexception.printStackTrace();
}
}
}



4. Compile it after sourcing the classpath


5. Result

PASSED : no virus found
FAILED : virus found
ERROR : Error during verification or connection






No comments:

Post a Comment