Jive Forums API (5.5.20.2-oracle) Developer Javadocs

com.jivesoftware.forum.virusscan
Class VirusScanManager

java.lang.Object
  extended by com.jivesoftware.forum.virusscan.VirusScanManager
All Implemented Interfaces:
JiveManager

public class VirusScanManager
extends java.lang.Object
implements JiveManager

Scans message attachments for viruses. This class communicates with an external virus scanning server using the ICAP protocol. The general logic flow is as follows:

  1. If a message contains one or more attachments, the VirusScanInterceptor will set the moderation value of the message to VIRUS_CHECK_MODERATION_VALUE, which is below the visible threshold and will prevent the message from being viewed by other users.
  2. A background task is launched that will scan messages in the queue.
  3. The attachments are scanned for viruses. If the attachment has a virus that can be cleaned, the original attachment is deleted and replaced with a cleaned attachment. If the attachment must be blocked due to an infection, the original attachment is deleted and replaced with a text message.
  4. Email notifications are optionally sent if there was a blocked infection.
  5. After scanning is completed, the message moderation value is reset to its original value and the message is removed from the queue.

See Also:
VirusScanInterceptor, JiveGlobals

Field Summary
static int VIRUS_CHECK_MODERATION_VALUE
          The moderation value that messages will be set to (-156) while waiting to be scanned for viruses.
 
Method Summary
 void addMessageToQueue(ForumMessage message)
          Adds message to the virus scan queue.
 void destroy()
          Notifies the manager to release any resources that may be holding on too.
 java.lang.String getEmailAddress()
          Gets the email address that notification emails will appear to be from
 java.lang.String getEmailBody(java.util.Locale locale)
          Gets the text for the body of the notification emails.
 java.lang.String getEmailName()
          Gets the name that notification emails will appear to be from
 java.lang.String getEmailNotifyList()
          Gets the comma-delimited list of email addresses to notify when an attachment is blocked
 java.lang.String getEmailSubject(java.util.Locale locale)
          Gets the text for the subject of notification emails
static VirusScanManager getInstance()
          Provides access to the single VirusScanManager instance
 int getQueueSize()
          Gets the number of messages in the queue waiting to br virus scanned.
 java.lang.String getVirusScannerUri()
          The URI of the ICAP server used for virus scanning.
 void initialize()
          Initialize the manager.
 boolean isDebugMode()
          Checks if the virus scanner is running in debug mode.
 boolean isNotifyUserEnabled()
          Checks if notify user has been enabled
 boolean isRunning()
          Returns true if the server is currently running.
 boolean isVirusScanEnabled()
          Checks if the virus scanner is enabled
 int numberOfMessagesInDB()
          Gets the number of messages in the database waiting to be virus scanned.
 void setDebugMode(boolean debugMode)
          Sets the virus scanner into debug mode.
 void setEmailAddress(java.lang.String emailAddress)
          Sets the email address that notification emails will appear to be from
 void setEmailBody(java.lang.String emailBody, java.util.Locale locale)
          Text for the body of of notification emails.
 void setEmailName(java.lang.String emailName)
          Sets The name that notification emails will appear to be from
 void setEmailNotifyList(java.lang.String emailNotifyList)
          Sets the list of email addresses to notify when an attachment is blocked
 void setEmailSubject(java.lang.String emailSubject, java.util.Locale locale)
          Sets the text for the subject of notification emails
 void setNotifyUserEnabled(boolean notifyUserEnabled)
          Sets wheter or not notify user is enabled.
 void setVirusScanEnabled(boolean virusScanEnabled)
          Sets wheter or not the virus scanner is enabled
 void setVirusScannerUri(java.lang.String uri)
          Sets the URI of the ICAP server uses for virus scanning.
 void start()
          Starts the virus scanner.
 void stop()
          Stops the virus scanner.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VIRUS_CHECK_MODERATION_VALUE

public static final int VIRUS_CHECK_MODERATION_VALUE
The moderation value that messages will be set to (-156) while waiting to be scanned for viruses. The value is below the visible threshold, which means that other users will not see the message until it's finished being scanned.

See Also:
Constant Field Values
Method Detail

getInstance

public static VirusScanManager getInstance()
Provides access to the single VirusScanManager instance

Returns:
the VirusScanManager instance

initialize

public void initialize()
Description copied from interface: JiveManager
Initialize the manager. It is within this method that it is ok to create, access and/or otherwise use external classes (including caches). Until this method is called implementation should not access any external classes that could possibly either access one of the main Factory classes or any caches since doing so can cause deadlocks and possible clustering issues during startup.

This method is used internally by Jive during application startup and should not be called during normal usage of the class.

Specified by:
initialize in interface JiveManager

destroy

public void destroy()
Description copied from interface: JiveManager
Notifies the manager to release any resources that may be holding on too. This could also be used to clear out the managers caches, etc.

This method is used internally by Jive during application startup and should not be called during normal usage of the class.

Specified by:
destroy in interface JiveManager

isVirusScanEnabled

public boolean isVirusScanEnabled()
Checks if the virus scanner is enabled

Returns:
true if the virus scanner is enabled; false otherwise

setVirusScanEnabled

public void setVirusScanEnabled(boolean virusScanEnabled)
Sets wheter or not the virus scanner is enabled

Parameters:
virusScanEnabled - true to enable the virus scanner; false to disable

getVirusScannerUri

public java.lang.String getVirusScannerUri()
The URI of the ICAP server used for virus scanning. For example: icap://example.com:1344/interscan or icap://example.com:1344/avscan.

Returns:
the ICAP server URI.

setVirusScannerUri

public void setVirusScannerUri(java.lang.String uri)
                        throws org.jivesoftware.antivirus.VirusScanException,
                               java.net.URISyntaxException
Sets the URI of the ICAP server uses for virus scanning. For example: icap://example.com:1344/interscan or icap://example.com:1344/avscan.

Parameters:
uri - the URI of the ICAP server.
Throws:
org.jivesoftware.antivirus.VirusScanException - if setting the the URI fails.
java.net.URISyntaxException - if a malformed ICAP URI.

isNotifyUserEnabled

public boolean isNotifyUserEnabled()
Checks if notify user has been enabled

Returns:
true if notify user is enabled; false otherwise

setNotifyUserEnabled

public void setNotifyUserEnabled(boolean notifyUserEnabled)
Sets wheter or not notify user is enabled. When enabled, sends notifications of blocked attachments to the user that posted them

Parameters:
notifyUserEnabled - true to enable notify user; false otherwise

getEmailNotifyList

public java.lang.String getEmailNotifyList()
Gets the comma-delimited list of email addresses to notify when an attachment is blocked

Returns:
the comma-delimited list of email addresses

setEmailNotifyList

public void setEmailNotifyList(java.lang.String emailNotifyList)
Sets the list of email addresses to notify when an attachment is blocked

Parameters:
emailNotifyList - the comma-delimited list of email addresses

getEmailName

public java.lang.String getEmailName()
Gets the name that notification emails will appear to be from

Returns:
The name that notification emails will appear to be from

setEmailName

public void setEmailName(java.lang.String emailName)
Sets The name that notification emails will appear to be from

Parameters:
emailName - the name that notification emails will appear to be from

getEmailAddress

public java.lang.String getEmailAddress()
Gets the email address that notification emails will appear to be from

Returns:
the email address that notification emails will appear to be from

setEmailAddress

public void setEmailAddress(java.lang.String emailAddress)
Sets the email address that notification emails will appear to be from

Parameters:
emailAddress - the email address that notification emails will appear to be from

getEmailSubject

public java.lang.String getEmailSubject(java.util.Locale locale)
Gets the text for the subject of notification emails

Returns:
the text for the subject of notification emails

setEmailSubject

public void setEmailSubject(java.lang.String emailSubject,
                            java.util.Locale locale)
Sets the text for the subject of notification emails

Parameters:
emailSubject - the text for the subject of notification emails

getEmailBody

public java.lang.String getEmailBody(java.util.Locale locale)
Gets the text for the body of the notification emails. A number of of special tokens can be used. Each token will be dynamically replaced with a real value when emails are sent. Valid tokens are: {fileName}, {virusList}, {jiveURL}, {messageUser}, {messageID}, {messageSubject}, {messageBody}, {messageModificatonDate}, {messageCreationDate}, {threadID}, {threadName}, {threadModificatonDate}, {threadCreationDate}, {forumID}, {forumName}, {categoryID}, {categoryName}, {user-ID}, {user-username}, {user-name}, {user-email}.

Returns:
the text for the body of the notification emails

setEmailBody

public void setEmailBody(java.lang.String emailBody,
                         java.util.Locale locale)
Text for the body of of notification emails. A number of of special tokens can be used. Each token will be dynamically replaced with a real value when emails are sent. Valid tokens are: {fileName}, {virusList}, {jiveURL}, {messageUser}, {messageID}, {messageSubject}, {messageBody}, {messageModificatonDate}, {messageCreationDate}, {threadID}, {threadName}, {threadModificatonDate}, {threadCreationDate}, {forumID}, {forumName}, {categoryID}, {categoryName}, {user-ID}, {user-username}, {user-name}, {user-email}.

Parameters:
emailBody - the text for the body of the notification emails

isDebugMode

public boolean isDebugMode()
Checks if the virus scanner is running in debug mode. Debug mode is used to get detailed information from the virus scanner to help debug errors.

Returns:
true if the virus scanner is in debug mode; false otherwise

setDebugMode

public void setDebugMode(boolean debugMode)
Sets the virus scanner into debug mode. Debug mode is used to get detailed information from the virus scanner to help debug errors.

Parameters:
debugMode - true to put the virus scanner in debug mode; false otherwise

numberOfMessagesInDB

public int numberOfMessagesInDB()
Gets the number of messages in the database waiting to be virus scanned.

Returns:
the number of messages in the database waiting to be virus scanned

getQueueSize

public int getQueueSize()
Gets the number of messages in the queue waiting to br virus scanned.

Returns:
the number of messages in the queue waiting to be virus scanned

addMessageToQueue

public void addMessageToQueue(ForumMessage message)
                       throws java.lang.Exception
Adds message to the virus scan queue.

Parameters:
message - the message to add to the virus scan queue
Throws:
java.lang.Exception

start

public void start()
Starts the virus scanner.


stop

public void stop()
Stops the virus scanner.


isRunning

public boolean isRunning()
Returns true if the server is currently running.

Returns:
true if the server is currently running.

Jive Forums Project Page

Copyright © 1999-2006 Jive Software.