Skip to content
This repository has been archived by the owner on May 18, 2022. It is now read-only.

ibm-cloud-security/security-advisor-sdk-java

Repository files navigation

DEPRECATED

The Security Insights feature is deprecated and will no longer be supported. Please migrate to new SDK https://github.com/IBM/scc-java-sdk

Build Status semantic-release

IBM Cloud Security Advisor Java SDK Version 2.0.1

Java client library to interact with various IBM Cloud Security Advisor.

Disclaimer: this SDK is being released initially as a pre-release version. Changes might occur which impact applications that use this SDK.

Table of Contents

Overview

The IBM Cloud Security Advisor Java SDK allows developers to programmatically interact with the following IBM Cloud services:

Service Name Artifact Coordinates
IBM Cloud Security Advisor Findings API com.ibm.cloud.securityadvisor:findings_api:2.0.1
IBM Cloud Security Advisor Notifications API com.ibm.cloud.securityadvisor:notifications_api:2.0.1

Prerequisites

  • An IBM Cloud account.
  • An IAM API key to allow the SDK to access your account. Create one here.
  • Java 8 or above.

Installation

The current version of this SDK is: 2.0.1

Each service's artifact coordinates are listed in the table above.

To use a particular service, define a dependency that contains the artifact coordinates (group id, artifact id and version) for the service, like this:

Maven
<dependency>
    <groupId>com.ibm.cloud</groupId>
    <artifactId>securityadvisor</artifactId>
    <version>2.0.1</version>
</dependency>
Gradle
'com.ibm.cloud:securityadvisor:2.0.1'

Authentication

IBM Cloud Security Advisor uses token-based Identity and Access Management (IAM) authentication.

IAM authentication uses a service API key to get an access token that is passed with the call. Access tokens are valid for a limited amount of time and must be regenerated.

To provide credentials to the SDK, you supply either an IAM service API key or an access token:

  • Use the API key to have the SDK manage the lifecycle of the access token. The SDK requests an access token, ensures that the access token is valid, and refreshes it if necessary.
  • Use the access token if you want to manage the lifecycle yourself. For details, check Authenticating using the IAM Token section.

Authenticating using the IAM API key:

import com.ibm.cloud.sdk.core.security.IamAuthenticator;
import com.ibm.cloud.securityadvisor.notifications_api.v1.NotificationsApi;
import com.ibm.cloud.securityadvisor.findings_api.v1.FindingsApi;

IamAuthenticator authenticator = new IamAuthenticator("<apiKey>");
NotificationsApi notificationsApi = new NotificationsApi("notifications_api", authenticator); //Initialize notifications service
FindingsApi findingsApi = new FindingsApi("findings_api", authenticator); //Initialize findings service

Authenticating using the IAM Token:

import com.ibm.cloud.sdk.core.security.IamAuthenticator;
import com.ibm.cloud.sdk.core.security.BearerTokenAuthenticator;
import com.ibm.cloud.securityadvisor.notifications_api.v1.NotificationsApi;
import com.ibm.cloud.securityadvisor.findings_api.v1.FindingsApi;

IamAuthenticator authenticator = new IamAuthenticator("<apiKey>");
IamToken iamToken = authenticator.requestToken(); //Generating the token
String token = iamToken.getAccessToken(); // Getting the token

BearerTokenAuthenticator bearerAuth = new BearerTokenAuthenticator(token); // initialize BearerTokenAuthenticator
NotificationsApi notificationsApi = new NotificationsApi("notifications_api", bearerAuth);//Initialize notifications service
FindingsApi findingsApi = new FindingsApi("findings_api", bearerAuth); //Initialize findings service

Using the SDK

For general SDK usage information, please see this link

For Findings API module usage information of the SDK, please see this link

For Notifications API module usage information of the SDK, please see this link

Questions

If you are having difficulties using this SDK or have a question about the IBM Cloud services, please ask a question at Stack Overflow.

Issues

If you encounter an issue with the project, you are welcome to submit a bug report. Before that, please search for similar issues. It's possible that someone has already reported the problem.

Open source @ IBM

Find more open source projects on the IBM Github Page

Contributing

See CONTRIBUTING.

License

The IBM Cloud Security Advisor Java SDK is released under the Apache 2.0 license. The license's full text can be found in LICENSE.