Remove code smells in dashboard 39/2639/4
authorelinuxhenrik <henrik.b.andersson@est.tech>
Tue, 3 Mar 2020 16:00:20 +0000 (17:00 +0100)
committerelinuxhenrik <henrik.b.andersson@est.tech>
Wed, 4 Mar 2020 07:15:27 +0000 (08:15 +0100)
Change-Id: I0478cbf0a45aea9a646fe028838f323e425effaf
Issue-ID: NONRTRIC-142
Signed-off-by: elinuxhenrik <henrik.b.andersson@est.tech>
18 files changed:
dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/DashboardApplication.java
dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/DashboardUserManager.java
dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/SpringContextCache.java
dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/WebSecurityConfiguration.java
dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/Html5PathsController.java
dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/PolicyController.java
dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/SimpleErrorController.java
dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/model/EcompUserDetails.java
dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/policyagentapi/PolicyAgentApi.java
dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/policyagentapi/PolicyAgentApiImpl.java
dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/portalapi/PortalAuthManager.java
dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/portalapi/PortalAuthenticationFilter.java
dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/portalapi/PortalRestCentralServiceImpl.java
dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/portalapi/PortalSdkDecryptorAes.java
dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/util/HttpsURLConnectionUtils.java
dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/DashboardTestServer.java
dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/PolicyControllerMockConfiguration.java
dashboard/webapp-frontend/src/app/navigation/sidenav-list/sidenav-list.component.html

index 2550b8e..b492ebd 100644 (file)
@@ -20,7 +20,6 @@
 
 package org.oransc.ric.portal.dashboard;
 
-import java.io.IOException;
 import java.lang.invoke.MethodHandles;
 
 import org.slf4j.Logger;
@@ -36,8 +35,8 @@ public class DashboardApplication {
 
     private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
-    public static void main(String[] args) throws IOException {
-        SpringApplication.run(DashboardApplication.class, args);
+    public static void main(String[] args) {
+        SpringApplication.run(DashboardApplication.class);
         // Ensure this appears on the console by using level WARN
         logger.warn("main: version '{}' successful start",
             getImplementationVersion(MethodHandles.lookup().lookupClass()));
index ffb7396..ee5f3e1 100644 (file)
  */
 package org.oransc.ric.portal.dashboard;
 
-import com.fasterxml.jackson.core.JsonGenerationException;
 import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.JsonMappingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
 
 import java.io.File;
 import java.io.IOException;
 import java.lang.invoke.MethodHandles;
+import java.nio.file.Files;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
@@ -42,8 +41,6 @@ import org.slf4j.LoggerFactory;
  * Provides simple user-management services.
  *
  * This first implementation serializes user details to a file.
- *
- * TODO: migrate to a database.
  */
 public class DashboardUserManager {
 
@@ -70,7 +67,7 @@ public class DashboardUserManager {
             logger.debug("ctor: removing file {}", userFile.getAbsolutePath());
             File f = new File(DashboardUserManager.USER_FILE_PATH);
             if (f.exists())
-                f.delete();
+                Files.delete(f.toPath());
             users.clear();
         }
     }
@@ -124,7 +121,7 @@ public class DashboardUserManager {
         return null;
     }
 
-    private void saveUsers() throws JsonGenerationException, JsonMappingException, IOException {
+    private void saveUsers() throws IOException {
         final ObjectMapper mapper = new ObjectMapper();
         mapper.writeValue(userFile, users);
     }
@@ -133,7 +130,9 @@ public class DashboardUserManager {
      * Allow at most one thread to create a user at one time.
      */
     public synchronized void createUser(EcompUser user) throws PortalAPIException {
-        logger.debug("createUser: loginId is " + user.getLoginId());
+        if (logger.isDebugEnabled()) {
+            logger.debug("createUser: loginId is {}", user.getLoginId());
+        }
         if (users.contains(user))
             throw new PortalAPIException("User exists: " + user.getLoginId());
         users.add(user);
@@ -149,7 +148,7 @@ public class DashboardUserManager {
      * last-edit-wins of course.
      */
     public synchronized void updateUser(String loginId, EcompUser user) throws PortalAPIException {
-        logger.debug("editUser: loginId is " + loginId);
+        logger.debug("editUser: loginId is {}", loginId);
         int index = users.indexOf(user);
         if (index < 0)
             throw new PortalAPIException("User does not exist: " + user.getLoginId());
index a2f3d8f..aaf4665 100644 (file)
@@ -7,9 +7,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -19,7 +19,6 @@
  */
 package org.oransc.ric.portal.dashboard.config;
 
-import org.springframework.beans.BeansException;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.ApplicationContextAware;
 import org.springframework.stereotype.Component;
@@ -30,14 +29,14 @@ import org.springframework.stereotype.Component;
 @Component
 public class SpringContextCache implements ApplicationContextAware {
 
-    private static ApplicationContext applicationContext = null;
+    private ApplicationContext applicationContext = null;
 
     @Override
-    public void setApplicationContext(final ApplicationContext appContext) throws BeansException {
+    public void setApplicationContext(final ApplicationContext appContext) {
         applicationContext = appContext;
     }
 
-    public static ApplicationContext getApplicationContext() {
+    public ApplicationContext getApplicationContext() {
         return applicationContext;
     }
 
index b43f8a9..e70b612 100644 (file)
@@ -85,7 +85,8 @@ public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter {
      * Resource paths that do not require authentication, especially including
      * Swagger-generated documentation.
      */
-    public static final String[] OPEN_PATHS = { //
+    @SuppressWarnings("squid:S1075")
+    protected static final String[] OPEN_PATHS = { //
         "/v2/api-docs", //
         "/swagger-resources/**", //
         "/swagger-ui.html", //
@@ -101,9 +102,8 @@ public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter {
     }
 
     @Bean
-    public PortalAuthManager portalAuthManagerBean()
-        throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException,
-        IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
+    public PortalAuthManager portalAuthManagerBean() throws ClassNotFoundException, InstantiationException,
+        IllegalAccessException, InvocationTargetException, NoSuchMethodException {
         return new PortalAuthManager(appName, userName, password, decryptor, userCookie);
     }
 
@@ -116,12 +116,9 @@ public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter {
      * bypass this filter, which seems to me means the filter participates
      * correctly.
      */
-    public PortalAuthenticationFilter portalAuthenticationFilterBean()
-        throws ClassNotFoundException, InstantiationException, IllegalAccessException, IOException,
-        IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
-        PortalAuthenticationFilter portalAuthenticationFilter =
-            new PortalAuthenticationFilter(portalapiSecurity, portalAuthManagerBean(), this.userManager);
-        return portalAuthenticationFilter;
+    public PortalAuthenticationFilter portalAuthenticationFilterBean() throws ClassNotFoundException,
+        InstantiationException, IllegalAccessException, IOException, InvocationTargetException, NoSuchMethodException {
+        return new PortalAuthenticationFilter(portalapiSecurity, portalAuthManagerBean(), this.userManager);
     }
 
 }
index 5d80538..20b8cc8 100644 (file)
@@ -57,8 +57,8 @@ public class Html5PathsController {
      *         On error
      */
     @RequestMapping(
-        method = {RequestMethod.OPTIONS, RequestMethod.GET}, //
-        path = {"/policy", "/user"})
+        method = {RequestMethod.GET}, //
+        path = {"/policy"})
     public void forwardAngularRoutes(HttpServletRequest request, HttpServletResponse response) throws IOException {
         URL url = new URL(request.getScheme(), request.getServerName(), request.getServerPort(), "/index.html");
         if (logger.isDebugEnabled())
index 20a0c3f..713d39a 100644 (file)
@@ -81,7 +81,7 @@ public class PolicyController {
      */
     @ApiOperation(value = "Gets the policy types from Near Realtime-RIC")
     @GetMapping(POLICY_TYPES_METHOD)
-    @Secured({ DashboardConstants.ROLE_ADMIN, DashboardConstants.ROLE_STANDARD })
+    @Secured({DashboardConstants.ROLE_ADMIN, DashboardConstants.ROLE_STANDARD})
     public ResponseEntity<String> getAllPolicyTypes(HttpServletResponse response) {
         logger.debug("getAllPolicyTypes");
         return this.policyAgentApi.getAllPolicyTypes();
@@ -89,7 +89,7 @@ public class PolicyController {
 
     @ApiOperation(value = "Returns the policy instances for the given policy type.")
     @GetMapping(POLICY_TYPES_METHOD + "/{" + POLICY_TYPE_ID_NAME + "}/" + POLICIES_NAME)
-    @Secured({ DashboardConstants.ROLE_ADMIN, DashboardConstants.ROLE_STANDARD })
+    @Secured({DashboardConstants.ROLE_ADMIN, DashboardConstants.ROLE_STANDARD})
     public ResponseEntity<String> getPolicyInstances(@PathVariable(POLICY_TYPE_ID_NAME) String policyTypeIdString) {
         logger.debug("getPolicyInstances {}", policyTypeIdString);
         return this.policyAgentApi.getPolicyInstancesForType(policyTypeIdString);
@@ -97,41 +97,41 @@ public class PolicyController {
 
     @ApiOperation(value = "Returns a policy instance of a type")
     @GetMapping(POLICY_TYPES_METHOD + "/{" + POLICY_TYPE_ID_NAME + "}/" + POLICIES_NAME + "/{" + POLICY_INSTANCE_ID_NAME
-            + "}")
-    @Secured({ DashboardConstants.ROLE_ADMIN, DashboardConstants.ROLE_STANDARD })
+        + "}")
+    @Secured({DashboardConstants.ROLE_ADMIN, DashboardConstants.ROLE_STANDARD})
     public ResponseEntity<Object> getPolicyInstance(@PathVariable(POLICY_TYPE_ID_NAME) String policyTypeIdString,
-            @PathVariable(POLICY_INSTANCE_ID_NAME) String policyInstanceId) {
+        @PathVariable(POLICY_INSTANCE_ID_NAME) String policyInstanceId) {
         logger.debug("getPolicyInstance {}:{}", policyTypeIdString, policyInstanceId);
         return this.policyAgentApi.getPolicyInstance(policyInstanceId);
     }
 
     @ApiOperation(value = "Creates the policy instances for the given policy type.")
     @PutMapping(POLICY_TYPES_METHOD + "/{" + POLICY_TYPE_ID_NAME + "}/" + POLICIES_NAME + "/{" + POLICY_INSTANCE_ID_NAME
-            + "}")
-    @Secured({ DashboardConstants.ROLE_ADMIN })
+        + "}")
+    @Secured({DashboardConstants.ROLE_ADMIN})
     public ResponseEntity<String> putPolicyInstance(@PathVariable(POLICY_TYPE_ID_NAME) String policyTypeIdString,
-            @RequestParam(name = "ric", required = true) String ric,
-            @PathVariable(POLICY_INSTANCE_ID_NAME) String policyInstanceId, @RequestBody String instance) {
-        logger.debug("putPolicyInstance typeId: {}, instanceId: {}, instance: {}", policyTypeIdString, policyInstanceId,
-                instance);
+        @RequestParam(name = "ric", required = true) String ric,
+        @PathVariable(POLICY_INSTANCE_ID_NAME) String policyInstanceId, @RequestBody String instance) {
+        logger.debug("putPolicyInstance ric: {}, typeId: {}, instanceId: {}, instance: {}", ric, policyTypeIdString,
+            policyInstanceId, instance);
         return this.policyAgentApi.putPolicy(policyTypeIdString, policyInstanceId, instance, ric);
     }
 
     @ApiOperation(value = "Deletes the policy instances for the given policy type.")
     @DeleteMapping(POLICY_TYPES_METHOD + "/{" + POLICY_TYPE_ID_NAME + "}/" + POLICIES_NAME + "/{"
-            + POLICY_INSTANCE_ID_NAME + "}")
-    @Secured({ DashboardConstants.ROLE_ADMIN })
+        + POLICY_INSTANCE_ID_NAME + "}")
+    @Secured({DashboardConstants.ROLE_ADMIN})
     public ResponseEntity<String> deletePolicyInstance(@PathVariable(POLICY_TYPE_ID_NAME) String policyTypeIdString,
-            @PathVariable(POLICY_INSTANCE_ID_NAME) String policyInstanceId) {
+        @PathVariable(POLICY_INSTANCE_ID_NAME) String policyInstanceId) {
         logger.debug("deletePolicyInstance typeId: {}, instanceId: {}", policyTypeIdString, policyInstanceId);
         return this.policyAgentApi.deletePolicy(policyInstanceId);
     }
 
     @ApiOperation(value = "Returns the rics supporting the given policy type.")
     @GetMapping("/rics")
-    @Secured({ DashboardConstants.ROLE_ADMIN, DashboardConstants.ROLE_STANDARD })
+    @Secured({DashboardConstants.ROLE_ADMIN, DashboardConstants.ROLE_STANDARD})
     public ResponseEntity<String> getRicsSupportingType(
-            @RequestParam(name = "policyType", required = true) String supportingPolicyType) {
+        @RequestParam(name = "policyType", required = true) String supportingPolicyType) {
         logger.debug("getRicsSupportingType {}", supportingPolicyType);
 
         return this.policyAgentApi.getRicsSupportingType(supportingPolicyType);
index 63b78ec..78f5ca9 100644 (file)
@@ -59,6 +59,7 @@ public class SimpleErrorController implements ErrorController {
 
     private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
+    @SuppressWarnings("squid:S1075")
     public static final String ERROR_PATH = "/error";
 
     private final ErrorAttributes errorAttributes;
@@ -81,9 +82,7 @@ public class SimpleErrorController implements ErrorController {
         if (t != null)
             logger.warn("handleError", t);
         Map<String, Object> attributes = errorAttributes.getErrorAttributes(servletWebRequest, true);
-        attributes.forEach((attribute, value) -> {
-            logger.warn("handleError: {} -> {}", attribute, value);
-        });
+        attributes.forEach((attribute, value) -> logger.warn("handleError: {} -> {}", attribute, value));
         // Return the name of the page INCLUDING suffix, which I guess is a "view" name.
         // Just "error" is not enough, but don't seem to need a ModelAndView object.
         return "error.html";
index 3a08206..92ddc46 100644 (file)
@@ -33,7 +33,7 @@ import org.springframework.security.core.userdetails.UserDetails;
 public class EcompUserDetails implements UserDetails {
 
     private static final long serialVersionUID = 1L;
-    private final EcompUser ecompUser;
+    private transient final EcompUser ecompUser;
 
     // This is the default Spring role-name prefix.
     private static final String ROLEP = "ROLE_";
index 6b7fdd2..7855464 100644 (file)
@@ -30,7 +30,7 @@ public interface PolicyAgentApi {
     public ResponseEntity<Object> getPolicyInstance(String id);
 
     public ResponseEntity<String> putPolicy(String policyTypeIdString, String policyInstanceId, Object json,
-            String ric);
+        String ric);
 
     public ResponseEntity<String> deletePolicy(String policyInstanceId);
 
index 470e2df..f01137e 100644 (file)
@@ -28,10 +28,10 @@ import com.google.gson.reflect.TypeToken;
 
 import java.lang.invoke.MethodHandles;
 import java.lang.reflect.Type;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
-import java.util.Vector;
 
 import org.immutables.gson.Gson;
 import org.immutables.value.Value;
@@ -58,14 +58,14 @@ public class PolicyAgentApiImpl implements PolicyAgentApi {
     RestTemplate restTemplate = new RestTemplate();
 
     private static com.google.gson.Gson gson = new GsonBuilder() //
-            .serializeNulls() //
-            .create(); //
+        .serializeNulls() //
+        .create(); //
 
     private final String urlPrefix;
 
     @Autowired
     public PolicyAgentApiImpl(
-            @org.springframework.beans.factory.annotation.Value("${policycontroller.url.prefix}") final String urlPrefix) {
+        @org.springframework.beans.factory.annotation.Value("${policycontroller.url.prefix}") final String urlPrefix) {
         logger.debug("ctor prefix '{}'", urlPrefix);
         this.urlPrefix = urlPrefix;
     }
@@ -119,8 +119,7 @@ public class PolicyAgentApiImpl implements PolicyAgentApi {
         }
 
         try {
-            Type listType = new TypeToken<List<ImmutablePolicyInfo>>() {
-            }.getType();
+            Type listType = new TypeToken<List<ImmutablePolicyInfo>>() {}.getType();
             List<PolicyInfo> rspParsed = gson.fromJson(rsp.getBody(), listType);
             PolicyInstances result = new PolicyInstances();
             for (PolicyInfo p : rspParsed) {
@@ -142,13 +141,13 @@ public class PolicyAgentApiImpl implements PolicyAgentApi {
 
     @Override
     public ResponseEntity<String> putPolicy(String policyTypeIdString, String policyInstanceId, Object json,
-            String ric) {
+        String ric) {
         String url = baseUrl() + "/policy?type={type}&instance={instance}&ric={ric}&service={service}";
         Map<String, ?> uriVariables = Map.of( //
-                "type", policyTypeIdString, //
-                "instance", policyInstanceId, //
-                "ric", ric, //
-                "service", "dashboard");
+            "type", policyTypeIdString, //
+            "instance", policyInstanceId, //
+            "ric", ric, //
+            "service", "dashboard");
 
         try {
             this.restTemplate.put(url, createJsonHttpEntity(json), uriVariables);
@@ -188,10 +187,9 @@ public class PolicyAgentApiImpl implements PolicyAgentApi {
         String rsp = this.restTemplate.getForObject(url, String.class, uriVariables);
 
         try {
-            Type listType = new TypeToken<List<ImmutableRicInfo>>() {
-            }.getType();
+            Type listType = new TypeToken<List<ImmutableRicInfo>>() {}.getType();
             List<RicInfo> rspParsed = gson.fromJson(rsp, listType);
-            Collection<String> result = new Vector<>(rspParsed.size());
+            Collection<String> result = new ArrayList<>(rspParsed.size());
             for (RicInfo ric : rspParsed) {
                 result.add(ric.ricName());
             }
@@ -204,7 +202,7 @@ public class PolicyAgentApiImpl implements PolicyAgentApi {
     private HttpEntity<Object> createJsonHttpEntity(Object content) {
         HttpHeaders headers = new HttpHeaders();
         headers.setContentType(MediaType.APPLICATION_JSON);
-        return new HttpEntity<Object>(content, headers);
+        return new HttpEntity<>(content, headers);
     }
 
 }
index f4daa5c..a94332b 100644 (file)
@@ -45,9 +45,8 @@ public class PortalAuthManager {
     private final String userIdCookieName;
 
     public PortalAuthManager(final String appName, final String username, final String password,
-        final String decryptorClassName, final String userCookie)
-        throws ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException,
-        InvocationTargetException, NoSuchMethodException, SecurityException {
+        final String decryptorClassName, final String userCookie) throws ClassNotFoundException, InstantiationException,
+        IllegalAccessException, InvocationTargetException, NoSuchMethodException {
         credentialsMap = new HashMap<>();
         credentialsMap.put(IPortalRestCentralService.CREDENTIALS_APP, appName);
         credentialsMap.put(IPortalRestCentralService.CREDENTIALS_USER, username);
index 711761a..fee668f 100644 (file)
@@ -72,7 +72,7 @@ import org.springframework.security.web.authentication.preauth.PreAuthenticatedA
  * created and EPService cookie is set.
  * </UL>
  *
- * TODO: What about sessions? Will this be stateless?
+ * Open question: What about sessions? Will this be stateless?
  *
  * This filter uses no annotations to avoid Spring's automatic registration,
  * which add this filter in the chain in the wrong order.
@@ -94,7 +94,7 @@ public class PortalAuthenticationFilter implements Filter {
     private final DashboardUserManager userManager;
 
     public PortalAuthenticationFilter(boolean portalSecurity, PortalAuthManager authManager,
-        DashboardUserManager userManager) {
+        DashboardUserManager userManager) throws IOException {
         this.enforcePortalSecurity = portalSecurity;
         this.authManager = authManager;
         this.userManager = userManager;
@@ -105,7 +105,7 @@ public class PortalAuthenticationFilter implements Filter {
                 if (in == null) {
                     String msg = "Failed to find property file on classpath: " + pf;
                     logger.error(msg);
-                    throw new RuntimeException(msg);
+                    throw new IOException(msg);
                 } else {
                     try {
                         in.close();
@@ -225,7 +225,7 @@ public class PortalAuthenticationFilter implements Filter {
         String redirectUrl = portalBaseUrl + "?" + PortalAuthenticationFilter.REDIRECT_URL_KEY + "=" + encodedAppUrl;
         String aHref = "<a href=\"" + redirectUrl + "\">";
         // If only Java had "here" documents.
-        String body = String.join(//
+        return String.join(//
             System.getProperty("line.separator"), //
             "<html>", //
             "<head>", //
@@ -244,7 +244,6 @@ public class PortalAuthenticationFilter implements Filter {
             "</p>", //
             "</body>", //
             "</html>");
-        return body;
     }
 
     /**
index a2fae9f..02a27d7 100644 (file)
@@ -32,6 +32,7 @@ import org.oransc.ric.portal.dashboard.DashboardUserManager;
 import org.oransc.ric.portal.dashboard.config.SpringContextCache;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.ApplicationContext;
 
 /**
@@ -47,11 +48,13 @@ public class PortalRestCentralServiceImpl implements IPortalRestCentralService {
 
     private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
+    @Autowired
+    private SpringContextCache springContextCache;
     private final PortalAuthManager authManager;
     private final DashboardUserManager userManager;
 
     public PortalRestCentralServiceImpl() throws IOException, PortalAPIException {
-        final ApplicationContext context = SpringContextCache.getApplicationContext();
+        final ApplicationContext context = springContextCache.getApplicationContext();
         authManager = context.getBean(PortalAuthManager.class);
         userManager = context.getBean(DashboardUserManager.class);
     }
index f62ea5f..4cbcf38 100644 (file)
@@ -7,9 +7,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -24,7 +24,8 @@ import org.onap.portalsdk.core.onboarding.util.CipherUtil;
 
 public class PortalSdkDecryptorAes implements IPortalSdkDecryptor {
 
-    @SuppressWarnings("deprecation")
+    @Override
+    @SuppressWarnings("squid:CallToDeprecatedMethod")
     public String decrypt(String cipherText) throws CipherUtilException {
         return CipherUtil.decrypt(cipherText);
     }
index d5f2cbf..b86bbfe 100644 (file)
@@ -27,7 +27,6 @@ import java.security.cert.X509Certificate;
 import javax.net.ssl.HostnameVerifier;
 import javax.net.ssl.HttpsURLConnection;
 import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLSession;
 import javax.net.ssl.TrustManager;
 import javax.net.ssl.X509TrustManager;
 
@@ -42,14 +41,10 @@ public final class HttpsURLConnectionUtils {
 
     private static final HostnameVerifier jvmHostnameVerifier = HttpsURLConnection.getDefaultHostnameVerifier();
 
-    private static final HostnameVerifier trivialHostnameVerifier = new HostnameVerifier() {
-        @Override
-        public boolean verify(String hostname, SSLSession sslSession) {
-            return true;
-        }
-    };
+    private static final HostnameVerifier trivialHostnameVerifier = (hostname, sslSession) -> true;
 
     private static final TrustManager[] UNQUESTIONING_TRUST_MANAGER = new TrustManager[] {new X509TrustManager() {
+        @SuppressWarnings("squid:S1168") // Must return null to get wanted behaviour.
         @Override
         public java.security.cert.X509Certificate[] getAcceptedIssuers() {
             return null;
@@ -57,10 +52,12 @@ public final class HttpsURLConnectionUtils {
 
         @Override
         public void checkClientTrusted(X509Certificate[] certs, String authType) {
+            // Do nothing.
         }
 
         @Override
         public void checkServerTrusted(X509Certificate[] certs, String authType) {
+            // Do nothing.
         }
     }};
 
index e19890b..9ed3869 100644 (file)
@@ -19,8 +19,6 @@
  */
 package org.oransc.ric.portal.dashboard;
 
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
 import java.lang.invoke.MethodHandles;
 
 import org.junit.jupiter.api.Test;
@@ -55,6 +53,7 @@ public class DashboardTestServer {
      * Keeps the test server alive forever. Use a guard so this test is never run by
      * Jenkins.
      */
+    @SuppressWarnings("squid:S2699") // To avoid warning about missing assertion.
     @EnabledIfSystemProperty(named = "org.oransc.ric.portal.dashboard", matches = "mock")
     @Test
     public void keepServerAlive() {
@@ -66,6 +65,5 @@ public class DashboardTestServer {
         } catch (Exception ex) {
             logger.warn(ex.toString());
         }
-        assertEquals(1, 2);
     }
 }
index 76ce40c..9c6d40c 100644 (file)
@@ -57,8 +57,8 @@ public class PolicyControllerMockConfiguration {
     private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
     private static com.google.gson.Gson gson = new GsonBuilder() //
-            .serializeNulls() //
-            .create(); //
+        .serializeNulls() //
+        .create(); //
 
     @Bean
     public PolicyAgentApi policyAgentApi() {
@@ -76,7 +76,7 @@ public class PolicyControllerMockConfiguration {
 
         @Override
         public ResponseEntity<String> putPolicy(String policyTypeIdString, String policyInstanceId, Object json,
-                String ric) {
+            String ric) {
             database.putInstance(policyTypeIdString, policyInstanceId, json, ric);
             return new ResponseEntity<>("Policy was put successfully", HttpStatus.OK);
         }
@@ -130,8 +130,8 @@ public class PolicyControllerMockConfiguration {
 
         private String getStringFromFile(String path) {
             try {
-                InputStream inputStream = MethodHandles.lookup().lookupClass().getClassLoader()
-                        .getResourceAsStream(path);
+                InputStream inputStream =
+                    MethodHandles.lookup().lookupClass().getClassLoader().getResourceAsStream(path);
                 return new BufferedReader(new InputStreamReader(inputStream)).lines().collect(Collectors.joining("\n"));
             } catch (Exception e) {
                 logger.error("Cannot read file :" + path, e);
@@ -149,7 +149,7 @@ public class PolicyControllerMockConfiguration {
 
         void putInstance(String typeId, String instanceId, Object instanceData, String ric) {
             PolicyInfo i = ImmutablePolicyInfo.builder().json(instanceData).lastModified(getTimeStampUTC())
-                    .id(instanceId).ric(ric).service("service").type(typeId).build();
+                .id(instanceId).ric(ric).service("service").type(typeId).build();
             instances.put(instanceId, i);
         }
 
index d91c4a9..9dea90a 100644 (file)
 <mat-nav-list [ngClass]="{'dark': darkMode}">
   <a mat-list-item routerLink="/" (click)="onSidenavClose()">
     <mat-icon>home</mat-icon> <span class="nav-caption">Home</span>
-  </a>  
-  <a mat-list-item routerLink="/control" (click)="onSidenavClose()">
-    <mat-icon>settings</mat-icon><span class="nav-caption">Control</span>
-  </a>  
+  </a>
   <a mat-list-item routerLink="/policy" (click)="onSidenavClose()">
       <mat-icon>assignment</mat-icon> <span class="nav-caption">Policy</span>
-  </a>    
+  </a>
 </mat-nav-list>