Install the Java agent with the RPM repository

To install the Java agent with the RPM repository:

  1. Use the following commands to configure your system to retrieve packages from the Contrast RPM repository:

    OSREL=$(rpm -E "%{rhel}")
    sudo -E tee /etc/yum.repos.d/contrast.repo << EOF
    [contrast]
    name=contrast repo
    baseurl=https://pkg.contrastsecurity.com/rpm-public/centos-$OSREL/
    gpgcheck=0
    enabled=1
    EOF
  2. Once you've finished configuration, install the Contrast Java agent:

    sudo yum install contrast-java-agent
  3. The Contrast Java agent JAR is now installed at /opt/contrast/contrast-agent.jar.

  4. Configure the agent. You can create or download a YAML configuration file. You must provide Contrast connection parameters using these agent keys.

  5. Tell the agent where to find the yaml configuration file (contrast.yaml). In the example below, substitute <YourContrastJarPath> with the path to your Contrast JAR (this may vary depending on your internal file structure and how you downloaded the file) and <ApplicationJar> with the name of your application JAR.

    java -javaagent:<YourContrastJarPath> -Dcontrast.config.path=contrast.yaml -jar <ApplicationJar>.jar

    Note

    If you are using system properties, environment variables to configure instead of YAML, or you have placed the YAML in a standard location where the agent can find it automatically, set the JVM parameter to include the Java agent.

    java -javaagent:<YourContrastJarPath> -jar <AppName>.jar
  6. Use the application as you normally would (for example, click on the web interface, send API commands). Verify that Contrast sees your application (for example, view your application in the Contrast web interface, view logs).

You can also provide security analysis for applications running in a test/QA or production environment, by installing the agent with an application server like:

You can also install using a container, like Docker.

Tip

Check the Contrast Support Portal for more information about other compatible ways to install the agent using tools like Pivotal Cloud Foundry (now VMware Tanzu).