Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
41de3c0
Wildcard checks in-line with other SDKs
ashah-splunk Jun 14, 2022
0cf88c0
Update PasswordTest.java
ashah-splunk Jun 14, 2022
771b971
Added 'args' parameter for Saved Search History function
ashah-splunk Jun 14, 2022
1f2b8a3
Update PasswordCollection.java
ashah-splunk Jun 14, 2022
7f62c7a
Merge pull request #191 from splunk/master
fantavlik Jun 17, 2022
2618f58
Merge pull request #188 from splunk/args-param-for-history
ashah-splunk Jul 12, 2022
a6ed62f
Update PasswordCollection.java
ashah-splunk Jul 12, 2022
cf26ad8
Merge pull request #187 from splunk/storagepasswords-wildcard-check
ashah-splunk Jul 20, 2022
fabe38c
Added logic to persist cookies from third party
ashah-splunk Aug 23, 2022
9117f03
Update CookieTest.java
ashah-splunk Aug 23, 2022
b552059
Added test case for Receiver without Splunk Cookie
ashah-splunk Aug 24, 2022
7adbaba
v2 Search API changes reverted
ashah-splunk Aug 29, 2022
2c18e26
Update JobCollection.java
ashah-splunk Aug 29, 2022
d6fe200
Revert "Update JobCollection.java"
ashah-splunk Aug 31, 2022
e7a921b
Revert "v2 Search API changes reverted"
ashah-splunk Aug 31, 2022
04e5668
updated version checks for v2 Search APIs
ashah-splunk Sep 1, 2022
baba144
Update Service.java
ashah-splunk Sep 1, 2022
a9774fd
Merge branch 'persist-cookies' into revert-v2-changes
ashah-splunk Sep 2, 2022
9423ce6
revamped version check logic for enabling V2 search APIs
ashah-splunk Sep 12, 2022
b91a623
Merge pull request #192 from splunk/persist-cookies
ashah-splunk Sep 12, 2022
be455c0
Merge pull request #193 from splunk/revert-v2-changes
ashah-splunk Sep 12, 2022
d822d12
Release updates
ashah-splunk Sep 13, 2022
9f46b7b
Update pom.xml
ashah-splunk Sep 13, 2022
0797d89
Update CHANGELOG.md
ashah-splunk Sep 13, 2022
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
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Splunk Enterprise SDK for Java Changelog

## Version 1.9.1

### New Features and APIs
* SDK Support for third-party (Load Balancer) "sticky sessions"(cookie persistence) (Github PR [#192](https://github.com/splunk/splunk-sdk-java/pull/192))
* 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) )

### Minor Changes
* 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))
* Updated checks to fetch Storage Passwords with wildcards in namespace. (GitHub PR [#187](https://github.com/splunk/splunk-sdk-java/pull/187))

## Version 1.9.0

### New Features and APIs
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[![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.9.0
#### Version 1.9.1

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.9.0</version>
<version>1.9.1</version>
</dependency>
</dependencies>
```
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.9.0"
declare -r version="1.9.1"

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.9.0.jar**, **target/splunk-1.9.0-javadoc.jar**, and
**target/splunk-1.9.0-sources.jar** to the **local**, **staging**, or **production**
Deploy transmits **target/splunk-1.9.1.jar**, **target/splunk-1.9.1-javadoc.jar**, and
**target/splunk-1.9.1-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.9.0/
├── splunk-1.9.0-javadoc.jar
├── splunk-1.9.0-javadoc.jar.md5
├── splunk-1.9.0-javadoc.jar.sha1
├── splunk-1.9.0-sources.jar
├── splunk-1.9.0-sources.jar.md5
├── splunk-1.9.0-sources.jar.sha1
├── splunk-1.9.0.jar
├── splunk-1.9.0.jar.md5
├── splunk-1.9.0.jar.sha1
├── splunk-1.9.0.pom
├── splunk-1.9.0.pom.md5
└── splunk-1.9.0.pom.sha1
com/splunk/splunk/1.9.1/
├── splunk-1.9.1-javadoc.jar
├── splunk-1.9.1-javadoc.jar.md5
├── splunk-1.9.1-javadoc.jar.sha1
├── splunk-1.9.1-sources.jar
├── splunk-1.9.1-sources.jar.md5
├── splunk-1.9.1-sources.jar.sha1
├── splunk-1.9.1.jar
├── splunk-1.9.1.jar.md5
├── splunk-1.9.1.jar.sha1
├── splunk-1.9.1.pom
├── splunk-1.9.1.pom.md5
└── splunk-1.9.1.pom.sha1

Verify this structure prior to release.
2 changes: 1 addition & 1 deletion examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<dependency>
<groupId>com.splunk</groupId>
<artifactId>splunk</artifactId>
<version>1.9.0</version>
<version>1.9.1</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
4 changes: 2 additions & 2 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.9.0</version.number>
<version.number>1.9.1</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 @@ -24,7 +24,7 @@
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.6</version>
<version>2.8.9</version>
</dependency>
<dependency>
<groupId>net.sf.opencsv</groupId>
Expand Down
2 changes: 1 addition & 1 deletion splunk/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>

<artifactId>splunk</artifactId>
<version>1.9.0</version>
<version>1.9.1</version>
<parent>
<artifactId>splunk-sdk-java</artifactId>
<groupId>com.splunk</groupId>
Expand Down
8 changes: 4 additions & 4 deletions splunk/src/main/java/com/splunk/HttpService.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public boolean verify(String s, SSLSession sslSession) {
private String prefix = null;

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

Expand Down Expand Up @@ -316,12 +316,12 @@ public void removeAllCookies() {
}

/**
* Returns true if the cookeStore has any cookies, false otherwise
* Returns true if the cookieStore has any Splunk Authorization cookies, false otherwise
*
* @return True if there are cookies, false otherwise
*/
public Boolean hasCookies() {
return !cookieStore.isEmpty();
public Boolean hasSplunkAuthCookies() {
return cookieStore.hasSplunkAuthCookie();
}

/**
Expand Down
4 changes: 2 additions & 2 deletions splunk/src/main/java/com/splunk/Job.java
Original file line number Diff line number Diff line change
Expand Up @@ -372,15 +372,15 @@ private InputStream getEventsMethod(String methodPath, Map args) {
// v1(GET), v2(POST)
String fullPath;
ResponseMessage response;
if (service.versionIsEarlierThan("9.0")) {
if (!service.enableV2SearchApi()) {
fullPath = path.replace(JobCollection.REST_PATH_V2, JobCollection.REST_PATH) + methodPath;
response = service.get(fullPath, args);
}
else {
fullPath = path.replace(JobCollection.REST_PATH, JobCollection.REST_PATH_V2) + methodPath;
response = service.post(fullPath, args);
}

return response.getContent();
}

Expand Down
6 changes: 3 additions & 3 deletions splunk/src/main/java/com/splunk/JobCollection.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class JobCollection extends EntityCollection<Job> {
* @param service The connected {@code Service} instance.
*/
JobCollection(Service service) {
super(service, service.versionIsAtLeast("9.0") ? REST_PATH_V2 : REST_PATH, Job.class);
super(service, service.enableV2SearchApi() ? REST_PATH_V2 : REST_PATH, Job.class);
this.refreshArgs.put("count", "0");
}

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

Expand Down Expand Up @@ -87,7 +87,7 @@ public Job create(String query, Map args) {
.item(0)
.getTextContent();

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

Expand Down
20 changes: 20 additions & 0 deletions splunk/src/main/java/com/splunk/PasswordCollection.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ public class PasswordCollection extends EntityCollection<Password> {
* @return The new credential.
*/
public Password create(String name, String password) {
if(checkForWildcards()){
throw new IllegalArgumentException("While creating StoragePasswords, namespace cannot have wildcards.");
}
Args args = new Args("password", password);
return create(name, args);
}
Expand All @@ -63,6 +66,9 @@ public Password create(String name, String password) {
* @return The new credential.
*/
public Password create(String name, String password, String realm) {
if(checkForWildcards()){
throw new IllegalArgumentException("While creating StoragePasswords, namespace cannot have wildcards.");
}
Args args = new Args();
args.put("password", password);
args.put("realm", realm);
Expand Down Expand Up @@ -97,11 +103,17 @@ public Password get(Object key) {
* @return The removed credential, or null if not found.
*/
public Password remove(String realm, String name) {
if(checkForWildcards()){
throw new IllegalArgumentException("app context must be specified when removing a password.");
}
return super.remove(String.format("%s:%s:", realm, name));
}

@Override
public Password remove(String key) {
if(checkForWildcards()){
throw new IllegalArgumentException("app context must be specified when removing a password.");
}
// Make it compatible with the old way (low-efficient)
if (!key.contains(":")) {
Password password = getByUsername((String) key);
Expand Down Expand Up @@ -129,4 +141,12 @@ private Password getByUsername(String name) {
}
return null;
}

private boolean checkForWildcards(){
boolean isWildCard = false;
if(("-").equals(service.getOwner()) || ("-").equals(service.getApp())){
isWildCard = true;
}
return isWildCard;
}
}
6 changes: 5 additions & 1 deletion splunk/src/main/java/com/splunk/Receiver.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,13 @@ public Socket attach(String indexName, Args args) throws IOException {
headers.add("Accept-Encoding: identity");
headers.add("X-Splunk-Input-Mode: Streaming");

if (service.hasCookies()) {
if (service.hasSplunkAuthCookies()) {
headers.add(String.format("Cookie: %s", service.stringifyCookies()));
} else {
// to persist the cookies other than Splunk such as from Load Balancer
if(!service.cookieStore.isEmpty()){
headers.add(String.format("Cookie: %s", service.stringifyCookies()));
}
headers.add(String.format("Authorization: %s", service.getToken()));
}
headers.add("");
Expand Down
Loading