diff options
author | 2017-08-21 20:00:50 -0400 | |
---|---|---|
committer | 2017-08-23 17:29:35 +0000 | |
commit | 80f072f60509ef3a35369a60857fe05f6c2a993a (patch) | |
tree | 7dca6266b225be3f192623fdc859ca80f4d1d493 /ONAP-SDK-APP/src/main/java/org/openecomp/portalapp/login | |
parent | c53fa990ea27ec074859eb94bcb7ec6deaa2157b (diff) |
Fixes for sonar critical issues
Fixes for critical and blocker issues reported in sonar.
Issue-Id: POLICY-113
Change-Id: I50969fe93a94b0497f3fb30864a6c45e63208fe6
Signed-off-by: Tej, Tarun <tt3868@att.com>
Diffstat (limited to 'ONAP-SDK-APP/src/main/java/org/openecomp/portalapp/login')
-rw-r--r-- | ONAP-SDK-APP/src/main/java/org/openecomp/portalapp/login/LoginStrategyImpl.java | 107 |
1 files changed, 55 insertions, 52 deletions
diff --git a/ONAP-SDK-APP/src/main/java/org/openecomp/portalapp/login/LoginStrategyImpl.java b/ONAP-SDK-APP/src/main/java/org/openecomp/portalapp/login/LoginStrategyImpl.java index a4b684719..13d8836ea 100644 --- a/ONAP-SDK-APP/src/main/java/org/openecomp/portalapp/login/LoginStrategyImpl.java +++ b/ONAP-SDK-APP/src/main/java/org/openecomp/portalapp/login/LoginStrategyImpl.java @@ -14,60 +14,63 @@ import org.openecomp.portalsdk.core.onboarding.util.PortalApiProperties; import org.springframework.web.servlet.ModelAndView; public class LoginStrategyImpl extends LoginStrategy { - - private static final Logger LOGGER = FlexLogger.getLogger(LoginStrategyImpl.class); - - @Override - public ModelAndView doLogin(HttpServletRequest request, HttpServletResponse response) throws Exception { - //'login' for opensource is same as 'external' login. - return doExternalLogin(request, response); - } - - @Override - public String getUserId(HttpServletRequest request) throws PortalAPIException { - // Check ONAP Portal cookie - if (!isLoginCookieExist(request)) - return null; - String userid = null; - try { - userid = getUserIdFromCookie(request); - } catch (Exception e) { - LOGGER.error("Exception Occured"+e); - } - return userid; - } + private static final Logger LOGGER = FlexLogger.getLogger(LoginStrategyImpl.class); - private static String getUserIdFromCookie(HttpServletRequest request) throws Exception { - String userId = ""; - Cookie[] cookies = request.getCookies(); - Cookie userIdcookie = null; - if (cookies != null) - for (Cookie cookie : cookies) - if (cookie.getName().equals(USER_ID)) - userIdcookie = cookie; - if(userIdcookie!=null){ - userId = CipherUtil.decrypt(userIdcookie.getValue(), - PortalApiProperties.getProperty(PortalApiConstants.Decryption_Key)); - } - return userId; - - } - - private static boolean isLoginCookieExist(HttpServletRequest request) { - Cookie ep = getCookie(request, EP_SERVICE); - return (ep != null); - } - - private static Cookie getCookie(HttpServletRequest request, String cookieName) { - Cookie[] cookies = request.getCookies(); - if (cookies != null) - for (Cookie cookie : cookies) - if (cookie.getName().equals(cookieName)) - return cookie; + @Override + public ModelAndView doLogin(HttpServletRequest request, HttpServletResponse response) throws Exception { + // 'login' for opensource is same as 'external' login. + return doExternalLogin(request, response); + } - return null; - } + @Override + public String getUserId(HttpServletRequest request) throws PortalAPIException { + // Check ONAP Portal cookie + if (!isLoginCookieExist(request)) + return null; + + String userid = null; + try { + userid = getUserIdFromCookie(request); + } catch (Exception e) { + LOGGER.error("Exception Occured" + e); + } + return userid; + } + + private static String getUserIdFromCookie(HttpServletRequest request) throws PortalAPIException { + String userId = ""; + Cookie[] cookies = request.getCookies(); + Cookie userIdcookie = null; + if (cookies != null) + for (Cookie cookie : cookies) + if (cookie.getName().equals(USER_ID)) + userIdcookie = cookie; + if (userIdcookie != null) { + try { + userId = CipherUtil.decrypt(userIdcookie.getValue(), + PortalApiProperties.getProperty(PortalApiConstants.Decryption_Key)); + } catch (Exception e) { + throw new PortalAPIException(e); + } + } + return userId; + + } + + private static boolean isLoginCookieExist(HttpServletRequest request) { + Cookie ep = getCookie(request, EP_SERVICE); + return (ep != null); + } + + private static Cookie getCookie(HttpServletRequest request, String cookieName) { + Cookie[] cookies = request.getCookies(); + if (cookies != null) + for (Cookie cookie : cookies) + if (cookie.getName().equals(cookieName)) + return cookie; + + return null; + } - } |