/contrast-sdk-java

Java SDK for Contrast REST API

Primary LanguageJava

Contrast TeamServer Java SDK

This SDK gives you a quick start for programmatically accessing the Contrast REST API using Java.

Requirements

  • JDK 7/8
  • Maven
  • TeamServer account

How to use this SDK

  1. Clone the project

  2. 'mvn clean install' Maven goals to build the artifact with the latest code

  3. Add contrast-sdk-java to your project dependency:

    <dependency>
        <groupId>com.contrastsecurity</groupId>
        <artifactId>contrast-sdk-java</artifactId>
    </dependency>
    
  4. Look up the following information from Contrast under "Your Account"

Code example:

ContrastSDK contrastSDK = new ContrastSDK.Builder("contrast_admin", "demo", "demo")
        .withApiUrl("http://localhost:19080/Contrast/api")
        .build();

String orgUuid = contrastSDK.getProfileDefaultOrganizations().getOrganization().getOrgUuid();

Applications apps = contrastSDK.getApplications(orgUuid);
for (Application app : apps.getApplications()) {
    System.out.println(app.getName() + " (" + app.getCodeShorthand() + " LOC)");
}

Sample output:

Aneritx (48K LOC)
Default Web Site (0k LOC)
EnterpriseTPS (48K LOC)
Feynmann (48K LOC)
jhipster-sample (0k LOC)
JSPWiki (48K LOC)
Liferay (48K LOC)
OpenMRS (65K LOC)
OracleFS (48K LOC)
Security Test (< 1K LOC)
Ticketbook (2K LOC)
WebGoat (48K LOC)
WebGoat7 (106K LOC)

Deprecation

The old-style constructor new ContrastSDK() has been deprecated in version 2.15. Please migrate your code to use new ContrastSDK.Builder()

We will remove the deprecated constructors in version 3.