Skip to content

Release/1.9.5 #216

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
May 18, 2023
6 changes: 4 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ on:
release:
types: [published]

permissions:
contents: write

name: Release

jobs:
Expand All @@ -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 }}
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
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.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.
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.4</version>
<version>1.9.5</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.4"
declare -r version="1.9.5"

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.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 |
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.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.
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.4</version>
<version>1.9.5</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion 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.4</version.number>
<version.number>1.9.5</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 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.4</version>
<version>1.9.5</version>
<parent>
<artifactId>splunk-sdk-java</artifactId>
<groupId>com.splunk</groupId>
Expand Down
21 changes: 12 additions & 9 deletions splunk/src/main/java/com/splunk/HttpService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<String> VALID_HOSTS = new ArrayList<String>(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();
Expand Down Expand Up @@ -91,7 +86,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.4");
put("User-Agent", "splunk-sdk-java/1.9.5");
put("Accept", "*/*");
}};

Expand Down Expand Up @@ -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]}.
Expand Down
35 changes: 32 additions & 3 deletions splunk/src/main/java/com/splunk/Service.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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<String> getClusterMasters(){
Entity caps = new Entity(this, "cluster/config");
List<String> hosts = new ArrayList<String>();
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.
*
Expand Down