diff --git a/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java b/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java index fa8e367eab..0eae9885df 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java @@ -53,6 +53,7 @@ import org.hibernate.boot.cfgxml.spi.LoadedConfig; import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; import org.hibernate.boot.spi.MetadataImplementor; import org.hibernate.boot.spi.SessionFactoryOptions; +import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.Environment; import org.hibernate.cfg.Settings; import org.hibernate.context.internal.JTASessionContext; @@ -225,7 +226,7 @@ public final class SessionFactoryImpl implements SessionFactoryImplementor { this.properties = new HashMap<>(); this.properties.putAll( serviceRegistry.getService( ConfigurationService.class ).getSettings() ); - + maskOutSensitiveInformation(this.properties); this.sqlFunctionRegistry = new SQLFunctionRegistry( jdbcServices.getJdbcEnvironment().getDialect(), options.getCustomSqlFunctionMap() ); this.cacheAccess = this.serviceRegistry.getService( CacheImplementor.class ); this.criteriaBuilder = new CriteriaBuilderImpl( this ); @@ -1478,4 +1479,15 @@ public final class SessionFactoryImpl implements SessionFactoryImplementor { final String name = isNamed ? ois.readUTF() : null; return (SessionFactoryImpl) locateSessionFactoryOnDeserialization( uuid, name ); } + + private void maskOutSensitiveInformation(Map props) { + maskOutIfSet( props, AvailableSettings.JPA_JDBC_USER ); + maskOutIfSet( props, AvailableSettings.PASS ); + } + + private void maskOutIfSet(Map props, String setting) { + if ( props.containsKey( setting ) ) { + props.put( setting, "****" ); + } + } }