public static void testDSRequestAuthentication() throws SQLException {
if (usingDerbyNetClient())
return;
EmbeddedDataSource ds = new EmbeddedDataSource();
// DataSource - EMPTY
dsConnectionRequests(new String[] {
"XJ004","XJ004","XJ004","XJ004",
"XJ004","XJ004","XJ004","XJ004","XJ004"}, ds);
// DataSource - connectionAttributes=databaseName=wombat");
ds.setConnectionAttributes("databaseName=" + dbName);
dsConnectionRequests(new String[] {
"XJ004","XJ004","XJ004","XJ004",
"XJ004","XJ004","XJ004","XJ004","XJ004"}, ds);
ds.setConnectionAttributes(null);
// DataSource - attributesAsPassword=true");
ds.setAttributesAsPassword(true);
dsConnectionRequests(new String[] {
"XJ004","XJ004","XJ004","XJ028",
"XJ028","XJ004","XJ004","XJ004","XJ004"}, ds);
ds.setAttributesAsPassword(false);
// DataSource - attributesAsPassword=true,
// connectionAttributes=databaseName=kangaroo");
ds.setAttributesAsPassword(true);
ds.setConnectionAttributes("databaseName=kangaroo");
dsConnectionRequests(new String[] {
"XJ004","XJ004","XJ004","XJ028",
"XJ028","XJ004","XJ004","XJ004","XJ004"}, ds);
ds.setAttributesAsPassword(false);
ds.setConnectionAttributes(null);
// Enable Authentication;
setDatabaseProperty("derby.user.fred", "wilma");
setDatabaseProperty("derby.user.APP", "APP");
setDatabaseProperty("derby.authentication.provider", "BUILTIN");
setDatabaseProperty("derby.connection.requireAuthentication", "true");
ds.setShutdownDatabase("shutdown");
try {
ds.getConnection();
} catch (SQLException sqle) {
assertSQLState("XJ015", sqle);
}
ds.setDatabaseName(null);
ds.setShutdownDatabase(null);
// "AUTHENTICATION NOW ENABLED");
// DataSource - attributesAsPassword=true
ds.setAttributesAsPassword(true);
dsConnectionRequests(new String[] {
"XJ004","XJ004","XJ004","XJ028",
"XJ028","XJ004","XJ004","XJ004","XJ004"}, ds);
ds.setAttributesAsPassword(false);
// ensure the DS property password is not treated as a set of
// attributes.
// DataSource - attributesAsPassword=true, user=fred,
// password=databaseName=wombat;password=wilma
ds.setAttributesAsPassword(true);
ds.setUser("fred");
ds.setPassword("databaseName=" + dbName + ";password=wilma");
dsConnectionRequests(new String[] {
"XJ004","XJ004","XJ004","XJ028",
"XJ028","XJ004","XJ004","XJ004","XJ004"}, ds);
ds.setAttributesAsPassword(false);
ds.setUser(null);
ds.setPassword(null);
ds = null;
// now with ConnectionPoolDataSource
EmbeddedConnectionPoolDataSource cpds = new EmbeddedConnectionPoolDataSource();
// ConnectionPoolDataSource - EMPTY