@Override
    public int execute() {
        try {
            LOG.info("Checking Ranger Deny Policy for {}", work.getTargetDbName());
            SecurityUtils.reloginExpiringKeytabUser();
            if (rangerRestClient == null) {
                rangerRestClient = getRangerRestClient();
            }
            URL url = work.getRangerConfigResource();
            if (url == null) {
                throw new SemanticException(ErrorMsg.REPL_INVALID_CONFIG_FOR_SERVICE
                        .format("Ranger configuration is not valid "
                                + ReplUtils.RANGER_CONFIGURATION_RESOURCE_NAME, ReplUtils.REPL_RANGER_SERVICE));
            }
            conf.addResource(url);
            String rangerHiveServiceName = conf.get(ReplUtils.RANGER_HIVE_SERVICE_NAME);
            String rangerEndpoint = conf.get(ReplUtils.RANGER_REST_URL);
            if (StringUtils.isEmpty(rangerEndpoint)) {
                throw new SemanticException(ErrorMsg.REPL_INVALID_CONFIG_FOR_SERVICE
                        .format("Ranger endpoint is not valid "
                                + rangerEndpoint, ReplUtils.REPL_RANGER_SERVICE));
            }
            if (!rangerRestClient.checkConnection(rangerEndpoint, conf)) {
                throw new SemanticException(ErrorMsg.REPL_EXTERNAL_SERVICE_CONNECTION_ERROR.format(
                        ReplUtils.REPL_RANGER_SERVICE, "Ranger endpoint is not valid " + rangerEndpoint));
            }
            Map<String, Long> metricMap = new HashMap<>();
            metricMap.put(ReplUtils.MetricName.POLICIES.name(), 1L);
            work.getMetricCollector().reportStageStart(getName(), metricMap);
            if (conf.getBoolVar(HiveConf.ConfVars.REPL_RANGER_ADD_DENY_POLICY_TARGET)) {
                RangerPolicy rangerDenyPolicy = rangerRestClient.getDenyPolicyForReplicatedDb(rangerHiveServiceName,
                        work.getSourceDbName(), work.getTargetDbName());

                RangerExportPolicyList rangerExportPolicyList = new RangerExportPolicyList();
                rangerExportPolicyList.setPolicies(new ArrayList<RangerPolicy>() {{add(rangerDenyPolicy);}});
                rangerRestClient.importRangerPolicies(rangerExportPolicyList, work.getTargetDbName(), rangerEndpoint,
                        rangerHiveServiceName, conf);
                work.getMetricCollector().reportStageProgress(getName(), ReplUtils.MetricName.POLICIES.name(), 1);
                LOG.info("Created Ranger Deny policy for {}", work.getTargetDbName());
            } else {
                String policyName = work.getSourceDbName() + "_replication deny policy for " + work.getTargetDbName();
                rangerRestClient.deleteRangerPolicy(policyName, rangerEndpoint, rangerHiveServiceName, conf);
                work.getMetricCollector().reportStageProgress(getName(), ReplUtils.MetricName.POLICIES.name(), 1);
                LOG.info("Deleted Ranger Deny policy for {}", work.getTargetDbName());
            }
            work.getMetricCollector().reportStageEnd(getName(), Status.SUCCESS);
            return 0;
        } catch (RuntimeException e) {
            LOG.error("Runtime Excepton during Ranger Deny policy creation.", e);
            setException(e);
            try{
                ReplUtils.handleException(true, e, work.getCurrentDumpPath().getParent().toString(),
                        work.getMetricCollector(), getName(), conf);
            } catch (Exception ex){
                LOG.error("Failed to collect replication metrics: ", ex);
            }
            throw e;
        } catch (Exception e) {
            try {
                LOG.error("Ranger Deny policy creation Failed", e);
                setException(e);
                return ReplUtils.handleException(true, e, work.getCurrentDumpPath().getParent().toString(), work.getMetricCollector(),
                        getName(), conf);
            } catch (Exception ex) {
                LOG.error("Failed to collect replication metrics: ", ex);
                int errorCode = ErrorMsg.getErrorMsg(e.getMessage()).getErrorCode();
                return errorCode;
            }
        }
    }
RangerDenyTask.

Task to add Ranger Deny Policy
ql/src/java/org/apache/hadoop/hive/ql/exec/repl/RangerDenyTask.java