Scan a Website for Malicious Content and Threats in Java

Cloudmersive
2 min readMar 29, 2022

--

Our website scan API will help identify a wide variety of application security threats that can be hidden within a URL, including Phishing attacks and common viruses. After inputting your URL and calling the API, you’ll quickly receive a “CleanResult” value (true or false), along with an identification of the “WebsiteThreatType” (if false). If a threat is detected, the relevant file name(s) will be returned along with the name of the virus they contain.

To include this API in your Java project, follow the steps below and create a free account on our website (www.cloudmersive.com) to receive the API key you’ll need. Your account will come with a limit of 800 API calls per month and zero financial commitments.

The below is for installation with Maven (for Gradle, head to the Cloudmersive API Console and look for the relevant Java snippets under the/virus/scan/website dropdown menu).

Start the Java SDK installation by adding a reference to the repository in pom.xml:

<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>

Next, add a reference to the dependency in pom.xml:

<dependencies>
<dependency>
<groupId>com.github.Cloudmersive</groupId>
<artifactId>Cloudmersive.APIClient.Java</artifactId>
<version>v4.25</version>
</dependency>
</dependencies>

Finally, at the top of the controller, add the below imports and call the validation function:

// Import classes:
//import com.cloudmersive.client.invoker.ApiClient;
//import com.cloudmersive.client.invoker.ApiException;
//import com.cloudmersive.client.invoker.Configuration;
//import com.cloudmersive.client.invoker.auth.*;
//import com.cloudmersive.client.ScanApi;
ApiClient defaultClient = Configuration.getDefaultApiClient();// Configure API key authorization: Apikey
ApiKeyAuth Apikey = (ApiKeyAuth) defaultClient.getAuthentication("Apikey");
Apikey.setApiKey("YOUR API KEY");
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//Apikey.setApiKeyPrefix("Token");
ScanApi apiInstance = new ScanApi();
WebsiteScanRequest input = new WebsiteScanRequest(); // WebsiteScanRequest |
try {
WebsiteScanResult result = apiInstance.scanWebsite(input);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling ScanApi#scanWebsite");
e.printStackTrace();
}

Just like that, you’re all set to go. In seconds, you’ll receive a “CleanResult” for your URL.

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

No responses yet