@Override
  public RangerPolicy getDenyPolicyForReplicatedDb(String rangerServiceName,
                                                   String sourceDb, String targetDb) throws SemanticException {
    if (StringUtils.isEmpty(rangerServiceName)) {
      throw new SemanticException(ErrorMsg.REPL_INVALID_CONFIG_FOR_SERVICE.format("Ranger Service " +
        "Name cannot be empty", ReplUtils.REPL_RANGER_SERVICE));
    }
    RangerPolicy denyRangerPolicy = new RangerPolicy();
    denyRangerPolicy.setService(rangerServiceName);
    denyRangerPolicy.setName(sourceDb + "_replication deny policy for " + targetDb);
    Map<String, RangerPolicy.RangerPolicyResource> rangerPolicyResourceMap = new HashMap<String,
        RangerPolicy.RangerPolicyResource>();
    RangerPolicy.RangerPolicyResource rangerPolicyResource = new RangerPolicy.RangerPolicyResource();
    List<String> resourceNameList = new ArrayList<String>();

    List<RangerPolicy.RangerPolicyItem> denyPolicyItemsForPublicGroup = denyRangerPolicy.getDenyPolicyItems();
    RangerPolicy.RangerPolicyItem denyPolicyItem = new RangerPolicy.RangerPolicyItem();
    List<RangerPolicy.RangerPolicyItemAccess> denyPolicyItemAccesses = new ArrayList<RangerPolicy.
        RangerPolicyItemAccess>();

    List<RangerPolicy.RangerPolicyItem> denyExceptionsItemsForBeaconUser = denyRangerPolicy.getDenyExceptions();
    RangerPolicy.RangerPolicyItem denyExceptionsPolicyItem = new RangerPolicy.RangerPolicyItem();
    List<RangerPolicy.RangerPolicyItemAccess> denyExceptionsPolicyItemAccesses = new ArrayList<RangerPolicy.
        RangerPolicyItemAccess>();

    resourceNameList.add(targetDb);
    resourceNameList.add("dummy");
    rangerPolicyResource.setValues(resourceNameList);
    RangerPolicy.RangerPolicyResource rangerPolicyResourceColumn =new RangerPolicy.RangerPolicyResource();
    rangerPolicyResourceColumn.setValues(new ArrayList<String>(){{add("*"); }});
    RangerPolicy.RangerPolicyResource rangerPolicyResourceTable =new RangerPolicy.RangerPolicyResource();
    rangerPolicyResourceTable.setValues(new ArrayList<String>(){{add("*"); }});
    rangerPolicyResourceMap.put("database", rangerPolicyResource);
    rangerPolicyResourceMap.put("table", rangerPolicyResourceTable);
    rangerPolicyResourceMap.put("column", rangerPolicyResourceColumn);
    denyRangerPolicy.setResources(rangerPolicyResourceMap);

    List<String> accessTypes = Arrays.asList("create", "update", "drop", "alter",
        "index", "lock", "write", "ReplAdmin");
    for (String access : accessTypes) {
      denyPolicyItemAccesses.add(new RangerPolicy.RangerPolicyItemAccess(access, true));
    }
    denyPolicyItem.setAccesses(denyPolicyItemAccesses);
    denyPolicyItemsForPublicGroup.add(denyPolicyItem);
    List<String> denyPolicyItemsGroups = new ArrayList<String>();
    denyPolicyItemsGroups.add("public");
    denyPolicyItem.setGroups(denyPolicyItemsGroups);
    denyRangerPolicy.setDenyPolicyItems(denyPolicyItemsForPublicGroup);

    List<String> denyExcludeAccessTypes = Arrays.asList("create", "update", "drop", "alter", "index", "lock", "write",
        "ReplAdmin", "select", "read");
    for (String access : denyExcludeAccessTypes) {
      denyExceptionsPolicyItemAccesses.add(new RangerPolicy.RangerPolicyItemAccess(access, true));
    }
    denyExceptionsPolicyItem.setAccesses(denyExceptionsPolicyItemAccesses);
    denyExceptionsItemsForBeaconUser.add(denyExceptionsPolicyItem);
    List<String> denyExceptionsPolicyItemsUsers = new ArrayList<String>();
    denyExceptionsPolicyItemsUsers.add("hive");
    denyExceptionsPolicyItem.setUsers(denyExceptionsPolicyItemsUsers);
    denyRangerPolicy.setDenyExceptions(denyExceptionsItemsForBeaconUser);

    return denyRangerPolicy;
  }
RangerRestClientImpl to connect to Ranger and export policies.
ql/src/java/org/apache/hadoop/hive/ql/exec/repl/ranger/RangerRestClientImpl.java