Package org.dspace.ctask.general
Class ClamScan
- java.lang.Object
-
- org.dspace.curate.AbstractCurationTask
-
- org.dspace.ctask.general.ClamScan
-
- All Implemented Interfaces:
CurationTask
@Suspendable(invoked=INTERACTIVE) public class ClamScan extends AbstractCurationTask
ClamScan.java A set of methods to scan using the clamav daemon. TODO: add a check for the inputstream size limit- Author:
- wbossons
-
-
Field Summary
Fields Modifier and Type Field Description protected BitstreamServicebitstreamServiceprotected StringCLEAN_MESSAGEprotected StringCONNECT_FAIL_MESSAGEprotected DataOutputStreamdataOutputStreamprotected intDEFAULT_CHUNK_SIZEprotected byte[]ENDprotected booleanfailfastprotected Stringhostprotected byte[]IDSESSIONprotected StringINFECTED_MESSAGEprotected byte[]INSTREAMprotected StringNEW_ITEM_HANDLEprotected byte[]PINGprotected StringPLUGIN_PREFIXprotected intportprotected List<String>resultsprotected StringSCAN_FAIL_MESSAGEprotected Socketsocketprotected byte[]STATSprotected intstatusprotected inttimeout-
Fields inherited from class org.dspace.curate.AbstractCurationTask
communityService, configurationService, curator, handleService, itemService, taskId
-
-
Constructor Summary
Constructors Constructor Description ClamScan()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcloseSession()closeSession Close the IDSESSION in CLAMDprotected voidformatResults(Item item)protected StringgetItemHandle(Item item)voidinit(Curator curator, String taskId)Initialize task - parameters inform the task of it's invoking curator.protected voidlogDebugMessage(String message)protected voidopenSession()openSession This method opens a session.intperform(DSpaceObject dso)Perform the curation task upon passed DSOprotected intscan(Bitstream bitstream, InputStream inputstream, String itemHandle)Issue the INSTREAM command and return the response to and from the clamav daemon.-
Methods inherited from class org.dspace.curate.AbstractCurationTask
dereference, distribute, perform, performItem, performObject, report, setResult, taskArrayProperty, taskBooleanProperty, taskIntProperty, taskLongProperty, taskProperty
-
-
-
-
Field Detail
-
DEFAULT_CHUNK_SIZE
protected final int DEFAULT_CHUNK_SIZE
- See Also:
- Constant Field Values
-
INSTREAM
protected final byte[] INSTREAM
-
PING
protected final byte[] PING
-
STATS
protected final byte[] STATS
-
IDSESSION
protected final byte[] IDSESSION
-
END
protected final byte[] END
-
PLUGIN_PREFIX
protected final String PLUGIN_PREFIX
- See Also:
- Constant Field Values
-
INFECTED_MESSAGE
protected final String INFECTED_MESSAGE
- See Also:
- Constant Field Values
-
CLEAN_MESSAGE
protected final String CLEAN_MESSAGE
- See Also:
- Constant Field Values
-
CONNECT_FAIL_MESSAGE
protected final String CONNECT_FAIL_MESSAGE
- See Also:
- Constant Field Values
-
SCAN_FAIL_MESSAGE
protected final String SCAN_FAIL_MESSAGE
- See Also:
- Constant Field Values
-
NEW_ITEM_HANDLE
protected final String NEW_ITEM_HANDLE
- See Also:
- Constant Field Values
-
host
protected String host
-
port
protected int port
-
timeout
protected int timeout
-
failfast
protected boolean failfast
-
status
protected int status
-
socket
protected Socket socket
-
dataOutputStream
protected DataOutputStream dataOutputStream
-
bitstreamService
protected BitstreamService bitstreamService
-
-
Method Detail
-
init
public void init(Curator curator, String taskId) throws IOException
Description copied from interface:CurationTaskInitialize task - parameters inform the task of it's invoking curator. Since the curator can provide services to the task, this represents curation DI.- Specified by:
initin interfaceCurationTask- Overrides:
initin classAbstractCurationTask- Parameters:
curator- the Curator controlling this tasktaskId- identifier task should use in invoking services- Throws:
IOException- if error
-
perform
public int perform(DSpaceObject dso) throws IOException
Description copied from interface:CurationTaskPerform the curation task upon passed DSO- Specified by:
performin interfaceCurationTask- Specified by:
performin classAbstractCurationTask- Parameters:
dso- the DSpace object- Returns:
- status code
- Throws:
IOException- if error
-
openSession
protected void openSession() throws IOExceptionopenSession This method opens a session.- Throws:
IOException- A general class of exceptions produced by failed or interrupted I/O operations.
-
closeSession
protected void closeSession()
closeSession Close the IDSESSION in CLAMD
-
scan
protected int scan(Bitstream bitstream, InputStream inputstream, String itemHandle)
Issue the INSTREAM command and return the response to and from the clamav daemon.- Parameters:
bitstream- the bitstream for reporting resultsinputstream- the InputStream to readitemHandle- the item handle for reporting results- Returns:
- a ScanResult representing the server response
-
formatResults
protected void formatResults(Item item) throws IOException
- Throws:
IOException
-
logDebugMessage
protected void logDebugMessage(String message)
-
-