class KerberosPrincipalFactory {

  public static KerberosPrincipal create(FileSystemOperations fsOperations,
                                         RemoteDirectoryManager remoteDirectoryManager,
                                         RunJobParameters parameters) throws IOException {
    Objects.requireNonNull(fsOperations,
        "FileSystemOperations must not be null!");
    Objects.requireNonNull(remoteDirectoryManager,
        "RemoteDirectoryManager must not be null!");
    Objects.requireNonNull(parameters, "Parameters must not be null!");

    if (StringUtils.isNotBlank(parameters.getKeytab()) && StringUtils
        .isNotBlank(parameters.getPrincipal())) {
      String keytab = parameters.getKeytab();
      String principal = parameters.getPrincipal();
      if (parameters.isDistributeKeytab()) {
        return handleDistributedKeytab(fsOperations, remoteDirectoryManager,
            parameters, keytab, principal);
      } else {
        return handleNormalKeytab(keytab, principal);
      }
    }
    LOG.debug("Principal and keytab was null or empty, " +
        "returning null KerberosPrincipal!");
    return null;
  }

  private  KerberosPrincipalFactory();

}