Skip to content

Commit 305e6aa

Browse files
authored
Merge pull request #194 from splunk/Release/1.9.1
Release/1.9.1
2 parents b4644fa + 0797d89 commit 305e6aa

22 files changed

+284
-58
lines changed

CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Splunk Enterprise SDK for Java Changelog
22

3+
## Version 1.9.1
4+
5+
### New Features and APIs
6+
* SDK Support for third-party (Load Balancer) "sticky sessions"(cookie persistence) (Github PR [#192](https://github.com/splunk/splunk-sdk-java/pull/192))
7+
* Added Args option for Saved Search history method (GitHub Issue [#126](https://github.com/splunk/splunk-sdk-java/issues/126) & PR [#188](https://github.com/splunk/splunk-sdk-java/pull/188) )
8+
9+
### Minor Changes
10+
* Special handling related to the semantic versioning of specific Search APIs functional in Splunk Enterprise 9.0.2 and (Splunk Cloud 9.0.2209). These SDK changes will enable seamless transition between the APIs based on the version of the Splunk Enterprise/Cloud (Github PR [#193](https://github.com/splunk/splunk-sdk-java/pull/193))
11+
* Updated checks to fetch Storage Passwords with wildcards in namespace. (GitHub PR [#187](https://github.com/splunk/splunk-sdk-java/pull/187))
12+
313
## Version 1.9.0
414

515
### New Features and APIs

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[![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.9.0
4+
#### Version 1.9.1
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.9.0</version>
78+
<version>1.9.1</version>
7979
</dependency>
8080
</dependencies>
8181
```

deploy

+1-1
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.9.0"
5+
declare -r version="1.9.1"
66

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

deploy.md

+15-15
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.9.0.jar**, **target/splunk-1.9.0-javadoc.jar**, and
13-
**target/splunk-1.9.0-sources.jar** to the **local**, **staging**, or **production**
12+
Deploy transmits **target/splunk-1.9.1.jar**, **target/splunk-1.9.1-javadoc.jar**, and
13+
**target/splunk-1.9.1-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.9.0/
25-
├── splunk-1.9.0-javadoc.jar
26-
├── splunk-1.9.0-javadoc.jar.md5
27-
├── splunk-1.9.0-javadoc.jar.sha1
28-
├── splunk-1.9.0-sources.jar
29-
├── splunk-1.9.0-sources.jar.md5
30-
├── splunk-1.9.0-sources.jar.sha1
31-
├── splunk-1.9.0.jar
32-
├── splunk-1.9.0.jar.md5
33-
├── splunk-1.9.0.jar.sha1
34-
├── splunk-1.9.0.pom
35-
├── splunk-1.9.0.pom.md5
36-
└── splunk-1.9.0.pom.sha1
24+
com/splunk/splunk/1.9.1/
25+
├── splunk-1.9.1-javadoc.jar
26+
├── splunk-1.9.1-javadoc.jar.md5
27+
├── splunk-1.9.1-javadoc.jar.sha1
28+
├── splunk-1.9.1-sources.jar
29+
├── splunk-1.9.1-sources.jar.md5
30+
├── splunk-1.9.1-sources.jar.sha1
31+
├── splunk-1.9.1.jar
32+
├── splunk-1.9.1.jar.md5
33+
├── splunk-1.9.1.jar.sha1
34+
├── splunk-1.9.1.pom
35+
├── splunk-1.9.1.pom.md5
36+
└── splunk-1.9.1.pom.sha1
3737

3838
Verify this structure prior to release.

examples/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
<dependency>
3838
<groupId>com.splunk</groupId>
3939
<artifactId>splunk</artifactId>
40-
<version>1.9.0</version>
40+
<version>1.9.1</version>
4141
<scope>provided</scope>
4242
</dependency>
4343
<dependency>

pom.xml

+2-2
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.9.0</version.number>
9+
<version.number>1.9.1</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>
@@ -24,7 +24,7 @@
2424
<dependency>
2525
<groupId>com.google.code.gson</groupId>
2626
<artifactId>gson</artifactId>
27-
<version>2.8.6</version>
27+
<version>2.8.9</version>
2828
</dependency>
2929
<dependency>
3030
<groupId>net.sf.opencsv</groupId>

splunk/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<modelVersion>4.0.0</modelVersion>
66

77
<artifactId>splunk</artifactId>
8-
<version>1.9.0</version>
8+
<version>1.9.1</version>
99
<parent>
1010
<artifactId>splunk-sdk-java</artifactId>
1111
<groupId>com.splunk</groupId>

splunk/src/main/java/com/splunk/HttpService.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public boolean verify(String s, SSLSession sslSession) {
8989
private String prefix = null;
9090

9191
static Map<String, String> defaultHeader = new HashMap<String, String>() {{
92-
put("User-Agent", "splunk-sdk-java/1.9.0");
92+
put("User-Agent", "splunk-sdk-java/1.9.1");
9393
put("Accept", "*/*");
9494
}};
9595

@@ -316,12 +316,12 @@ public void removeAllCookies() {
316316
}
317317

318318
/**
319-
* Returns true if the cookeStore has any cookies, false otherwise
319+
* Returns true if the cookieStore has any Splunk Authorization cookies, false otherwise
320320
*
321321
* @return True if there are cookies, false otherwise
322322
*/
323-
public Boolean hasCookies() {
324-
return !cookieStore.isEmpty();
323+
public Boolean hasSplunkAuthCookies() {
324+
return cookieStore.hasSplunkAuthCookie();
325325
}
326326

327327
/**

splunk/src/main/java/com/splunk/Job.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -372,15 +372,15 @@ private InputStream getEventsMethod(String methodPath, Map args) {
372372
// v1(GET), v2(POST)
373373
String fullPath;
374374
ResponseMessage response;
375-
if (service.versionIsEarlierThan("9.0")) {
375+
if (!service.enableV2SearchApi()) {
376376
fullPath = path.replace(JobCollection.REST_PATH_V2, JobCollection.REST_PATH) + methodPath;
377377
response = service.get(fullPath, args);
378378
}
379379
else {
380380
fullPath = path.replace(JobCollection.REST_PATH, JobCollection.REST_PATH_V2) + methodPath;
381381
response = service.post(fullPath, args);
382382
}
383-
383+
384384
return response.getContent();
385385
}
386386

splunk/src/main/java/com/splunk/JobCollection.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class JobCollection extends EntityCollection<Job> {
3434
* @param service The connected {@code Service} instance.
3535
*/
3636
JobCollection(Service service) {
37-
super(service, service.versionIsAtLeast("9.0") ? REST_PATH_V2 : REST_PATH, Job.class);
37+
super(service, service.enableV2SearchApi() ? REST_PATH_V2 : REST_PATH, Job.class);
3838
this.refreshArgs.put("count", "0");
3939
}
4040

@@ -46,7 +46,7 @@ public class JobCollection extends EntityCollection<Job> {
4646
* return and how to sort them (see {@link CollectionArgs}).
4747
*/
4848
JobCollection(Service service, Args args) {
49-
super(service, service.versionIsAtLeast("9.0") ? REST_PATH_V2 : REST_PATH, Job.class, args);
49+
super(service, service.enableV2SearchApi() ? REST_PATH_V2 : REST_PATH, Job.class);
5050
this.refreshArgs.put("count", "0");
5151
}
5252

@@ -87,7 +87,7 @@ public Job create(String query, Map args) {
8787
.item(0)
8888
.getTextContent();
8989

90-
String path = service.versionIsAtLeast("9.0") ? REST_PATH_V2 : REST_PATH;
90+
String path = service.enableV2SearchApi() ? REST_PATH_V2 : REST_PATH;
9191
Job job = new Job(service, path + "/" + sid);
9292
job.refresh();
9393

splunk/src/main/java/com/splunk/PasswordCollection.java

+20
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ public class PasswordCollection extends EntityCollection<Password> {
5050
* @return The new credential.
5151
*/
5252
public Password create(String name, String password) {
53+
if(checkForWildcards()){
54+
throw new IllegalArgumentException("While creating StoragePasswords, namespace cannot have wildcards.");
55+
}
5356
Args args = new Args("password", password);
5457
return create(name, args);
5558
}
@@ -63,6 +66,9 @@ public Password create(String name, String password) {
6366
* @return The new credential.
6467
*/
6568
public Password create(String name, String password, String realm) {
69+
if(checkForWildcards()){
70+
throw new IllegalArgumentException("While creating StoragePasswords, namespace cannot have wildcards.");
71+
}
6672
Args args = new Args();
6773
args.put("password", password);
6874
args.put("realm", realm);
@@ -97,11 +103,17 @@ public Password get(Object key) {
97103
* @return The removed credential, or null if not found.
98104
*/
99105
public Password remove(String realm, String name) {
106+
if(checkForWildcards()){
107+
throw new IllegalArgumentException("app context must be specified when removing a password.");
108+
}
100109
return super.remove(String.format("%s:%s:", realm, name));
101110
}
102111

103112
@Override
104113
public Password remove(String key) {
114+
if(checkForWildcards()){
115+
throw new IllegalArgumentException("app context must be specified when removing a password.");
116+
}
105117
// Make it compatible with the old way (low-efficient)
106118
if (!key.contains(":")) {
107119
Password password = getByUsername((String) key);
@@ -129,4 +141,12 @@ private Password getByUsername(String name) {
129141
}
130142
return null;
131143
}
144+
145+
private boolean checkForWildcards(){
146+
boolean isWildCard = false;
147+
if(("-").equals(service.getOwner()) || ("-").equals(service.getApp())){
148+
isWildCard = true;
149+
}
150+
return isWildCard;
151+
}
132152
}

splunk/src/main/java/com/splunk/Receiver.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,13 @@ public Socket attach(String indexName, Args args) throws IOException {
9898
headers.add("Accept-Encoding: identity");
9999
headers.add("X-Splunk-Input-Mode: Streaming");
100100

101-
if (service.hasCookies()) {
101+
if (service.hasSplunkAuthCookies()) {
102102
headers.add(String.format("Cookie: %s", service.stringifyCookies()));
103103
} else {
104+
// to persist the cookies other than Splunk such as from Load Balancer
105+
if(!service.cookieStore.isEmpty()){
106+
headers.add(String.format("Cookie: %s", service.stringifyCookies()));
107+
}
104108
headers.add(String.format("Authorization: %s", service.getToken()));
105109
}
106110
headers.add("");

0 commit comments

Comments
 (0)