Package org.postgresql.core.v3
Class AuthenticationPluginManager
- java.lang.Object
-
- org.postgresql.core.v3.AuthenticationPluginManager
-
class AuthenticationPluginManager extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
AuthenticationPluginManager.PasswordAction<T,R>
-
Field Summary
Fields Modifier and Type Field Description private static java.util.logging.Logger
LOGGER
-
Constructor Summary
Constructors Modifier Constructor Description private
AuthenticationPluginManager()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> T
withEncodedPassword(AuthenticationRequestType type, java.util.Properties info, AuthenticationPluginManager.PasswordAction<byte[],T> action)
Helper that wrapswithPassword(AuthenticationRequestType, Properties, PasswordAction)
, checks that it is not-null, and encodes it as a byte array.static <T> T
withPassword(AuthenticationRequestType type, java.util.Properties info, AuthenticationPluginManager.PasswordAction<char[],T> action)
If a password is requested by the server during connection initiation, this method will be invoked to supply the password.
-
-
-
Method Detail
-
withPassword
public static <T> T withPassword(AuthenticationRequestType type, java.util.Properties info, AuthenticationPluginManager.PasswordAction<char[],T> action) throws PSQLException, java.io.IOException
If a password is requested by the server during connection initiation, this method will be invoked to supply the password. This method will only be invoked if the server actually requests a password, e.g. trust authentication will skip it entirely.The caller provides a action method that will be invoked with the
char[]
password. After completion, for security reasons thechar[]
array will be wiped by filling it with zeroes. Callers must not rely on being able to read the passwordchar[]
after the action has completed.- Parameters:
type
- The authentication type that is being requestedinfo
- The connection properties for the connectionaction
- The action to invoke with the password- Throws:
PSQLException
- Throws a PSQLException if the plugin class cannot be instantiatedjava.io.IOException
- Bubbles up any thrown IOException from the provided action
-
withEncodedPassword
public static <T> T withEncodedPassword(AuthenticationRequestType type, java.util.Properties info, AuthenticationPluginManager.PasswordAction<byte[],T> action) throws PSQLException, java.io.IOException
Helper that wrapswithPassword(AuthenticationRequestType, Properties, PasswordAction)
, checks that it is not-null, and encodes it as a byte array. Used by internal code paths that require an encoded password that may be an empty string, but not null.The caller provides a callback method that will be invoked with the
byte[]
encoded password. After completion, for security reasons thebyte[]
array will be wiped by filling it with zeroes. Callers must not rely on being able to read the passwordbyte[]
after the callback has completed.- Parameters:
type
- The authentication type that is being requestedinfo
- The connection properties for the connectionaction
- The action to invoke with the encoded password- Throws:
PSQLException
- Throws a PSQLException if the plugin class cannot be instantiated or if the retrieved password is null.java.io.IOException
- Bubbles up any thrown IOException from the provided callback
-
-