Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
e5d0c5b
Apps/appinstall is replaced with apps/local.
bparmar-splunk Jul 16, 2021
11fd633
Test Case for the PR 150
ashah-splunk Aug 4, 2021
4cf9e23
Merge pull request #166 from splunk/DVPL-9722
ashah-splunk Aug 9, 2021
be9be1d
Merge pull request #167 from splunk/master
bparmar-splunk Aug 10, 2021
992b81f
Apps/appinstall is replaced with apps/local.
bparmar-splunk Jul 16, 2021
be18226
Modular input change introduced
bparmar-splunk Aug 9, 2021
a08cf75
Merge branch 'DVPL-9706' of https://github.com/splunk/splunk-sdk-java…
bparmar-splunk Aug 10, 2021
b3cdb95
Splunk Apps URL added in Github actions test
bparmar-splunk Aug 10, 2021
9370c44
Github workflow test modified.
bparmar-splunk Aug 10, 2021
46f6a24
SDK App collection URL updated.
bparmar-splunk Aug 10, 2021
c4b9737
Apps/appinstall is replaced with apps/local.
bparmar-splunk Jul 16, 2021
d174155
Splunk Apps URL added in Github actions test
bparmar-splunk Aug 10, 2021
7029597
Github workflow test modified.
bparmar-splunk Aug 10, 2021
0781f7c
SDK App collection URL updated.
bparmar-splunk Aug 10, 2021
939eafb
Merge branch 'DVPL-9706' of https://github.com/splunk/splunk-sdk-java…
bparmar-splunk Aug 10, 2021
8ec3c9e
Merge pull request #168 from splunk/DVPL-9706
bparmar-splunk Aug 11, 2021
b4f075e
Methods for setting Splunk and Bearer token added.
bparmar-splunk Sep 13, 2021
fb9ff38
Method name modified
bparmar-splunk Sep 13, 2021
4dfeeab
Deploy plugin is removed from splunk module.
bparmar-splunk Sep 13, 2021
60fefb4
Merge pull request #171 from splunk/DVPL-9993
bparmar-splunk Sep 15, 2021
4c30b09
Merge pull request #172 from splunk/DVPL-10002
ashah-splunk Sep 15, 2021
7b50bf8
Remove dependency on maven-deploy-plugin
jkozlowski Oct 13, 2021
73fc474
Merge pull request #173 from jkozlowski/patch-1
bparmar-splunk Oct 28, 2021
54ec8d0
Allowing all certificates for local environment.
bparmar-splunk Oct 28, 2021
e3f1a6c
ValidateCertificates made public and true by default.
bparmar-splunk Nov 1, 2021
4d3b762
Test case for bypassing certificate validation added.
bparmar-splunk Nov 8, 2021
d7e2fba
Method name modified.
bparmar-splunk Nov 8, 2021
c167356
Allow test cases to run for local environment
bparmar-splunk Nov 11, 2021
e0e4a91
Github CI Test: Splunk version modified to latest from 8.2.0
bparmar-splunk Nov 11, 2021
69d854c
HttpService: Unused flags & class are removed.
bparmar-splunk Nov 18, 2021
969a275
ClientCert param was added in OutputServer class
bparmar-splunk Nov 22, 2021
4c5562f
README.md updated with Test example
bparmar-splunk Nov 24, 2021
842b8a0
Splunk version updated to latest.
bparmar-splunk Nov 24, 2021
98f9e3f
README file updated
bparmar-splunk Nov 25, 2021
8ea97d7
Merge pull request #177 from splunk/DVPL-10226
bparmar-splunk Nov 25, 2021
c961d13
Merge pull request #178 from splunk/master
fantavlik Nov 26, 2021
ef99efe
Merge pull request #175 from splunk/DVPL-9696
bparmar-splunk Dec 1, 2021
9e4a6fa
Headers modified in Socket creation.
bparmar-splunk Dec 1, 2021
7cd0e88
External Entities restricted in XML factory.
bparmar-splunk Dec 1, 2021
9af4c72
Merge pull request #179 from splunk/DVPL-7634
bparmar-splunk Dec 7, 2021
b10bc8d
Merge pull request #180 from splunk/DVPL-7631
bparmar-splunk Dec 7, 2021
e747fe4
Release v1.7.2
bparmar-splunk Dec 8, 2021
43c535d
Release v1.8.0
bparmar-splunk Dec 9, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- 1.8
splunk-version:
- "8.0"
- "8.2.0"
- "latest"
runs-on: ${{ matrix.os }}

services:
Expand All @@ -26,6 +26,7 @@ jobs:
TEST_TCP_PORT: 10667
TEST_UDP_PORT: 10668
SPLUNK_HOME: "/opt/splunk"
SPLUNK_APPS_URL: https://github.com/splunk/sdk-app-collection/releases/download/v1.1.0/sdkappcollection.tgz
ports:
- 8000:8000
- 8089:8089
Expand Down Expand Up @@ -58,7 +59,7 @@ jobs:
echo version=${{ matrix.splunk }} >> .splunkrc

- name: Test using maven
run: make test
run: mvn test -fae
env:
SPLUNK_HOME: "/opt/splunk"
TEST_TCP_PORT: 10667
Expand Down
29 changes: 0 additions & 29 deletions .idea/misc.xml

This file was deleted.

26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
# Splunk Enterprise SDK for Java Changelog

## Version 1.8.0

### New Features and APIs
* Added a support to add custom headers in Service class. (Github PR [#176](https://github.com/splunk/splunk-sdk-java/pull/176)).
* SSL Certificate validation (default implementation) added. (Github PR [#175](https://github.com/splunk/splunk-sdk-java/pull/175)).
* Boolean flag is introduced to skip/validate certificate. Use _HttpService.setValidateCertificates()_ to enable/disable certificate validation.
* Breaking change: Certificate validation is now enforced by default, for local or non-production use cases use _HttpService.setValidateCertificates(false)_.
* Apps/app-install replaced with **apps/local**. (Github PR [#168](https://github.com/splunk/splunk-sdk-java/pull/168))
* Breaking change: HttpService.useTLS flag removed, please use _HttpService.setSslSecurityProtocol()_ to set a specific SSL/TLS implementation or else TLS v1.2 is used by default for Java 1.8.

### Minor Changes

* External Entities restricted in XML factory. (Github PR [#180](https://github.com/splunk/splunk-sdk-java/pull/180)).
* Prevent expansion of external entities in Document Builder factory.
* Headers modified in Socket creation. (Github PR [#179](https://github.com/splunk/splunk-sdk-java/pull/179)).
* Http Request uses raw request headers by including escape characters which seems vulnerable. It was replaced with PrintWriter methods to avoid escape characters.
* Host parameter used in Socket is omitted to prevent exposing it to external users.
* README.md file modified with all login methods along with Splunk Search creation example. (Github PR [#177](https://github.com/splunk/splunk-sdk-java/pull/177)).
* Deploy plugin is removed from Splunk module pom to avoid redundancy. (Github PR [#172](https://github.com/splunk/splunk-sdk-java/pull/172)).
* Setter methods for Session and Bearer token added along with test case. (Github PR [#171](https://github.com/splunk/splunk-sdk-java/pull/171))
* **Use:** service.setSplunkToken() for session tokens and service.setBearerToken() for long-lived tokens.
* Modular input folder name renamed based on newer splunk folder name validation. (Github PR [#168](https://github.com/splunk/splunk-sdk-java/pull/168))
* SDK app collection URL has been updated to v1.1.0 in docker compose file. (Github PR [#168](https://github.com/splunk/splunk-sdk-java/pull/168))
* Test files in sdk app collections are modified based on python v3 syntax.
* Added Saved Search test case based on title. (Github PR [#166](https://github.com/splunk/splunk-sdk-java/pull/166))

## Version 1.7.1

### Minor Changes
Expand Down
161 changes: 158 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
![Build Status](https://github.com/splunk/splunk-sdk-java/actions/workflows/release.yml/badge.svg?branch=master)
[![Java SDK Test](https://github.com/splunk/splunk-sdk-java/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/splunk/splunk-sdk-java/actions/workflows/test.yml)
# The Splunk Software Development Kit for Java

#### Version 1.7.1
#### Version 1.8.0

The Splunk Software Development Kit (SDK) for Java contains library code and
examples designed to enable developers to build applications using Splunk.
Expand Down Expand Up @@ -75,7 +75,7 @@ To add the Splunk SDK for Java `.JAR` file as a dependency:
<dependency>
<groupId>com.splunk</groupId>
<artifactId>splunk</artifactId>
<version>1.7.1</version>
<version>1.8.0</version>
</dependency>
</dependencies>
```
Expand Down Expand Up @@ -109,6 +109,161 @@ To build the documentation for the SDK, it is being automatically generated with
cd splunk
mvn javadoc:javadoc

### Usage
#### Login using username and password
```java
import com.splunk.Service;
import com.splunk.ServiceArgs;

/**
* Login using username and password
*/
public class SplunkLogin {

static Service service = null;
public static void main(String args[]) {
ServiceArgs loginArgs = new ServiceArgs();
loginArgs.setPort(8089);
loginArgs.setHost("localhost");
loginArgs.setScheme("https");
loginArgs.setUsername("USERNAME"); // Use your username
loginArgs.setPassword("PASSWORD"); // Use your password

// Initialize the SDK client
service = Service.connect(loginArgs);
}
}
```

#### Login using Session Token
```java
import com.splunk.Service;
import com.splunk.ServiceArgs;

/**
* Login using Session token
*/
public class SplunkLogin {

static Service service = null;
/**
* Session Token.
* Actual token length would be longer than this token length.
*/
static String token = "1k_Ostpl6NBe4iVQ5d6I3Ohla_U5";

public static void main(String args[]) {
ServiceArgs loginArgs = new ServiceArgs();
loginArgs.setPort(8089);
loginArgs.setHost("localhost");
loginArgs.setScheme("https");
loginArgs.setToken(String.format("Splunk %s", token));

// Initialize the SDK client
service = Service.connect(loginArgs);
}
}
```
* Login using username and password will create Session token internally.
* Login using Credentials (username & password) OR directly using Session token are similar.
* In above two approaches, there is one limitation that expiration time of Session token cannot be extended. User has to re-login every time when token expires.
* To overcome this limitation, **Authentication** token is used instead of Session token.
* In **Authentication** token, user has a provision to set token expiration time. Splunk allows user to set relative/absolute time for token expiration.
* In other words, **Authentication** token is configurable whereas Session token cannot be configured.

#### Login using Authentication Token (RECOMMENDED)
```java
import com.splunk.Service;
import com.splunk.ServiceArgs;

/**
* Login using Authentication token
*/
public class SplunkLogin {

static Service service = null;
/**
* Authentication Token.
* Actual token length would be longer than this token length.
*/
static String token = "1k_Ostpl6NBe4iVQ5d6I3Ohla_U5";

public static void main(String args[]) {
ServiceArgs loginArgs = new ServiceArgs();
loginArgs.setPort(8089);
loginArgs.setHost("localhost");
loginArgs.setScheme("https");
loginArgs.setToken(String.format("Bearer %s", token));

// Initialize the SDK client
service = Service.connect(loginArgs);
}
}
```

#### Example of running a simple search by first creating the search job
```java
import com.splunk.Job;
import com.splunk.ResultsReader;
import com.splunk.ResultsReaderXml;
import com.splunk.Service;
import com.splunk.ServiceArgs;

/**
* Logged in using Authentication token.
* Assuming that authentication token is already created from Splunk web.
* Create Job using search creation.
* Read results and print _raw fields
*/
public class SearchExample {

static Service service = null;

/**
* Authentication Token.
* Actual token length would be longer than this token length.
*/
static String token = "1k_Ostpl6NBe4iVQ5d6I3Ohla_U5";

public static void main(String args[]) {

ServiceArgs loginArgs = new ServiceArgs();
loginArgs.setPort(8089);
loginArgs.setHost("localhost");
loginArgs.setScheme("https");
loginArgs.setToken(String.format("Bearer %s", token));

// Initialize the SDK client
service = Service.connect(loginArgs);

// Run a simple search by first creating the search job
Job job = service.getJobs().create("search index=_internal | head 10");

// Waiting for search results to be ready
while (!job.isReady()) {
try {
Thread.sleep(500); // 500 ms
} catch (Exception e) {
// Handle exception here.
}
}

// Read results
try {
ResultsReader reader = new ResultsReaderXml(job.getEvents());

// Iterate over events and print _raw field
reader.forEach(event -> System.out.println(event.get("_raw")));

} catch (Exception e) {
// Handle exception here.
}
}
}
```

For more information on authentication using tokens, please visit [Splunk Docs](https://docs.splunk.com/Documentation/Splunk/latest/Security/Setupauthenticationwithtokens).

### Unit tests

The Splunk SDK for Java includes several unit tests that are run at
Expand Down
2 changes: 1 addition & 1 deletion deploy
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare -r scriptDirectory="$(dirname $(readlink -e $0))"
declare -r scriptName="$(basename $0)"
declare -r version="1.7.1"
declare -r version="1.8.0"

if [[ $# -ne 1 ]]; then
echo 1>&2 "Usage: ${scriptName} {local|staging||production}"
Expand Down
30 changes: 15 additions & 15 deletions deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ deploy \<repository-name>

##DESCRIPTION

Deploy transmits **target/splunk-1.7.1.jar**, **target/splunk-1.7.1-javadoc.jar**, and
**target/splunk-1.7.1-sources.jar** to the **local**, **staging**, or **production**
Deploy transmits **target/splunk-1.8.0.jar**, **target/splunk-1.8.0-javadoc.jar**, and
**target/splunk-1.8.0-sources.jar** to the **local**, **staging**, or **production**
maven repository. Repository names are mapped to locations as follows.

| repository-name | location |
Expand All @@ -21,18 +21,18 @@ maven repository. Repository names are mapped to locations as follows.

After deployment you should find this tree structure at the location of your repository

com/splunk/splunk/1.7.1/
├── splunk-1.7.1-javadoc.jar
├── splunk-1.7.1-javadoc.jar.md5
├── splunk-1.7.1-javadoc.jar.sha1
├── splunk-1.7.1-sources.jar
├── splunk-1.7.1-sources.jar.md5
├── splunk-1.7.1-sources.jar.sha1
├── splunk-1.7.1.jar
├── splunk-1.7.1.jar.md5
├── splunk-1.7.1.jar.sha1
├── splunk-1.7.1.pom
├── splunk-1.7.1.pom.md5
└── splunk-1.7.1.pom.sha1
com/splunk/splunk/1.8.0/
├── splunk-1.8.0-javadoc.jar
├── splunk-1.8.0-javadoc.jar.md5
├── splunk-1.8.0-javadoc.jar.sha1
├── splunk-1.8.0-sources.jar
├── splunk-1.8.0-sources.jar.md5
├── splunk-1.8.0-sources.jar.sha1
├── splunk-1.8.0.jar
├── splunk-1.8.0.jar.md5
├── splunk-1.8.0.jar.sha1
├── splunk-1.8.0.pom
├── splunk-1.8.0.pom.md5
└── splunk-1.8.0.pom.sha1

Verify this structure prior to release.
5 changes: 3 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ version: '3.6'

services:
splunk:
image: "splunk/splunk:8.0"
image: "splunk/splunk:latest"
container_name: splunk
environment:
- SPLUNK_START_ARGS=--accept-license
- SPLUNK_HEC_TOKEN=11111111-1111-1111-1111-1111111111113
- SPLUNK_PASSWORD=changed!
- SPLUNK_APPS_URL=https://github.com/splunk/sdk-app-collection/releases/download/v1.0.0/sdk-app-collection.tgz
- SPLUNK_APPS_URL=https://github.com/splunk/sdk-app-collection/releases/download/v1.1.0/sdkappcollection.tgz
- JAVA_VERSION=openjdk:8
ports:
- 8000:8000
- 8088:8088
Expand Down
5 changes: 3 additions & 2 deletions examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<artifactId>splunk-sdk-java</artifactId>
<groupId>com.splunk</groupId>
<version>1.0.0</version>
<version>1.0.1</version>
</parent>

<build>
Expand All @@ -21,6 +21,7 @@
<skipTests>true</skipTests>
</configuration>
</plugin>
<!-- Deploy plugin is overridden here because we are skipping deployment in case of examples module. -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
Expand All @@ -36,7 +37,7 @@
<dependency>
<groupId>com.splunk</groupId>
<artifactId>splunk</artifactId>
<version>1.7.1</version>
<version>1.8.0</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
10 changes: 2 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<modelVersion>4.0.0</modelVersion>

<properties>
<version.number>1.7.1</version.number>
<version.number>1.8.0</version.number>
<maven.resources.overwrite>true</maven.resources.overwrite>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>8</maven.compiler.source>
Expand All @@ -15,7 +15,7 @@

<groupId>com.splunk</groupId>
<artifactId>splunk-sdk-java</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
<packaging>pom</packaging>
<name>Splunk SDK for Java</name>
<url>https://dev.splunk.com/enterprise/docs/devtools/java/sdk-java</url>
Expand All @@ -31,12 +31,6 @@
<artifactId>opencsv</artifactId>
<version>2.3</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.0.0-M1</version>
<type>maven-plugin</type>
</dependency>
</dependencies>
<modules>
<module>splunk</module>
Expand Down
Loading