OpenIdConnectLoginStrategy sonar issues fix 85/90285/1
authorDominik Mizyn <d.mizyn@samsung.com>
Fri, 21 Jun 2019 09:31:35 +0000 (11:31 +0200)
committerDominik Mizyn <d.mizyn@samsung.com>
Fri, 21 Jun 2019 09:31:43 +0000 (11:31 +0200)
Redundant suppression("rawtypes") removed.
Sonar issue:
Move the "" string literal on the left side of this string comparison.
Define and throw a dedicated exception instead of using a generic one.

Issue-ID: PORTAL-649
Change-Id: Ia2c80ad4848c22c94a2db731425250784d382841
Signed-off-by: Dominik Mizyn <d.mizyn@samsung.com>
ecomp-portal-BE-os/src/main/java/org/onap/portalapp/authentication/OpenIdConnectLoginStrategy.java

index 4306d1f..456f001 100644 (file)
@@ -55,12 +55,9 @@ import org.springframework.util.StringUtils;
 import org.springframework.web.servlet.ModelAndView;
 
 public class OpenIdConnectLoginStrategy extends org.onap.portalsdk.core.auth.LoginStrategy implements org.onap.portalapp.authentication.LoginStrategy {
-       
-       private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(OpenIdConnectLoginStrategy.class);
-       
+       private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(OpenIdConnectLoginStrategy.class);
        private static final String GLOBAL_LOCATION_KEY = "Location";
 
-       @SuppressWarnings("rawtypes")
        public boolean login(HttpServletRequest request, HttpServletResponse response) throws Exception{
                
                logger.info("Attempting Login");                                                                                                
@@ -93,7 +90,7 @@ public class OpenIdConnectLoginStrategy extends org.onap.portalsdk.core.auth.Log
                                String loginUrl = SystemProperties.getProperty(EPSystemProperties.LOGIN_URL_NO_RET_VAL);
                                logger.info(EELFLoggerDelegate.errorLogger, "Authentication Mechanism: '" + authentication + "'.");
                                
-                               if (authentication == null || authentication.equals("") || authentication.trim().equals("OIDC")) {                              
+                               if (authentication == null || "".equals(authentication) || "OIDC".equals(authentication.trim())) {
                                    response.sendRedirect("oid-login");
                                } else {
                                        logger.info(EELFLoggerDelegate.errorLogger, "No cookies are found, redirecting the request to '" + loginUrl + "'.");
@@ -108,10 +105,10 @@ public class OpenIdConnectLoginStrategy extends org.onap.portalsdk.core.auth.Log
        }
 
        @Override
-       public ModelAndView doLogin(HttpServletRequest request, HttpServletResponse response) throws Exception {
+       public ModelAndView doLogin(HttpServletRequest request, HttpServletResponse response) throws PortalAPIException {
                String message = "Method not implmented; Cannot be called";
                logger.error(EELFLoggerDelegate.errorLogger, message);
-               throw new Exception(message);
+               throw new PortalAPIException(message);
        }
 
        @Override