*/
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;
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;
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.
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;
}
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);
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;
}