Details
-
Type:
Improvement
-
Status:
Resolved
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: 6.0.1
-
Fix Version/s: 6.1.2rc1
-
Component/s: Security and SSL
-
Labels:None
-
Environment:Derby 10.2.1
-
Number of attachments :
Description
Trying to get Jetty JDBCUserRealm to work with Derby does not work easily.
SQL generated by role query is rejected by Derby
SQL: select r.rolename from roles r, userroles u where u.userid = '1' and r.id = u.roleid;
Derby: ERROR 42818: Comparisons between 'INTEGER' and 'CHAR' are not supported.
(Assumption: table userroles has userid column of type INTEGER (or any non-char data type); I believe this assumption is sensible).
The condition u.userid = '1' is rejected because of the quotes. Request runs fine without the quotes.
Internally, org.mortbay.jetty.security.JDBCUserRealm::loadUser uses
Object key = rs.getObject(_userTableKey);
put(username, rs.getString(_userTablePasswordField));
stat.close();
stat = _con.prepareStatement(_roleSql);
stat.setObject(1, key);
where (for Derby at least)
int key = rs.getInt(_userTableKey);
put(username, rs.getString(_userTablePasswordField));
stat.close();
stat = _con.prepareStatement(_roleSql);
stat.setInt(1, key);
would be better. With the code changed as above realm access does work.
I suggest adding a further boolean configuration attribute like "isBooleanUserTableKey" (default false) to this class?
This would maintain backwards compatibility.
Or maybe a further JDBCUserRealm variant, maybe derived from that class?
Armi, can you change the JDBCUserRealm class do use integer comparison, and test it for backwards compatibility with mysql? Thanks.