diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 2df6aeb3..d008e42b 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -2,6 +2,9 @@ on:
release:
types: [published]
+permissions:
+ contents: write
+
name: Release
jobs:
@@ -22,8 +25,7 @@ jobs:
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
-# body_path: ${{ github.workflow }}-CHANGELOG.txt
- files: ./target/*.jar
+ files: ./splunk/target/*.jar
draft: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4348b96b..8aad9ae9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,11 @@
# Splunk Enterprise SDK for Java Changelog
+## Version 1.9.5
+
+### New Features and APIs
+* Added static method _addClusterMasterURIsToHosts_ in HttpService class to update list of Valid Hosts with Cluster Master Hosts (GitHub PR [#215](https://github.com/splunk/splunk-sdk-java/pull/215))
+* Added instance method _getClusterMasters_ in Service class to get list of cluster master hosts
+
## Version 1.9.4
### Minor Changes
diff --git a/README.md b/README.md
index 9c9b2bc9..8c63c07f 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
[](https://github.com/splunk/splunk-sdk-java/actions/workflows/test.yml)
# The Splunk Software Development Kit for Java
-#### Version 1.9.4
+#### Version 1.9.5
The Splunk Software Development Kit (SDK) for Java contains library code and
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:
com.splunk
splunk
- 1.9.4
+ 1.9.5
```
diff --git a/deploy b/deploy
index 8e224780..ab8acd24 100755
--- a/deploy
+++ b/deploy
@@ -2,7 +2,7 @@
declare -r scriptDirectory="$(dirname $(readlink -e $0))"
declare -r scriptName="$(basename $0)"
-declare -r version="1.9.4"
+declare -r version="1.9.5"
if [[ $# -ne 1 ]]; then
echo 1>&2 "Usage: ${scriptName} {local|staging||production}"
diff --git a/deploy.md b/deploy.md
index 1c7d3a2a..aed545f5 100644
--- a/deploy.md
+++ b/deploy.md
@@ -9,8 +9,8 @@ deploy \
##DESCRIPTION
-Deploy transmits **target/splunk-1.9.4.jar**, **target/splunk-1.9.4-javadoc.jar**, and
-**target/splunk-1.9.4-sources.jar** to the **local**, **staging**, or **production**
+Deploy transmits **target/splunk-1.9.5.jar**, **target/splunk-1.9.5-javadoc.jar**, and
+**target/splunk-1.9.5-sources.jar** to the **local**, **staging**, or **production**
maven repository. Repository names are mapped to locations as follows.
| repository-name | location |
@@ -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.4/
- ├── splunk-1.9.4-javadoc.jar
- ├── splunk-1.9.4-javadoc.jar.md5
- ├── splunk-1.9.4-javadoc.jar.sha1
- ├── splunk-1.9.4-sources.jar
- ├── splunk-1.9.4-sources.jar.md5
- ├── splunk-1.9.4-sources.jar.sha1
- ├── splunk-1.9.4.jar
- ├── splunk-1.9.4.jar.md5
- ├── splunk-1.9.4.jar.sha1
- ├── splunk-1.9.4.pom
- ├── splunk-1.9.4.pom.md5
- └── splunk-1.9.4.pom.sha1
+ com/splunk/splunk/1.9.5/
+ ├── splunk-1.9.5-javadoc.jar
+ ├── splunk-1.9.5-javadoc.jar.md5
+ ├── splunk-1.9.5-javadoc.jar.sha1
+ ├── splunk-1.9.5-sources.jar
+ ├── splunk-1.9.5-sources.jar.md5
+ ├── splunk-1.9.5-sources.jar.sha1
+ ├── splunk-1.9.5.jar
+ ├── splunk-1.9.5.jar.md5
+ ├── splunk-1.9.5.jar.sha1
+ ├── splunk-1.9.5.pom
+ ├── splunk-1.9.5.pom.md5
+ └── splunk-1.9.5.pom.sha1
Verify this structure prior to release.
diff --git a/examples/pom.xml b/examples/pom.xml
index 9c5eaa01..18bbb711 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -37,7 +37,7 @@
com.splunk
splunk
- 1.9.4
+ 1.9.5
provided
diff --git a/pom.xml b/pom.xml
index 920736a6..37ef9e19 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
4.0.0
- 1.9.4
+ 1.9.5
true
UTF-8
8
diff --git a/splunk/pom.xml b/splunk/pom.xml
index 9b61229a..7dede37e 100644
--- a/splunk/pom.xml
+++ b/splunk/pom.xml
@@ -5,7 +5,7 @@
4.0.0
splunk
- 1.9.4
+ 1.9.5
splunk-sdk-java
com.splunk
diff --git a/splunk/src/main/java/com/splunk/HttpService.java b/splunk/src/main/java/com/splunk/HttpService.java
index 26a88ada..70b99269 100644
--- a/splunk/src/main/java/com/splunk/HttpService.java
+++ b/splunk/src/main/java/com/splunk/HttpService.java
@@ -23,11 +23,8 @@
import java.io.OutputStreamWriter;
import java.net.*;
import java.security.cert.X509Certificate;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import java.util.Map.Entry;
-import java.util.Objects;
/**
* The {@code HttpService} class represents a generic HTTP service at a given
@@ -50,13 +47,11 @@ public class HttpService {
private static SSLSocketFactory sslSocketFactory = createSSLFactory();
private static String HTTPS_SCHEME = "https";
private static String HTTP_SCHEME = "http";
- private static String HOSTNAME = "localhost";
- private static String HOSTIP = "127.0.0.1";
- private static String HOSTIPv6 = "::1";
+ private static List VALID_HOSTS = new ArrayList(Arrays.asList("localhost", "127.0.0.1", "::1"));
private static final HostnameVerifier HOSTNAME_VERIFIER = new HostnameVerifier() {
public boolean verify(String s, SSLSession sslSession) {
- if (s.equals(HOSTNAME) || s.equals(HOSTIP) || s.equals(HOSTIPv6)) {
+ if(VALID_HOSTS.contains(s)){
return true;
} else {
HostnameVerifier hv = HttpsURLConnection.getDefaultHostnameVerifier();
@@ -91,7 +86,7 @@ public boolean verify(String s, SSLSession sslSession) {
private String prefix = null;
static Map defaultHeader = new HashMap() {{
- put("User-Agent", "splunk-sdk-java/1.9.4");
+ put("User-Agent", "splunk-sdk-java/1.9.5");
put("Accept", "*/*");
}};
@@ -239,6 +234,14 @@ public static void setSslSecurityProtocol(SSLSecurityProtocol securityProtocol)
}
}
+ /**
+ * Adds list of Cluster Master Hosts to the list of Valid Hosts for Hostname verification.
+ * @param searchHeadService Splunk SearchHead Service instance
+ */
+ public static void addClusterMasterURIsToHosts(Service searchHeadService){
+ VALID_HOSTS.addAll(searchHeadService.getClusterMasters());
+ }
+
/**
* Returns the URL prefix of this service, consisting of
* {@code scheme://host[:port]}.
diff --git a/splunk/src/main/java/com/splunk/Service.java b/splunk/src/main/java/com/splunk/Service.java
index 05a5ae6d..57609010 100644
--- a/splunk/src/main/java/com/splunk/Service.java
+++ b/splunk/src/main/java/com/splunk/Service.java
@@ -19,9 +19,9 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
-import java.net.Socket;
-import java.net.URLEncoder;
-import java.net.URLStreamHandler;
+import java.net.*;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Map;
/**
@@ -594,6 +594,35 @@ public ServiceInfo getInfo() {
return new ServiceInfo(this);
}
+ /**
+ * Returns list of all applicable Cluster Master Hosts for the SearchHead Service.
+ *
+ * @return List of Cluster Master Host(s).
+ */
+ public List getClusterMasters(){
+ Entity caps = new Entity(this, "cluster/config");
+ List hosts = new ArrayList();
+ try {
+ String clusterMasterURIs = caps.getString("master_uri");
+ URL clusterMasterUrl;
+ //for multi-cluster environment, there might be more than cluster master for the searchHead
+ if(clusterMasterURIs.contains(",")){
+ String[] masterURIs = clusterMasterURIs.split(",");
+ for(String uri : masterURIs){
+ clusterMasterUrl = new URL(uri);
+ hosts.add(clusterMasterUrl.getHost());
+ }
+ }else {
+ clusterMasterUrl = new URL(clusterMasterURIs);
+ hosts.add(clusterMasterUrl.getHost());
+ }
+ return hosts;
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ }
+ return hosts;
+ }
+
/**
* Returns a collection of configured inputs.
*