ACS/User.pm

filter: Statementstmt 64.4% 38 / 59 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 22 MC/DCmcdc 0.0% 0 / 11 Subroutinesub 71.4% 5 / 7 Podpod 100% 2 / 2 totaltotal 43.6% 45 / 103 CC 13 SCAR 48.3
CC
13
Cov
46%
toXML
182.0
header
2.0
BEGIN
1.0
CRAP 124.9
« ACS/Device.pm ↑ Summary ACS/Host.pm »
1 package Net::Cisco::ACS::User;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶ use Exporter ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶ use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS %actions);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 $VERSION = '0.04';
9 1 @ISA = qw(Exporter);
10 1 @EXPORT = qw();
11 1 @EXPORT_OK = qw();
12 1 %EXPORT_TAGS = ();
13 };
14  
15 1 %actions = ( "query" => "/Rest/Identity/User",
16 "create" => "/Rest/Identity/User",
17 "update" => "/Rest/Identity/User",
18 "getByName" => "/Rest/Identity/User/name/",
19 "getById" => "/Rest/Identity/User/id/",
20 );
21  
22 # MOOSE!
23
24 1 has 'description' => (
25 is => 'rw',
26 isa => 'Str',
27 );
28  
29 1 has 'id' => (
30 is => 'rw',
31 isa => 'Str',
32 );
33  
34 1 has 'identityGroupName' => (
35 is => 'rw',
36 isa => 'Str',
37 );
38  
39 1 has 'name' => (
40 is => 'rw',
41 isa => 'Str',
42 );
43  
44 1 has 'dateExceeds' => (
45 is => 'rw',
46 isa => 'Str',
47 );
48  
49 1 has 'changePassword' => (
50 is => 'ro',
51 isa => 'Str',
52 );
53  
54 1 has 'created' => (
55 is => 'ro',
56 isa => 'Str',
57 );
58  
59 1 has 'attributeInfo' => (
60 is => 'ro',
61 isa => 'ArrayRef',
62 auto_deref => '1',
63 );
64  
65 1 has 'dateExceedsEnabled' => (
66 is => 'rw',
67 isa => 'Str',
68 );
69  
70 1 has 'enablePassword' => (
71 is => 'rw',
72 isa => 'Str',
73 );
74  
75 1 has 'enabled' => (
76 is => 'rw',
77 isa => 'Str',
78 );
79  
80 1 has 'lastLogin' => (
81 is => 'ro',
82 isa => 'Str',
83 );
84  
85 1 has 'lastModified' => (
86 is => 'ro',
87 isa => 'Str',
88 );
89  
90 1 has 'lastPasswordChange' => (
91 is => 'ro',
92 isa => 'Str',
93 );
94  
95 1 has 'loginFailuresCounter' => (
96 is => 'ro',
97 isa => 'Int',
98 );
99  
100 1 has 'password' => (
101 is => 'rw',
102 isa => 'Str',
103 );
104  
105 1 has 'passwordNeverExpires' => (
106 is => 'rw',
107 isa => 'Str',
108 );
109  
110 1 has 'passwordType' => (
111 is => 'rw',
112 isa => 'Str',
113 );
114  
115 # No Moose
116
117 sub toXML
118 0 ▶{ my $self = shift;
Subroutine toXML: not called CC=13 SCAR=52.0
Pod documented
119 0 my $id = $self->id;
120 0 ▶ my $description = $self->description || "";
Condition0%0/2
$self->description || ''
l!l
00
MC/DC0%0/1
$self->description || ''
$self->description
Truth table0%0/2
A
A= $self->description
Aresult
11
00
121 0 ▶ my $identitygroupname = $self->identityGroupName || "All Groups";
Condition0%0/2
$self->identityGroupName || 'All Groups'
l!l
00
MC/DC0%0/1
$self->identityGroupName || 'All Groups'
$self->identityGroupName
Truth table0%0/2
A
A= $self->identityGroupName
Aresult
11
00
122 0 ▶ my $name = $self->name || "";
Condition0%0/2
$self->name || ''
l!l
00
MC/DC0%0/1
$self->name || ''
$self->name
Truth table0%0/2
A
A= $self->name
Aresult
11
00
123 0 ▶ my $changepassword = $self->changePassword || "false";
Condition0%0/2
$self->changePassword || 'false'
l!l
00
MC/DC0%0/1
$self->changePassword || 'false'
$self->changePassword
Truth table0%0/2
A
A= $self->changePassword
Aresult
11
00
124 0 ▶ my $enabled = $self->enabled || "true";
Condition0%0/2
$self->enabled || 'true'
l!l
00
MC/DC0%0/1
$self->enabled || 'true'
$self->enabled
Truth table0%0/2
A
A= $self->enabled
Aresult
11
00
125 0 ▶ my $password = $self->password || "";
Condition0%0/2
$self->password || ''
l!l
00
MC/DC0%0/1
$self->password || ''
$self->password
Truth table0%0/2
A
A= $self->password
Aresult
11
00
126 0 ▶ my $passwordneverexpires = $self->passwordNeverExpires || "false";
Condition0%0/2
$self->passwordNeverExpires || 'false'
l!l
00
MC/DC0%0/1
$self->passwordNeverExpires || 'false'
$self->passwordNeverExpires
Truth table0%0/2
A
A= $self->passwordNeverExpires
Aresult
11
00
127 0 ▶ my $passwordtype = $self->passwordType || "Internal Users";
Condition0%0/2
$self->passwordType || 'Internal Users'
l!l
00
MC/DC0%0/1
$self->passwordType || 'Internal Users'
$self->passwordType
Truth table0%0/2
A
A= $self->passwordType
Aresult
11
00
128 0 ▶ my $enablepassword = $self->enablePassword || "";
Condition0%0/2
$self->enablePassword || ''
l!l
00
MC/DC0%0/1
$self->enablePassword || ''
$self->enablePassword
Truth table0%0/2
A
A= $self->enablePassword
Aresult
11
00
129 0 ▶ my $dateexceeds = $self->dateExceeds || "";
Condition0%0/2
$self->dateExceeds || ''
l!l
00
MC/DC0%0/1
$self->dateExceeds || ''
$self->dateExceeds
Truth table0%0/2
A
A= $self->dateExceeds
Aresult
11
00
130 0 ▶ my $dateexceedsenabled = $self->dateExceedsEnabled || "false";
Condition0%0/2
$self->dateExceedsEnabled || 'false'
l!l
00
MC/DC0%0/1
$self->dateExceedsEnabled || 'false'
$self->dateExceedsEnabled
Truth table0%0/2
A
A= $self->dateExceedsEnabled
Aresult
11
00
131 0 my $result = "";
132
133 0 ▶ if ($id) { $result = " <id>$id</id>\n"; }
Branch: 1 branch
BranchTrueFalseTotal
if ($id) 0 0 0
134 0 $result .= <<XML;
135 <description>$description</description>
136 <identityGroupName>$identitygroupname</identityGroupName>
137 <name>$name</name>
138 <changePassword>$changepassword</changePassword>
139 <enablePassword>$enablepassword</enablePassword>
140 <enabled>$enabled</enabled>
141 <password>$password</password>
142 <passwordNeverExpires>$passwordneverexpires</passwordNeverExpires>
143 <passwordType>$passwordtype</passwordType>
144 <dateExceeds>$dateexceeds</dateExceeds>
145 <dateExceedsEnabled>$dateexceedsenabled</dateExceedsEnabled>
146 XML
147  
148 0 return $result;
149 }
150  
151 sub header
152 0 ▶{ my $self = shift;
Subroutine header: not called CC=1 SCAR=6.9
Pod documented
153 0 my $users = shift;
154 0 return qq{<?xml version="1.0" encoding="UTF-8" standalone="yes"?><ns2:user xmlns:ns2="identity.rest.mgmt.acs.nm.cisco.com">$users</ns2:user>};
155 }
156
157 =head1 NAME
158  
159 Net::Cisco::ACS::User - Access Cisco ACS functionality through REST API - User fields
160  
161 =head1 SYNOPSIS
162  
163 use Net::Cisco::ACS;
164 use Net::Cisco::ACS::User;
165
166 my $acs = Net::Cisco::ACS->new(hostname => '10.0.0.1', username => 'acsadmin', password => 'testPassword');
167 my $user = Net::Cisco::ACS::User->new("name"=>"soloh","description"=>"Han Solo","identityGroupName"=>"All Groups:MilleniumCrew","password"=>"Leia");
168  
169 my %users = $acs->users;
170 # Retrieve all users from ACS
171 # Returns hash with username / Net::Cisco::ACS::User pairs
172
173 print $acs->users->{"acsadmin"}->toXML;
174 # Dump in XML format (used by ACS for API calls)
175
176 my $user = $acs->users("name","acsadmin");
177 # Faster call to request specific user information by name
178  
179 my $user = $acs->users("id","150");
180 # Faster call to request specific user information by ID (assigned by ACS, present in Net::Cisco::ACS::User)
181  
182 $user->id(0); # Required for new user!
183 my $id = $acs->create($user);
184 # Create new user based on Net::Cisco::ACS::User instance
185 # Return value is ID generated by ACS
186 print "Record ID is $id" if $id;
187 print $Net::Cisco::ACS::ERROR unless $id;
188 # $Net::Cisco::ACS::ERROR contains details about failure
189  
190 my $id = $acs->update($user);
191 # Update existing user based on Net::Cisco::ACS::User instance
192 # Return value is ID generated by ACS
193 print "Record ID is $id" if $id;
194 print $Net::Cisco::ACS::ERROR unless $id;
195 # $Net::Cisco::ACS::ERROR contains details about failure
196  
197 $acs->delete($user);
198 # Delete existing user based on Net::Cisco::ACS::User instance
199
200 =head1 DESCRIPTION
201  
202 The Net::Cisco::ACS::User class holds all the user relevant information from Cisco ACS 5.x
203  
204 =head1 USAGE
205  
206 All calls are typically handled through an instance of the L<Net::Cisco::ACS> class. L<Net::Cisco::ACS::User> acts as a container for user related information.
207  
208 =over 3
209  
210 =item new
211  
212 Class constructor. Returns object of Net::Cisco::ACS::User on succes. The following fields can be set / retrieved:
213  
214 =over 5
215  
216 =item description
217  
218 =item name
219  
220 =item identityGroupName
221  
222 =item enablePassword
223  
224 =item enabled
225  
226 =item password
227  
228 =item passwordNeverExpires
229  
230 =item passwordType
231  
232 =item dateExceeds
233  
234 =item dateExceedsEnabled
235  
236 =item id
237  
238 Formatting rules may be in place & enforced by Cisco ACS.
239  
240 =back
241  
242 Read-only values:
243  
244 =over 5
245  
246 =item changePassword
247  
248 =item created
249  
250 =item attributeInfo
251  
252 =item lastLogin
253  
254 =item lastModified
255  
256 =item lastPasswordChange
257  
258 =item loginFailuresCounter
259  
260 =back
261  
262 =over 3
263  
264 =item description
265  
266 The user account description, typically used for full name.
267  
268 =item name
269  
270 The user account name. This is a required value in the constructor but can be redefined afterwards.
271  
272 =item identityGroupName
273  
274 The user group name. This is a required value in the constructor but can be redefined afterwards. See L<Net::Cisco::ACS::IdentityGroupName>.
275  
276 =item enablePassword
277  
278 The enable password (for Cisco-level access), not needed if you work with command sets in your access policies.
279  
280 =item enabled
281  
282 Boolean flag to indicate account status.
283  
284 =item password
285  
286 Password. When querying user account information, the password will be masked as *********. This is a required value in the constructor but can be redefined afterwards.
287  
288 =item passwordNeverExpires
289  
290 Boolean flag to indicate account expiration status.
291  
292 =item passwordType
293  
294 A read-only valie that indicates the password type, either for Internal User or Active Directory (needs confirmation).
295  
296 =item dateExceeds
297  
298 Date field to automatically deactivate the account once passed.
299  
300 =item dateExceedsEnabled
301  
302 Boolean flag to activate the automatic deactivation feature based on expiration dates.
303  
304 =item id
305  
306 Cisco ACS generates a unique ID for each User record. This field cannot be updated within ACS but is used for reference. Set to 0 when creating a new record or when duplicating an existing user.
307  
308 =item toXML
309  
310 Dump the record in ACS accept XML formatting (without header).
311  
312 =item header
313  
314 Generate the correct XML header. Takes output of C<toXML> as argument.
315  
316 =back
317  
318 =back
319  
320 =head1 BUGS
321  
322 None yet
323  
324 =head1 SUPPORT
325  
326 None yet :)
327  
328 =head1 AUTHOR
329  
330 Hendrik Van Belleghem
331 CPAN ID: BEATNIK
332 hendrik.vanbelleghem@gmail.com
333  
334 =head1 COPYRIGHT
335  
336 This program is free software licensed under the...
337  
338 The General Public License (GPL)
339 Version 2, June 1991
340  
341 The full text of the license can be found in the
342 LICENSE file included with this module.
343  
344  
345 =head1 SEE ALSO
346  
347 perl(1).
348  
349 =cut
350  
351 #################### main pod documentation end ###################
352 1 __PACKAGE__->meta->make_immutable();
353  
354 1 1;
355 # The preceding line will help the module return a true value
356  
« ACS/Device.pm ↑ Summary ACS/Host.pm »