summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorburdziak <olaf.burdziakowski@nokia.com>2019-07-08 15:47:42 +0200
committerburdziak <olaf.burdziakowski@nokia.com>2019-07-08 15:47:42 +0200
commita3a00c9ada80cc0c0e97f8d4367db35066dfabf8 (patch)
treec0548cd4165dc854b466a0e106a5fb687ae50a40
parent179ff1eb0c1ac9eef4d152c47df5cb12a4584c0f (diff)
Fix sonar issues in OnBoardingApiServiceImpl
Change-Id: I0352a767386746f19413e6420550dc9563bbf255 Issue-ID: PORTAL-523 Signed-off-by: burdziak <olaf.burdziakowski@nokia.com>
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/service/OnBoardingApiServiceImpl.java31
1 files changed, 12 insertions, 19 deletions
diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/service/OnBoardingApiServiceImpl.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/service/OnBoardingApiServiceImpl.java
index e2875125..ae131a05 100644
--- a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/service/OnBoardingApiServiceImpl.java
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/service/OnBoardingApiServiceImpl.java
@@ -37,6 +37,8 @@
*/
package org.onap.portalapp.service;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.type.TypeFactory;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
@@ -45,9 +47,7 @@ import java.util.Map;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
-
import javax.servlet.http.HttpServletRequest;
-
import org.onap.portalsdk.core.auth.LoginStrategy;
import org.onap.portalsdk.core.domain.App;
import org.onap.portalsdk.core.domain.Role;
@@ -72,16 +72,12 @@ import org.onap.portalsdk.core.service.RestApiRequestBuilder;
import org.onap.portalsdk.core.service.RoleService;
import org.onap.portalsdk.core.service.UserProfileService;
import org.onap.portalsdk.core.service.UserService;
-import org.onap.portalsdk.core.service.WebServiceCallService;
import org.onap.portalsdk.core.util.JSONUtil;
import org.onap.portalsdk.core.util.SystemProperties;
import org.onap.portalsdk.core.web.support.UserUtils;
import org.slf4j.MDC;
import org.springframework.context.ApplicationContext;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.type.TypeFactory;
-
/**
* Implements the REST API interface to answer requests made by Portal app about
* users and active sessions.
@@ -95,6 +91,9 @@ public class OnBoardingApiServiceImpl implements IPortalRestAPIService, IPortalR
private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(OnBoardingApiServiceImpl.class);
+ private static final String USER_NAME = "username";
+ private static final String PASSWORD = "password";
+
private RoleService roleService;
private UserProfileService userProfileService;
private IAdminAuthExtension adminAuthExtensionServiceImpl;
@@ -489,25 +488,19 @@ public class OnBoardingApiServiceImpl implements IPortalRestAPIService, IPortalR
}
String appUserName = "";
String appPassword = "";
- String appName = "";
for (Map.Entry<String, String> entry : appCredentials.entrySet()) {
- if (entry.getKey().equalsIgnoreCase("username")) {
+ if (USER_NAME.equalsIgnoreCase(entry.getKey())) {
appUserName = entry.getValue();
- } else if (entry.getKey().equalsIgnoreCase("password")) {
+ } else if (PASSWORD.equalsIgnoreCase(entry.getKey())) {
appPassword = entry.getValue();
- } else {
- appName = entry.getValue();
}
}
try {
- String appUser = request.getHeader("username");
- String password = request.getHeader("password");
- if (password.equals(appPassword) && appUserName.equals(appUser)) {
- return true;
- }
- return false;
+ String appUser = request.getHeader(USER_NAME);
+ String password = request.getHeader(PASSWORD);
+ return password.equals(appPassword) && appUserName.equals(appUser);
} catch (Exception e) {
String response = "OnboardingApiService.isAppAuthenticated failed";
logger.error(EELFLoggerDelegate.errorLogger, response, e);
@@ -550,8 +543,8 @@ public class OnBoardingApiServiceImpl implements IPortalRestAPIService, IPortalR
appUserName = "unknown";
appName = SystemProperties.SDK_NAME;
}
- credentialsMap.put("username", appUserName);
- credentialsMap.put("password", decryptedPwd);
+ credentialsMap.put(USER_NAME, appUserName);
+ credentialsMap.put(PASSWORD, decryptedPwd);
credentialsMap.put("appName", appName);
return credentialsMap;
}