Skip to content

Commit f3ed5b4

Browse files
authored
Merge pull request #34 from NASA-AMMOS/decouple-es
Decouple Elasticsearch from CWS, make into external dependency
2 parents 1b467fc + df0ce69 commit f3ed5b4

File tree

26 files changed

+387
-631
lines changed

26 files changed

+387
-631
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ creds.txt
2121
cws-test/newCWSDir
2222

2323
.DS_Store
24-
install/logging/logstash-6.4.2.zip
24+
install/logging/logstash-7.9.0.zip

NOTICE.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ This software includes third party software subject to the following copyrights:
1717
- The AWS SDK for Java is Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
1818
- The Camunda BPMN Platform is Copyright 2013-2020 Camunda Services GmbH.
1919
- The Camunda Modeler is Copyright (c) Camunda Services GmbH.
20-
- The Elasticsearch software is Copyright 2009-2018 Elasticsearch.
2120
- The Logstash software is Copyright 2009-2018 Elasticsearch.
2221
- The Bootstrap software has the following copyright holders:
2322
- Copyright (c) 2011-2020 Twitter, Inc.

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ See the [wiki](https://github.com/NASA-AMMOS/common-workflow-service/wiki) for m
1818
- A database for CWS to use. `cws` is a good default.
1919
- A database user with full access to the above database.
2020
- [ITerm2](https://iterm2.com/): Currently these build scripts include commands to open new terminal windows using ITerm2, so they are best run from that terminal.
21-
- **Logstash**: You will need to place the logstash 6.4.2 zip in `install/logging/`. This is a temporary workaround while we clean up our installation process. You can find the zip download [here](https://www.elastic.co/downloads/past-releases/logstash-6-4-2).
21+
- **Logstash 7.9+**: You will need to place the logstash 7.9.0 zip in `install/logging/`. This is a temporary workaround while we clean up our installation process. You can find the zip download [here](https://www.elastic.co/downloads/past-releases/logstash-7-9-0).
22+
- **Elasticsearch 7.9+**: CWS requires an externally-configured elasticsearch cluster to be set up. You can use elasticsearch with or without authentication. Please note that CWS currently only supports basic HTTP authentication.
2223
- Tomcat **keystore and truststore files** (needed for CWS web console to work properly):
2324
- You will need to add your own Tomcat keystore file to the `install/` direcotory
2425
- You will need to add your own truststor file to the `install/tomcat_lib/` directory

create_server_dist.sh

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,10 @@ fi
5959
print 'Copying Logstash zip into place...'
6060
cp ${INSTALL_DIR}/logging/logstash-${LOGSTASH_VER}.zip ${CWS}/server
6161

62-
# -----------------
63-
# ELASTICSEARCH
64-
print 'Copying elasticsearch zip into place...'
65-
cp ${INSTALL_DIR}/elasticsearch/elasticsearch-${ELASTICSEARCH_VER}.zip ${CWS}/server
66-
6762
# MOVE TEMPLATE CONFIG FILES INTO PLACE
6863
print 'Copying configuration templates...'
6964
CONFIG_TEMPLATES_DIR=${CWS}/config/templates
70-
mkdir -p ${CONFIG_TEMPLATES_DIR}/{cws-engine,cws-ui,tomcat_bin,tomcat_lib,tomcat_conf,camunda_mods,engine-rest_mods,elasticsearch,logging}
65+
mkdir -p ${CONFIG_TEMPLATES_DIR}/{cws-engine,cws-ui,tomcat_bin,tomcat_lib,tomcat_conf,camunda_mods,engine-rest_mods,logging}
7166

7267
cp ${INSTALL_DIR}/tomcat_lib/css-jaas.cfg ${CONFIG_TEMPLATES_DIR}/tomcat_lib
7368
cp ${INSTALL_DIR}/tomcat_bin/setenv.sh ${CONFIG_TEMPLATES_DIR}/tomcat_bin
@@ -85,8 +80,6 @@ cp ${INSTALL_DIR}/cws-ui/*.ftl ${CONFIG_TEMPLATES
8580
cp ${INSTALL_DIR}/cws-ui/sqs_dispatcher_thread_bean.xml ${CONFIG_TEMPLATES_DIR}/cws-ui
8681
cp ${INSTALL_DIR}/camunda_mods/web.xml ${CONFIG_TEMPLATES_DIR}/camunda_mods
8782
cp ${INSTALL_DIR}/engine-rest/web.xml ${CONFIG_TEMPLATES_DIR}/engine-rest_mods
88-
cp ${INSTALL_DIR}/elasticsearch/elasticsearch.yml ${CONFIG_TEMPLATES_DIR}/elasticsearch
89-
cp ${INSTALL_DIR}/elasticsearch/jvm.options ${CONFIG_TEMPLATES_DIR}/elasticsearch
9083
cp ${INSTALL_DIR}/logging/cws-logstash.conf ${CONFIG_TEMPLATES_DIR}/logging
9184
cp ${INSTALL_DIR}/refresh_cws_token.sh ${CONFIG_TEMPLATES_DIR}
9285
cp ${INSTALL_DIR}/stop_cws.sh ${CONFIG_TEMPLATES_DIR}
@@ -211,7 +204,6 @@ cp ${INSTALL_DIR}/stop_cws.sh ${CWS}
211204
cp ${INSTALL_DIR}/refresh_cws_token.sh ${CWS}
212205
cp ${INSTALL_DIR}/deploy_proc_def.sh ${CWS}
213206
cp ${INSTALL_DIR}/launch_ls.sh ${CWS}
214-
cp ${INSTALL_DIR}/launch_es.sh ${CWS}
215207

216208
print 'Copying Modeller scripts and libraries...'
217209
cp -R ${INSTALL_DIR}/modeler ${CWS}

cws-core/src/main/java/jpl/cws/core/web/WebUtils.java

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.io.OutputStream;
55
import java.net.HttpURLConnection;
66
import java.net.URL;
7+
import java.util.Base64;
78

89
import javax.net.ssl.HttpsURLConnection;
910
import javax.net.ssl.SSLContext;
@@ -47,16 +48,29 @@ public static RestCallResult restCall(String urlString, String method, String po
4748
return restCall(urlString, method, postData,
4849
null, // cookie
4950
null, // acceptType
50-
null, // contentType
51-
false // allowInsecureRequests
51+
null // contentType
5252
);
5353
}
54+
55+
/**
56+
* Performs an unauthenticated REST call
57+
*/
58+
public static RestCallResult restCall(String urlString, String method, String data, String cookie, String acceptType, String contentType) throws Exception {
59+
return restCall(urlString, method, data, cookie, acceptType, contentType, true, null, null);
60+
}
61+
62+
/**
63+
* Performs an authenticated REST call
64+
*/
65+
public static RestCallResult restCall(String urlString, String method, String data, String cookie, String acceptType, String contentType, String username, String password) throws Exception {
66+
return restCall(urlString, method, data, cookie, acceptType, contentType, false, username, password);
67+
}
5468

5569
/**
5670
* Performs a REST call
5771
*
5872
*/
59-
public static RestCallResult restCall(String urlString, String method, String data, String cookie, String acceptType, String contentType, Boolean allowInsecureRequests) throws Exception {
73+
public static RestCallResult restCall(String urlString, String method, String data, String cookie, String acceptType, String contentType, Boolean allowInsecureRequests, String username, String password) throws Exception {
6074
log.trace("urlString = " + urlString);
6175
HttpURLConnection connection = null;
6276
try {
@@ -72,7 +86,14 @@ else if (rootAndQueryString.length > 2) {
7286

7387
URL url = new URL(urlString);
7488
connection = (HttpURLConnection) url.openConnection();
75-
89+
90+
// Add authentication to request
91+
if (username != null) {
92+
String userpass = username + ":" + password;
93+
String basicAuth = "Basic " + new String(Base64.getEncoder().encode(userpass.getBytes()));
94+
connection.setRequestProperty ("Authorization", basicAuth);
95+
}
96+
7697
if (allowInsecureRequests) {
7798

7899
log.info("SSL 'insecure' mode activated.");
@@ -136,10 +157,10 @@ else if (rootAndQueryString.length > 2) {
136157
out.close();
137158
}
138159
}
139-
160+
140161
// Perform the connection
141162
connection.connect();
142-
163+
143164
int responseCode = -1;
144165
try {
145166
responseCode = connection.getResponseCode();
@@ -149,7 +170,7 @@ else if (rootAndQueryString.length > 2) {
149170
}
150171
if (responseCode == 200) {
151172
log.trace("REST "+method+" for " + url + " was successful (HTTP 200).");
152-
173+
153174
InputStream in = connection.getInputStream();
154175
// FIXME: potential memory suck if response is large
155176
String response = IOUtils.toString(in);
@@ -158,7 +179,7 @@ else if (rootAndQueryString.length > 2) {
158179
}
159180
else {
160181
log.warn("REST " + method + " FAILED for " + url + ". Response code was " + responseCode);
161-
182+
162183
return new RestCallResult(responseCode, null, connection.getResponseMessage());
163184
}
164185
}
@@ -179,8 +200,8 @@ else if (rootAndQueryString.length > 2) {
179200
}
180201
}
181202
}
182-
183-
203+
204+
184205
/**
185206
*
186207
*/

0 commit comments

Comments
 (0)