From 29a1a27e804018b63bde7dd54aa653e7dc7a3f8e Mon Sep 17 00:00:00 2001 From: vidhya9lakshmi Date: Fri, 9 Jul 2021 11:44:36 -0400 Subject: [PATCH 1/5] changed ssl to TLSv1.2 --- .../com/capitalone/dashboard/service/UserInfoServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/capitalone/dashboard/service/UserInfoServiceImpl.java b/src/main/java/com/capitalone/dashboard/service/UserInfoServiceImpl.java index b897da3b..ad77001f 100644 --- a/src/main/java/com/capitalone/dashboard/service/UserInfoServiceImpl.java +++ b/src/main/java/com/capitalone/dashboard/service/UserInfoServiceImpl.java @@ -200,7 +200,7 @@ public boolean searchLdapUser(String searchId) throws NamingException { private Properties setProperties() { Properties props = new Properties(); props.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); - props.put("java.naming.security.protocol", "ssl"); + props.put("java.naming.security.protocol", "TLSv1.2"); props.put(Context.SECURITY_AUTHENTICATION, "simple"); try { From a7031fc86762b7ea8a8c668a84f805db96d3083b Mon Sep 17 00:00:00 2001 From: vidhya9lakshmi Date: Fri, 9 Jul 2021 13:03:38 -0400 Subject: [PATCH 2/5] changed ssl to TLSv1.2 --- .../service/UserInfoServiceImpl.java | 13 ++++--- .../dashboard/settings/ApiSettings.java | 34 +++++++++++++++++++ .../dashboard/config/TestAuthConfig.java | 7 ++-- .../config/TestDefaultAuthConfig.java | 7 +++- .../service/UserInfoServiceImplTest.java | 5 ++- 5 files changed, 58 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/capitalone/dashboard/service/UserInfoServiceImpl.java b/src/main/java/com/capitalone/dashboard/service/UserInfoServiceImpl.java index ad77001f..71452771 100644 --- a/src/main/java/com/capitalone/dashboard/service/UserInfoServiceImpl.java +++ b/src/main/java/com/capitalone/dashboard/service/UserInfoServiceImpl.java @@ -5,6 +5,7 @@ import java.util.Properties; import com.capitalone.dashboard.auth.AuthProperties; +import com.capitalone.dashboard.settings.ApiSettings; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; @@ -38,12 +39,16 @@ public class UserInfoServiceImpl implements UserInfoService { @Autowired private AuthProperties authProperties; + private final ApiSettings apiSettings; + + private InitialDirContext initialDirContext; @Autowired - public UserInfoServiceImpl(UserInfoRepository userInfoRepository, AuthProperties authProperties) { + public UserInfoServiceImpl(UserInfoRepository userInfoRepository, AuthProperties authProperties, ApiSettings apiSettings) { this.userInfoRepository = userInfoRepository; this.authProperties = authProperties; + this.apiSettings = apiSettings; } @Override @@ -199,9 +204,9 @@ public boolean searchLdapUser(String searchId) throws NamingException { private Properties setProperties() { Properties props = new Properties(); - props.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); - props.put("java.naming.security.protocol", "TLSv1.2"); - props.put(Context.SECURITY_AUTHENTICATION, "simple"); + props.put(Context.INITIAL_CONTEXT_FACTORY, apiSettings.getContextFactory()); + props.put("java.naming.security.protocol", apiSettings.getContextProtocol()); + props.put(Context.SECURITY_AUTHENTICATION, apiSettings.getContextSecurityAuthentication()); try { if (!StringUtils.isBlank(authProperties.getAdUrl())) { diff --git a/src/main/java/com/capitalone/dashboard/settings/ApiSettings.java b/src/main/java/com/capitalone/dashboard/settings/ApiSettings.java index cc29e56a..35fa1318 100644 --- a/src/main/java/com/capitalone/dashboard/settings/ApiSettings.java +++ b/src/main/java/com/capitalone/dashboard/settings/ApiSettings.java @@ -42,6 +42,16 @@ public class ApiSettings { private String capturePattern; + @Value("${contextFactory:com.sun.jndi.ldap.LdapCtxFactory}") + private String contextFactory; + + @Value("${contextProtocol:ssl}") + private String contextProtocol; + + @Value("${contextSecurityAuthentication:simple}") + private String contextSecurityAuthentication; + + private List ignoreEndPoints = new ArrayList(); private List ignoreApiUsers = new ArrayList(); private List ignoreBodyEndPoints = new ArrayList(); @@ -222,4 +232,28 @@ public String getBuildCollectorName() { public void setBuildCollectorName(String buildCollectorName) { this.buildCollectorName = buildCollectorName; } + + public String getContextFactory() { + return contextFactory; + } + + public void setContextFactory(String contextFactory) { + this.contextFactory = contextFactory; + } + + public String getContextProtocol() { + return contextProtocol; + } + + public void setContextProtocol(String contextProtocol) { + this.contextProtocol = contextProtocol; + } + + public String getContextSecurityAuthentication() { + return contextSecurityAuthentication; + } + + public void setContextSecurityAuthentication(String contextSecurityAuthentication) { + this.contextSecurityAuthentication = contextSecurityAuthentication; + } } diff --git a/src/test/java/com/capitalone/dashboard/config/TestAuthConfig.java b/src/test/java/com/capitalone/dashboard/config/TestAuthConfig.java index c31f61e1..fc3410b3 100644 --- a/src/test/java/com/capitalone/dashboard/config/TestAuthConfig.java +++ b/src/test/java/com/capitalone/dashboard/config/TestAuthConfig.java @@ -55,8 +55,9 @@ import com.capitalone.dashboard.service.UserInfoService; import com.capitalone.dashboard.service.UserInfoServiceImpl; import com.capitalone.dashboard.service.InfraStructureService; -import com.capitalone.dashboard.service.InfraStructureServiceImpl; +import com.capitalone.dashboard.settings.ApiSettings; import com.capitalone.dashboard.util.PaginationHeaderUtility; +import org.mockito.Mock; import org.mockito.Mockito; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; @@ -67,6 +68,8 @@ @ComponentScan(basePackages = {"com.capitalone.dashboard.auth"}) public class TestAuthConfig { + @Mock + private ApiSettings apiSettings; @Bean public DashboardRepository dashboardRepository() { return Mockito.mock(DashboardRepository.class); @@ -94,7 +97,7 @@ public UserInfoRepository userInfoRepository() { @Bean public UserInfoService userInfoService() { - return new UserInfoServiceImpl(userInfoRepository(), authProperties()); + return new UserInfoServiceImpl(userInfoRepository(), authProperties(), apiSettings); } @Bean diff --git a/src/test/java/com/capitalone/dashboard/config/TestDefaultAuthConfig.java b/src/test/java/com/capitalone/dashboard/config/TestDefaultAuthConfig.java index e90b008b..0b137b6b 100644 --- a/src/test/java/com/capitalone/dashboard/config/TestDefaultAuthConfig.java +++ b/src/test/java/com/capitalone/dashboard/config/TestDefaultAuthConfig.java @@ -53,7 +53,9 @@ import com.capitalone.dashboard.service.UserInfoService; import com.capitalone.dashboard.service.UserInfoServiceImpl; import com.capitalone.dashboard.service.InfraStructureService; +import com.capitalone.dashboard.settings.ApiSettings; import com.capitalone.dashboard.util.PaginationHeaderUtility; +import org.mockito.Mock; import org.mockito.Mockito; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; @@ -64,6 +66,9 @@ @ComponentScan(basePackages = {"com.capitalone.dashboard.auth"}) public class TestDefaultAuthConfig { + @Mock + private ApiSettings apiSettings; + @Bean public DashboardRepository dashboardRepository() { return Mockito.mock(DashboardRepository.class); @@ -86,7 +91,7 @@ public UserInfoRepository userInfoRepository() { @Bean public UserInfoService userInfoService() { - return new UserInfoServiceImpl(userInfoRepository(),authProperties()); + return new UserInfoServiceImpl(userInfoRepository(),authProperties(), apiSettings); } @Bean diff --git a/src/test/java/com/capitalone/dashboard/service/UserInfoServiceImplTest.java b/src/test/java/com/capitalone/dashboard/service/UserInfoServiceImplTest.java index 58546d4e..65b02150 100644 --- a/src/test/java/com/capitalone/dashboard/service/UserInfoServiceImplTest.java +++ b/src/test/java/com/capitalone/dashboard/service/UserInfoServiceImplTest.java @@ -15,6 +15,7 @@ import java.util.Collection; import com.capitalone.dashboard.auth.AuthProperties; +import com.capitalone.dashboard.settings.ApiSettings; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -57,6 +58,8 @@ public class UserInfoServiceImplTest { @InjectMocks private UserInfoServiceImpl service; + @Mock private ApiSettings apiSettings; + @Before public void setup(){ authProperties = new AuthProperties(); @@ -233,7 +236,7 @@ public void shouldSearchLdapUser() throws NamingException { // setup authProperties setup(); - service = new UserInfoServiceImpl(userInfoRepository,authProperties); + service = new UserInfoServiceImpl(userInfoRepository,authProperties, apiSettings); context = Mockito.mock(InitialDirContext.class); service.setInitialContext(context); From 9486c4c44f7e79ece091f1720012e19852034ced Mon Sep 17 00:00:00 2001 From: vidhya9lakshmi Date: Fri, 9 Jul 2021 13:17:33 -0400 Subject: [PATCH 3/5] changed ssl to TLSv1.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index bbdfcce0..c2104c6e 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ api jar ${project.groupId}:${project.artifactId} - 3.4.21-SNAPSHOT + 3.4.22-SNAPSHOT Hygieia Rest API Layer https://github.com/Hygieia/api From 9a9f889a1f1050e3fe75e498c8144d07d05f2b4d Mon Sep 17 00:00:00 2001 From: vidhya9lakshmi Date: Fri, 9 Jul 2021 13:24:36 -0400 Subject: [PATCH 4/5] changed ssl to TLSv1.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c2104c6e..2e5d7162 100644 --- a/pom.xml +++ b/pom.xml @@ -69,7 +69,7 @@ 3.10 2.2.0-RC2 29.0-jre - 5.4.2.Final + 6.1.5.Final 2.10.3 1.18 1.2.3 From 76b6651d3ff77d3c80c7af749cb8c2e702171571 Mon Sep 17 00:00:00 2001 From: vidhya9lakshmi Date: Fri, 9 Jul 2021 14:06:40 -0400 Subject: [PATCH 5/5] changed ssl to TLSv1.2 --- .../dashboard/rest/DashboardControllerTest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/java/com/capitalone/dashboard/rest/DashboardControllerTest.java b/src/test/java/com/capitalone/dashboard/rest/DashboardControllerTest.java index e09d4925..28965c5f 100644 --- a/src/test/java/com/capitalone/dashboard/rest/DashboardControllerTest.java +++ b/src/test/java/com/capitalone/dashboard/rest/DashboardControllerTest.java @@ -115,12 +115,12 @@ public void createDashboard_nullRequest() throws Exception { .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(new DashboardRequest()))) .andExpect(status().isBadRequest()) - .andExpect(jsonPath("$.fieldErrors.template", hasItems("may not be null"))) + .andExpect(jsonPath("$.fieldErrors.template", hasItems("must not be null"))) // TODO: These are no longer necessary in all cases. Potentially add new class-level validator. // .andExpect(jsonPath("$.fieldErrors.componentName", hasItems("may not be null"))) // .andExpect(jsonPath("$.fieldErrors.applicationName", hasItems("may not be null"))) - .andExpect(jsonPath("$.fieldErrors.type", hasItems("may not be null"))) - .andExpect(jsonPath("$.fieldErrors.dashboardRequestTitle", hasItems("may not be null"))); + .andExpect(jsonPath("$.fieldErrors.type", hasItems("must not be null"))) + .andExpect(jsonPath("$.fieldErrors.dashboardRequestTitle", hasItems("must not be null"))); } @Test @@ -308,7 +308,7 @@ public void renameTeamDashboard_nullTitle() throws Exception { .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(request))) .andExpect(status().isBadRequest()) - .andExpect(jsonPath("$.fieldErrors.title", hasItems("may not be null"))) + .andExpect(jsonPath("$.fieldErrors.title", hasItems("must not be null"))) ; }