--- a/java/sql-dk/src/info/globalcode/sql/dk/DatabaseConnection.java Wed Jan 01 02:44:29 2014 +0100
+++ b/java/sql-dk/src/info/globalcode/sql/dk/DatabaseConnection.java Wed Jan 01 02:56:08 2014 +0100
@@ -39,6 +39,8 @@
public class DatabaseConnection implements AutoCloseable {
private static final Logger log = Logger.getLogger(DatabaseConnection.class.getName());
+ private static final String JDBC_PROPERTY_USER = "user";
+ public static final String JDBC_PROPERTY_PASSWORD = "password";
private DatabaseDefinition databaseDefinition;
private Connection connection;
private Properties properties;
@@ -47,9 +49,13 @@
this.databaseDefinition = databaseDefinition;
this.properties = properties;
+ if (properties.hasProperty(JDBC_PROPERTY_PASSWORD)) {
+ log.log(Level.WARNING, "Passing DB password as CLI parameter is insecure!");
+ }
+
Properties credentials = new Properties();
- credentials.add(new Property("user", databaseDefinition.getUserName()));
- credentials.add(new Property("password", databaseDefinition.getPassword()));
+ credentials.add(new Property(JDBC_PROPERTY_USER, databaseDefinition.getUserName()));
+ credentials.add(new Property(JDBC_PROPERTY_PASSWORD, databaseDefinition.getPassword()));
credentials.setDefaults(databaseDefinition.getProperties());
properties.setDefaults(credentials);
java.util.Properties javaProperties = properties.getJavaProperties();
--- a/java/sql-dk/src/info/globalcode/sql/dk/configuration/Properties.java Wed Jan 01 02:44:29 2014 +0100
+++ b/java/sql-dk/src/info/globalcode/sql/dk/configuration/Properties.java Wed Jan 01 02:56:08 2014 +0100
@@ -82,6 +82,10 @@
return p == null ? defaultValue : Integer.valueOf(p.getValue());
}
+ public boolean hasProperty(String name) {
+ return findByName(this, name) != null;
+ }
+
@Override
public Properties clone() {
Properties clone = new Properties(size());