Class PgPassParser

java.lang.Object
org.postgresql.jdbcurlresolver.PgPassParser

public class PgPassParser extends Object
helps to read Password File. https://www.postgresql.org/docs/current/libpq-pgpass.html
  • Field Details

    • LOGGER

      private static final Logger LOGGER
    • SEPARATOR

      private static final char SEPARATOR
      See Also:
    • hostname

      private final String hostname
    • port

      private final String port
    • database

      private final String database
    • user

      private final String user
  • Constructor Details

  • Method Details

    • getPassword

      public static String getPassword(String hostname, String port, String database, String user)
      Read .pgpass resource
      Parameters:
      hostname - hostname or *
      port - port or *
      database - database or *
      user - username or *
      Returns:
      password or null
    • findPassword

      private String findPassword()
    • openInputStream

      private InputStream openInputStream(String resourceName) throws IOException
      Throws:
      IOException
    • findPgPasswordResourceName

      private String findPgPasswordResourceName()
    • parseInputStream

      private String parseInputStream(InputStream inputStream) throws IOException
      Throws:
      IOException
    • evaluateLine

      private String evaluateLine(String fullLine, int currentLine)
    • extractPassword

      private String extractPassword(String line)
    • checkForPattern

      private String checkForPattern(String line, String value)