-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Events ... Reference Documentation confusing
PostPosted: Tue Jul 26, 2005 11:47 am 
Newbie

Joined: Tue Jul 26, 2005 9:16 am
Posts: 3
Location: Madison, WI
Hibernate version: 3.0

The reference documentation for events shows the following example:

Code:
public class MyLoadListener extends DefaultLoadEventListener {
    // this is the single method defined by the LoadEventListener interface
    public Object onLoad(LoadEvent event, LoadEventListener.LoadType loadType)
            throws HibernateException {
        if ( !MySecurity.isAuthorized( event.getEntityClassName(), event.getEntityId() ) ) {
            throw MySecurityException("Unauthorized access");
        }
        return super.onLoad(event, loadType);
    }
}


My question is, where does MySecurity come from? Also, how does MySecurity know what user is making the request? In order to check security, the listener would need to know which user was attempting the load. This means that:

Code:
cfg.getSessionEventListenerConfig().setLoadEventListener( new MyLoadListener() );


would have to be called each time a user logs in (so that you could set an attribute in MySecurity or in MyLoadListener indicating the user identity).

Based on the reference documentation, a Configuration and SessionFactory should not be created for each login (assuming a web ui model). It should only be created when the application is deployed.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 26, 2005 11:51 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
MySecurity can be anything in your application that exposes some security and authorization context. It's just an example! You can easily implement stuff like this with a ThreadLocal variable (use Google).


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.