This SDK gives you a quick start for programmatically accessing the Contrast REST API using Java.
- JDK 7/8
- Maven
- TeamServer account
-
Clone the project
-
'mvn clean install' Maven goals to build the artifact with the latest code
-
Add contrast-sdk-java to your project dependency:
<dependency> <groupId>com.contrastsecurity</groupId> <artifactId>contrast-sdk-java</artifactId> </dependency>
-
Look up the following information from Contrast under "Your Account"
- Username
- Service Key
- API Key
- Contrast REST API URL
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)
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.