UserInfo - class representing user account information
Shane P. McCarron <shane@aptest.com>
Copyright 2001-2011 Applied Testing and Technology, Inc. All Rights Reserved.
use UserInfo; # create a new object from a username my $info = new UserInfo($username); # create a new object from a hash (sessionID) my $info = newFromHash UserInfo($userhash); # validate a user $res = $info->authenticate($password); # check access $res = $info->access($suite, $feature); # get/set report preferences $prefs = $info->reportPref($suite, $report); # get/set execution preferences $prefs = $info->execPrefs($suite, $report);
The UserInfo object acts as a repository for access control information associated with a specific user.
a hash of information about each user defined in the suite
$userInfo = new UserInfo([username [, accountHash]]);
Creates a new UserInfo object, optionally populating it with data about the user from the account database.
The name opf the user.
Reference to an Account object. If not provided, one will be created.
returns a reference to the UserInfo object. If the user is not defined, returns undef.
$userInfo = UserInfo->newFakeUser();
Returns a reference to a UserInfo object.
$userInfo = UserInfo->newFromHash(hash [, activity, request, readonly, autoActivate, suite] );
Hash is an identifier returned by the userHash method above.
Activity is an optional string that reflects what the user is doing.
Request is an optional reference to an Apache Request object, and will be used to update the user's cookie.
Readonly is a boolean flag that forces the Account database to be opened in readonly mode, rather than the default read/write mode. If the Account database is only open in read mode, newFromHash won't update activities or re-insert an expired session.
autoActivate is a boolean that indicates whether an account should be reactivated if it is inactive. Defaults to true.
suite is the name of the test suite currently selected. As a convenience if the suite parameter is passed in then the lastSelectedSuite setting for the user will be automatically updated.
Returns a reference to a userInfo object.
$userInfo->setCookie(sid, mason);
sid is an authentication token.
mason is a reference to an mason component object
Sets the cookie in the header for this request.
$userInfo->atime(activity);
Ensures that the access time is up to date.
my $dir = $userInfo->cacheDir( [sid] ) ;
sid is an optional parameter for a specific session id. If omitted, the current session is used.
returns the path to the sessions private cache.
Returns 1 if we do, 0 if we do not.
$userInfo->loadUser() ;
Updates the object's internal data with the current data from the database.
$userInfo->Lock() ;
Aquires an account database in write mode if necessary, then sets the lock on it. Designed to perform a transaction. Do an Unlock to release the database.
$count = $userInfo->loggedIn();
Returns the current number of logged in users. See Account for more information.
$status = $userInfo->login( [ sid, activity, request ] );
sid - a session ID to reuse (for re-login of an established session)
activity - an optional indication of what the user is doing.
request - an optional reference to an Apache request object. If supplied, it will be used to update the cookie.
Sets the user's login time, generates a cookie, and stores that cookie in the user database. Requires write access to the user database.
Returns 1 if it succeeded, 0 if it failed.
$status = $userInfo->logout();
Removes the associated login record from the user database.
Returns 1 if it succeeded, 0 if it failed.
returns 9999 if it is set to unlimited returns the value from the USERS field of the license file.
$exp = $userInfo->expires() ;
$exp = $userInfo->supExpires();
$userInfo->access(suite, feature, suiteMode, closed);
suite is the test suite
feature is the feature to which access is needed. The list of currently defined features includes:
account - account management
suiteMode is the type of access to the suite. If not defined, the ACL must just not say "no".
closed is a boolean - do we care if ATM is closed or not right now? Default is true.
returns true if access is granted. NOTE: If the feature parameter is provided, but the user is explicitly denied access to the test suite (or their access level is less than the optional suiteMode parameter) then access will be denied at that level. This does not mean the user does not have that feature enabled. If you want to explicitly test for a feature, provide no suite parameter.
$aclRef = $userInfo->acl;
returns a reference to the ACL hash within the user data structure. If there is no ACL for a user, it returns undef.
Releases the optional account database, if it is attached.
$setting = $userInfo->sessSet(name [, value [, delete ] ]) ;
name is the name of the session setting to use.
value is an optional value parameter to store in the setting.
delete is an optional flag. If provided, then the setting is removed from the session record altogether.
returns the individual setting, or undef if it is not defined.
$setting = $userInfo->setting(name, subName [, value] ) ;
name is the name of a setting or setting collection.
subName is the name of a sub-setting in a collection (e.g., a suite name) ;
value is a value to store in the setting or subsetting.
returns the individual setting, or undef if it is not defined.
$setRef = $userInfo->settings;
returns a reference to the settings hash within the user's data structure
$ok = $userInfo->authenticate(password);
Returns true if the password is correct for the user. Returns false if the password is incorrect. Returns undef if the account is disabled.
$addr = $userInfo->email() ;
$pass = $userInfo->password() ;
$conn = $userInfo->fromLDAP() ;
$num = $userInfo->serverNum() ;
$enc = $userInfo->encrypted() ;
$userInfo->print();
returns the string-ified version of the entire userinfo data structure.
$sid = $userInfo->sid() ;
@levels = $userInfo->alist();
returns a hash of test suite access level IDs and values
@list = $userInfo->anames();
returns a list of test suite access level names
@tips = $userInfo->atips();
returns a list of test suite access level tips
$level = $userInfo->alevel(suite) ;
suite is the name of a test suite.
Returns the access level for suite for this user. In a list context, returns the access level AND the tool tip for that level.
$epochSecs = $userInfo->cdate();
Returns seconds since the epoch. Note that if the user was created before version 2.19, it will return 0.
$state = $userInfo->disabled() ;
Returns true if the account is marked as disabled.
$mustChange = $userInfo->mustChange() ;
Returns true if the account is rrequired to change its password.
@list = $userInfo->flist();
returns a list of feature names.
@features = $userInfo->fnames() ;
Returns a list of features descriptions.
$name = $userInfo->fullname();
$tz = $userInfo->lastLogin() ;
$time = $userInfo->lastAccess() ;
Returns the last time the user touched the system.
$start = $userInfo->startPage() ;
returns an optional start page for the user. The list of pages and their names is available via the sPageList method.
$url = $userInfo->startPageURL( [page] ) ;
Returns the relative URI for the mason component associated with the selected start page.
@pages = $userInfo->sPageList() ;
Returns a list of hashes with a 'val' and a 'desc' key for each available start page.
$locale = $userInfo->timelocale() ;
$tz = $userInfo->timestyle() ;
$tz = $userInfo->timezone() ;
$userInfo->Unlock();
Unlocks the associated account database. If it was acquired via a previous call to Lock, also releases the database. Tracks the depth of the Locks to ensure that only the last Unlock call actually releases the data file.
$rows = $userInfo->rowsPerPage() ;
$version = $userInfo->checkForUpdates() ; ($version, $error) = $userInfo->checkForUpdates() ;
Returns nothing, or the name of a newer version if one is available. In an array context, will also return any error message if there was one.
$string = $userInfo->checkVersion();
Returns a message about any new version(s) available, and undef if there is nothing to report.
$msg = $userInfo->shouldNotify();
Returns any message that should be send to people with the updates trigger.
Copyright © 2000-2013 Applied Testing and Technology, Inc. All rights reserved.