SPOPS::Secure::Util - Common utilities for SPOPS::Secure and subclasses


 my $levels = SPOPS::Secure::Util->parse_object_into_hashref( \@security_objects );
 print "Given security from objects:\n",
       "USER: $levels->{ SEC_SCOPE_USER() }\n",
       "WORLD: $levels->{ SEC_SCOPE_WORLD() }\n";
       "GROUP [ID/LEVEL]: ";
 print join( ' ', map { "[$_/$levels->{ SEC_SCOPE_GROUP() }{ $_ }" }
                      keys %{ $levels->{ SEC_SCOPE_GROUP() } } );

 # Not sure if $item is class or object?

 sub somesub {
     my ( $item, $params ) = @_;
     my ( $object_class, $object_id ) =
                         SPOPS::Secure::Util->find_class_and_oid( $item, $params );


Common utility methods for security tasks.


All methods are class methods.

parse_objects_into_hashref( \@security_objects )

Places the relevant information from \@security_objects into a hashref for easy analysis. If no objects are in \@security_objects it returns undef. Otherwise the returned hashref should have as the three keys the constants SEC_SCOPE_WORLD, SEC_SCOPE_GROUP and SEC_SCOPE_USER.

The values of SEC_SCOPE_WORLD and SEC_SCOPE_USER are a single value corresponding to one of the SEC_LEVEL_* constants. The value of SEC_LEVEL_GROUP is another hashref with the keys as the group IDs each of which has a single value corresponding to one of the SEC_LEVEL_* constants.

find_class_and_oid( [$class|$object], \%params )

Useful when a method can be called as a class or object method and the class/ID to be analyzed can be either in the object calling or in the class and the parameters.

Returns a two-argument list. The first is the object class, the second is the object ID.

If the first argument is an object and it has a method id(), we assign the result of calling it to the object ID; for the object class we call ref on the object.

Otherwise we look in \%params for a parameter 'class'. If it is not found we use the first argument. For the object ID we look in \%params for a parameter 'object_id' or 'oid'. If neither are found we assign '0' to the object ID. For example:

 my $class = 'My::Object'; my ( $object_class, $object_id ) =
                    SPOPS::Secure::Util->find_class_and_oid( $class, { object_id => 5 } );
 # $object_class = 'My::Object'; $object_id = 5

 my $object = My::OtherObject->new({ id => 99 });
 my ( $object_class, $object_id ) =
                    SPOPS::Secure::Util->find_class_and_oid( $object );
 # $object_class = 'My::OtherObject'; $object_id = 99


None known.


Nothing known.



Copyright (c) 2002-2004, inc.. All rights reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


Chris Winters <>