if (_roleQuery == null)
return principal != null && "user".equals(role);
else if (principal == null || role == null)
return false;
CachingPrincipal cachingPrincipal = null;
if (principal instanceof CachingPrincipal) {
cachingPrincipal = (CachingPrincipal) principal;
Boolean isInRole = cachingPrincipal.isInRole(role);
if (isInRole != null)
return isInRole.equals(Boolean.TRUE);
}
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs = null;
try {
conn = _dataSource.getConnection();
stmt = conn.prepareStatement(_roleQuery);
stmt.setString(1, principal.getName());
boolean inRole = false;
rs = stmt.executeQuery();
while (rs.next()) {
String dbRole = rs.getString(1);
if (cachingPrincipal != null)
cachingPrincipal.addRole(dbRole);
if (role.equals(dbRole))
inRole = true;
}