Skip to content

Commit 7222d59

Browse files
Merge pull request #182 from splunk/release/1.8.0
Release/1.8.0
2 parents c6f3008 + 43c535d commit 7222d59

26 files changed

+395
-231
lines changed

.github/workflows/test.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- 1.8
1515
splunk-version:
1616
- "8.0"
17-
- "8.2.0"
17+
- "latest"
1818
runs-on: ${{ matrix.os }}
1919

2020
services:
@@ -26,6 +26,7 @@ jobs:
2626
TEST_TCP_PORT: 10667
2727
TEST_UDP_PORT: 10668
2828
SPLUNK_HOME: "/opt/splunk"
29+
SPLUNK_APPS_URL: https://github.com/splunk/sdk-app-collection/releases/download/v1.1.0/sdkappcollection.tgz
2930
ports:
3031
- 8000:8000
3132
- 8089:8089
@@ -58,7 +59,7 @@ jobs:
5859
echo version=${{ matrix.splunk }} >> .splunkrc
5960
6061
- name: Test using maven
61-
run: make test
62+
run: mvn test -fae
6263
env:
6364
SPLUNK_HOME: "/opt/splunk"
6465
TEST_TCP_PORT: 10667

.idea/misc.xml

Lines changed: 0 additions & 29 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,31 @@
11
# Splunk Enterprise SDK for Java Changelog
22

3+
## Version 1.8.0
4+
5+
### New Features and APIs
6+
* Added a support to add custom headers in Service class. (Github PR [#176](https://github.com/splunk/splunk-sdk-java/pull/176)).
7+
* SSL Certificate validation (default implementation) added. (Github PR [#175](https://github.com/splunk/splunk-sdk-java/pull/175)).
8+
* Boolean flag is introduced to skip/validate certificate. Use _HttpService.setValidateCertificates()_ to enable/disable certificate validation.
9+
* Breaking change: Certificate validation is now enforced by default, for local or non-production use cases use _HttpService.setValidateCertificates(false)_.
10+
* Apps/app-install replaced with **apps/local**. (Github PR [#168](https://github.com/splunk/splunk-sdk-java/pull/168))
11+
* 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.
12+
13+
### Minor Changes
14+
15+
* External Entities restricted in XML factory. (Github PR [#180](https://github.com/splunk/splunk-sdk-java/pull/180)).
16+
* Prevent expansion of external entities in Document Builder factory.
17+
* Headers modified in Socket creation. (Github PR [#179](https://github.com/splunk/splunk-sdk-java/pull/179)).
18+
* Http Request uses raw request headers by including escape characters which seems vulnerable. It was replaced with PrintWriter methods to avoid escape characters.
19+
* Host parameter used in Socket is omitted to prevent exposing it to external users.
20+
* 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)).
21+
* Deploy plugin is removed from Splunk module pom to avoid redundancy. (Github PR [#172](https://github.com/splunk/splunk-sdk-java/pull/172)).
22+
* Setter methods for Session and Bearer token added along with test case. (Github PR [#171](https://github.com/splunk/splunk-sdk-java/pull/171))
23+
* **Use:** service.setSplunkToken() for session tokens and service.setBearerToken() for long-lived tokens.
24+
* Modular input folder name renamed based on newer splunk folder name validation. (Github PR [#168](https://github.com/splunk/splunk-sdk-java/pull/168))
25+
* 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))
26+
* Test files in sdk app collections are modified based on python v3 syntax.
27+
* Added Saved Search test case based on title. (Github PR [#166](https://github.com/splunk/splunk-sdk-java/pull/166))
28+
329
## Version 1.7.1
430

531
### Minor Changes

README.md

Lines changed: 158 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
![Build Status](https://github.com/splunk/splunk-sdk-java/actions/workflows/release.yml/badge.svg?branch=master)
1+
[![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)
22
# The Splunk Software Development Kit for Java
33

4-
#### Version 1.7.1
4+
#### Version 1.8.0
55

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

112+
### Usage
113+
#### Login using username and password
114+
```java
115+
import com.splunk.Service;
116+
import com.splunk.ServiceArgs;
117+
118+
/**
119+
* Login using username and password
120+
*/
121+
public class SplunkLogin {
122+
123+
static Service service = null;
124+
public static void main(String args[]) {
125+
ServiceArgs loginArgs = new ServiceArgs();
126+
loginArgs.setPort(8089);
127+
loginArgs.setHost("localhost");
128+
loginArgs.setScheme("https");
129+
loginArgs.setUsername("USERNAME"); // Use your username
130+
loginArgs.setPassword("PASSWORD"); // Use your password
131+
132+
// Initialize the SDK client
133+
service = Service.connect(loginArgs);
134+
}
135+
}
136+
```
137+
138+
#### Login using Session Token
139+
```java
140+
import com.splunk.Service;
141+
import com.splunk.ServiceArgs;
142+
143+
/**
144+
* Login using Session token
145+
*/
146+
public class SplunkLogin {
147+
148+
static Service service = null;
149+
/**
150+
* Session Token.
151+
* Actual token length would be longer than this token length.
152+
*/
153+
static String token = "1k_Ostpl6NBe4iVQ5d6I3Ohla_U5";
154+
155+
public static void main(String args[]) {
156+
ServiceArgs loginArgs = new ServiceArgs();
157+
loginArgs.setPort(8089);
158+
loginArgs.setHost("localhost");
159+
loginArgs.setScheme("https");
160+
loginArgs.setToken(String.format("Splunk %s", token));
161+
162+
// Initialize the SDK client
163+
service = Service.connect(loginArgs);
164+
}
165+
}
166+
```
167+
* Login using username and password will create Session token internally.
168+
* Login using Credentials (username & password) OR directly using Session token are similar.
169+
* 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.
170+
* To overcome this limitation, **Authentication** token is used instead of Session token.
171+
* In **Authentication** token, user has a provision to set token expiration time. Splunk allows user to set relative/absolute time for token expiration.
172+
* In other words, **Authentication** token is configurable whereas Session token cannot be configured.
173+
174+
#### Login using Authentication Token (RECOMMENDED)
175+
```java
176+
import com.splunk.Service;
177+
import com.splunk.ServiceArgs;
178+
179+
/**
180+
* Login using Authentication token
181+
*/
182+
public class SplunkLogin {
183+
184+
static Service service = null;
185+
/**
186+
* Authentication Token.
187+
* Actual token length would be longer than this token length.
188+
*/
189+
static String token = "1k_Ostpl6NBe4iVQ5d6I3Ohla_U5";
190+
191+
public static void main(String args[]) {
192+
ServiceArgs loginArgs = new ServiceArgs();
193+
loginArgs.setPort(8089);
194+
loginArgs.setHost("localhost");
195+
loginArgs.setScheme("https");
196+
loginArgs.setToken(String.format("Bearer %s", token));
197+
198+
// Initialize the SDK client
199+
service = Service.connect(loginArgs);
200+
}
201+
}
202+
```
203+
204+
#### Example of running a simple search by first creating the search job
205+
```java
206+
import com.splunk.Job;
207+
import com.splunk.ResultsReader;
208+
import com.splunk.ResultsReaderXml;
209+
import com.splunk.Service;
210+
import com.splunk.ServiceArgs;
211+
212+
/**
213+
* Logged in using Authentication token.
214+
* Assuming that authentication token is already created from Splunk web.
215+
* Create Job using search creation.
216+
* Read results and print _raw fields
217+
*/
218+
public class SearchExample {
219+
220+
static Service service = null;
221+
222+
/**
223+
* Authentication Token.
224+
* Actual token length would be longer than this token length.
225+
*/
226+
static String token = "1k_Ostpl6NBe4iVQ5d6I3Ohla_U5";
227+
228+
public static void main(String args[]) {
229+
230+
ServiceArgs loginArgs = new ServiceArgs();
231+
loginArgs.setPort(8089);
232+
loginArgs.setHost("localhost");
233+
loginArgs.setScheme("https");
234+
loginArgs.setToken(String.format("Bearer %s", token));
235+
236+
// Initialize the SDK client
237+
service = Service.connect(loginArgs);
238+
239+
// Run a simple search by first creating the search job
240+
Job job = service.getJobs().create("search index=_internal | head 10");
241+
242+
// Waiting for search results to be ready
243+
while (!job.isReady()) {
244+
try {
245+
Thread.sleep(500); // 500 ms
246+
} catch (Exception e) {
247+
// Handle exception here.
248+
}
249+
}
250+
251+
// Read results
252+
try {
253+
ResultsReader reader = new ResultsReaderXml(job.getEvents());
254+
255+
// Iterate over events and print _raw field
256+
reader.forEach(event -> System.out.println(event.get("_raw")));
257+
258+
} catch (Exception e) {
259+
// Handle exception here.
260+
}
261+
}
262+
}
263+
```
264+
265+
For more information on authentication using tokens, please visit [Splunk Docs](https://docs.splunk.com/Documentation/Splunk/latest/Security/Setupauthenticationwithtokens).
266+
112267
### Unit tests
113268

114269
The Splunk SDK for Java includes several unit tests that are run at

deploy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare -r scriptDirectory="$(dirname $(readlink -e $0))"
44
declare -r scriptName="$(basename $0)"
5-
declare -r version="1.7.1"
5+
declare -r version="1.8.0"
66

77
if [[ $# -ne 1 ]]; then
88
echo 1>&2 "Usage: ${scriptName} {local|staging||production}"

deploy.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ deploy \<repository-name>
99

1010
##DESCRIPTION
1111

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

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

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

24-
com/splunk/splunk/1.7.1/
25-
├── splunk-1.7.1-javadoc.jar
26-
├── splunk-1.7.1-javadoc.jar.md5
27-
├── splunk-1.7.1-javadoc.jar.sha1
28-
├── splunk-1.7.1-sources.jar
29-
├── splunk-1.7.1-sources.jar.md5
30-
├── splunk-1.7.1-sources.jar.sha1
31-
├── splunk-1.7.1.jar
32-
├── splunk-1.7.1.jar.md5
33-
├── splunk-1.7.1.jar.sha1
34-
├── splunk-1.7.1.pom
35-
├── splunk-1.7.1.pom.md5
36-
└── splunk-1.7.1.pom.sha1
24+
com/splunk/splunk/1.8.0/
25+
├── splunk-1.8.0-javadoc.jar
26+
├── splunk-1.8.0-javadoc.jar.md5
27+
├── splunk-1.8.0-javadoc.jar.sha1
28+
├── splunk-1.8.0-sources.jar
29+
├── splunk-1.8.0-sources.jar.md5
30+
├── splunk-1.8.0-sources.jar.sha1
31+
├── splunk-1.8.0.jar
32+
├── splunk-1.8.0.jar.md5
33+
├── splunk-1.8.0.jar.sha1
34+
├── splunk-1.8.0.pom
35+
├── splunk-1.8.0.pom.md5
36+
└── splunk-1.8.0.pom.sha1
3737

3838
Verify this structure prior to release.

docker-compose.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ version: '3.6'
22

33
services:
44
splunk:
5-
image: "splunk/splunk:8.0"
5+
image: "splunk/splunk:latest"
66
container_name: splunk
77
environment:
88
- SPLUNK_START_ARGS=--accept-license
99
- SPLUNK_HEC_TOKEN=11111111-1111-1111-1111-1111111111113
1010
- SPLUNK_PASSWORD=changed!
11-
- SPLUNK_APPS_URL=https://github.com/splunk/sdk-app-collection/releases/download/v1.0.0/sdk-app-collection.tgz
11+
- SPLUNK_APPS_URL=https://github.com/splunk/sdk-app-collection/releases/download/v1.1.0/sdkappcollection.tgz
12+
- JAVA_VERSION=openjdk:8
1213
ports:
1314
- 8000:8000
1415
- 8088:8088

examples/pom.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<parent>
99
<artifactId>splunk-sdk-java</artifactId>
1010
<groupId>com.splunk</groupId>
11-
<version>1.0.0</version>
11+
<version>1.0.1</version>
1212
</parent>
1313

1414
<build>
@@ -21,6 +21,7 @@
2121
<skipTests>true</skipTests>
2222
</configuration>
2323
</plugin>
24+
<!-- Deploy plugin is overridden here because we are skipping deployment in case of examples module. -->
2425
<plugin>
2526
<groupId>org.apache.maven.plugins</groupId>
2627
<artifactId>maven-deploy-plugin</artifactId>
@@ -36,7 +37,7 @@
3637
<dependency>
3738
<groupId>com.splunk</groupId>
3839
<artifactId>splunk</artifactId>
39-
<version>1.7.1</version>
40+
<version>1.8.0</version>
4041
<scope>provided</scope>
4142
</dependency>
4243
<dependency>

pom.xml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<modelVersion>4.0.0</modelVersion>
77

88
<properties>
9-
<version.number>1.7.1</version.number>
9+
<version.number>1.8.0</version.number>
1010
<maven.resources.overwrite>true</maven.resources.overwrite>
1111
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1212
<maven.compiler.source>8</maven.compiler.source>
@@ -15,7 +15,7 @@
1515

1616
<groupId>com.splunk</groupId>
1717
<artifactId>splunk-sdk-java</artifactId>
18-
<version>1.0.0</version>
18+
<version>1.0.1</version>
1919
<packaging>pom</packaging>
2020
<name>Splunk SDK for Java</name>
2121
<url>https://dev.splunk.com/enterprise/docs/devtools/java/sdk-java</url>
@@ -31,12 +31,6 @@
3131
<artifactId>opencsv</artifactId>
3232
<version>2.3</version>
3333
</dependency>
34-
<dependency>
35-
<groupId>org.apache.maven.plugins</groupId>
36-
<artifactId>maven-deploy-plugin</artifactId>
37-
<version>3.0.0-M1</version>
38-
<type>maven-plugin</type>
39-
</dependency>
4034
</dependencies>
4135
<modules>
4236
<module>splunk</module>

0 commit comments

Comments
 (0)