NAME
SPOPS::Impl::Security - Implement a security object and basic operations
SYNOPSIS
use SPOPS::Secure qw( :all );
my $sec_class = 'SPOPS::Impl::Security';
# Create a security object with level WRITE
# for user $user on object $obj
my $sec = $sec_class->new();
$sec->{class} = ref $obj;
$sec->{oid} = $obj->id;
$sec->{scope} = SEC_SCOPE_USER;
$sec->{scope_id} = $user->id;
$sec->{level} = SEC_LEVEL_WRITE;
$sec->save;
# Clone that object and change its scope to
# GROUP and level to READ
my $secg = $sec->clone( scope => SEC_SCOPE_GROUP,
scope_id => $group->id,
level => SEC_LEVEL_READ );
$secg->save;
DESCRIPTION
This class works a little behind-the-scenes, so you probably will not deal directly with it very much. Instead, check out SPOPS::Secure for module developer (and other) information.
Each security setting to an object is itself an object. In this manner we can use the SPOPS framework to create/edit/remove security settings. (Note that if you modify the 'SPOPS::Impl::SecurityObj' class to use 'SPOPS::Secure' in its @ISA, you will probably collapse the Earth -- or at least your system -- in a self-referential object definition cycle. Do not do that.)
METHODS
fetch_match( $obj, scope = SCOPE, scope_id => $ );
Returns a security object matching the $obj for the scope and scope_id passed in, undef if none found.
Examples:
my $sec_class = 'SPOPS::Impl::SecurityObj';
# Returns security object matching $obj with a scope of WORLD
my $secw = $sec_class->fetch_match( $obj, scope => SEC_SCOPE_WORLD );
# Returns security object matching $obj with a scope of GROUP
# matching the ID from $group
my $secg = $sec_class->fetch_match( $obj, scope => SEC_SCOPE_GROUP,
scope_id => $group->id );
# Returns security object matching $obj with a scope of USER
# matching the ID from $user
my $secg = $sec_class->fetch_match( $obj, scope => SEC_SCOPE_USER,
scope_id => $user->id );
fetch_by_object( $obj, { user = \@, group => \@ ... } )>
Returns a hashref with security information for a particular object. The keys of the hashref are SEC_SCOPE_WORLD, SEC_SCOPE_USER, and SEC_SCOPE_GROUP as exported by SPOPS::Secure.
You can restrict the security returned for USER and/or GROUP by passing a hashref of objects or ID values under the 'user' or 'group' keys.
You can also pass in a 'class' and 'oid' value to use that for the object identifier for the lookup.
Examples:
my \%info = $sec->fetch_by_object( $obj );
Returns all security information for $obj.
my \%info = $sec->fetch_by_object( $obj, { user => [ 1, 2, 3 ] } );
Returns $obj security information for WORLD, all GROUPs but only USERs with ID 1, 2 or 3.
my \%info = $sec->fetch_by_object( $obj, { user => [ 1, 2, 3 ],
group => [ 817, 901, 716 ] } );
Returns $obj security information for WORLD, USERs 1, 2 and 3 and GROUPs 817, 901, 716.
TO DO
BUGS
COPYRIGHT
Copyright (c) 2000 intes.net, inc.. All rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
AUTHORS
Chris Winters <chris@cwinters.com>