Add infrastructure to enable setting of username and password for DB access
git-svn-id: http://webgoat.googlecode.com/svn/trunk@127 4033779f-a91e-0410-96ef-6bf7bf53c507
This commit is contained in:
parent
e19c3353e7
commit
6f5e7c37f7
@ -65,7 +65,14 @@ public class DatabaseUtilities
|
|||||||
{
|
{
|
||||||
Class.forName(s.getDatabaseDriver());
|
Class.forName(s.getDatabaseDriver());
|
||||||
|
|
||||||
|
String password = s.getDatabasePassword();
|
||||||
|
if (password == null || password.equals("")) {
|
||||||
return (DriverManager.getConnection(s.getDatabaseConnectionString()));
|
return (DriverManager.getConnection(s.getDatabaseConnectionString()));
|
||||||
|
} else {
|
||||||
|
String conn = s.getDatabaseConnectionString();
|
||||||
|
String user = s.getDatabaseUser();
|
||||||
|
return DriverManager.getConnection(conn, user, password);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -99,6 +99,16 @@ public class WebSession
|
|||||||
/**
|
/**
|
||||||
* Description of the Field
|
* Description of the Field
|
||||||
*/
|
*/
|
||||||
|
public final static String DATABASE_USER = "DatabaseUser";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description of the Field
|
||||||
|
*/
|
||||||
|
public final static String DATABASE_PASSWORD = "DatabasePassword";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description of the Field
|
||||||
|
*/
|
||||||
public final static int ERROR = 0;
|
public final static int ERROR = 0;
|
||||||
|
|
||||||
public static final String STAGE = "stage";
|
public static final String STAGE = "stage";
|
||||||
@ -207,6 +217,10 @@ public class WebSession
|
|||||||
|
|
||||||
private String databaseDriver;
|
private String databaseDriver;
|
||||||
|
|
||||||
|
private String databaseUser;
|
||||||
|
|
||||||
|
private String databasePassword;
|
||||||
|
|
||||||
private static Connection connection = null;
|
private static Connection connection = null;
|
||||||
|
|
||||||
private int hintNum = -1;
|
private int hintNum = -1;
|
||||||
@ -273,6 +287,8 @@ public class WebSession
|
|||||||
isDebug = "true".equals( servlet.getInitParameter( DEBUG ) );
|
isDebug = "true".equals( servlet.getInitParameter( DEBUG ) );
|
||||||
databaseConnectionString = servlet.getInitParameter( DATABASE_CONNECTION_STRING );
|
databaseConnectionString = servlet.getInitParameter( DATABASE_CONNECTION_STRING );
|
||||||
databaseDriver = servlet.getInitParameter( DATABASE_DRIVER );
|
databaseDriver = servlet.getInitParameter( DATABASE_DRIVER );
|
||||||
|
databaseUser = servlet.getInitParameter(DATABASE_USER);
|
||||||
|
databasePassword = servlet.getInitParameter(DATABASE_PASSWORD);
|
||||||
servletName = servlet.getServletName();
|
servletName = servlet.getServletName();
|
||||||
this.context = context;
|
this.context = context;
|
||||||
course = new Course();
|
course = new Course();
|
||||||
@ -461,6 +477,24 @@ public class WebSession
|
|||||||
return ( databaseDriver );
|
return ( databaseDriver );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the databaseUser attribute of the WebSession object
|
||||||
|
*
|
||||||
|
* @return The databaseUser value
|
||||||
|
*/
|
||||||
|
public String getDatabaseUser() {
|
||||||
|
return (databaseUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the databasePassword attribute of the WebSession object
|
||||||
|
*
|
||||||
|
* @return The databasePassword value
|
||||||
|
*/
|
||||||
|
public String getDatabasePassword() {
|
||||||
|
return (databasePassword);
|
||||||
|
}
|
||||||
|
|
||||||
public String getRestartLink()
|
public String getRestartLink()
|
||||||
{
|
{
|
||||||
List<String> parameters = new ArrayList<String>();
|
List<String> parameters = new ArrayList<String>();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user