-->
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.  [ 7 posts ] 
Author Message
 Post subject: Access a session ctx in a custom validator w/o ThreadLocal
PostPosted: Wed Nov 15, 2006 7:50 am 
Newbie

Joined: Thu Jul 21, 2005 10:19 pm
Posts: 13
Hibernate version: 3.2.ga (annotations+core)

This is more a question on how you guys do it in the real life...

1. I need a validator that checks, i.e. if an user have rights to delete an specific object (he owns that object), for instance, i want to check for:

currentUser.owns(objectToValidate) == true

2. The objectToValidate is provided by HibernateValidator for my validator to check it

3. The currentUser is located in the session scope of my web app

First question: I need to get access to this current user but without making use of any ThreadLocal variables (nasty IMHO...), any tips on how to do it?



Second question: What would make my day is a way to allow HibernateValidator to inject its dependencies in my validator as I needed them. I could provide the validator a IoCProvider that would do the job...

_________________
http://www.caelum.com.br
xstream, paranamer and waffle .codehaus.org


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 23, 2006 12:53 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I don't understand. You want to generate a validator exception if the user does not have the right to delete the object, but HV describe domain model constraints, not really operation constraints (ie what if you have an object not targeted to be deleted, will you also raise the exception?)

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 23, 2006 4:57 pm 
Newbie

Joined: Thu Jul 21, 2005 10:19 pm
Posts: 13
emmanuel wrote:
I don't understand. You want to generate a validator exception if the user does not have the right to delete the object, but HV describe domain model constraints, not really operation constraints


It makes sense... how do you implement such operation constraints using Seam? Programatically doing it?

_________________
http://www.caelum.com.br
xstream, paranamer and waffle .codehaus.org


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 23, 2006 6:00 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Security will be handle through a set of rules (think JBoss Rules). That's the idea floating around.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 23, 2006 6:37 pm 
Newbie

Joined: Thu Jul 21, 2005 10:19 pm
Posts: 13
emmanuel wrote:
Security will be handle through a set of rules (think JBoss Rules). That's the idea floating around.


Rules will solve it for adding/removing/so on...

What about filtering resources, would it make sense for me to give the Query object (im using jpa) to the rule engine and leave it to add the string part which filters only objects for that user? ... too much "string" for me...

The idea is....?

_________________
http://www.caelum.com.br
xstream, paranamer and waffle .codehaus.org


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 30, 2006 5:35 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
you can use Hibernate Filters
But that has nothing to do with a Validator, or I don't understand what you are saying

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 30, 2006 6:10 pm 
Newbie

Joined: Thu Jul 21, 2005 10:19 pm
Posts: 13
emmanuel wrote:
you can use Hibernate Filters
But that has nothing to do with a Validator, or I don't understand what you are saying


You are right... I first though about using validator... but I have seen that it doesnt make sense.

Filters seems like the right way to go...

Thanks once again

_________________
http://www.caelum.com.br
xstream, paranamer and waffle .codehaus.org


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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.