class KerberosOperationHandler {

  protected String escapeCharacters(String string, Set<Character> charactersToEscape, Character escapeCharacter) {
    if (StringUtils.isEmpty(string) || (charactersToEscape == null) || charactersToEscape.isEmpty()) {
      return string;
    } else {
      StringBuilder builder = new StringBuilder();

      for (char character : string.toCharArray()) {
        if (charactersToEscape.contains(character)) {
          builder.append(escapeCharacter);
        }
        builder.append(character);
      }

      return builder.toString();
    }
  }

}