Skip to content

Commit 1e1ea17

Browse files
authored
Merge pull request #216 from splunk/Release/1.9.5
Release/1.9.5
2 parents 3e1cbf6 + 838ca9a commit 1e1ea17

File tree

10 files changed

+75
-35
lines changed

10 files changed

+75
-35
lines changed

.github/workflows/release.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ on:
22
release:
33
types: [published]
44

5+
permissions:
6+
contents: write
7+
58
name: Release
69

710
jobs:
@@ -22,8 +25,7 @@ jobs:
2225
- name: Create GitHub Release
2326
uses: softprops/action-gh-release@v1
2427
with:
25-
# body_path: ${{ github.workflow }}-CHANGELOG.txt
26-
files: ./target/*.jar
28+
files: ./splunk/target/*.jar
2729
draft: true
2830
env:
2931
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

CHANGELOG.md

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

3+
## Version 1.9.5
4+
5+
### New Features and APIs
6+
* 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))
7+
* Added instance method _getClusterMasters_ in Service class to get list of cluster master hosts
8+
39
## Version 1.9.4
410

511
### Minor Changes

README.md

Lines changed: 2 additions & 2 deletions
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.4
4+
#### Version 1.9.5
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.4</version>
78+
<version>1.9.5</version>
7979
</dependency>
8080
</dependencies>
8181
```

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.9.4"
5+
declare -r version="1.9.5"
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.9.4.jar**, **target/splunk-1.9.4-javadoc.jar**, and
13-
**target/splunk-1.9.4-sources.jar** to the **local**, **staging**, or **production**
12+
Deploy transmits **target/splunk-1.9.5.jar**, **target/splunk-1.9.5-javadoc.jar**, and
13+
**target/splunk-1.9.5-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.4/
25-
├── splunk-1.9.4-javadoc.jar
26-
├── splunk-1.9.4-javadoc.jar.md5
27-
├── splunk-1.9.4-javadoc.jar.sha1
28-
├── splunk-1.9.4-sources.jar
29-
├── splunk-1.9.4-sources.jar.md5
30-
├── splunk-1.9.4-sources.jar.sha1
31-
├── splunk-1.9.4.jar
32-
├── splunk-1.9.4.jar.md5
33-
├── splunk-1.9.4.jar.sha1
34-
├── splunk-1.9.4.pom
35-
├── splunk-1.9.4.pom.md5
36-
└── splunk-1.9.4.pom.sha1
24+
com/splunk/splunk/1.9.5/
25+
├── splunk-1.9.5-javadoc.jar
26+
├── splunk-1.9.5-javadoc.jar.md5
27+
├── splunk-1.9.5-javadoc.jar.sha1
28+
├── splunk-1.9.5-sources.jar
29+
├── splunk-1.9.5-sources.jar.md5
30+
├── splunk-1.9.5-sources.jar.sha1
31+
├── splunk-1.9.5.jar
32+
├── splunk-1.9.5.jar.md5
33+
├── splunk-1.9.5.jar.sha1
34+
├── splunk-1.9.5.pom
35+
├── splunk-1.9.5.pom.md5
36+
└── splunk-1.9.5.pom.sha1
3737

3838
Verify this structure prior to release.

examples/pom.xml

Lines changed: 1 addition & 1 deletion
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.4</version>
40+
<version>1.9.5</version>
4141
<scope>provided</scope>
4242
</dependency>
4343
<dependency>

pom.xml

Lines changed: 1 addition & 1 deletion
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.4</version.number>
9+
<version.number>1.9.5</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>

splunk/pom.xml

Lines changed: 1 addition & 1 deletion
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.4</version>
8+
<version>1.9.5</version>
99
<parent>
1010
<artifactId>splunk-sdk-java</artifactId>
1111
<groupId>com.splunk</groupId>

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

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,8 @@
2323
import java.io.OutputStreamWriter;
2424
import java.net.*;
2525
import java.security.cert.X509Certificate;
26-
import java.util.HashMap;
27-
import java.util.List;
28-
import java.util.Map;
26+
import java.util.*;
2927
import java.util.Map.Entry;
30-
import java.util.Objects;
3128

3229
/**
3330
* The {@code HttpService} class represents a generic HTTP service at a given
@@ -50,13 +47,11 @@ public class HttpService {
5047
private static SSLSocketFactory sslSocketFactory = createSSLFactory();
5148
private static String HTTPS_SCHEME = "https";
5249
private static String HTTP_SCHEME = "http";
53-
private static String HOSTNAME = "localhost";
54-
private static String HOSTIP = "127.0.0.1";
55-
private static String HOSTIPv6 = "::1";
50+
private static List<String> VALID_HOSTS = new ArrayList<String>(Arrays.asList("localhost", "127.0.0.1", "::1"));
5651

5752
private static final HostnameVerifier HOSTNAME_VERIFIER = new HostnameVerifier() {
5853
public boolean verify(String s, SSLSession sslSession) {
59-
if (s.equals(HOSTNAME) || s.equals(HOSTIP) || s.equals(HOSTIPv6)) {
54+
if(VALID_HOSTS.contains(s)){
6055
return true;
6156
} else {
6257
HostnameVerifier hv = HttpsURLConnection.getDefaultHostnameVerifier();
@@ -91,7 +86,7 @@ public boolean verify(String s, SSLSession sslSession) {
9186
private String prefix = null;
9287

9388
static Map<String, String> defaultHeader = new HashMap<String, String>() {{
94-
put("User-Agent", "splunk-sdk-java/1.9.4");
89+
put("User-Agent", "splunk-sdk-java/1.9.5");
9590
put("Accept", "*/*");
9691
}};
9792

@@ -239,6 +234,14 @@ public static void setSslSecurityProtocol(SSLSecurityProtocol securityProtocol)
239234
}
240235
}
241236

237+
/**
238+
* Adds list of Cluster Master Hosts to the list of Valid Hosts for Hostname verification.
239+
* @param searchHeadService Splunk SearchHead Service instance
240+
*/
241+
public static void addClusterMasterURIsToHosts(Service searchHeadService){
242+
VALID_HOSTS.addAll(searchHeadService.getClusterMasters());
243+
}
244+
242245
/**
243246
* Returns the URL prefix of this service, consisting of
244247
* {@code scheme://host[:port]}.

splunk/src/main/java/com/splunk/Service.java

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
import java.io.IOException;
2020
import java.io.InputStream;
2121
import java.io.UnsupportedEncodingException;
22-
import java.net.Socket;
23-
import java.net.URLEncoder;
24-
import java.net.URLStreamHandler;
22+
import java.net.*;
23+
import java.util.ArrayList;
24+
import java.util.List;
2525
import java.util.Map;
2626

2727
/**
@@ -594,6 +594,35 @@ public ServiceInfo getInfo() {
594594
return new ServiceInfo(this);
595595
}
596596

597+
/**
598+
* Returns list of all applicable Cluster Master Hosts for the SearchHead Service.
599+
*
600+
* @return List of Cluster Master Host(s).
601+
*/
602+
public List<String> getClusterMasters(){
603+
Entity caps = new Entity(this, "cluster/config");
604+
List<String> hosts = new ArrayList<String>();
605+
try {
606+
String clusterMasterURIs = caps.getString("master_uri");
607+
URL clusterMasterUrl;
608+
//for multi-cluster environment, there might be more than cluster master for the searchHead
609+
if(clusterMasterURIs.contains(",")){
610+
String[] masterURIs = clusterMasterURIs.split(",");
611+
for(String uri : masterURIs){
612+
clusterMasterUrl = new URL(uri);
613+
hosts.add(clusterMasterUrl.getHost());
614+
}
615+
}else {
616+
clusterMasterUrl = new URL(clusterMasterURIs);
617+
hosts.add(clusterMasterUrl.getHost());
618+
}
619+
return hosts;
620+
} catch (MalformedURLException e) {
621+
e.printStackTrace();
622+
}
623+
return hosts;
624+
}
625+
597626
/**
598627
* Returns a collection of configured inputs.
599628
*

0 commit comments

Comments
 (0)