The Deep Security Java SDK consists of the Java client library and source (JAR files), and several dependency JAR files. The client library enables you to use Java to interact with the API. If you would rather use the API directly via tools such as Postman and curl, you do not need the SDK.
For guidance on using the SDK, see First Steps Toward Deep Security Automation.
Get set up to use the Java SDK
The Deep Security API supports Java 1.8 and later versions, such as Oracle Java SE 8.
Download and install the JDK and Deep Security Java SDK
- Install version 1.8 (or later) of the Java Development Kit.
- Download the SDK ZIP file and unzip it.
Add the SDK to a Java project
If you are using Eclipse, see the Add the SDK to a Java project in Eclipse section below. Otherwise:
- Add the
deepsecurity-11.x.xxx.jarfile to the classpath or build path of your Java project.
- Add the JAR files in the lib folder to the classpath or build path of your Java project.
Add the SDK to a Java project in Eclipse
- Open Eclipse.
- Click File > New Java Project, and click Next.
Type a name for the project, such as ‘Run Deep Security Code Examples’, and click Finish.
- Right-click the project folder and click Properties.
- Click Java Build Path, click the Libraries tab, and then click External JARs.
- Go to the folder containing the extracted SDK, select the
deepsecurity-11.x.xxx.jarfile and click Open.
- Similarly, add all of the files in the lib sub folder from the SDK.
- Click Apply and Close.
- Right-click the ‘src’ folder and click New > Package.
- Type a package name (for example,
com.trendmicro.deepsecurity.docs) and click Finish.
Import self-signed certificates
Java prevents clients from making secure connections to untrusted servers. If the Deep Security Manager in your development environment uses the default self-signed certificate for establishing secure HTTP connections, you need to import the certificate to a local truststore. If you do not import the certificate, you cannot connect to the server.
The path of the default truststore of the JDK’s JRE is
JAVA_HOME/jre/lib/security/cacerts, and the default password is
changeit. You can use a different truststore if you like.
- Open the Deep Security Manager console in your web browser.
- Use the browser to download the site’s certificate (see your browser documentation)
- Chrome: Developer Tools > Security Tab > View Certificate > Details tab > Copy To File.
- FireFox: Click the lock icon next to the URL > Secure Connection > More Information > View Certificate > Details > Export
- Safari: Click the lock icon next to the URL > Drag the certificate icon to your desktop.
- Use keytool to import the certificate into your truststore (replace the alias and path placeholders with actual values):
keytool -import -v -trustcacerts -alias <alias> -file <path to certificate file> -keystore <path to truststore>
- If you are not using the default truststore of the JRE, run your programs using the following JVM option (replace the path with the actual value):
-Djavax.net.ssl.trustStore=<path to truststore>