How to Check if a URL is a High-Risk Server Administration Path in Java
Are you familiar with server administration paths? These paths are typically utilized by developers when designing directory access for a website, and while they may have been reliable at one time, the ingenuity of cyber attacks have made them a high-risk target. Malicious users seek out the vulnerabilities in these paths that will enable them to step outside of the allowable access into other restricted files on the system. To proactively guard against these risks, you can use the following API in Java to automatically check if a URL or relative path is a server administration path.
First, we will install the Maven SDK by adding a jitpack reference to the repository:
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Then, we can add a reference to the dependency:
<dependencies>
<dependency>
<groupId>com.github.Cloudmersive</groupId>
<artifactId>Cloudmersive.APIClient.Java</artifactId>
<version>v3.90</version>
</dependency>
</dependencies>
Now we’re ready to add the imports to the top of our controller 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.DomainApi;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");DomainApi apiInstance = new DomainApi();
String value = "value_example"; // String | URL or relative path to check, e.g. \"/admin/login\". The input is a string so be sure to enclose it in double-quotes.
try {
IsAdminPathResponse result = apiInstance.domainIsAdminPath(value);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling DomainApi#domainIsAdminPath");
e.printStackTrace();
}
And just like that, our task is complete! To retrieve your API key, visit the Cloudmersive website to register for a free account that will provide access to 800 monthly calls across our entire library of APIs.