パッケージ org.postgresql.util
クラス PasswordUtil
java.lang.Object
org.postgresql.util.PasswordUtil
-
コンストラクタの概要
コンストラクタ -
メソッドの概要
修飾子とタイプメソッド説明static String
推奨されていません。static String
encodePassword
(String user, char[] password, String encryptionType) Encode the given password for the specified encryption type.static String
encodeScramSha256
(char[] password) Encode the given password for SCRAM-SHA-256 authentication using the default iteration count and a random salt.static String
encodeScramSha256
(char[] password, int iterations, byte[] salt) Generate the encoded text representation of the given password for SCRAM-SHA-256 authentication.static String
genAlterUserPasswordSQL
(String user, char[] password, String encryptionType) Generate the SQL statement to alter a user's password using the given encryption.
-
コンストラクタの詳細
-
PasswordUtil
public PasswordUtil()
-
-
メソッドの詳細
-
encodeScramSha256
Generate the encoded text representation of the given password for SCRAM-SHA-256 authentication. The return value of this method is the literal text that may be used when creating or modifying a user with the given password without the surrounding single quotes.- パラメータ:
password
- The plain text of the user's password. The implementation will zero out the array after useiterations
- The number of iterations of the hashing algorithm to performsalt
- The random salt value- 戻り値:
- The text representation of the password encrypted for SCRAM-SHA-256 authentication
-
encodeScramSha256
Encode the given password for SCRAM-SHA-256 authentication using the default iteration count and a random salt.- パラメータ:
password
- The plain text of the user's password. The implementation will zero out the array after use- 戻り値:
- The text representation of the password encrypted for SCRAM-SHA-256 authentication
-
encodeMd5
推奨されていません。preferPGConnection.alterUserPassword(String, char[], String)
orencodeScramSha256(char[])
for better security.Encode the given password for use with md5 authentication. The PostgreSQL server uses the username as the per-user salt so that must also be provided. The return value of this method is the literal text that may be used when creating or modifying a user with the given password without the surrounding single quotes.- パラメータ:
user
- The username of the database userpassword
- The plain text of the user's password. The implementation will zero out the array after use- 戻り値:
- The text representation of the password encrypted for md5 authentication.
-
encodePassword
public static String encodePassword(String user, char[] password, String encryptionType) throws SQLException Encode the given password for the specified encryption type. The word "encryption" is used here to match the verbiage in the PostgreSQL server, i.e. the "password_encryption" setting. In reality, a cryptographic digest / HMAC operation is being performed. The database user is only required for the md5 encryption type.- パラメータ:
user
- The username of the database userpassword
- The plain text of the user's password. The implementation will zero out the array after useencryptionType
- The encryption type for which to encode the user's password. This should match the database's supported methods and value of the password_encryption setting.- 戻り値:
- The encoded password
- 例外:
SQLException
- If an error occurs encoding the password
-
genAlterUserPasswordSQL
public static String genAlterUserPasswordSQL(String user, char[] password, String encryptionType) throws SQLException Generate the SQL statement to alter a user's password using the given encryption. All other encryption settings for the password will use the driver's defaults.- パラメータ:
user
- The username of the database userpassword
- The plain text of the user's password. The implementation will zero out the array after useencryptionType
- The encryption type of the password- 戻り値:
- An SQL statement that may be executed to change the user's password
- 例外:
SQLException
- If an error occurs encoding the password
-
PGConnection.alterUserPassword(String, char[], String)
orencodeScramSha256(char[])
for better security.