class ElasticSearchInternalAccessRule extends BaseRule {

    public RuleResult execute(final Map<String, String> ruleParam,
            Map<String, String> resourceAttributes) {
        logger.debug("========ElasticSearchInternalAccessRule started=========");
        String privateIPAddress = resourceAttributes
                .get(PacmanRuleConstants.PRIVATE_IP_ADDRESS);
        String portNum = ruleParam.get(PacmanRuleConstants.PORT);

        String severity = ruleParam.get(PacmanRuleConstants.SEVERITY);
        String category = ruleParam.get(PacmanRuleConstants.CATEGORY);

        MDC.put("executionId", ruleParam.get("executionId"));
        MDC.put("ruleId", ruleParam.get(PacmanSdkConstants.RULE_ID));

        List<LinkedHashMap<String, Object>> issueList = new ArrayList<>();
        LinkedHashMap<String, Object> issue = new LinkedHashMap<>();

        if (!PacmanUtils.doesAllHaveValue(severity, category,portNum)) {
            logger.info(PacmanRuleConstants.MISSING_CONFIGURATION);
            throw new InvalidInputException(PacmanRuleConstants.MISSING_CONFIGURATION);
        }

        if ((!StringUtils.isNullOrEmpty(privateIPAddress))
                && (!StringUtils.isNullOrEmpty(portNum))) {
            String urlString = null;
            Annotation annotation = null;
            urlString = "http://" + privateIPAddress + ":" + portNum;
            CloseableHttpClient httpClient = null;
            try {
                URL url = new URL(urlString);
                URI uri = new URI(url.getProtocol(), url.getUserInfo(),
                        url.getHost(), url.getPort(), url.getPath(),
                        url.getQuery(), url.getRef());

                httpClient = HttpClientBuilder.create()
                        .setConnectionTimeToLive(1, TimeUnit.SECONDS).build();
                HttpGet httpGet = new HttpGet(uri);
                HttpResponse response = httpClient.execute(httpGet);
                String responseJson = EntityUtils
                        .toString(response.getEntity());
                if (responseJson.contains("lucene_version")) {
                    logger.info("ES end point can be accessed internally");
                    annotation = Annotation.buildAnnotation(ruleParam,
                            Annotation.Type.ISSUE);
                    annotation.put(PacmanSdkConstants.DESCRIPTION,
                            "Private IP public accessble with port 9200");
                    annotation.put(PacmanRuleConstants.SEVERITY, severity);
                    annotation.put(PacmanRuleConstants.CATEGORY, category);

                    issue.put(PacmanRuleConstants.VIOLATION_REASON,
                            "Private IP public accessble with port 9200");
                    issue.put("private_ip", privateIPAddress);
                    issue.put("port_number", portNum);
                    issueList.add(issue);
                    annotation.put("issueDetails", issueList.toString());

                    logger.debug("========ElasticSearchInternalAccessRule ended with an annotation {} :=========", annotation);
                    return new RuleResult(PacmanSdkConstants.STATUS_FAILURE,
                            PacmanRuleConstants.FAILURE_MESSAGE, annotation);
                }
            } catch (Exception mue) {
                logger.info(mue.toString());
            }  finally {
                if (null != httpClient)
                    try {
                        httpClient.close();
                    } catch (IOException e) {
                        logger.error("unable to close http client");
                    }
            }

        } else {
            logger.info("Private IP/Port#  value is null");
            throw new InvalidInputException(PacmanRuleConstants.MISSING_CONFIGURATION);

        }
        logger.debug("========ElasticSearchInternalAccessRule ended=========");
        return new RuleResult(PacmanSdkConstants.STATUS_SUCCESS,
                PacmanRuleConstants.SUCCESS_MESSAGE);
    }

}