public void addPamAuthentication(UserEntity userEntity, String userName, boolean persist) throws AmbariException {
    addAuthentication(userEntity,
        UserAuthenticationType.PAM,
        userName,
            (user, key) -> {
              List<UserAuthenticationEntity> authenticationEntities = user.getAuthenticationEntities();

              // Ensure only one UserAuthenticationEntity exists for PAM for the user...
              for (UserAuthenticationEntity entity : authenticationEntities) {
                if (entity.getAuthenticationType() == UserAuthenticationType.PAM) {
                  throw new AmbariException("The authentication type already exists for this user");
                }
              }
            },
        persist);
  }
Adds the ability for a user to authenticate using Pam

@param userEntity the user
@param userName   the user's os-level username
@param persist    true, to persist the created entity; false, to not persist the created entity
@throws AmbariException
ambari-server/src/main/java/org/apache/ambari/server/security/authorization/Users.java