Eric Hacker > Agent-TCLI-0.032 > Net::CLI::User

Download:
Agent-TCLI-0.032.tar.gz

Annotate this POD

View/Report Bugs
Source  

NAME ^

Net::CLI::User - A User class for Net::CLI.

SYNOPSIS ^

An object for storing Net::CLI user information.

        my $user = Net::CLI::User->new(
                'id'            => 'user@example.com',
                'protocol'      => 'jabber',
                'auth'          => 'read only',
        );

        my $name = $user->get_name;

        print "My user is ".$name.". \n";
        print $name."'s domain is ".$user->get_domain.". \n";

ATTRIBUTES

The following attributes are accessible through standard accessor/mutator methods and may be set as a parameter to new unless otherwise noted.

id

ID of user in a form acceptable to the protocol. XMPP/Jabber IDs MUST not include resource information.

protocol

Protocol that user is allowed access on. Currently only xmpp and xmpp-groupchat are supported by Transport::XMPP. If the protocol is xmpp-groupchat, the Transport will automatically join the conference room at start-up.

auth

Authorization level of user. MUST be one of these values: reader has read access writer has write access master has root access logger receives copies of all messages, can't do anything

Note that commands must choose from the above to determine if a user can do anything. Not very robust, but hey, it's not even 1.0 yet.

Every user should be defined with an auth, but currently this is not being checked anywhere.

password

A password for the user.

For a private XMPP chatroom, this is used to log on. It is not used anywhere else currently.

METHODS

new (lots of stuff)

Creates a new user object. All the above attributes may be specified. Currently all are optional, but it would be rather useless to have a user without an id or protocol and auth is strongly recommended.

get_name()

Retrieve the short name for the user. Currently anything in front of the '@'.

get_domain()

Retrieve the domain for the user. Currently whatever is after the '@'.

not_authorized ( { parameters (see usage) } )

Returns 0 if user is authorized, 'Not found' if user is not a match, and a message if a match, but the protocol and/or auth do not match.

Checks id and optional parameters and returns false if matched. This method will automatically strip off Jabber resource before matching user. It is usually used as a passthrough while looping through an array/hash of users in some other object.

It has optional parameters protocol and auth which must be supplied as regular expression. The default is to use a regexp of any, which means that the value must be defined in the user in order to match.

By returning false for authorization, one can check the reason why a true value was returned for unauthorized, or just ignore it.

Usage:

        not_authorized ( { id      =>  value,        # user id. Will strip off resource
                                          protocol =>  qr(jabber),   # optional regex for protocol
                                          auth     =>  qr(master|writer),   # option regex for auth
                                        } );

INHERITED METHODS

This module is an Object::InsideOut object that inherits from Agent::TCLI::Base. It inherits methods from both. Please refer to their documentation for more details.

AUTHOR ^

Eric Hacker <hacker at cpan.org>

BUGS ^

SHOULDS and MUSTS are currently not always enforced.

Test scripts not thorough enough.

Probably many others.

LICENSE ^

Copyright (c) 2007, Alcatel Lucent, All rights resevred.

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

syntax highlighting: