Puzzle: Adding domain-based security to Squeak.

Michael van der Gulik squeakml at gulik.co.nz
Tue Aug 8 09:21:19 UTC 2006


Thanks, Ron.

This would assume that domains use some other form of aggregation - such 
as using the ImageSegment tricks that Michael Roberts suggested.

I'm trying to work out if this presents another possibility for 
implementing what I'm trying. Thanks for the tip.

Michael.

Ron Teitelbaum wrote:
> Hi Michael,
> 
> If changing the base object is not possible (like adding an ivar to Object)
> then solve the problem with a back pointer.
> 
> Object subclass: DomainConnector
> Ivars: 'domain subject'
> 
> Object subclass: Domain
> Ivars: 'name'
> 
> Obviously you need a way to figure out what domain a user is on
> 
> Object subclass: User
> Ivars: '.... domain'
> 
> Now for every object created that needs to be attached to a domain you do
> 
> DomainConnector addObject: anObject toDomain: aDomain
> 	"Create a domain connector object which links anObject to aDomain
> 
> 	^self new
> 		subject: anObject;
> 		domain: aDomain;
> 		yourself.
> 
> Depending on whether or not you are using a database you could manage
> objects.
> 	As you said not every object needs a domain so you could implement a
> #needsDomain method on the objects that need it.  Consider root objects and
> places where creating a dependent object doesn't make sense to your class
> model (I would never have classB without an instance of ClassA) and then
> implement needs domain on that root class.
> 	The update of domain objects could be done at the time of commit for
> a database, 
> 	commitObjectsForUser: aUser
> 		domainObjects := self objectsToCommit select: [:a | a
> needsDomain].
> 		domainObjects do: [:a | DomainConnector addObject: a
> toDomain: aUser domain].
> 
> 	Or you could change new to do newForUser on root objects.
> 
> There are lots of possibilities, the main point is that once the connecter
> is created you can find out if an object is in a domain by querying the back
> pointer.
> 	If you are in a database the query is simple 
> 	Object >> isInDomain: aDomain
> 		self needsDomain ifFalse: [NotInDomainError signal: 'Not a
> Domain Object'].
> 		aConnector := DomainConnector where: [:a | a subject =
> self].
> 		^aConnector domain = aDomain
> 	If you are not in a database then updating a dictionary that lives
> on a class variable that separates by class, object oids or something will
> speed lookup of domain objects.
> 	aConnector := (DomainConnecter someOrginazationDictionaryFind: self
> ).
> 	^aConnector domain = aDomain.
> 
> Hope that helps!




More information about the Squeak-dev mailing list