summaryrefslogtreecommitdiffstats
path: root/sdnr/wt/common
diff options
context:
space:
mode:
Diffstat (limited to 'sdnr/wt/common')
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/ExtRestClient.java55
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/DbFilter.java19
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/queries/QueryBuilders.java14
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseHTTPClient.java9
-rw-r--r--sdnr/wt/common/src/test/resources/testpom.xml6
5 files changed, 46 insertions, 57 deletions
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/ExtRestClient.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/ExtRestClient.java
index f8734d5a6..1f67e5ef8 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/ExtRestClient.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/ExtRestClient.java
@@ -29,10 +29,8 @@ import java.security.UnrecoverableKeyException;
import java.security.cert.CertificateException;
import java.security.spec.InvalidKeySpecException;
import java.text.ParseException;
-
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLSession;
-
import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
@@ -140,57 +138,6 @@ public class ExtRestClient {
}
}
- // private class SSLCercAuthHttpClientConfigCallback implements HttpClientConfigCallback {
- //
- // private final String certFilename;
- //
- // SSLCercAuthHttpClientConfigCallback(String certfile) {
- // this.certFilename = certfile;
- // }
- //
- // @Override
- // public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
- // if (this.certFilename == null) {
- // return httpClientBuilder;
- // }
- //
- // char[] keystorePass = "MY PASSWORD".toCharArray();
- //
- // FileInputStream fis = null;
- //
- // // Loading KEYSTORE in JKS format
- // KeyStore keyStorePci = null;
- // try {
- // keyStorePci = KeyStore.getInstance(KeyStore.getDefaultType());
- // } catch (KeyStoreException e1) {
- // LOG.warn("unable to load keystore: {}",e1);
- // }
- // if (keyStorePci != null) {
- // try {
- // fis = new FileInputStream(this.certFilename);
- // keyStorePci.load(fis, keystorePass);
- // } catch (Exception e) {
- // LOG.error("Error loading keystore: " + this.certFilename);
- // } finally {
- // if (fis != null) {
- // try {
- // fis.close();
- // } catch (IOException e) {
- //
- // }
- // }
- // }
- // }
- // SSLContext sslcontext=null;
- // try {
- // sslcontext = SSLContexts.custom().loadKeyMaterial(keyStorePci, keystorePass).build();
- // } catch (KeyManagementException | UnrecoverableKeyException | NoSuchAlgorithmException
- // | KeyStoreException e) {
- // LOG.warn("unable to load sslcontext: {}",e);
- // }
- // return httpClientBuilder.setSSLContext(sslcontext);
- // }
- // }
private final RestClient client;
private final boolean isES7;
@@ -298,7 +245,7 @@ public class ExtRestClient {
/**
* Search for database entries
- *
+ *
* @param request inputRequest
* @param ignoreParseException especially for usercreated filters which may cause ES server response exceptions
* @return Response with related entries
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/DbFilter.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/DbFilter.java
index 82c036406..70e41c280 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/DbFilter.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/DbFilter.java
@@ -37,9 +37,28 @@ public class DbFilter {
return restFilterValue == null ? false : restFilterValue.contains("*") || restFilterValue.contains("?");
}
+ public static boolean hasSearchParams(List<String> restFilterValues) {
+ for (String restFilterValue : restFilterValues) {
+ if (!hasSearchParams(restFilterValue)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
public static boolean isComparisonValid(String restFilterValue) {
return restFilterValue == null ? false : restFilterValue.contains(">") || restFilterValue.contains("<");
}
+
+ public static boolean isComparisonValid(List<String> restFilterValues) {
+ for (String restFilterValue : restFilterValues) {
+ if (!isComparisonValid(restFilterValue)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
public static boolean isDatetimeKeyValue(String key, String value) {
return timestampValueNames.contains(key.toLowerCase());
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/queries/QueryBuilders.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/queries/QueryBuilders.java
index 7b22fd5e7..582d749d5 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/queries/QueryBuilders.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/queries/QueryBuilders.java
@@ -21,6 +21,7 @@
*/
package org.onap.ccsdk.features.sdnr.wt.common.database.queries;
+import java.util.List;
import org.json.JSONObject;
public class QueryBuilders {
@@ -34,6 +35,11 @@ public class QueryBuilders {
o.put(key, value);
return new QueryBuilder().setQuery("term", o);
}
+ public static QueryBuilder multiTermQuery(String key, List<String> value) {
+ JSONObject o = new JSONObject();
+ o.put(key, value);
+ return new QueryBuilder().setQuery("terms", o);
+ }
public static QueryBuilder matchQuery(String key, Object value) {
JSONObject o = new JSONObject();
@@ -41,6 +47,14 @@ public class QueryBuilders {
return new QueryBuilder().setQuery("match", o);
}
+ public static QueryBuilder matchQuery(String key, List<?> values) {
+ BoolQueryBuilder query = boolQuery();
+ for (Object value : values) {
+ query.should(matchQuery(key, value));
+ }
+ return query;
+ }
+
public static BoolQueryBuilder boolQuery() {
return new BoolQueryBuilder();
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseHTTPClient.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseHTTPClient.java
index 937e2d898..ffb31c676 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseHTTPClient.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseHTTPClient.java
@@ -370,6 +370,15 @@ public class BaseHTTPClient {
return SSLCERT_PEM;
}
+ public static String decodeBasicAuthHeaderUsername(String authHeader) {
+ if(authHeader.startsWith("Basic")) {
+ authHeader = authHeader.substring(6);
+ }
+ final String decoded = new String(Base64.getDecoder().decode(authHeader));
+ String[] tmp = decoded.split(":");
+ return tmp.length > 0 ? tmp[0] : null;
+ }
+
}
diff --git a/sdnr/wt/common/src/test/resources/testpom.xml b/sdnr/wt/common/src/test/resources/testpom.xml
index e57fed436..6fba87af9 100644
--- a/sdnr/wt/common/src/test/resources/testpom.xml
+++ b/sdnr/wt/common/src/test/resources/testpom.xml
@@ -29,13 +29,13 @@
<parent>
<groupId>org.onap.ccsdk.parent</groupId>
<artifactId>binding-parent</artifactId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<relativePath/>
</parent>
<groupId>org.onap.ccsdk.features.sdnr.wt</groupId>
<artifactId>sdnr-wt-common</artifactId>
- <version>1.1.1-SNAPSHOT</version>
+ <version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>ccsdk-features :: ${project.artifactId}</name>
@@ -63,7 +63,7 @@
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
- <artifactId>javax.servlet-api</artifactId>
+ <artifactId>servlet-api</artifactId>
</dependency>
<dependency>
<groupId>org.osgi</groupId>