Anti-Malware: Java Examples
AntiMalwarePolicyExtension example
Create an AntiMalwarePolicyExtension and set property values to configure the
state, identify the malware scan configurations to use, and the schedule for real-time
scans:
AntiMalwarePolicyExtension antiMalwarePolicyExtension = new AntiMalwarePolicyExtension();
antiMalwarePolicyExtension.setState(AntiMalwarePolicyExtension.StateEnum.ON);
antiMalwarePolicyExtension.setRealTimeScanConfigurationID(realTimeScanConfigID);
antiMalwarePolicyExtension.setRealTimeScanScheduleID(scheduleID);
Modify Anti-Malware policy example
Add the AntiMalwarePolicyExtension object to a Policy
object, and then use a PoliciesApi object to modify a policy on Deep Security
Manager.
Policy policy = new Policy();
policy.setAntiMalware(antiMalwarePolicyExtension);
// Modify the policy on Deep Security Manager
PoliciesApi policiesApi = new PoliciesApi();
return policiesApi.modifyPolicy(policyID, policy, Boolean.FALSE, apiVersion);
The policy_id (or policyID) parameter of
modifyPolicy identifies the actual policy on Deep Security Manager that is to
be modified. This policy is modified according to the policy object that is used as the
policy parameter. Any properties of the policy parameter that
are not set remain unchanged on the actual policy.
Complete policy configuration example
The following example creates an AntiMalwarePolicyExtension object and uses
it to turn on the Anti-Malware module, set the real-time scan configuration to use, and specify
the scan schedule for real-time scans.
// Create a PolicyLevelConfigurationForTheAntiMalwareModule object and configure
AntiMalwarePolicyExtension antiMalwarePolicyExtension = new AntiMalwarePolicyExtension();
antiMalwarePolicyExtension.setState(AntiMalwarePolicyExtension.StateEnum.ON);
antiMalwarePolicyExtension.setRealTimeScanConfigurationID(realTimeScanConfigID);
antiMalwarePolicyExtension.setRealTimeScanScheduleID(scheduleID);
Policy policy = new Policy();
policy.setAntiMalware(antiMalwarePolicyExtension);
// Modify the policy on Deep Security Manager
PoliciesApi policiesApi = new PoliciesApi();
policy = policiesApi.modifyPolicy(policyID, policy, Boolean.FALSE, apiVersion);
Example malware scan configuration
The following example sets the directory exclusions for a malware scan configuration and modifies the scan configuration on Deep Security Manager.
// create a real time scan configuration object
AntiMalwareConfiguration realtimeConfig = new AntiMalwareConfiguration();
// Set the ID of the directory exclusion list
realtimeConfig.setExcludedDirectoryListID(dirListId);
// Update Deep Security Manager
AntiMalwareConfigurationsApi amConfigsApi = new AntiMalwareConfigurationsApi();
realtimeConfig = amConfigsApi.modifyAntiMalware(scanConfigID, realtimeConfig, apiVersion);
To use an HTTP client to interact with a malware scan configuration, use the /api/antimalwareconfigurations endpoint. (See the Anti Malware Configurations operations in the API Reference.)
