@Test public void getCerticatesDetailsTest() throws Exception { String response = "{\"_scroll_id\":\"scrollid\",\"hits\":{\"hits\":[{\"_index\":\"aws_cert\",\"_type\":\"cert\",\"_id\":\"tst.domain_Public\",\"_score\":0.2211614,\"_source\":{\"certType\":\"Public\",\"tags.Environment\":\"\",\"tags.Application\":\"APP1\",\"tags.Owner\":\"\",\"status\":\"active\",\"validto\":\"9/11/2018 10:44\"," + "\"commonname\":\"tst.domain\",\"validfrom\":\"9/11/2017 10:14\"}},{\"_index\":\"aws_cert\",\"_type\":\"cert\",\"_id\":\"dev1r2.rbl_Internal\",\"_score\":0.2211614,\"_source\":{\"certType\":\"Internal\",\"tags.Environment\":\"Non-Prod\",\"tags.Application\":\"APP1\"," + "\"issuerdn\":\"CN=T-Mobile USA Enterprise Issuing CA 01, DC=gsm1900, DC=org\",\"tags.Owner\":\"\",\"status\":\"active\",\"validto\":\"9/15/2018 10:06\",\"commonname\":\"dev1r2.rbl\",\"validfrom\":\"9/15/2017 10:06\"}}]}}"; when(elasticSearchRepository.getTotalDocumentCountForIndexAndType( anyString(),anyString(),anyObject(),anyObject(),anyObject(),anyObject(),anyObject())).thenReturn(11000L); when(elasticSearchRepository.buildScrollRequest(anyString(),anyString())).thenReturn(""); mockStatic(PacHttpUtils.class); when(PacHttpUtils.doHttpPost(anyString(), anyString())).thenReturn(response); ReflectionTestUtils.setField(certificateRepository, "esUrl", "dummyEsURL"); when(elasticSearchRepository.processResponseAndSendTheScrollBack(anyString(), anyObject())).thenCallRealMethod(); List<Map<String, Object>> certificatesDetails = certificateRepository.getCertificatesDetails("APP1", null, new HashMap<>()); assertTrue(certificatesDetails.size() == 4); assertTrue(certificatesDetails.get(0).get("name").equals("tst.domain")); }
@SuppressWarnings("unchecked") public List<Map<String, Object>> getCertificatesDetails(String assetGroup, String searchText, Map<String, String> filter) throws DataException { List<Map<String, Object>> certificateDetails = new ArrayList<>(); try { Map<String, Object> mustFilter = new HashMap<>(); mustFilter.put("latest", true); if (null != filter && filter.size() > 0) { filter.forEach((key, value) -> mustFilter.put(key, value)); } StringBuilder urlToQueryBuffer = new StringBuilder(esUrl) .append("/").append(assetGroup).append(CERT_SEARCH) .append("?scroll=").append(esPageScrollTTL); String urlToQuery = urlToQueryBuffer.toString(); String urlToScroll = new StringBuilder(esUrl).append("/") .append("_search").append("/scroll").toString(); StringBuilder requestBody = new StringBuilder( "{\"size\":").append(TEN_THOUSAND).append(",\"query\":{\"bool\":{\"must\":[{\"match\":{\"latest\":\"true\"}}"); if (filter.containsKey("tags.Application.keyword")) { requestBody .append(",{\"match\":{\"tags.Application.keyword\":\""); requestBody.append(filter.get("tags.Application.keyword")); requestBody.append("\"}}"); } if (filter.containsKey("tags.Environment.keyword")) { requestBody .append(",{\"match\":{\"tags.Environment.keyword\":\""); requestBody.append(filter.get("tags.Environment.keyword")); requestBody.append("\"}}"); } if (filter.containsKey(EXP_IN)) { if (filter.get(EXP_IN).equals(THIRTY)) { requestBody .append(",{\"has_child\":{\"type\":\"issue_cert\",\"query\":{\"bool\":{\"must\":[{\"term\":{\"issueStatus.keyword\":\"open\"}},{\"term\":{\"type.keyword\":\"issue\"}},{\"match\":{\"ruleId.keyword\":\""); requestBody.append(SSL_CERT_30_DAYS_EXP_RULE); requestBody.append("\"}}]}}}}"); } else if (filter.get(EXP_IN).equals(FOURTYFIVE)) { requestBody .append(",{\"has_child\":{\"type\":\"issue_cert\",\"query\":{\"bool\":{\"must\":[{\"term\":{\"issueStatus.keyword\":\"open\"}},{\"term\":{\"type.keyword\":\"issue\"}},{\"match\":{\"ruleId.keyword\":\""); requestBody.append(SSL_CERT_45_DAYS_EXP_RULE); requestBody.append("\"}}]}}}}"); } mustFilter.remove(EXP_IN); } requestBody.append("]}}}"); List<Map<String, Object>> certificatesDetailsFromES = new ArrayList<>(); Long totalDocs = getCertificatesDetailsCount(assetGroup, mustFilter); String request = requestBody.toString(); String scroolId = null; String responseDetails; for (int index = 0; index <= (totalDocs / esPageSize); index++) { try{ if (!Strings.isNullOrEmpty(scroolId)) { request = elasticSearchRepository.buildScrollRequest( scroolId, esPageScrollTTL); urlToQuery = urlToScroll; } responseDetails = PacHttpUtils.doHttpPost(urlToQuery, request); scroolId = elasticSearchRepository .processResponseAndSendTheScrollBack( responseDetails, certificatesDetailsFromES); } catch (Exception e) { LOGGER.error("Error in getCerticatesDetails from ES", e); throw new DataException(e); } } certificatesDetailsFromES = (List<Map<String, Object>>) CommonUtils .filterMatchingCollectionElements( certificatesDetailsFromES, searchText, true); certificatesDetailsFromES.sort(Comparator .comparing(m -> LocalDateTime.parse( (String) m.get(VALID_TO), DateTimeFormatter.ofPattern("M/d/yyyy H:m")) .toLocalDate())); for (Map<String, Object> _certificatesDetailsFromES : certificatesDetailsFromES) { Map<String, Object> certificate = new LinkedHashMap<>(); certificate.put("name", _certificatesDetailsFromES.get("commonname")); if (StringUtils.isNotEmpty(_certificatesDetailsFromES.get( VALID_TO).toString())) { certificate.put(EXP_IN, calculateExpiryDuration(_certificatesDetailsFromES .get(VALID_TO).toString()) + " days"); } else { certificate.put(EXP_IN, 0); } certificate.put("type", _certificatesDetailsFromES.get("certType")); certificate.put("application", _certificatesDetailsFromES.get("tags.Application")); certificate.put("environment", _certificatesDetailsFromES.get("tags.Environment")); certificate.put("owner", _certificatesDetailsFromES.get("tags.Owner")); certificate.put("issuer", _certificatesDetailsFromES.get("issuerdn")); certificate.put("validUntil", _certificatesDetailsFromES.get(VALID_TO)); certificate.put("validfrom", _certificatesDetailsFromES.get("validfrom")); certificate.put("status", _certificatesDetailsFromES.get("status")); certificateDetails.add(certificate); } } catch (DataException e) { LOGGER.error("Error in getCerticatesDetails", e); } return certificateDetails; }
CertificateRepository implements Constants { @SuppressWarnings("unchecked") public List<Map<String, Object>> getCertificatesDetails(String assetGroup, String searchText, Map<String, String> filter) throws DataException { List<Map<String, Object>> certificateDetails = new ArrayList<>(); try { Map<String, Object> mustFilter = new HashMap<>(); mustFilter.put("latest", true); if (null != filter && filter.size() > 0) { filter.forEach((key, value) -> mustFilter.put(key, value)); } StringBuilder urlToQueryBuffer = new StringBuilder(esUrl) .append("/").append(assetGroup).append(CERT_SEARCH) .append("?scroll=").append(esPageScrollTTL); String urlToQuery = urlToQueryBuffer.toString(); String urlToScroll = new StringBuilder(esUrl).append("/") .append("_search").append("/scroll").toString(); StringBuilder requestBody = new StringBuilder( "{\"size\":").append(TEN_THOUSAND).append(",\"query\":{\"bool\":{\"must\":[{\"match\":{\"latest\":\"true\"}}"); if (filter.containsKey("tags.Application.keyword")) { requestBody .append(",{\"match\":{\"tags.Application.keyword\":\""); requestBody.append(filter.get("tags.Application.keyword")); requestBody.append("\"}}"); } if (filter.containsKey("tags.Environment.keyword")) { requestBody .append(",{\"match\":{\"tags.Environment.keyword\":\""); requestBody.append(filter.get("tags.Environment.keyword")); requestBody.append("\"}}"); } if (filter.containsKey(EXP_IN)) { if (filter.get(EXP_IN).equals(THIRTY)) { requestBody .append(",{\"has_child\":{\"type\":\"issue_cert\",\"query\":{\"bool\":{\"must\":[{\"term\":{\"issueStatus.keyword\":\"open\"}},{\"term\":{\"type.keyword\":\"issue\"}},{\"match\":{\"ruleId.keyword\":\""); requestBody.append(SSL_CERT_30_DAYS_EXP_RULE); requestBody.append("\"}}]}}}}"); } else if (filter.get(EXP_IN).equals(FOURTYFIVE)) { requestBody .append(",{\"has_child\":{\"type\":\"issue_cert\",\"query\":{\"bool\":{\"must\":[{\"term\":{\"issueStatus.keyword\":\"open\"}},{\"term\":{\"type.keyword\":\"issue\"}},{\"match\":{\"ruleId.keyword\":\""); requestBody.append(SSL_CERT_45_DAYS_EXP_RULE); requestBody.append("\"}}]}}}}"); } mustFilter.remove(EXP_IN); } requestBody.append("]}}}"); List<Map<String, Object>> certificatesDetailsFromES = new ArrayList<>(); Long totalDocs = getCertificatesDetailsCount(assetGroup, mustFilter); String request = requestBody.toString(); String scroolId = null; String responseDetails; for (int index = 0; index <= (totalDocs / esPageSize); index++) { try{ if (!Strings.isNullOrEmpty(scroolId)) { request = elasticSearchRepository.buildScrollRequest( scroolId, esPageScrollTTL); urlToQuery = urlToScroll; } responseDetails = PacHttpUtils.doHttpPost(urlToQuery, request); scroolId = elasticSearchRepository .processResponseAndSendTheScrollBack( responseDetails, certificatesDetailsFromES); } catch (Exception e) { LOGGER.error("Error in getCerticatesDetails from ES", e); throw new DataException(e); } } certificatesDetailsFromES = (List<Map<String, Object>>) CommonUtils .filterMatchingCollectionElements( certificatesDetailsFromES, searchText, true); certificatesDetailsFromES.sort(Comparator .comparing(m -> LocalDateTime.parse( (String) m.get(VALID_TO), DateTimeFormatter.ofPattern("M/d/yyyy H:m")) .toLocalDate())); for (Map<String, Object> _certificatesDetailsFromES : certificatesDetailsFromES) { Map<String, Object> certificate = new LinkedHashMap<>(); certificate.put("name", _certificatesDetailsFromES.get("commonname")); if (StringUtils.isNotEmpty(_certificatesDetailsFromES.get( VALID_TO).toString())) { certificate.put(EXP_IN, calculateExpiryDuration(_certificatesDetailsFromES .get(VALID_TO).toString()) + " days"); } else { certificate.put(EXP_IN, 0); } certificate.put("type", _certificatesDetailsFromES.get("certType")); certificate.put("application", _certificatesDetailsFromES.get("tags.Application")); certificate.put("environment", _certificatesDetailsFromES.get("tags.Environment")); certificate.put("owner", _certificatesDetailsFromES.get("tags.Owner")); certificate.put("issuer", _certificatesDetailsFromES.get("issuerdn")); certificate.put("validUntil", _certificatesDetailsFromES.get(VALID_TO)); certificate.put("validfrom", _certificatesDetailsFromES.get("validfrom")); certificate.put("status", _certificatesDetailsFromES.get("status")); certificateDetails.add(certificate); } } catch (DataException e) { LOGGER.error("Error in getCerticatesDetails", e); } return certificateDetails; } }
CertificateRepository implements Constants { @SuppressWarnings("unchecked") public List<Map<String, Object>> getCertificatesDetails(String assetGroup, String searchText, Map<String, String> filter) throws DataException { List<Map<String, Object>> certificateDetails = new ArrayList<>(); try { Map<String, Object> mustFilter = new HashMap<>(); mustFilter.put("latest", true); if (null != filter && filter.size() > 0) { filter.forEach((key, value) -> mustFilter.put(key, value)); } StringBuilder urlToQueryBuffer = new StringBuilder(esUrl) .append("/").append(assetGroup).append(CERT_SEARCH) .append("?scroll=").append(esPageScrollTTL); String urlToQuery = urlToQueryBuffer.toString(); String urlToScroll = new StringBuilder(esUrl).append("/") .append("_search").append("/scroll").toString(); StringBuilder requestBody = new StringBuilder( "{\"size\":").append(TEN_THOUSAND).append(",\"query\":{\"bool\":{\"must\":[{\"match\":{\"latest\":\"true\"}}"); if (filter.containsKey("tags.Application.keyword")) { requestBody .append(",{\"match\":{\"tags.Application.keyword\":\""); requestBody.append(filter.get("tags.Application.keyword")); requestBody.append("\"}}"); } if (filter.containsKey("tags.Environment.keyword")) { requestBody .append(",{\"match\":{\"tags.Environment.keyword\":\""); requestBody.append(filter.get("tags.Environment.keyword")); requestBody.append("\"}}"); } if (filter.containsKey(EXP_IN)) { if (filter.get(EXP_IN).equals(THIRTY)) { requestBody .append(",{\"has_child\":{\"type\":\"issue_cert\",\"query\":{\"bool\":{\"must\":[{\"term\":{\"issueStatus.keyword\":\"open\"}},{\"term\":{\"type.keyword\":\"issue\"}},{\"match\":{\"ruleId.keyword\":\""); requestBody.append(SSL_CERT_30_DAYS_EXP_RULE); requestBody.append("\"}}]}}}}"); } else if (filter.get(EXP_IN).equals(FOURTYFIVE)) { requestBody .append(",{\"has_child\":{\"type\":\"issue_cert\",\"query\":{\"bool\":{\"must\":[{\"term\":{\"issueStatus.keyword\":\"open\"}},{\"term\":{\"type.keyword\":\"issue\"}},{\"match\":{\"ruleId.keyword\":\""); requestBody.append(SSL_CERT_45_DAYS_EXP_RULE); requestBody.append("\"}}]}}}}"); } mustFilter.remove(EXP_IN); } requestBody.append("]}}}"); List<Map<String, Object>> certificatesDetailsFromES = new ArrayList<>(); Long totalDocs = getCertificatesDetailsCount(assetGroup, mustFilter); String request = requestBody.toString(); String scroolId = null; String responseDetails; for (int index = 0; index <= (totalDocs / esPageSize); index++) { try{ if (!Strings.isNullOrEmpty(scroolId)) { request = elasticSearchRepository.buildScrollRequest( scroolId, esPageScrollTTL); urlToQuery = urlToScroll; } responseDetails = PacHttpUtils.doHttpPost(urlToQuery, request); scroolId = elasticSearchRepository .processResponseAndSendTheScrollBack( responseDetails, certificatesDetailsFromES); } catch (Exception e) { LOGGER.error("Error in getCerticatesDetails from ES", e); throw new DataException(e); } } certificatesDetailsFromES = (List<Map<String, Object>>) CommonUtils .filterMatchingCollectionElements( certificatesDetailsFromES, searchText, true); certificatesDetailsFromES.sort(Comparator .comparing(m -> LocalDateTime.parse( (String) m.get(VALID_TO), DateTimeFormatter.ofPattern("M/d/yyyy H:m")) .toLocalDate())); for (Map<String, Object> _certificatesDetailsFromES : certificatesDetailsFromES) { Map<String, Object> certificate = new LinkedHashMap<>(); certificate.put("name", _certificatesDetailsFromES.get("commonname")); if (StringUtils.isNotEmpty(_certificatesDetailsFromES.get( VALID_TO).toString())) { certificate.put(EXP_IN, calculateExpiryDuration(_certificatesDetailsFromES .get(VALID_TO).toString()) + " days"); } else { certificate.put(EXP_IN, 0); } certificate.put("type", _certificatesDetailsFromES.get("certType")); certificate.put("application", _certificatesDetailsFromES.get("tags.Application")); certificate.put("environment", _certificatesDetailsFromES.get("tags.Environment")); certificate.put("owner", _certificatesDetailsFromES.get("tags.Owner")); certificate.put("issuer", _certificatesDetailsFromES.get("issuerdn")); certificate.put("validUntil", _certificatesDetailsFromES.get(VALID_TO)); certificate.put("validfrom", _certificatesDetailsFromES.get("validfrom")); certificate.put("status", _certificatesDetailsFromES.get("status")); certificateDetails.add(certificate); } } catch (DataException e) { LOGGER.error("Error in getCerticatesDetails", e); } return certificateDetails; }  }
CertificateRepository implements Constants { @SuppressWarnings("unchecked") public List<Map<String, Object>> getCertificatesDetails(String assetGroup, String searchText, Map<String, String> filter) throws DataException { List<Map<String, Object>> certificateDetails = new ArrayList<>(); try { Map<String, Object> mustFilter = new HashMap<>(); mustFilter.put("latest", true); if (null != filter && filter.size() > 0) { filter.forEach((key, value) -> mustFilter.put(key, value)); } StringBuilder urlToQueryBuffer = new StringBuilder(esUrl) .append("/").append(assetGroup).append(CERT_SEARCH) .append("?scroll=").append(esPageScrollTTL); String urlToQuery = urlToQueryBuffer.toString(); String urlToScroll = new StringBuilder(esUrl).append("/") .append("_search").append("/scroll").toString(); StringBuilder requestBody = new StringBuilder( "{\"size\":").append(TEN_THOUSAND).append(",\"query\":{\"bool\":{\"must\":[{\"match\":{\"latest\":\"true\"}}"); if (filter.containsKey("tags.Application.keyword")) { requestBody .append(",{\"match\":{\"tags.Application.keyword\":\""); requestBody.append(filter.get("tags.Application.keyword")); requestBody.append("\"}}"); } if (filter.containsKey("tags.Environment.keyword")) { requestBody .append(",{\"match\":{\"tags.Environment.keyword\":\""); requestBody.append(filter.get("tags.Environment.keyword")); requestBody.append("\"}}"); } if (filter.containsKey(EXP_IN)) { if (filter.get(EXP_IN).equals(THIRTY)) { requestBody .append(",{\"has_child\":{\"type\":\"issue_cert\",\"query\":{\"bool\":{\"must\":[{\"term\":{\"issueStatus.keyword\":\"open\"}},{\"term\":{\"type.keyword\":\"issue\"}},{\"match\":{\"ruleId.keyword\":\""); requestBody.append(SSL_CERT_30_DAYS_EXP_RULE); requestBody.append("\"}}]}}}}"); } else if (filter.get(EXP_IN).equals(FOURTYFIVE)) { requestBody .append(",{\"has_child\":{\"type\":\"issue_cert\",\"query\":{\"bool\":{\"must\":[{\"term\":{\"issueStatus.keyword\":\"open\"}},{\"term\":{\"type.keyword\":\"issue\"}},{\"match\":{\"ruleId.keyword\":\""); requestBody.append(SSL_CERT_45_DAYS_EXP_RULE); requestBody.append("\"}}]}}}}"); } mustFilter.remove(EXP_IN); } requestBody.append("]}}}"); List<Map<String, Object>> certificatesDetailsFromES = new ArrayList<>(); Long totalDocs = getCertificatesDetailsCount(assetGroup, mustFilter); String request = requestBody.toString(); String scroolId = null; String responseDetails; for (int index = 0; index <= (totalDocs / esPageSize); index++) { try{ if (!Strings.isNullOrEmpty(scroolId)) { request = elasticSearchRepository.buildScrollRequest( scroolId, esPageScrollTTL); urlToQuery = urlToScroll; } responseDetails = PacHttpUtils.doHttpPost(urlToQuery, request); scroolId = elasticSearchRepository .processResponseAndSendTheScrollBack( responseDetails, certificatesDetailsFromES); } catch (Exception e) { LOGGER.error("Error in getCerticatesDetails from ES", e); throw new DataException(e); } } certificatesDetailsFromES = (List<Map<String, Object>>) CommonUtils .filterMatchingCollectionElements( certificatesDetailsFromES, searchText, true); certificatesDetailsFromES.sort(Comparator .comparing(m -> LocalDateTime.parse( (String) m.get(VALID_TO), DateTimeFormatter.ofPattern("M/d/yyyy H:m")) .toLocalDate())); for (Map<String, Object> _certificatesDetailsFromES : certificatesDetailsFromES) { Map<String, Object> certificate = new LinkedHashMap<>(); certificate.put("name", _certificatesDetailsFromES.get("commonname")); if (StringUtils.isNotEmpty(_certificatesDetailsFromES.get( VALID_TO).toString())) { certificate.put(EXP_IN, calculateExpiryDuration(_certificatesDetailsFromES .get(VALID_TO).toString()) + " days"); } else { certificate.put(EXP_IN, 0); } certificate.put("type", _certificatesDetailsFromES.get("certType")); certificate.put("application", _certificatesDetailsFromES.get("tags.Application")); certificate.put("environment", _certificatesDetailsFromES.get("tags.Environment")); certificate.put("owner", _certificatesDetailsFromES.get("tags.Owner")); certificate.put("issuer", _certificatesDetailsFromES.get("issuerdn")); certificate.put("validUntil", _certificatesDetailsFromES.get(VALID_TO)); certificate.put("validfrom", _certificatesDetailsFromES.get("validfrom")); certificate.put("status", _certificatesDetailsFromES.get("status")); certificateDetails.add(certificate); } } catch (DataException e) { LOGGER.error("Error in getCerticatesDetails", e); } return certificateDetails; }  Map<String, Object> getCertificatesExpiryByApplication(
            String assetGroup); @SuppressWarnings("unchecked") List<Map<String, Object>> getCertificatesDetails(String assetGroup,
            String searchText, Map<String, String> filter); Map<String, Object> getCertificatesSummary(String assetGroup); }
CertificateRepository implements Constants { @SuppressWarnings("unchecked") public List<Map<String, Object>> getCertificatesDetails(String assetGroup, String searchText, Map<String, String> filter) throws DataException { List<Map<String, Object>> certificateDetails = new ArrayList<>(); try { Map<String, Object> mustFilter = new HashMap<>(); mustFilter.put("latest", true); if (null != filter && filter.size() > 0) { filter.forEach((key, value) -> mustFilter.put(key, value)); } StringBuilder urlToQueryBuffer = new StringBuilder(esUrl) .append("/").append(assetGroup).append(CERT_SEARCH) .append("?scroll=").append(esPageScrollTTL); String urlToQuery = urlToQueryBuffer.toString(); String urlToScroll = new StringBuilder(esUrl).append("/") .append("_search").append("/scroll").toString(); StringBuilder requestBody = new StringBuilder( "{\"size\":").append(TEN_THOUSAND).append(",\"query\":{\"bool\":{\"must\":[{\"match\":{\"latest\":\"true\"}}"); if (filter.containsKey("tags.Application.keyword")) { requestBody .append(",{\"match\":{\"tags.Application.keyword\":\""); requestBody.append(filter.get("tags.Application.keyword")); requestBody.append("\"}}"); } if (filter.containsKey("tags.Environment.keyword")) { requestBody .append(",{\"match\":{\"tags.Environment.keyword\":\""); requestBody.append(filter.get("tags.Environment.keyword")); requestBody.append("\"}}"); } if (filter.containsKey(EXP_IN)) { if (filter.get(EXP_IN).equals(THIRTY)) { requestBody .append(",{\"has_child\":{\"type\":\"issue_cert\",\"query\":{\"bool\":{\"must\":[{\"term\":{\"issueStatus.keyword\":\"open\"}},{\"term\":{\"type.keyword\":\"issue\"}},{\"match\":{\"ruleId.keyword\":\""); requestBody.append(SSL_CERT_30_DAYS_EXP_RULE); requestBody.append("\"}}]}}}}"); } else if (filter.get(EXP_IN).equals(FOURTYFIVE)) { requestBody .append(",{\"has_child\":{\"type\":\"issue_cert\",\"query\":{\"bool\":{\"must\":[{\"term\":{\"issueStatus.keyword\":\"open\"}},{\"term\":{\"type.keyword\":\"issue\"}},{\"match\":{\"ruleId.keyword\":\""); requestBody.append(SSL_CERT_45_DAYS_EXP_RULE); requestBody.append("\"}}]}}}}"); } mustFilter.remove(EXP_IN); } requestBody.append("]}}}"); List<Map<String, Object>> certificatesDetailsFromES = new ArrayList<>(); Long totalDocs = getCertificatesDetailsCount(assetGroup, mustFilter); String request = requestBody.toString(); String scroolId = null; String responseDetails; for (int index = 0; index <= (totalDocs / esPageSize); index++) { try{ if (!Strings.isNullOrEmpty(scroolId)) { request = elasticSearchRepository.buildScrollRequest( scroolId, esPageScrollTTL); urlToQuery = urlToScroll; } responseDetails = PacHttpUtils.doHttpPost(urlToQuery, request); scroolId = elasticSearchRepository .processResponseAndSendTheScrollBack( responseDetails, certificatesDetailsFromES); } catch (Exception e) { LOGGER.error("Error in getCerticatesDetails from ES", e); throw new DataException(e); } } certificatesDetailsFromES = (List<Map<String, Object>>) CommonUtils .filterMatchingCollectionElements( certificatesDetailsFromES, searchText, true); certificatesDetailsFromES.sort(Comparator .comparing(m -> LocalDateTime.parse( (String) m.get(VALID_TO), DateTimeFormatter.ofPattern("M/d/yyyy H:m")) .toLocalDate())); for (Map<String, Object> _certificatesDetailsFromES : certificatesDetailsFromES) { Map<String, Object> certificate = new LinkedHashMap<>(); certificate.put("name", _certificatesDetailsFromES.get("commonname")); if (StringUtils.isNotEmpty(_certificatesDetailsFromES.get( VALID_TO).toString())) { certificate.put(EXP_IN, calculateExpiryDuration(_certificatesDetailsFromES .get(VALID_TO).toString()) + " days"); } else { certificate.put(EXP_IN, 0); } certificate.put("type", _certificatesDetailsFromES.get("certType")); certificate.put("application", _certificatesDetailsFromES.get("tags.Application")); certificate.put("environment", _certificatesDetailsFromES.get("tags.Environment")); certificate.put("owner", _certificatesDetailsFromES.get("tags.Owner")); certificate.put("issuer", _certificatesDetailsFromES.get("issuerdn")); certificate.put("validUntil", _certificatesDetailsFromES.get(VALID_TO)); certificate.put("validfrom", _certificatesDetailsFromES.get("validfrom")); certificate.put("status", _certificatesDetailsFromES.get("status")); certificateDetails.add(certificate); } } catch (DataException e) { LOGGER.error("Error in getCerticatesDetails", e); } return certificateDetails; }  Map<String, Object> getCertificatesExpiryByApplication(
            String assetGroup); @SuppressWarnings("unchecked") List<Map<String, Object>> getCertificatesDetails(String assetGroup,
            String searchText, Map<String, String> filter); Map<String, Object> getCertificatesSummary(String assetGroup);  }