aboutsummaryrefslogtreecommitdiffstats
path: root/reference
diff options
context:
space:
mode:
Diffstat (limited to 'reference')
-rw-r--r--reference/logging-filter/logging-filter-base/src/main/java/org/onap/logging/filter/base/MDCSetup.java2
-rw-r--r--reference/logging-filter/logging-filter-base/src/test/java/org/onap/logging/filter/base/MDCSetupTest.java12
2 files changed, 13 insertions, 1 deletions
diff --git a/reference/logging-filter/logging-filter-base/src/main/java/org/onap/logging/filter/base/MDCSetup.java b/reference/logging-filter/logging-filter-base/src/main/java/org/onap/logging/filter/base/MDCSetup.java
index d0caa46..a900968 100644
--- a/reference/logging-filter/logging-filter-base/src/main/java/org/onap/logging/filter/base/MDCSetup.java
+++ b/reference/logging-filter/logging-filter-base/src/main/java/org/onap/logging/filter/base/MDCSetup.java
@@ -248,7 +248,7 @@ public class MDCSetup {
protected String getBasicAuthUserName(SimpleMap headers) {
String encodedAuthorizationValue = headers.get(HttpHeaders.AUTHORIZATION);
- if (encodedAuthorizationValue != null) {
+ if (encodedAuthorizationValue != null && encodedAuthorizationValue.startsWith("Basic")) {
try {
// This will strip the word Basic and single space
encodedAuthorizationValue = encodedAuthorizationValue.substring(6);
diff --git a/reference/logging-filter/logging-filter-base/src/test/java/org/onap/logging/filter/base/MDCSetupTest.java b/reference/logging-filter/logging-filter-base/src/test/java/org/onap/logging/filter/base/MDCSetupTest.java
index 22ab9c3..bdf8bd0 100644
--- a/reference/logging-filter/logging-filter-base/src/test/java/org/onap/logging/filter/base/MDCSetupTest.java
+++ b/reference/logging-filter/logging-filter-base/src/test/java/org/onap/logging/filter/base/MDCSetupTest.java
@@ -191,6 +191,18 @@ public class MDCSetupTest extends MDCSetup {
}
@Test
+ public void setMDCPartnerNameBearerToken() {
+ MultivaluedMap<String, String> headerMap = new MultivaluedHashMap<>();
+ String value = "Bearer some-compex-token";
+ headerMap.putSingle(HttpHeaders.AUTHORIZATION, value);
+ SimpleMap headers = new SimpleJaxrsHeadersMap(headerMap);
+
+ setMDCPartnerName(headers);
+
+ assertEquals(Constants.DefaultValues.UNKNOWN, MDC.get(ONAPLogConstants.MDCs.PARTNER_NAME));
+ }
+
+ @Test
public void setMDCPartnerNameFromBasicAuth() {
MultivaluedMap<String, String> headerMap = new MultivaluedHashMap<>();
String value = "Basic dXNlcjpwYXNz"; // decodes to user:pass