NAME

UserInfo - class representing user account information

AUTHOR

Shane P. McCarron <shane@aptest.com>

COPYRIGHT

Copyright 2001-2011 Applied Testing and Technology, Inc. All Rights Reserved.

SYNOPSIS

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.

DATA STRUCTURE

userName->

a hash of information about each user defined in the suite

fromLDAP
fullname
phoneNumber
password
disabled
forceChange
lastLogin
lastLogout
lastActivity
cookies

METHODS

new - get a user's information

$userInfo = new UserInfo([username [, accountHash]]);

Creates a new UserInfo object, optionally populating it with data about the user from the account database.

username

The name opf the user.

accountRef

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.

newFakeUser - create a fake user when not in multiuser mode

$userInfo = UserInfo->newFakeUser();

Returns a reference to a UserInfo object.

newFromHash - return a user's information

$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.

setCookie - set the authentication token

$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.

atime - update access time

$userInfo->atime(activity);

Ensures that the access time is up to date.

cacheDir - get a path to a folder with private, cached data for a session

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.

needToUpdate - check if we need to update the access time

Returns 1 if we do, 0 if we do not.

loadUser - grab the user data from the account db

$userInfo->loadUser() ;

Updates the object's internal data with the current data from the database.

Lock - lock the associated account 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.

loggedIn - accessor for the number of logged in users

$count = $userInfo->loggedIn();

Returns the current number of logged in users. See Account for more information.

login - update the user's record to show they are logged in

$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.

logout - update the user's record to show they are logged out

$status = $userInfo->logout();

Removes the associated login record from the user database.

Returns 1 if it succeeded, 0 if it failed.

maxUsers - what is the maximum number of simultaneous users

returns 9999 if it is set to unlimited returns the value from the USERS field of the license file.

expires - return when this license expires

$exp = $userInfo->expires() ;

supExpires - return when the support expires

$exp = $userInfo->supExpires();

access - check the access for a user to various functions

$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.

acl - get/set the user's access control list

$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.

release - release the object

Releases the optional account database, if it is attached.

sessSet - accessor for individual session custom setting

$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 - accessor for an individual custom setting

$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.

settings - get the user's custom settings

$setRef = $userInfo->settings;

returns a reference to the settings hash within the user's data structure

authenticate - check the user's password

$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.

email - return the email address for the user

$addr = $userInfo->email() ;

password - return the password for this account

$pass = $userInfo->password() ;

fromLDAP - return the state of the LDAP connection

$conn = $userInfo->fromLDAP() ;

serverNum - return the ID of the LDAP server associated with this user

$num = $userInfo->serverNum() ;

encrypted - return the flag indicating if encrypted

$enc = $userInfo->encrypted() ;

print - print the contents of the userinfo structure

$userInfo->print();

returns the string-ified version of the entire userinfo data structure.

sid - return the session ID for this user

$sid = $userInfo->sid() ;

alist - return a list of test suite access levels

@levels = $userInfo->alist();

returns a hash of test suite access level IDs and values

anames - return a list of test suite access level names

@list = $userInfo->anames();

returns a list of test suite access level names

atips - return a list of test suite access level tips

@tips = $userInfo->atips();

returns a list of test suite access level tips

alevel - return the access level for this user for a suite

$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.

cdate - return the creation date of this user

$epochSecs = $userInfo->cdate();

Returns seconds since the epoch. Note that if the user was created before version 2.19, it will return 0.

disabled - is this account disabled?

$state = $userInfo->disabled() ;

Returns true if the account is marked as disabled.

mustChange - is this account required to change its password

$mustChange = $userInfo->mustChange() ;

Returns true if the account is rrequired to change its password.

flist - return a list of features

@list = $userInfo->flist();

returns a list of feature names.

fnames - return the list of feature descriptions.

@features = $userInfo->fnames() ;

Returns a list of features descriptions.

fullname - return the fullname of this user

$name = $userInfo->fullname();

lastLogin - return the last time the user logged in

$tz = $userInfo->lastLogin() ;

lastAccess - return the last time this user did something

$time = $userInfo->lastAccess() ;

Returns the last time the user touched the system.

startPage - user's preferred start page

$start = $userInfo->startPage() ;

returns an optional start page for the user. The list of pages and their names is available via the sPageList method.

startPageURL - return the URL for a startPage

$url = $userInfo->startPageURL( [page] ) ;

Returns the relative URI for the mason component associated with the selected start page.

sPageList - return a list of potential start pages

@pages = $userInfo->sPageList() ;

Returns a list of hashes with a 'val' and a 'desc' key for each available start page.

timelocale - return the timelocale for this user

$locale = $userInfo->timelocale() ;

timestyle - return the timestyle for this user

$tz = $userInfo->timestyle() ;

timezone - return the timezone for this user

$tz = $userInfo->timezone() ;

Unlock - unlock an account database, optionally releasing it

$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.

rowsPerPage - return the number of rows per page

$rows = $userInfo->rowsPerPage() ;

checkForUpdates - phone home and see if there is a newer version

$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.

checkVersion - return information about any new version

$string = $userInfo->checkVersion();

Returns a message about any new version(s) available, and undef if there is nothing to report.

shouldNotify - get any notification message for updates

$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.