Top Description Fields Constructors Methods
org.postgresql.jdbcurlresolver

public Class PgPassParser

extends Object
Class Inheritance
Imports
org.postgresql.PGEnvironment, org.postgresql.util.OSUtil, org.checkerframework.checker.nullness.qual.Nullable, java.io.BufferedReader, .File, .FileInputStream, .IOException, .InputStream, .InputStreamReader, .Reader, java.net.MalformedURLException, .URL, java.nio.charset.StandardCharsets, java.util.logging.Level, .Logger

helps to read Password File. https://www.postgresql.org/docs/current/libpq-pgpass.html

Field Summary

Modifier and TypeField and Description
private final String
private final String
private static final Logger
private final String
private static final char
private final String

Constructor Summary

AccessConstructor and Description
private
PgPassParser(String hostname, String port, String database, String user)

Method Summary

Modifier and TypeMethod and Description
private @Nullable String
private @Nullable String
evaluateLine(String fullLine, int currentLine)

private String
private @Nullable String
private @Nullable String
public static @Nullable String

Returns:

password or null
getPassword
(@Nullable String
hostname or *
hostname
,
@Nullable String
port or *
port
,
@Nullable String
database or *
database
,
@Nullable String
username or *
user
)

Read .pgpass resource

private InputStream
openInputStream(String resourceName)

private @Nullable String
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

databaseback to summary
private final String database
hostnameback to summary
private final String hostname
LOGGERback to summary
private static final Logger LOGGER
portback to summary
private final String port
SEPARATORback to summary
private static final char SEPARATOR
userback to summary
private final String user

Constructor Detail

PgPassParserback to summary
private PgPassParser(String hostname, String port, String database, String user)

Method Detail

checkForPatternback to summary
private @Nullable String checkForPattern(String line, String value)
evaluateLineback to summary
private @Nullable String evaluateLine(String fullLine, int currentLine)
extractPasswordback to summary
private String extractPassword(String line)
findPasswordback to summary
private @Nullable String findPassword()
findPgPasswordResourceNameback to summary
private @Nullable String findPgPasswordResourceName()
getPasswordback to summary
public static @Nullable String getPassword(@Nullable String hostname, @Nullable String port, @Nullable String database, @Nullable String user)

Read .pgpass resource

Parameters
hostname:@Nullable String

hostname or *

port:@Nullable String

port or *

database:@Nullable String

database or *

user:@Nullable String

username or *

Returns:@Nullable String

password or null

openInputStreamback to summary
private InputStream openInputStream(String resourceName) throws IOException
parseInputStreamback to summary
private @Nullable String parseInputStream(InputStream inputStream) throws IOException