Contentment::Security::Principal - object for representing principals
This generic object is used by the Contentment security system to represent principals. A principal represents the client's identity. This principal is meant to allow for "identity" to be fairly losely defined. However, each identity should have the following attributes:
The type of the identity is a scalar that is useful to the security manager (see Contentment::Security::Manager). It can be used when a security manager needs to identify different kinds of principals. For example, the built-in system uses two types: "authenticated" and "anonymous".
The profile for the principal stores the real information for the principal. Some convenience methods are applied to grab this data without referring to the profile directly.
The principal may have zero or more roles associated with it.
The really important aspect of the princpal is that it has zero or more permissions associated with it.
Every principal object defines the following methods:
Returns the principal type. Since this value could be anything useful to the security manager, it's probably best if the plugins avoid relying upon this value.
The $profile object returned will be an object implementing the interface given in Contentment::Security::Profile.
$profile
Returns a list of role objects (of type Contentment::Security::Role) associated with the principal.
Returns a hash of permission objects (of type Contentment::Security::Permission) associated with the principal. The keys will be the string names for the permissions and the values will be the actual permission object for that permission name.
A short-hand for:
$username = $principal->profile->username
$full_name = $principal->profile->full_name
$email_address = $principal->profile->email_address
$web_site = $principal->profile->web_site
$information = $principal->profile->information
$preferences = $principal->profile->preferences
The following methods are provided for use by security managers only. Only code in the security managers should muck with these. PERIOD.
Returns a blank principal object.
Sets the type of the principal.
Sets the profile for the principal.
Sets the roles that have been associated with the profile.
This method loads all the permissions associated with the roles set on the roles attribute.
Andrew Sterling Hanenkamp, <hanenkamp@cpan.org>
Copyright 2005 Andrew Sterling Hanenkamp <hanenkamp@cpan.org>. All Rights Reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
To install Contentment, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Contentment
CPAN shell
perl -MCPAN -e shell install Contentment
For more information on module installation, please visit the detailed CPAN module installation guide.