diff options
author | 2017-10-04 08:22:43 -0400 | |
---|---|---|
committer | 2017-10-04 08:24:16 -0400 | |
commit | 4031c6ae9074f898e768cbf5ccb5158a59a7072a (patch) | |
tree | 1aa2ff6ce771d6f605f8d4e89db18240623545f2 /ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core | |
parent | 3a2b5c60384feb490e878020bdb9c01f514d7856 (diff) |
Repair redirect; correct javadoc site path
[PORTAL-53] Correct path for deployment of javadoc web site
[PORTAL-78] Prevent SDJ from redirecting multiples times during single signon
[St164634] Tone down the logging when communicating with the Partnering Applications
Add missing license headers; drop FusionLicenseImpl.
Issue: PORTAL-53 PORTAL-78
Change-Id: I3f8200d8e41754ade05e3f7b38d0db6bdd5e59e8
Signed-off-by: Christopher Lott (cl778h) <clott@research.att.com>
Diffstat (limited to 'ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core')
-rw-r--r-- | ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/PortalRestAPIProxy.java | 71 |
1 files changed, 50 insertions, 21 deletions
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 1dec7b7c..1303aad5 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 @@ -104,6 +104,11 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer * Client-supplied class that implements our interface. */ 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 isCentralized = "remote"; + public PortalRestAPIProxy() { // Ensure that any additional fields sent by the Portal @@ -237,11 +242,17 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer // Example: /user <-- create user if (requestUri.endsWith(PortalApiConstants.API_PREFIX + "/user")) { try { - EcompUser user = mapper.readValue(requestBody, EcompUser.class); - pushUser(user); - logger.debug("doPost: pushUser: success"); - responseJson = buildJsonResponse(true, null); - response.setStatus(HttpServletResponse.SC_OK); + if (isCentralized.equals(isAccessCentralized)) { + responseJson = buildJsonResponse(true, errorMessage); + response.setStatus(HttpServletResponse.SC_OK); + } else { + EcompUser user = mapper.readValue(requestBody, EcompUser.class); + pushUser(user); + if (logger.isDebugEnabled()) + logger.debug("doPost: pushUser: success"); + responseJson = buildJsonResponse(true, null); + response.setStatus(HttpServletResponse.SC_OK); + } } catch (Exception ex) { responseJson = buildJsonResponse(ex); response.setStatus(HttpServletResponse.SC_BAD_REQUEST); @@ -252,11 +263,17 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer 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); - editUser(loginId, user); - logger.debug("doPost: editUser: success"); - responseJson = buildJsonResponse(true, null); - response.setStatus(HttpServletResponse.SC_OK); + if (isCentralized.equals(isAccessCentralized)) { + responseJson = buildJsonResponse(true, errorMessage); + response.setStatus(HttpServletResponse.SC_OK); + } else { + EcompUser user = mapper.readValue(requestBody, EcompUser.class); + editUser(loginId, user); + if (logger.isDebugEnabled()) + logger.debug("doPost: editUser: success"); + responseJson = buildJsonResponse(true, null); + response.setStatus(HttpServletResponse.SC_OK); + } } catch (Exception ex) { responseJson = buildJsonResponse(ex); response.setStatus(HttpServletResponse.SC_BAD_REQUEST); @@ -268,13 +285,19 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer String loginId = requestUri.substring(requestUri.indexOf("/user/") + ("/user").length() + 1, requestUri.lastIndexOf('/')); try { - TypeReference<List<EcompRole>> typeRef = new TypeReference<List<EcompRole>>() { - }; - List<EcompRole> roles = mapper.readValue(requestBody, typeRef); - pushUserRole(loginId, roles); - logger.debug("doPost: pushUserRole: success"); - responseJson = buildJsonResponse(true, null); - response.setStatus(HttpServletResponse.SC_OK); + if (isCentralized.equals(isAccessCentralized)) { + responseJson = buildJsonResponse(true, errorMessage); + response.setStatus(HttpServletResponse.SC_OK); + } else { + TypeReference<List<EcompRole>> typeRef = new TypeReference<List<EcompRole>>() { + }; + List<EcompRole> roles = mapper.readValue(requestBody, typeRef); + pushUserRole(loginId, roles); + if (logger.isDebugEnabled()) + logger.debug("doPost: pushUserRole: success"); + responseJson = buildJsonResponse(true, null); + response.setStatus(HttpServletResponse.SC_OK); + } } catch (Exception ex) { responseJson = buildJsonResponse(ex); response.setStatus(HttpServletResponse.SC_BAD_REQUEST); @@ -381,11 +404,11 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer */ if (requestUri.endsWith("/sessionTimeOuts")) { - responseJson = getSessionTimeOuts(); - if (responseJson != null && responseJson.length() > 0) { + try { + responseJson = getSessionTimeOuts(); logger.debug("doGet: got session timeouts"); response.setStatus(HttpServletResponse.SC_OK); - } else { + } catch(Exception ex) { String msg = "Failed to get session time outs"; logger.error("doGet: " + msg); responseJson = buildJsonResponse(false, msg); @@ -400,7 +423,7 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer if (logger.isDebugEnabled()) logger.debug("doGet: getUsers: " + responseJson); } catch (Exception ex) { - responseJson = buildJsonResponse(ex); + responseJson = buildShortJsonResponse(ex); response.setStatus(HttpServletResponse.SC_BAD_REQUEST); logger.error("doGet: getUsers: caught exception", ex); } @@ -610,6 +633,12 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer t.printStackTrace(pw); return buildJsonResponse(false, sw.toString()); } + + private String buildShortJsonResponse(Throwable t) + { + String errorMessage = t.getMessage(); + return buildJsonResponse(false, errorMessage); + } @Override public String getUserId(HttpServletRequest request) throws PortalAPIException { |