Skip to content

Commit

Permalink
Log out the password hash
Browse files Browse the repository at this point in the history
  • Loading branch information
halprin committed May 24, 2024
1 parent 01899f2 commit aadfff0
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import gov.hhs.cdc.trustedintermediary.wrappers.database.DatabaseCredentialsProvider;
import java.sql.Connection;
import java.sql.SQLException;
import org.apache.commons.codec.digest.DigestUtils;
import org.postgresql.ds.PGSimpleDataSource;

public class PasswordChangingPostgresDataSource extends PGSimpleDataSource {
Expand All @@ -16,6 +17,11 @@ public Connection getConnection() throws SQLException {
var latestPassword =
ApplicationContext.getImplementation(DatabaseCredentialsProvider.class)
.getPassword();

var passwordHash = DigestUtils.sha256Hex(latestPassword);
ApplicationContext.getImplementation(Logger.class)
.logInfo("Password hash={}", passwordHash);

this.setPassword(latestPassword);

return super.getConnection();
Expand All @@ -29,6 +35,11 @@ public Connection getConnection(String username, String password) throws SQLExce
var latestPassword =
ApplicationContext.getImplementation(DatabaseCredentialsProvider.class)
.getPassword();

var passwordHash = DigestUtils.sha256Hex(latestPassword);
ApplicationContext.getImplementation(Logger.class)
.logInfo("Password hash={}", passwordHash);

this.setPassword(latestPassword);

return super.getConnection(username, latestPassword);
Expand Down

0 comments on commit aadfff0

Please sign in to comment.