aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/org/onap/dcae/restapi/ApiAuthInterceptor.java
diff options
context:
space:
mode:
authorVijay Venkatesh Kumar <vv770d@att.com>2023-02-03 18:42:28 -0500
committerVijay Venkatesh Kumar <vv770d@att.com>2023-02-03 18:52:24 -0500
commit147999fca04f4c857209ff9594a69ccb2e2754d1 (patch)
tree7dd61925f756806000e6f1a20f4925fa5c57184f /src/main/java/org/onap/dcae/restapi/ApiAuthInterceptor.java
parent952fa4a24a47b648b68f6d86b73e2cc05e044d46 (diff)
VESCollector test additions
Add additional tests for ConfigProcessor and ApiAuthInterceptor Change-Id: Ic8a3debe9bb11997b8aef3dc752017d2b2804b14 Signed-off-by: Vijay Venkatesh Kumar <vv770d@att.com> Issue-ID: DCAEGEN2-3345 Signed-off-by: Vijay Venkatesh Kumar <vv770d@att.com>
Diffstat (limited to 'src/main/java/org/onap/dcae/restapi/ApiAuthInterceptor.java')
-rw-r--r--src/main/java/org/onap/dcae/restapi/ApiAuthInterceptor.java13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/main/java/org/onap/dcae/restapi/ApiAuthInterceptor.java b/src/main/java/org/onap/dcae/restapi/ApiAuthInterceptor.java
index 8c5fb82a..a9f309a3 100644
--- a/src/main/java/org/onap/dcae/restapi/ApiAuthInterceptor.java
+++ b/src/main/java/org/onap/dcae/restapi/ApiAuthInterceptor.java
@@ -3,6 +3,7 @@
* org.onap.dcaegen2.collectors.ves
* ================================================================================
* Copyright (C) 2018 - 2019 Nokia. All rights reserved.
+ * Copyright (C) 2023 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -115,18 +116,18 @@ public class ApiAuthInterceptor extends HandlerInterceptorAdapter {
return false;
}
- private boolean isBasicAuth() {
+ boolean isBasicAuth() {
return settings.authMethod().equalsIgnoreCase(AuthMethodType.CERT_BASIC_AUTH.value());
}
- private boolean isAuthorized(String authorizationHeader) {
+ boolean isAuthorized(String authorizationHeader) {
try {
String decodeCredentials = decodeCredentials(authorizationHeader);
String providedUser = extractUser(decodeCredentials);
String providedPassword = extractPassword(decodeCredentials);
Option<String> maybeSavedPassword = settings.validAuthorizationCredentials().get(providedUser);
boolean userRegistered = maybeSavedPassword.isDefined();
- return userRegistered && cryptPassword.matches(providedPassword,maybeSavedPassword.get());
+ return userRegistered && verifyCryptPassword(providedPassword,maybeSavedPassword);
} catch (Exception e) {
LOG.warn(String.format("Could not check if user is authorized (header: '%s')), probably malformed header.",
authorizationHeader), e);
@@ -134,6 +135,10 @@ public class ApiAuthInterceptor extends HandlerInterceptorAdapter {
}
}
+ Boolean verifyCryptPassword(String providedPassword, Option<String> maybeSavedPassword) {
+ return cryptPassword.matches(providedPassword,maybeSavedPassword.get());
+ }
+
private String extractPassword(String decodeCredentials) {
return decodeCredentials.split(":")[1].trim();
}
@@ -146,4 +151,4 @@ public class ApiAuthInterceptor extends HandlerInterceptorAdapter {
String encodedData = authorizationHeader.split(" ")[1];
return new String(Base64.getDecoder().decode(encodedData));
}
-} \ No newline at end of file
+}