diff options
author | 2019-07-29 11:41:36 -0400 | |
---|---|---|
committer | 2019-07-30 13:35:33 -0400 | |
commit | 19087734d0cd4d7e7c892490a795b01e93ba00d0 (patch) | |
tree | dc18fcd42374b9c74098b09f20ca99245b13bad5 /ecomp-sdk/epsdk-fw/src/main/java | |
parent | 69d4e12be832b560ed5ee1bb84a4ab3b0855310f (diff) |
Publish fixed strings as public constants
Change-Id: I47c8458a0f16251ef19043eb63cf5f392990efdf
Issue-ID: PORTAL-657
Signed-off-by: Lott, Christopher (cl778h) <cl778h@att.com>
Diffstat (limited to 'ecomp-sdk/epsdk-fw/src/main/java')
9 files changed, 86 insertions, 78 deletions
diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/IPortalRestAPIService.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/IPortalRestAPIService.java index c707d137..0c445bd3 100644 --- a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/IPortalRestAPIService.java +++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/IPortalRestAPIService.java @@ -172,6 +172,8 @@ public interface IPortalRestAPIService { * * @param request * HttpServletRequest + * @param appCredentials + * Map with app name, user name, password * @return true if the request contains appropriate credentials, else false. * @throws PortalAPIException * If an unexpected error occurs while processing the request. diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/IPortalRestCentralService.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/IPortalRestCentralService.java index 87b460e3..2d35a9f9 100644 --- a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/IPortalRestCentralService.java +++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/IPortalRestCentralService.java @@ -46,13 +46,22 @@ import org.onap.portalsdk.core.restful.domain.EcompUser; public interface IPortalRestCentralService { + public static final String CREDENTIALS_APP = "appName"; + public static final String CREDENTIALS_USER = "username"; + public static final String CREDENTIALS_PASS = "password"; + public static final String CREDENTIALS_UEB = "uebkey"; + /** * Gets and returns the Map with username, password and appName of application .If any error * occurs, the method should throw PortalApiException with an appropriate * message. The FW library will catch the exception and send an appropriate * response to Portal. * - * @return a map with keys username, password and appName + * @return a map with keys {@link IPortalRestCentralService#CREDENTIALS_APP}, + * {@link IPortalRestCentralService#CREDENTIALS_USER}, and + * {@link IPortalRestCentralService#CREDENTIALS_PASS}, + * @throws PortalAPIException + * If any error occurs */ public Map<String, String> getAppCredentials() throws PortalAPIException; diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/PortalRestAPICentralServiceImpl.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/PortalRestAPICentralServiceImpl.java index 27e90221..54ce2f4f 100644 --- a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/PortalRestAPICentralServiceImpl.java +++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/PortalRestAPICentralServiceImpl.java @@ -81,9 +81,9 @@ public class PortalRestAPICentralServiceImpl implements IPortalRestAPIService { try { Class<?> centralImplClass = Class.forName(centralClassName); portalRestCentralService = (IPortalRestCentralService) (centralImplClass.getConstructor().newInstance()); - username = portalRestCentralService.getAppCredentials().get("username"); - password = portalRestCentralService.getAppCredentials().get("password"); - appName = portalRestCentralService.getAppCredentials().get("appName"); + username = portalRestCentralService.getAppCredentials().get(IPortalRestCentralService.CREDENTIALS_USER); + password = portalRestCentralService.getAppCredentials().get(IPortalRestCentralService.CREDENTIALS_PASS); + appName = portalRestCentralService.getAppCredentials().get(IPortalRestCentralService.CREDENTIALS_APP); } catch (Exception e) { throw new ClassCastException("Failed to find or instantiate class "); } @@ -205,9 +205,9 @@ public class PortalRestAPICentralServiceImpl implements IPortalRestAPIService { public Map<String, String> getCredentials() throws PortalAPIException{ Map<String, String> credentialsMap = new HashMap<>(); - credentialsMap.put("username", username); - credentialsMap.put("password", password); - credentialsMap.put("appName", appName); + credentialsMap.put(IPortalRestCentralService.CREDENTIALS_USER, username); + credentialsMap.put(IPortalRestCentralService.CREDENTIALS_PASS, password); + credentialsMap.put(IPortalRestCentralService.CREDENTIALS_APP, appName); return credentialsMap; } diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/PortalRestAPIProxy.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/PortalRestAPIProxy.java index 29095970..15f0d664 100644 --- a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/PortalRestAPIProxy.java +++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/PortalRestAPIProxy.java @@ -95,7 +95,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; @WebServlet(urlPatterns = { PortalApiConstants.API_PREFIX + "/*" }) public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPIService { - + private static final long serialVersionUID = 1L; private static final String APPLICATION_JSON = "application/json"; @@ -113,10 +113,9 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer private static IPortalRestAPIService portalRestApiServiceImpl; private static final String isAccessCentralized = PortalApiProperties .getProperty(PortalApiConstants.ROLE_ACCESS_CENTRALIZED); - private static final String errorMessage = "Access Management is not allowed for Centralized applications." ; + private static final String errorMessage = "Access Management is not allowed for Centralized applications."; private static final String isCentralized = "remote"; - public PortalRestAPIProxy() { // Ensure that any additional fields sent by the Portal // will be ignored when creating objects. @@ -135,7 +134,7 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer if (!isCentralized.equals(isAccessCentralized)) portalRestApiServiceImpl = (IPortalRestAPIService) (implClass.getConstructor().newInstance()); else { - portalRestApiServiceImpl = new PortalRestAPICentralServiceImpl(); + portalRestApiServiceImpl = new PortalRestAPICentralServiceImpl(); } } catch (Exception ex) { throw new ServletException("init: Failed to find or instantiate class " + className, ex); @@ -152,8 +151,7 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer response.getWriter().write(buildJsonResponse(false, "Misconfigured - no instance of service class")); return; } - - + String requestUri = request.getRequestURI(); String responseJson = ""; String storeAnalyticsContextPath = "/storeAnalytics"; @@ -178,15 +176,15 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer for (Map.Entry<String, String> entry : getCredentials().entrySet()) { - if (entry.getKey().equalsIgnoreCase("username")) { + if (entry.getKey().equalsIgnoreCase(IPortalRestCentralService.CREDENTIALS_USER)) { appUserName = entry.getValue(); - } else if (entry.getKey().equalsIgnoreCase("password")) { + } else if (entry.getKey().equalsIgnoreCase(IPortalRestCentralService.CREDENTIALS_PASS)) { appPassword = entry.getValue(); } else { appName = entry.getValue(); } } - + String credential = PortalApiProperties.getProperty(PortalApiConstants.UEB_APP_KEY); // for now lets also pass uebkey as user name and password String requestBody = readRequestBody(request); @@ -195,7 +193,7 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer // add user ID bodyMap.put("userid", userId); requestBody = mapper.writeValueAsString(bodyMap); - logger.debug("doPost: StoreAnalytics requestbody: "+ requestBody); + logger.debug("doPost: StoreAnalytics requestbody: " + requestBody); responseJson = RestWebServiceClient.getInstance().postPortalContent(storeAnalyticsContextPath, userId, appName, null, appUserName, appPassword, "application/json", requestBody, true); logger.debug("doPost: postPortalContent returns " + responseJson); @@ -225,7 +223,6 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer writeAndFlush(response, APPLICATION_JSON, buildJsonResponse(false, "Not authorized")); return; } - try { String requestBody = readRequestBody(request); @@ -273,7 +270,7 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer if (requestUri.endsWith(PortalApiConstants.API_PREFIX + "/user")) { try { EcompUser user = mapper.readValue(requestBody, EcompUser.class); - logger.debug("doPost: create user requestbody: "+ requestBody); + logger.debug("doPost: create user requestbody: " + requestBody); Set<EcompRole> userEcompRoles = getEcompRolesOfUser(user); user.setRoles(userEcompRoles); pushUser(user); @@ -282,17 +279,17 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer responseJson = buildJsonResponse(true, "user saved successfully"); response.setStatus(HttpServletResponse.SC_OK); } catch (Exception ex) { - responseJson = buildShortJsonResponse(ex); + responseJson = buildShortJsonResponse(ex); response.setStatus(HttpServletResponse.SC_BAD_REQUEST); logger.error("doPost: pushUser: caught exception", ex); } } else - // Example: /user/abc <-- edit user abc + // Example: /user/abc <-- edit user abc if (requestUri.contains(PortalApiConstants.API_PREFIX + "/user/") && !(requestUri.endsWith("/roles"))) { String loginId = requestUri.substring(requestUri.lastIndexOf('/') + 1); try { EcompUser user = mapper.readValue(requestBody, EcompUser.class); - logger.debug("doPost: update user requestbody: "+ requestBody); + logger.debug("doPost: update user requestbody: " + requestBody); Set<EcompRole> userEcompRoles = getEcompRolesOfUser(user); user.setRoles(userEcompRoles); editUser(loginId, user); @@ -301,7 +298,7 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer responseJson = buildJsonResponse(true, "user saved successfully"); response.setStatus(HttpServletResponse.SC_OK); } catch (Exception ex) { - responseJson = buildShortJsonResponse(ex); + responseJson = buildShortJsonResponse(ex); response.setStatus(HttpServletResponse.SC_BAD_REQUEST); logger.error("doPost: editUser: caught exception", ex); } @@ -331,7 +328,7 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer } } else { String msg = "doPost: no match for request " + requestUri; - logger.warn( ESAPI.encoder().encodeForHTML(msg)); + logger.warn(ESAPI.encoder().encodeForHTML(msg)); responseJson = buildJsonResponse(false, msg); response.setStatus(HttpServletResponse.SC_BAD_REQUEST); } @@ -357,7 +354,6 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer buildJsonResponse(false, "Misconfigured - no instance of service class")); return; } - String requestUri = request.getRequestURI(); String contentType = APPLICATION_JSON; @@ -384,9 +380,9 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer for (Map.Entry<String, String> entry : getCredentials().entrySet()) { - if (entry.getKey().equalsIgnoreCase("username")) { + if (entry.getKey().equalsIgnoreCase(IPortalRestCentralService.CREDENTIALS_USER)) { appUserName = entry.getValue(); - } else if (entry.getKey().equalsIgnoreCase("password")) { + } else if (entry.getKey().equalsIgnoreCase(IPortalRestCentralService.CREDENTIALS_PASS)) { appPassword = entry.getValue(); } else { appName = entry.getValue(); @@ -398,7 +394,7 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer responseString = RestWebServiceClient.getInstance().getPortalContent(webAnalyticsContextPath, userId, appName, null, appUserName, appPassword, true); - + if (logger.isDebugEnabled()) logger.debug("doGet: " + webAnalyticsContextPath + ": " + responseString); response.setStatus(HttpServletResponse.SC_OK); @@ -445,14 +441,14 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer */ if (requestUri.endsWith("/sessionTimeOuts")) { - try { + try { responseJson = getSessionTimeOuts(); logger.debug("doGet: got session timeouts"); response.setStatus(HttpServletResponse.SC_OK); - } catch(Exception ex) { + } catch (Exception ex) { String msg = "Failed to get session time outs"; logger.error("doGet: " + msg); - responseJson = buildShortJsonResponse(ex); + responseJson = buildShortJsonResponse(ex); response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } } else @@ -478,7 +474,7 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer if (logger.isDebugEnabled()) logger.debug("doGet: getAvailableRoles: " + responseJson); } catch (Exception ex) { - responseJson = buildShortJsonResponse(ex); + responseJson = buildShortJsonResponse(ex); response.setStatus(HttpServletResponse.SC_BAD_REQUEST); logger.error("doGet: getAvailableRoles: caught exception", ex); } @@ -492,7 +488,7 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer if (logger.isDebugEnabled()) logger.debug("doGet: getUser: " + responseJson); } catch (Exception ex) { - responseJson = buildShortJsonResponse(ex); + responseJson = buildShortJsonResponse(ex); response.setStatus(HttpServletResponse.SC_BAD_REQUEST); logger.error("doGet: getUser: caught exception", ex); } @@ -511,8 +507,7 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer response.setStatus(HttpServletResponse.SC_BAD_REQUEST); logger.error("doGet: getUserRoles: caught exception", ex); } - } - else { + } else { logger.warn("doGet: no match found for request"); responseJson = buildJsonResponse(false, "No match for request"); response.setStatus(HttpServletResponse.SC_BAD_REQUEST); @@ -573,7 +568,8 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer } @Override - public boolean isAppAuthenticated(HttpServletRequest request, Map<String,String> appCredentials) throws PortalAPIException { + public boolean isAppAuthenticated(HttpServletRequest request, Map<String, String> appCredentials) + throws PortalAPIException { return portalRestApiServiceImpl.isAppAuthenticated(request, appCredentials); } @@ -605,22 +601,22 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer String body = null; StringBuilder stringBuilder = new StringBuilder(); - try(InputStream inputStream = request.getInputStream()) { + try (InputStream inputStream = request.getInputStream()) { if (inputStream != null) { - try(BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));){ + try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));) { char[] charBuffer = new char[1024]; int bytesRead = -1; while ((bytesRead = bufferedReader.read(charBuffer)) > 0) { stringBuilder.append(charBuffer, 0, bytesRead); } - } catch(IOException e) { + } catch (IOException e) { logger.error("readRequestBody", e); throw e; } } else { stringBuilder.append(""); } - } catch(IOException e) { + } catch (IOException e) { logger.error("readRequestBody", e); throw e; } @@ -632,9 +628,10 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer * Builds JSON object with status + message response body. * * @param success - * True to indicate success, false to signal failure. + * True to indicate success, false to signal failure. * @param msg - * Message to include in the response object; ignored if null. + * Message to include in the response object; ignored if + * null. * @return * * <pre> @@ -659,7 +656,7 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer * for the specified throwable. * * @param t - * Throwable with stack trace to use as message + * Throwable with stack trace to use as message * * @return * @@ -673,9 +670,8 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer t.printStackTrace(pw); return buildJsonResponse(false, sw.toString()); } - - private String buildShortJsonResponse(Throwable t) - { + + private String buildShortJsonResponse(Throwable t) { String errorMessage = t.getMessage(); return buildJsonResponse(false, errorMessage); } @@ -692,15 +688,14 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer public static void setPortalRestApiServiceImpl(IPortalRestAPIService portalRestApiServiceImpl) { PortalRestAPIProxy.portalRestApiServiceImpl = portalRestApiServiceImpl; } - + @Override - public Map<String, String> getCredentials() throws PortalAPIException { + public Map<String, String> getCredentials() throws PortalAPIException { return portalRestApiServiceImpl.getCredentials(); } - private Set<EcompRole> getEcompRolesOfUser(EcompUser user) throws JsonProcessingException - { - + private Set<EcompRole> getEcompRolesOfUser(EcompUser user) throws JsonProcessingException { + Set<EcompRole> userEcompRoles = new TreeSet<>(); Set<EcompRole> ecompRoles = user.getRoles(); for (EcompRole role : ecompRoles) { @@ -715,7 +710,7 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer Map<String, String> result = Arrays.stream(str1.split(",")).map(s -> s.split(":")) .collect(Collectors.toMap(a -> a[0], // key a -> a[1] // value - )); + )); EcompRoleFunction roleFunction = new EcompRoleFunction(); for (Map.Entry<String, String> set : result.entrySet()) { diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/SessionCommunicationService.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/SessionCommunicationService.java index 847707bc..3a886af6 100644 --- a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/SessionCommunicationService.java +++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/SessionCommunicationService.java @@ -79,9 +79,9 @@ public class SessionCommunicationService { con.setConnectTimeout(3000); con.setReadTimeout(8000); // add request header - con.setRequestProperty("username", userName); - con.setRequestProperty("password", password); - con.setRequestProperty("uebkey", uebKey); + con.setRequestProperty(IPortalRestCentralService.CREDENTIALS_USER, userName); + con.setRequestProperty(IPortalRestCentralService.CREDENTIALS_PASS, password); + con.setRequestProperty(IPortalRestCentralService.CREDENTIALS_UEB, uebKey); String encoding = Base64.getEncoder().encodeToString((userName + ":" + password).getBytes()); con.setRequestProperty("Authorization", "Basic " + encoding); @@ -138,9 +138,9 @@ public class SessionCommunicationService { con.setReadTimeout(15000); // add request header - con.setRequestProperty("username", userName); - con.setRequestProperty("password", password); - con.setRequestProperty("uebkey", uebKey); + con.setRequestProperty(IPortalRestCentralService.CREDENTIALS_USER, userName); + con.setRequestProperty(IPortalRestCentralService.CREDENTIALS_PASS, password); + con.setRequestProperty(IPortalRestCentralService.CREDENTIALS_UEB, uebKey); con.setRequestProperty("sessionMap", sessionTimeoutMap); String encoding = Base64.getEncoder().encodeToString((userName + ":" + password).getBytes()); diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/rest/RestWebServiceClient.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/rest/RestWebServiceClient.java index a5608746..dce26752 100644 --- a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/rest/RestWebServiceClient.java +++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/rest/RestWebServiceClient.java @@ -47,6 +47,7 @@ import java.util.UUID; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.onap.portalsdk.core.onboarding.crossapi.IPortalRestCentralService; import org.onap.portalsdk.core.onboarding.util.PortalApiConstants; import org.onap.portalsdk.core.onboarding.util.PortalApiProperties; import org.owasp.esapi.ESAPI; @@ -216,8 +217,8 @@ public class RestWebServiceClient { con.setRequestProperty("user-agent", appName); con.setRequestProperty("X-ECOMP-RequestID", requestId); logger.debug("Post: X-ECOMP-RequestID: "+ requestId); - con.setRequestProperty("username", appUserName); - con.setRequestProperty("password", appPassword); + con.setRequestProperty(IPortalRestCentralService.CREDENTIALS_USER, appUserName); + con.setRequestProperty(IPortalRestCentralService.CREDENTIALS_PASS, appPassword); if (useBasicAuth) { String encoding = Base64.getEncoder().encodeToString((appUserName + ":" + appPassword).getBytes()); con.setRequestProperty("Authorization", "Basic " + encoding); @@ -348,11 +349,11 @@ public class RestWebServiceClient { Integer.parseInt(PortalApiProperties.getProperty(PortalApiConstants.EXT_REQUEST_READ_TIMEOUT))); // add request header - con.setRequestProperty("uebkey", appUebKey); + con.setRequestProperty(IPortalRestCentralService.CREDENTIALS_UEB, appUebKey); if (appUserName != null) - con.setRequestProperty("username", appUserName); + con.setRequestProperty(IPortalRestCentralService.CREDENTIALS_USER, appUserName); if (appPassword != null) - con.setRequestProperty("password", appPassword); + con.setRequestProperty(IPortalRestCentralService.CREDENTIALS_PASS, appPassword); con.setRequestProperty("LoginId", loginId); con.setRequestProperty("user-agent", appName); con.setRequestProperty("X-ECOMP-RequestID", requestId); @@ -490,11 +491,11 @@ public class RestWebServiceClient { Integer.parseInt(PortalApiProperties.getProperty(PortalApiConstants.EXT_REQUEST_READ_TIMEOUT))); // add request header - con.setRequestProperty("uebkey", appUebKey); + con.setRequestProperty(IPortalRestCentralService.CREDENTIALS_UEB, appUebKey); if (appUserName != null) - con.setRequestProperty("username", appUserName); + con.setRequestProperty(IPortalRestCentralService.CREDENTIALS_USER, appUserName); if (appPassword != null) - con.setRequestProperty("password", appPassword); + con.setRequestProperty(IPortalRestCentralService.CREDENTIALS_PASS, appPassword); con.setRequestProperty("LoginId", loginId); con.setRequestProperty("user-agent", appName); con.setRequestProperty("X-ECOMP-RequestID", requestId); diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/AuthUtil.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/AuthUtil.java index dc49933e..ac310805 100644 --- a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/AuthUtil.java +++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/AuthUtil.java @@ -53,6 +53,7 @@ import org.apache.commons.logging.LogFactory; import org.onap.aaf.cadi.CadiWrap; import org.onap.aaf.cadi.Permission; import org.onap.aaf.cadi.aaf.AAFPermission; +import org.onap.portalsdk.core.onboarding.crossapi.IPortalRestCentralService; import org.onap.portalsdk.core.onboarding.exception.PortalAPIException; public class AuthUtil { @@ -215,9 +216,9 @@ public class AuthUtil { String appName = ""; for (Map.Entry<String, String> entry : appCredentials.entrySet()) { - if (entry.getKey().equalsIgnoreCase("username")) { + if (entry.getKey().equalsIgnoreCase(IPortalRestCentralService.CREDENTIALS_USER)) { appUserName = entry.getValue(); - } else if (entry.getKey().equalsIgnoreCase("password")) { + } else if (entry.getKey().equalsIgnoreCase(IPortalRestCentralService.CREDENTIALS_PASS)) { appPassword = entry.getValue(); } else { appName = entry.getValue(); @@ -225,8 +226,8 @@ public class AuthUtil { } try { - String appUser = request.getHeader("username"); - String password = request.getHeader("password"); + String appUser = request.getHeader(IPortalRestCentralService.CREDENTIALS_USER); + String password = request.getHeader(IPortalRestCentralService.CREDENTIALS_PASS); if (password.equals(appPassword) && appUserName.equals(appUser)) { isauthorized = true; diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/KeyProperties.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/KeyProperties.java index 6fa35372..28ada258 100644 --- a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/KeyProperties.java +++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/KeyProperties.java @@ -57,7 +57,7 @@ public class KeyProperties { private static final Log logger = LogFactory.getLog(KeyProperties.class); private static Properties properties; - private static String propertyFileName = "key.properties"; + public static final String PROPERTY_FILE_NAME = "key.properties"; private static final Object lockObject = new Object(); @@ -81,11 +81,11 @@ public class KeyProperties { synchronized (lockObject) { try { if (!initialize()) { - logger.error("Failed to read property file " + propertyFileName); + logger.error("Failed to read property file " + PROPERTY_FILE_NAME); return null; } } catch (IOException e) { - logger.error("Failed to read property file " + propertyFileName, e); + logger.error("Failed to read property file " + PROPERTY_FILE_NAME, e); return null; } } @@ -109,7 +109,7 @@ public class KeyProperties { private static boolean initialize() throws IOException { if (properties != null) return true; - InputStream in = KeyProperties.class.getClassLoader().getResourceAsStream(propertyFileName); + InputStream in = KeyProperties.class.getClassLoader().getResourceAsStream(PROPERTY_FILE_NAME); if (in == null) return false; properties = new Properties(); diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/PortalApiProperties.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/PortalApiProperties.java index aba57e44..501d35ca 100644 --- a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/PortalApiProperties.java +++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/PortalApiProperties.java @@ -58,7 +58,7 @@ public class PortalApiProperties { private static final Log logger = LogFactory.getLog(PortalApiProperties.class); private static Properties properties; - private static String propertyFileName = "portal.properties"; + public static final String PROPERTY_FILE_NAME = "portal.properties"; private static final Object lockObject = new Object(); @@ -82,11 +82,11 @@ public class PortalApiProperties { synchronized (lockObject) { try { if (!initialize()) { - logger.error("Failed to read property file " + propertyFileName); + logger.error("Failed to read property file " + PROPERTY_FILE_NAME); return null; } } catch (IOException e) { - logger.error("Failed to read property file " + propertyFileName, e); + logger.error("Failed to read property file " + PROPERTY_FILE_NAME, e); return null; } } @@ -110,7 +110,7 @@ public class PortalApiProperties { public static boolean initialize() throws IOException { if (properties != null) return true; - InputStream in = PortalApiProperties.class.getClassLoader().getResourceAsStream(propertyFileName); + InputStream in = PortalApiProperties.class.getClassLoader().getResourceAsStream(PROPERTY_FILE_NAME); if (in == null) return false; properties = new Properties(); |