Andrej Koelewijn

7/21/2004

Using VPD with BC4J

Filed under: — andrejk @ 9:14 am

On OTN you’ll find a document outlining how to use VPD with BC4J: How To Create Secure BC4J Applications with Oracle9i VPD and Oracle 9iAS JAAS Provider.

I’ve tried the method described, but couldn’t get it to work properly. The afterConnect method is called only once, if you do not use connection pooling. I tested this by setting the max application module pool size to 1, and starting 2 browser sessions. Logging in with the first browser, afterConnect is called, setting the application context for VPD. After logging in with the second browser, afterConnect is not called as the application module already has a database connection.

You need to use afterActivation instead of afterConnect to make this work. AfterActivation is called every time an application module is activated from the pool. Now you can set your VPD context in the database before doing any work in the application module.

Update: Steve Muench has commented that it’s better to implement this using prepareSession(), instead of afterActivation().

3 Responses to “Using VPD with BC4J”

  1. Steve Muench Says:

    prepareSession() is the method you should use. The article needs updating to reflect this.

  2. Andrej Says:

    Thanks, i’ll update my entry.

  3. Viliam Durina Says:

    We had this problem year ago when implementing VPD according this article. We opened a TAR and the guy was not able to answer (it was a new feature that time). We solved it ourselves using prepareSession, which works well for us since then. Maybe we should have contact the author that time, maybe we are not the only confused by this article :-(

    Viliam

Leave a Reply

Powered by WordPress