com.contrastsecurity.rest
Class ContrastConnection

java.lang.Object
  extended by com.contrastsecurity.rest.ContrastConnection

public class ContrastConnection
extends Object

Entry point for using the Contrast REST API. Make an instance of this class and call methods. Easy!


Constructor Summary
ContrastConnection(String user, String serviceKey, String apiKey)
          Create a ContrastConnection object that attempts to use the Contrast SaaS service.
ContrastConnection(String user, String serviceKey, String apiKey, String restApiURL)
          Create a ContrastConnection object that will attempt to use the Contrast installation in the
 
Method Summary
 int checkForTrace(String appId, String conditions)
           
 byte[] getAgent(AgentType type)
          Download a Contrast agent associated with this account and the platform passed in.
 byte[] getAgent(AgentType type, String profileName)
          Download a contrast.jar agent associated with this account.
 Application getApplication(String appId)
          Get summary information about a single app.
 List<Application> getApplications()
          Get the list of applications being monitored by Contrast.
 Coverage getCoverage(String appId)
          Return coverage data about the monitored Contrast application.
 List<Library> getLibraries(String appId)
          Return the libraries of the monitored Contrast application.
 List<Trace> getTraces(String appId)
          Get the vulnerabilities in the application whose ID is passed in.
static void main(String[] args)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContrastConnection

public ContrastConnection(String user,
                          String serviceKey,
                          String apiKey,
                          String restApiURL)
                   throws IllegalArgumentException
Create a ContrastConnection object that will attempt to use the Contrast installation in the

Parameters:
user - Username (e.g., joe@acme.com)
serviceKey - User service key
apiKey - API Key
restApiURL - the base Contrast API URL
Throws:
IllegalArgumentException - if the API URL is malformed

ContrastConnection

public ContrastConnection(String user,
                          String serviceKey,
                          String apiKey)
Create a ContrastConnection object that attempts to use the Contrast SaaS service.

Method Detail

getApplication

public Application getApplication(String appId)
                           throws IOException,
                                  UnauthorizedException,
                                  ResourceNotFoundException
Get summary information about a single app.

Parameters:
appId - the ID of the application
Returns:
an ApplicationSummary representing the object whose ID was passed in
Throws:
UnauthorizedException - if the Contrast account failed to authorize
IOException - if there was a communication problem
ResourceNotFoundException

getApplications

public List<Application> getApplications()
                                  throws UnauthorizedException,
                                         IOException
Get the list of applications being monitored by Contrast.

Returns:
a List of Application objects that are being monitored
Throws:
UnauthorizedException - if the Contrast account failed to authorize
IOException - if there was a communication problem

getCoverage

public Coverage getCoverage(String appId)
                     throws IOException,
                            UnauthorizedException
Return coverage data about the monitored Contrast application.

Parameters:
appId - the ID of the application
Returns:
a List of Library objects for the given app
Throws:
UnauthorizedException - if the Contrast account failed to authorize
IOException - if there was a communication problem

getLibraries

public List<Library> getLibraries(String appId)
                           throws IOException,
                                  UnauthorizedException
Return the libraries of the monitored Contrast application.

Parameters:
appId - the ID of the application
Returns:
a List of Library objects for the given app
Throws:
UnauthorizedException - if the Contrast account failed to authorize
IOException - if there was a communication problem

getTraces

public List<Trace> getTraces(String appId)
                      throws IOException,
                             UnauthorizedException
Get the vulnerabilities in the application whose ID is passed in.

Parameters:
appId - the ID of the application
Returns:
a List of Trace objects representing the vulnerabilities
Throws:
UnauthorizedException - if the Contrast account failed to authorize
IOException - if there was a communication problem

checkForTrace

public int checkForTrace(String appId,
                         String conditions)
                  throws IOException,
                         UnauthorizedException
Parameters:
appId - the ID of the application
conditions - a name=value pair querystring of trace conditions
Returns:
the HTTP response code of the given query
Throws:
UnauthorizedException - if the Contrast account failed to authorize
IOException - if there was a communication problem

getAgent

public byte[] getAgent(AgentType type,
                       String profileName)
                throws IOException
Download a contrast.jar agent associated with this account. The user should save this byte array to a file named 'contrast.jar'. This signature takes a parameter which contains the name of the saved engine profile to download.

Parameters:
profileName - the name of the saved engine profile to download,
Returns:
a byte[] array of the contrast.jar file contents, which the user should
Throws:
IOException - if there was a communication problem

getAgent

public byte[] getAgent(AgentType type)
                throws IOException
Download a Contrast agent associated with this account and the platform passed in.

Throws:
IOException

main

public static void main(String[] args)
                 throws UnauthorizedException,
                        IOException
Throws:
UnauthorizedException
IOException


Copyright © 2014. All Rights Reserved.