On 7/7/10 2:11 PM, Ken wrote:
This is a hand rolled solution I used:
Create an interceptor which checks if a User object exists when
accessing a secure package, if it does not exist redirect the user to a
login page and record the initial url (will redirect back to that page
after login).

This isn't part 2 of the asked question, but part 1. "Best Practices" in security usually means "Don't roll your own" since you're very likely to implement the same bugs that widely used packages have had time and eyeballs needed to fix.

I use hibernate... so the user object contains a connection to the
database.

For the duration of the hibernate session, yes. But be careful about this, too, as for example if you store that in the http session you may be keeping hibernate sessions open far too long, or encountering hibernate backed objects that no longer have their active session and thus their connection to the DB.

If you're also using hibernate you'll
notice you can supply the specific "hibernate.cfg.xml" when establishing
the connection, by making this choice dependant on the particular user
you can supply different database connections or even restrict data
access.  In this case I think xml files are better than annotations as
you don't need to change the POJO which the *.hbm.xml files refer to.

That's an interesting idea, although I don't know how having a per-user hibernate.cfg allows you to control which rows of which tables are fetchable...and I'd think complex business logic would quickly make this untenable.

"Person X has read access to all rows of Y that are not marked 'private', and write access to all rows of Y that are linked to some other object that lists person X as a manager."

-Dale

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to