I'm playing with database-mysql and trying to get connection through it. 
However I can't get plain string password encrypted to Secret.
However Secret.formString() gives me NPE. Am I missing something?

public static Connection getConnection(String host, String dbName, String 
username, String password, String properties) {
        Secret secret = Secret.fromString(password);
        MySQLDatabase  database = new MySQLDatabase(host, dbName, username, 
secret, properties);
        Connection conn = null;
        try {
            conn = database.getDataSource().getConnection();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return conn;
    }

java.lang.NullPointerException
at jenkins.security.ConfidentialStore.get(ConfidentialStore.java:66)
at jenkins.security.ConfidentialKey.load(ConfidentialKey.java:47)
at 
jenkins.security.CryptoConfidentialKey.getKey(CryptoConfidentialKey.java:32)
at 
jenkins.security.CryptoConfidentialKey.decrypt(CryptoConfidentialKey.java:67)
at hudson.util.Secret.decrypt(Secret.java:137)
at hudson.util.Secret.fromString(Secret.java:186)
at 
com.novoda.persistence.PersistenceManager.getConnection(PersistenceManager.java:25)
at 
com.novoda.persistence.PersistenceManagerTest.test_should_create_connection_and_close_without_error(PersistenceManagerTest.java:74)

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to