Subject | Re: [Firebird-Java] How to specify RoleName in the JNDI resource? |
---|---|
Author | Jose Maria Lopez Lagunas |
Post date | 2002-11-14T15:14:56Z |
Hi.
I guess ROLES are not implemented in the current version of the driver.
I had a similar problem because we use roles too. To solve it I modified
the FBDriver.java file
to accept roles by using the 'roleName' property (as InterClient does).
This is what I modified (sorry for not submitting it, I did the changes
yesterday and was testing my applications):
FBDriver.java
...
public class FBDriver implements Driver {
...
public static final String DATABASE = "database";
public static final String ROLENAME = "roleName"; // I added this
field
public static final String BLOB_BUFFER_LENGTH = "blob_buffer_length";
...
public Connection connect(String url, java.util.Properties info)
throws SQLException
{
...
if (password == null)
throw new SQLException(
"Password for database connection not specified.");
// THIS IS WHAT I MODIFIED
/////////////////////////////////////////////////////////
// extract the roleName
String roleName = info.getProperty(ROLENAME);
if (roleName == null)
roleName =
conCri.getStringProperty(GDS.isc_dpb_sql_role_name);
else
conCri.setProperty(GDS.isc_dpb_sql_role_name,roleName);
// Should I do that?
// Maybe it should ignore role if it is not found so the
next code might be removed
if ((roleName == null) && (!user.equalsIgnoreCase("sysdba")))
throw new SQLException(
"User role for database connection not specified.");
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// extract the database URL
String databaseURL = url.substring(FIREBIRD_PROTOCOL.length());
...
I hope this helps.
Andrew Guts wrote:
I guess ROLES are not implemented in the current version of the driver.
I had a similar problem because we use roles too. To solve it I modified
the FBDriver.java file
to accept roles by using the 'roleName' property (as InterClient does).
This is what I modified (sorry for not submitting it, I did the changes
yesterday and was testing my applications):
FBDriver.java
...
public class FBDriver implements Driver {
...
public static final String DATABASE = "database";
public static final String ROLENAME = "roleName"; // I added this
field
public static final String BLOB_BUFFER_LENGTH = "blob_buffer_length";
...
public Connection connect(String url, java.util.Properties info)
throws SQLException
{
...
if (password == null)
throw new SQLException(
"Password for database connection not specified.");
// THIS IS WHAT I MODIFIED
/////////////////////////////////////////////////////////
// extract the roleName
String roleName = info.getProperty(ROLENAME);
if (roleName == null)
roleName =
conCri.getStringProperty(GDS.isc_dpb_sql_role_name);
else
conCri.setProperty(GDS.isc_dpb_sql_role_name,roleName);
// Should I do that?
// Maybe it should ignore role if it is not found so the
next code might be removed
if ((roleName == null) && (!user.equalsIgnoreCase("sysdba")))
throw new SQLException(
"User role for database connection not specified.");
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// extract the database URL
String databaseURL = url.substring(FIREBIRD_PROTOCOL.length());
...
I hope this helps.
Andrew Guts wrote:
>Hello All,
>
>I've defined and used DataSource with Tomcat 4.1.2. Now it is time to
>test it under real account instead of SYSDBA user. My database security
>based on roles. So how to provide role parameter to DateSource in
>server.xml?
>
>Thanks ahead
>
>Andrew
>
>PS: which place below?
>
> <Resource name="jdbc/FE2" auth="Container" type="javax.sql.DataSource"/>
> <ResourceParams name="jdbc/FE2">
> <parameter>
> <name>factory</name>
> <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
> </parameter>
> <parameter>
> <name>maxWait</name>
> <value>5000</value>
> </parameter>
> <parameter>
> <name>maxActive</name>
> <value>4</value>
> </parameter>
> <parameter>
> <name>username</name>
> <value>TOMCAT</value>
> </parameter>
> <parameter>
> <name>password</name>
> <value>12345</value>
> </parameter>
> <parameter>
> <name>url</name>
>
><value>jdbc:firebirdsql:127.0.0.1/3050:/data/db?lc_ctype=WIN1251</value>
> </parameter>
> <parameter>
> <name>driverClassName</name>
> <value>org.firebirdsql.jdbc.FBDriver</value>
> </parameter>
> <parameter>
> <name>maxIdle</name>
> <value>2</value>
> </parameter>
> </ResourceParams>
>
>
>
>
>
>
>To unsubscribe from this group, send an email to:
>Firebird-Java-unsubscribe@yahoogroups.com
>
>
>
>Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>
>
>