blib/lib/Net/Cisco/ISE.pm

filter: Statementstmt 10.0% 53 / 527 Branchbran 0.0% 0 / 232 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 45.1% 14 / 31 Podpod 23.5% 4 / 17 totaltotal 8.7% 71 / 810 CC 127 SCAR 60.6
CC
127
Cov
7%
parse_xml
1122.0
query
756.0
create
210.0
CRAP 426.9
↑ Summary blib/lib/Net/Cisco/ISE/InternalUser.pm »
1 package Net::Cisco::ISE;
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 # REST IO stuff here
6 1 ▶use IO::Socket::SSL qw( SSL_VERIFY_NONE );
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use LWP::UserAgent;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use XML::Simple;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 # Generics
11 1 ▶use MIME::Base64;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use URI::Escape;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 # Net::Cisco::ISE::*
16 1 ▶use Net::Cisco::ISE::InternalUser;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use Net::Cisco::ISE::IdentityGroup;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 #use Net::Cisco::ISE::NetworkDevice;
19 #use Net::Cisco::ISE::NetworkDeviceGroup;
20 #use Net::Cisco::ISE::Endpoint;
21 #use Net::Cisco::ISE::EndpointCertificate;
22 #use Net::Cisco::ISE::EndpointIdentityGroup;
23 #use Net::Cisco::ISE::Portal;
24 #use Net::Cisco::ISE::Profile;
25  
26 BEGIN {
27 1 ▶ use Exporter ();
Subroutine BEGIN: called CC=1 SCAR=0.0
28 1 ▶ use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $ERROR %actions);
Subroutine BEGIN: called CC=1 SCAR=0.0
29 1 ▶ $VERSION = '0.02';
Subroutine BEGIN: called CC=1 SCAR=0.0
30 1 @ISA = qw(Exporter);
31 1 @EXPORT = qw();
32 1 @EXPORT_OK = qw();
33 1 %EXPORT_TAGS = ();
34
35 1 $ERROR = ""; # TODO: Document error properly!
36 1 %actions = ( "version" => "/Rest/Common/AcsVersion",
37 "serviceLocation" => "/Rest/Common/ServiceLocation",
38 "errorMessage" => "/Rest/Common/ErrorMessage",
39 );
40 }
41  
42 # Moose!
43  
44 has 'ssl_options' => (
45 is => 'rw',
46 isa => 'HashRef',
47 1 ▶ default => sub { { 'SSL_verify_mode' => SSL_VERIFY_NONE, 'verify_hostname' => '0' } }
Subroutine __ANON__: called CC=1 SCAR=0.0
48 1 );
49  
50 1 has 'ssl' => (
51 is => 'rw',
52 isa => 'Str',
53 default => '1',
54 );
55  
56 1 has 'hostname' => (
57 is => 'rw',
58 isa => 'Str',
59 required => '1',
60 );
61  
62 1 has 'port' => (
63 is => 'rw',
64 isa => 'Str',
65 default => '9060'
66 );
67
68 1 has 'mock' => (
69 is => 'rw',
70 isa => 'Str',
71 default => '0',
72 );
73
74 sub internalusers # No Moose here :(
75 0 ▶{ my $self = shift;
Subroutine internalusers: not called CC=4 SCAR=30.0
Pod undocumented
76 0 $ERROR = "";
77 0 ▶ if (@_)
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 0 0
78 0 { my %args = @_;
79 0 $self->{"InternalUsers"} = $args{"internalusers"};
80 0 ▶ if ($self->mock())
Branch: 1 branch
BranchTrueFalseTotal
if ($self->mock) 0 0 0
81 0 { return $self->{"InternalUsers"}; }
82 0 ▶ if ($args{"id"})
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"id"}) 0 0 0
83 0 { $self->{"InternalUsers"} = $self->query("InternalUser","id",$args{"id"}); }
84 } else
85 0 { $self->{"InternalUsers"} = $self->query("InternalUser");
86 }
87 0 return $self->{"InternalUsers"};
88 }
89  
90 sub identitygroups # No Moose here :(
91 0 ▶{ my $self = shift;
Subroutine identitygroups: not called CC=4 SCAR=30.0
Pod documented
92 0 $ERROR = "";
93 0 ▶ if (@_)
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 0 0
94 0 { my %args = @_;
95 0 $self->{"IdentityGroups"} = $args{"identitygroups"};
96 0 ▶ if ($self->mock())
Branch: 1 branch
BranchTrueFalseTotal
if ($self->mock) 0 0 0
97 0 { return $self->{"IdentityGroups"}; }
98  
99 0 ▶ if ($args{"id"})
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"id"}) 0 0 0
100 0 { $self->{"IdentityGroups"} = $self->query("IdentityGroup","id",$args{"id"}); }
101 } else
102 0 { $self->{"IdentityGroups"} = $self->query("IdentityGroup");
103 }
104 0 return $self->{"IdentityGroups"};
105 }
106  
107 sub endpointidentitygroups # No Moose here :(
108 0 ▶{ my $self = shift;
Subroutine endpointidentitygroups: not called CC=4 SCAR=30.0
Pod undocumented
109 0 $ERROR = "";
110 0 ▶ if (@_)
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 0 0
111 0 { my %args = @_;
112 0 $self->{"EndpointIdentityGroups"} = $args{"endpointidentitygroups"};
113 0 ▶ if ($self->mock())
Branch: 1 branch
BranchTrueFalseTotal
if ($self->mock) 0 0 0
114 0 { return $self->{"EndpointIdentityGroups"}; }
115  
116 0 ▶ if ($args{"id"})
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"id"}) 0 0 0
117 0 { $self->{"EndpointIdentityGroups"} = $self->query("EndpointIdentityGroup","id",$args{"id"}); }
118 } else
119 0 { $self->{"EndpointIdentityGroups"} = $self->query("EndpointIdentityGroup");
120 }
121 0 return $self->{"EndpointIdentityGroups"};
122 }
123  
124 sub networkdevices # No Moose here :(
125 0 ▶{ my $self = shift;
Subroutine networkdevices: not called CC=4 SCAR=30.0
Pod undocumented
126 0 $ERROR = "";
127 0 ▶ if (@_)
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 0 0
128 0 { my %args = @_;
129 0 $self->{"NetworkDevices"} = $args{"networkdevices"};
130 0 ▶ if ($self->mock())
Branch: 1 branch
BranchTrueFalseTotal
if ($self->mock) 0 0 0
131 0 { return $self->{"NetworkDevices"}; }
132  
133 0 ▶ if ($args{"id"})
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"id"}) 0 0 0
134 0 { $self->{"NetworkDevices"} = $self->query("NetworkDevice","id",$args{"id"}); }
135 } else
136 0 { $self->{"NetworkDevices"} = $self->query("NetworkDevice");
137 }
138 0 return $self->{"NetworkDevices"};
139 }
140  
141 sub networkdevicegroups # No Moose here :(
142 0 ▶{ my $self = shift;
Subroutine networkdevicegroups: not called CC=4 SCAR=30.0
Pod undocumented
143 0 $ERROR = "";
144 0 ▶ if (@_)
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 0 0
145 0 { my %args = @_;
146 0 $self->{"NetworkDeviceGroups"} = $args{"networkdevicegroups"};
147 0 ▶ if ($self->mock())
Branch: 1 branch
BranchTrueFalseTotal
if ($self->mock) 0 0 0
148 0 { return $self->{"NetworkDeviceGroups"}; }
149  
150 0 ▶ if ($args{"id"})
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"id"}) 0 0 0
151 0 { $self->{"NetworkDeviceGroups"} = $self->query("NetworkDeviceGroup","id",$args{"id"}); }
152 } else
153 0 { $self->{"NetworkDeviceGroups"} = $self->query("NetworkDeviceGroup");
154 }
155 0 return $self->{"NetworkDeviceGroups"};
156 }
157  
158 sub endpoints # No Moose here :(
159 0 ▶{ my $self = shift;
Subroutine endpoints: not called CC=4 SCAR=30.0
Pod undocumented
160 0 $ERROR = "";
161 0 ▶ if (@_)
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 0 0
162 0 { my %args = @_;
163 0 $self->{"Endpoints"} = $args{"endpoints"};
164 0 ▶ if ($self->mock())
Branch: 1 branch
BranchTrueFalseTotal
if ($self->mock) 0 0 0
165 0 { return $self->{"Endpoints"}; }
166  
167 0 ▶ if ($args{"id"})
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"id"}) 0 0 0
168 0 { $self->{"Endpoints"} = $self->query("Endpoint","id",$args{"id"}); }
169 } else
170 0 { $self->{"Endpoints"} = $self->query("Endpoint");
171 }
172 0 return $self->{"Endpoints"};
173 }
174
175 sub endpointcertificates # No Moose here :(
176 0 ▶{ my $self = shift;
Subroutine endpointcertificates: not called CC=4 SCAR=30.0
Pod undocumented
177 0 $ERROR = "";
178 0 ▶ if (@_)
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 0 0
179 0 { my %args = @_;
180 0 $self->{"EndpointCertificates"} = $args{"endpointcertificates"};
181 0 ▶ if ($self->mock())
Branch: 1 branch
BranchTrueFalseTotal
if ($self->mock) 0 0 0
182 0 { return $self->{"EndpointCertificates"}; }
183  
184 0 ▶ if ($args{"id"})
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"id"}) 0 0 0
185 0 { $self->{"EndpointCertificates"} = $self->query("EndpointCertificate","id",$args{"id"}); }
186 } else
187 0 { $self->{"EndpointCertificates"} = $self->query("EndpointCertificate");
188 }
189 0 return $self->{"EndpointCertificates"};
190 }
191  
192 sub portals # No Moose here :(
193 0 ▶{ my $self = shift;
Subroutine portals: not called CC=4 SCAR=30.0
Pod undocumented
194 0 $ERROR = "";
195 0 ▶ if (@_)
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 0 0
196 0 { my %args = @_;
197 0 $self->{"Portals"} = $args{"portals"};
198 0 ▶ if ($self->mock())
Branch: 1 branch
BranchTrueFalseTotal
if ($self->mock) 0 0 0
199 0 { return $self->{"Portals"}; }
200  
201 0 ▶ if ($args{"id"})
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"id"}) 0 0 0
202 0 { $self->{"Portals"} = $self->query("Portal","id",$args{"id"}); }
203 } else
204 0 { $self->{"Portals"} = $self->query("Portal");
205 }
206 0 return $self->{"Portals"};
207 }
208  
209 sub profiles # No Moose here :(
210 0 ▶{ my $self = shift;
Subroutine profiles: not called CC=4 SCAR=30.0
Pod undocumented
211 0 $ERROR = "";
212 0 ▶ if (@_)
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 0 0
213 0 { my %args = @_;
214 0 $self->{"Profiles"} = $args{"profiles"};
215 0 ▶ if ($self->mock())
Branch: 1 branch
BranchTrueFalseTotal
if ($self->mock) 0 0 0
216 0 { return $self->{"Profiles"}; }
217  
218 0 ▶ if ($args{"id"})
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"id"}) 0 0 0
219 0 { $self->{"Profiles"} = $self->query("Profile","id",$args{"id"}); }
220 } else
221 0 { $self->{"Profiles"} = $self->query("Profile");
222 }
223 0 return $self->{"Profiles"};
224 }
225  
226 1 has 'username' => (
227 is => 'rw',
228 isa => 'Str',
229 required => '1',
230 );
231  
232 1 has 'password' => (
233 is => 'rw',
234 isa => 'Str',
235 required => '1',
236 );
237  
238 sub version # No Moose here :(
239 0 ▶{ my $self = shift;
Subroutine version: not called CC=2 SCAR=17.9
Pod undocumented
240 0 $ERROR = "";
241 0 ▶ unless ($self->{"Version"}) # Version is not going to magically change in one session
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"Version"}) 0 0 0
242 0 { $self->{"Version"} = $self->query("Version"); }
243 0 return $self->{"Version"};
244 }
245
246 sub servicelocation # No Moose here :(
247 0 ▶{ my $self = shift;
Subroutine servicelocation: not called CC=2 SCAR=17.9
Pod undocumented
248 0 $ERROR = "";
249 0 ▶ unless ($self->{"ServiceLocation"}) # serviceLocation is not going to magically change in one session
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"ServiceLocation"}) 0 0 0
250 0 { $self->{"ServiceLocation"} = $self->query("ServiceLocation"); }
251 0 return $self->{"ServiceLocation"};
252 }
253  
254 sub errormessage # No Moose here :(
255 0 ▶{ my $self = shift;
Subroutine errormessage: not called CC=1 SCAR=6.9
Pod undocumented
256 0 $ERROR = "";
257 0 $self->{"ErrorMessage"} = $self->query("ErrorMessage");
258 0 return $self->{"ErrorMessage"};
259 }
260
261 # Non-Moose
262  
263 sub query
264 0 ▶{ my ($self, $type, $key, $value) = @_;
Subroutine query: not called CC=27 SCAR=66.3
Pod undocumented
265 0 my $hostname = $self->hostname;
266 0 my $credentials = encode_base64($self->username.":".$self->password);
267 0 ▶ if ($self->ssl)
Branch: 1 branch
BranchTrueFalseTotal
if ($self->ssl) { } 0 0 0
268 0 { $hostname = "https://$hostname"; } else
269 0 { $hostname = "http://$hostname"; }
270 0 ▶ $hostname .= ":".$self->port if $self->port;
Branch: 1 branch
BranchTrueFalseTotal
if $self->port 0 0 0
271 0 my $action = "";
272 0 my $mode = "";
273 0 my $accepttype ="";
274 0 ▶ $key ||= "";
Condition0%0/2
$key ||= ""
l!l
00
MC/DC0%0/1
$key ||= ""
$key
Truth table0%0/2
A
A= $key
Aresult
11
00
275 0 ▶ if ($type eq "InternalUser")
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "InternalUser") 0 0 0
276 0 { $action = $Net::Cisco::ISE::InternalUser::actions{"query"};
277 0 $mode = "InternalUsers";
278 0 $accepttype = "identity.internaluser.1.0";
279 0 ▶ if ($key eq "id")
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "id") 0 0 0
280 0 { $action = $Net::Cisco::ISE::InternalUser::actions{"getById"}.$value;
281 0 $mode = "InternalUser";
282 }
283 }
284 0 ▶ if ($type eq "IdentityGroup")
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "IdentityGroup") 0 0 0
285 0 { $action = $Net::Cisco::ISE::IdentityGroup::actions{"query"};
286 0 $mode = "IdentityGroups";
287 0 $accepttype = "identity.identitygroup.1.0";
288 0 ▶ if ($key eq "id")
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "id") 0 0 0
289 0 { $action = $Net::Cisco::ISE::IdentityGroup::actions{"getById"}.$value;
290 0 $mode = "IdentityGroup";
291 }
292 }
293  
294 0 ▶ if ($type eq "EndpointIdentityGroup")
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "EndpointIdentityGroup") 0 0 0
295 { #$action = $Net::Cisco::ISE::EndpointIdentityGroup::actions{"query"};
296 0 $mode = "EndpointIdentityGroups";
297 0 $accepttype = "identity.endpointgroup.1.0";
298 0 ▶ if ($key eq "id")
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "id") 0 0 0
299 { #$action = $Net::Cisco::ISE::EndpointIdentityGroup::actions{"getById"}.$value;
300 0 $mode = "EndpointIdentityGroup";
301 }
302 }
303 0 ▶ if ($type eq "NetworkDevice")
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "NetworkDevice") 0 0 0
304 { #$action = $Net::Cisco::ISE::NetworkDevice::actions{"query"};
305 0 $mode = "NetworkDevices";
306 0 $accepttype = "network.networkdevice.1.1";
307 0 ▶ if ($key eq "id")
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "id") 0 0 0
308 { #$action = $Net::Cisco::ISE::NetworkDevice::actions{"getById"}.$value;
309 0 $mode = "NetworkDevice";
310 }
311 }
312 0 ▶ if ($type eq "NetworkDeviceGroup")
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "NetworkDeviceGroup") 0 0 0
313 { #$action = $Net::Cisco::ISE::NetworkDeviceGroup::actions{"query"};
314 0 $mode = "NetworkDeviceGroups";
315 0 $accepttype = "network.networkdevicegroup.1.1";
316 0 ▶ if ($key eq "id")
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "id") 0 0 0
317 { #$action = $Net::Cisco::ISE::NetworkDeviceGroup::actions{"getById"}.$value;
318 0 $mode = "NetworkDeviceGroup";
319 }
320 }
321 0 ▶ if ($type eq "Endpoint")
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "Endpoint") 0 0 0
322 { #$action = $Net::Cisco::ISE::Endpoint::actions{"query"};
323 0 $mode = "Endpoints";
324 0 $accepttype = "identity.endpoint.1.0";
325 0 ▶ if ($key eq "id")
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "id") 0 0 0
326 { #$action = $Net::Cisco::ISE::Endpoint::actions{"getById"}.$value;
327 0 $mode = "Endpoint";
328 }
329 }
330 0 ▶ if ($type eq "EndpointCertificate")
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "EndpointCertificate") 0 0 0
331 { #$action = $Net::Cisco::ISE::EndpointCertificate::actions{"query"};
332 0 $mode = "EndpointCertificates";
333 0 $accepttype = "ca.endpointcert.1.0";
334 0 ▶ if ($key eq "id")
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "id") 0 0 0
335 { #$action = $Net::Cisco::ISE::EndpointCertificate::actions{"getById"}.$value;
336 0 $mode = "EndpointCertificate";
337 }
338 }
339  
340 0 ▶ if ($type eq "Portal")
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "Portal") 0 0 0
341 { #$action = $Net::Cisco::ISE::Portal::actions{"query"};
342 0 $mode = "Portals";
343 0 $accepttype = "identity.portal.1.0";
344 0 ▶ if ($key eq "id")
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "id") 0 0 0
345 { #$action = $Net::Cisco::ISE::Portal::actions{"getById"}.$value;
346 0 $mode = "Portal";
347 }
348 }
349 0 ▶ if ($type eq "Profile")
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "Profile") 0 0 0
350 { #$action = $Net::Cisco::ISE::Profile::actions{"query"};
351 0 $mode = "Profiles";
352 0 $accepttype = "identity.profilerprofile.1.0";
353 0 ▶ if ($key eq "id")
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "id") 0 0 0
354 { #$action = $Net::Cisco::ISE::Profile::actions{"getById"}.$value;
355 0 $mode = "Profile";
356 }
357 }
358  
359 0 ▶ if ($type eq "Version")
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "Version") 0 0 0
360 0 { $action = $Net::Cisco::ISE::actions{"version"};
361 0 $mode = "Version";
362 }
363 0 ▶ if ($type eq "ServiceLocation")
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "ServiceLocation") 0 0 0
364 0 { $action = $Net::Cisco::ISE::actions{"serviceLocation"};
365 0 $mode = "ServiceLocation";
366 }
367 0 ▶ if ($type eq "ErrorMessage")
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "ErrorMessage") 0 0 0
368 0 { $action = $Net::Cisco::ISE::actions{"errorMessage"};
369 0 $mode = "ErrorMessage";
370 }
371  
372 0 $hostname = $hostname . $action;
373 0 my $useragent = LWP::UserAgent->new (ssl_opts => $self->ssl_options);
374 0 my $request = HTTP::Request->new(GET => $hostname );
375 0 $request->header('Authorization' => "Basic $credentials", Accept => "application/vnd.com.cisco.ise.$accepttype+xml");
376 0 my $result = $useragent->request($request);
377 0 ▶ if ($result->code eq "400") { $ERROR = "Bad Request - HTTP Status: 400"; }
Branch: 1 branch
BranchTrueFalseTotal
if ($result->code eq 400) 0 0 0
378 0 ▶ if ($result->code eq "410") { $ERROR = "Unknown $type queried by name or ID - HTTP Status: 410"; }
Branch: 1 branch
BranchTrueFalseTotal
if ($result->code eq 410) 0 0 0
379 0 print $result->content;
380 0 $self->parse_xml($mode, $result->content);
381 }
382  
383 sub create
384 0 ▶{ my $self = shift;
Subroutine create: not called CC=14 SCAR=53.5
Pod documented
385 0 my $record = shift;
386 0 ▶ return unless $record;
Branch: 1 branch
BranchTrueFalseTotal
unless $record 0 0 0
387 0 my $hostname = $self->hostname;
388 0 my $credentials = encode_base64($self->username.":".$self->password);
389 0 ▶ if ($self->ssl)
Branch: 1 branch
BranchTrueFalseTotal
if ($self->ssl) { } 0 0 0
390 0 { $hostname = "https://$hostname"; } else
391 0 { $hostname = "http://$hostname"; }
392 0 ▶ $hostname .= ":".$self->port if $self->port;
Branch: 1 branch
BranchTrueFalseTotal
if $self->port 0 0 0
393 0 my $action = "";
394 0 my $data = "";
395 0 my $accepttype = "";
396 0 ▶ if (ref($record) eq "Net::Cisco::ISE::InternalUser")
Branch: 1 branch
BranchTrueFalseTotal
if (ref $record eq "Net::Cisco::ISE::InternalUser") 0 0 0
397 0 { $action = $Net::Cisco::ISE::InternalUser::actions{"create"};
398 0 $accepttype = "identity.internaluser.1.0";
399 }
400  
401 0 ▶ if (ref($record) eq "Net::Cisco::ISE::IdentityGroup")
Branch: 1 branch
BranchTrueFalseTotal
if (ref $record eq "Net::Cisco::ISE::IdentityGroup") 0 0 0
402 { #$action = $Net::Cisco::ISE::IdentityGroup::actions{"create"};
403 #$accepttype = "identity.identitygroup.1.0";
404 # ISE does not support creating Identity Groups through the API. No idea why this is!
405 }
406  
407 0 ▶ if (ref($record) eq "Net::Cisco::ISE::NetworkDevice")
Branch: 1 branch
BranchTrueFalseTotal
if (ref $record eq "Net::Cisco::ISE::NetworkDevice") 0 0 0
408 { #$action = $Net::Cisco::ISE::NetworkDevice::actions{"create"};
409 0 $accepttype = "network.networkdevice.1.1";
410 }
411
412 0 ▶ if (ref($record) eq "Net::Cisco::ISE::NetworkDeviceGroup")
Branch: 1 branch
BranchTrueFalseTotal
if (ref $record eq "Net::Cisco::ISE::NetworkDeviceGroup") 0 0 0
413 { #$action = $Net::Cisco::ISE::NetworkDeviceGroup::actions{"create"};
414 0 $accepttype = "network.networkdevicegroup.1.1";
415 }
416  
417 0 ▶ if (ref($record) eq "Net::Cisco::ISE::Endpoint")
Branch: 1 branch
BranchTrueFalseTotal
if (ref $record eq "Net::Cisco::ISE::Endpoint") 0 0 0
418 { #$action = $Net::Cisco::ISE::Endpoint::actions{"create"};
419 0 $accepttype = "identity.endpoint.1.0";
420 }
421 0 ▶ if (ref($record) eq "Net::Cisco::ISE::EndpointCertificate")
Branch: 1 branch
BranchTrueFalseTotal
if (ref $record eq "Net::Cisco::ISE::EndpointCertificate") 0 0 0
422 { #$action = $Net::Cisco::ISE::EndpointCertificate::actions{"create"};
423 0 $accepttype = "ca.endpointcert.1.0";
424 }
425 0 ▶ if (ref($record) eq "Net::Cisco::ISE::EndpointIdentityGroup")
Branch: 1 branch
BranchTrueFalseTotal
if (ref $record eq "Net::Cisco::ISE::EndpointIdentityGroup") 0 0 0
426 { #$action = $Net::Cisco::ISE::EndpointIdentityGroup::actions{"create"};
427 0 $accepttype = "identity.endpointgroup.1.0";
428 }
429 0 ▶ if (ref($record) eq "Net::Cisco::ISE::Portal")
Branch: 1 branch
BranchTrueFalseTotal
if (ref $record eq "Net::Cisco::ISE::Portal") 0 0 0
430 { #$action = $Net::Cisco::ISE::Portal::actions{"create"};
431 0 $accepttype = "identity.portal.1.0";
432 }
433 0 ▶ if (ref($record) eq "Net::Cisco::ISE::Profile")
Branch: 1 branch
BranchTrueFalseTotal
if (ref $record eq "Net::Cisco::ISE::Profile") 0 0 0
434 { #$action = $Net::Cisco::ISE::Profile::actions{"create"};
435 0 $accepttype = "identity.profilerprofile.1.0";
436 }
437  
438 0 $data .= $record->toXML;
439 0 $data = $record->header($data,$record);
440 0 warn $data;
441 0 $hostname = $hostname . $action;
442 0 my $useragent = LWP::UserAgent->new (ssl_opts => $self->ssl_options);
443 0 my $request = HTTP::Request->new(POST => $hostname );
444 0 $request->content_type("application/xml");
445 0 $request->header("Authorization" => "Basic $credentials", "Content-Type" => "application/vnd.com.cisco.ise.$accepttype+xml");
446 0 $request->content($data);
447 0 my $result = $useragent->request($request);
448 0 my $id = "";
449 0 ▶ if ($result->code ne "201")
Branch: 1 branch
BranchTrueFalseTotal
if ($result->code ne '201') { } 0 0 0
450 0 { my $result_ref = $self->parse_xml("messages", $result->content);
451 0 $ERROR = $result_ref->{"messages"}{"message"}{"type"}.":".$result_ref->{"messages"}{"message"}{"code"}." - ".$result_ref->{"messages"}{"message"}{"title"}." "." - HTTP Status: ".$result->code;
452 } else
453 0 { my $location = $result->header("location");
454 0 ($id) = $location =~ /^.*\/([^\/]*)$/;
455 }
456 0 return $id;
457 }
458  
459 sub update
460 0 ▶{ my $self = shift;
Subroutine update: not called CC=14 SCAR=53.5
Pod documented
461 0 my $record = shift;
462 0 ▶ return unless $record;
Branch: 1 branch
BranchTrueFalseTotal
unless $record 0 0 0
463 0 my $hostname = $self->hostname;
464 0 my $credentials = encode_base64($self->username.":".$self->password);
465 0 ▶ if ($self->ssl)
Branch: 1 branch
BranchTrueFalseTotal
if ($self->ssl) { } 0 0 0
466 0 { $hostname = "https://$hostname"; } else
467 0 { $hostname = "http://$hostname"; }
468 0 ▶ $hostname .= ":".$self->port if $self->port;
Branch: 1 branch
BranchTrueFalseTotal
if $self->port 0 0 0
469 0 my $action = "";
470 0 my $data = "";
471 0 my $accepttype = "";
472 0 ▶ if (ref($record) eq "Net::Cisco::ISE::InternalUser")
Branch: 1 branch
BranchTrueFalseTotal
if (ref $record eq "Net::Cisco::ISE::InternalUser") 0 0 0
473 0 { $action = $Net::Cisco::ISE::InternalUser::actions{"update"};
474 0 $accepttype = "identity.internaluser.1.0";
475 }
476  
477 0 ▶ if (ref($record) eq "Net::Cisco::ISE::IdentityGroup")
Branch: 1 branch
BranchTrueFalseTotal
if (ref $record eq "Net::Cisco::ISE::IdentityGroup") 0 0 0
478 0 { $action = $Net::Cisco::ISE::IdentityGroup::actions{"update"};
479 0 $accepttype = "identity.identitygroup.1.0";
480 }
481  
482 0 ▶ if (ref($record) eq "Net::Cisco::ISE::NetworkDevice")
Branch: 1 branch
BranchTrueFalseTotal
if (ref $record eq "Net::Cisco::ISE::NetworkDevice") 0 0 0
483 { #$action = $Net::Cisco::ISE::NetworkDevice::actions{"update"};
484 0 $accepttype = "network.networkdevice.1.1";
485 }
486
487 0 ▶ if (ref($record) eq "Net::Cisco::ISE::NetworkDeviceGroup")
Branch: 1 branch
BranchTrueFalseTotal
if (ref $record eq "Net::Cisco::ISE::NetworkDeviceGroup") 0 0 0
488 { #$action = $Net::Cisco::ISE::NetworkDeviceGroup::actions{"update"};
489 0 $accepttype = "network.networkdevicegroup.1.1";
490 }
491  
492 0 ▶ if (ref($record) eq "Net::Cisco::ISE::Endpoint")
Branch: 1 branch
BranchTrueFalseTotal
if (ref $record eq "Net::Cisco::ISE::Endpoint") 0 0 0
493 { #$action = $Net::Cisco::ISE::Endpoint::actions{"update"};
494 0 $accepttype = "identity.endpoint.1.0";
495 }
496  
497 0 ▶ if (ref($record) eq "Net::Cisco::ISE::EndpointCertificate")
Branch: 1 branch
BranchTrueFalseTotal
if (ref $record eq "Net::Cisco::ISE::EndpointCertificate") 0 0 0
498 { #$action = $Net::Cisco::ISE::EndpointCertificate::actions{"update"};
499 0 $accepttype = "ca.endpointcert.1.0";
500 }
501  
502 0 ▶ if (ref($record) eq "Net::Cisco::ISE::EndpointIdentityGroup")
Branch: 1 branch
BranchTrueFalseTotal
if (ref $record eq "Net::Cisco::ISE::EndpointIdentityGroup") 0 0 0
503 { #$action = $Net::Cisco::ISE::EndpointIdentityGroup::actions{"update"};
504 0 $accepttype = "identity.endpointgroup.1.0";
505 }
506  
507 0 ▶ if (ref($record) eq "Net::Cisco::ISE::Portal")
Branch: 1 branch
BranchTrueFalseTotal
if (ref $record eq "Net::Cisco::ISE::Portal") 0 0 0
508 { #$action = $Net::Cisco::ISE::Portal::actions{"update"};
509 0 $accepttype = "identity.portal.1.0";
510 }
511  
512 0 ▶ if (ref($record) eq "Net::Cisco::ISE::Profile")
Branch: 1 branch
BranchTrueFalseTotal
if (ref $record eq "Net::Cisco::ISE::Profile") 0 0 0
513 { #$action = $Net::Cisco::ISE::Profile::actions{"update"};
514 0 $accepttype = "identity.profilerprofile.1.0";
515 }
516  
517 0 $data .= $record->toXML;
518  
519 0 $data = $record->header($data, $record);
520 0 $hostname = $hostname . $action.$record->id;
521 0 my $useragent = LWP::UserAgent->new (ssl_opts => $self->ssl_options);
522 0 my $request = HTTP::Request->new(PUT => $hostname );
523 0 $request->content_type("application/xml");
524 0 $request->header("Authorization" => "Basic $credentials", "Content-Type" => "application/vnd.com.cisco.ise.$accepttype+xml");
525 0 $request->content($data);
526 0 my $result = $useragent->request($request);
527 0 my $id = "";
528 0 ▶ if ($result->code ne "200")
Branch: 1 branch
BranchTrueFalseTotal
if ($result->code ne '200') { } 0 0 0
529 0 { my $result_ref = $self->parse_xml("messages", $result->content);
530 0 $ERROR = $result_ref->{"messages"}{"message"}{"type"}.":".$result_ref->{"messages"}{"message"}{"code"}." - ".$result_ref->{"messages"}{"message"}{"title"}." "." - HTTP Status: ".$result->code;
531 } else
532 0 { my $location = $result->header("location");
533 0 warn $location;
534 0 ($id) = $location =~ /^.*\/([^\/]*)$/;
535 }
536 0 return $id;
537 }
538  
539 sub delete
540 0 ▶{ my $self = shift;
Subroutine delete: not called CC=14 SCAR=53.5
Pod documented
541 0 my $record = shift;
542 0 my $hostname = $self->hostname;
543 0 my $credentials = encode_base64($self->username.":".$self->password);
544 0 ▶ if ($self->ssl)
Branch: 1 branch
BranchTrueFalseTotal
if ($self->ssl) { } 0 0 0
545 0 { $hostname = "https://$hostname"; } else
546 0 { $hostname = "http://$hostname"; }
547 0 ▶ $hostname .= ":".$self->port if $self->port;
Branch: 1 branch
BranchTrueFalseTotal
if $self->port 0 0 0
548 0 my $action = "";
549 0 my $type = "";
550 0 my $accepttype = "";
551
552 0 ▶ if (ref($record) eq "ARRAY") { $record = $record->[0]; }
Branch: 1 branch
BranchTrueFalseTotal
if (ref $record eq "ARRAY") 0 0 0
553 0 ▶ if (ref($record) eq "Net::Cisco::ISE::InternalUser")
Branch: 1 branch
BranchTrueFalseTotal
if (ref $record eq "Net::Cisco::ISE::InternalUser") 0 0 0
554 0 { $action = $Net::Cisco::ISE::InternalUser::actions{"getById"};
555 0 $type = "InternalUser";
556 0 $accepttype = "identity.internaluser.1.0";
557 }
558  
559 0 ▶ if (ref($record) eq "Net::Cisco::ISE::IdentityGroup")
Branch: 1 branch
BranchTrueFalseTotal
if (ref $record eq "Net::Cisco::ISE::IdentityGroup") 0 0 0
560 0 { $action = $Net::Cisco::ISE::IdentityGroup::actions{"getById"};
561 0 $type = "IdentityGroup";
562 0 $accepttype = "identity.identitygroup.1.0";
563 }
564  
565 0 ▶ if (ref($record) eq "Net::Cisco::ISE::NetworkDevice")
Branch: 1 branch
BranchTrueFalseTotal
if (ref $record eq "Net::Cisco::ISE::NetworkDevice") 0 0 0
566 { #$action = $Net::Cisco::ISE::NetworkDevice::actions{"getById"};
567 0 $type = "NetworkDevice";
568 0 $accepttype = "network.networkdevice.1.1";
569 }
570
571 0 ▶ if (ref($record) eq "Net::Cisco::ISE::NetworkDeviceGroup")
Branch: 1 branch
BranchTrueFalseTotal
if (ref $record eq "Net::Cisco::ISE::NetworkDeviceGroup") 0 0 0
572 { #$action = $Net::Cisco::ISE::NetworkDeviceGroup::actions{"getById"};
573 0 $type = "NetworkDeviceGroup";
574 0 $accepttype = "network.networkdevicegroup.1.1";
575 }
576  
577 0 ▶ if (ref($record) eq "Net::Cisco::ISE::Endpoint")
Branch: 1 branch
BranchTrueFalseTotal
if (ref $record eq "Net::Cisco::ISE::Endpoint") 0 0 0
578 { #$action = $Net::Cisco::ISE::Endpoint::actions{"getById"};
579 0 $type = "Endpoint";
580 0 $accepttype = "identity.endpoint.1.0";
581 }
582  
583 # Not sure Endpoint Certificates can be deleted
584 0 ▶ if (ref($record) eq "Net::Cisco::ISE::EndpointCertificate")
Branch: 1 branch
BranchTrueFalseTotal
if (ref $record eq "Net::Cisco::ISE::EndpointCertificate") 0 0 0
585 { #$action = $Net::Cisco::ISE::EndpointCertificate::actions{"getById"};
586 0 $type = "EndpointCertificate";
587 0 $accepttype = "ca.endpointcert.1.0";
588 }
589  
590 0 ▶ if (ref($record) eq "Net::Cisco::ISE::EndpointIdentityGroup")
Branch: 1 branch
BranchTrueFalseTotal
if (ref $record eq "Net::Cisco::ISE::EndpointIdentityGroup") 0 0 0
591 { #$action = $Net::Cisco::ISE::EndpointIdentityGroup::actions{"getById"};
592 0 $type = "EndpointIdentityGroup";
593 0 $accepttype = "identity.endpointgroup.1.0";
594 }
595  
596 0 ▶ if (ref($record) eq "Net::Cisco::ISE::Portal")
Branch: 1 branch
BranchTrueFalseTotal
if (ref $record eq "Net::Cisco::ISE::Portal") 0 0 0
597 { #$action = $Net::Cisco::ISE::Portal::actions{"getById"};
598 0 $type = "Portal";
599 0 $accepttype = "identity.portal.1.0";
600 }
601  
602 0 ▶ if (ref($record) eq "Net::Cisco::ISE::Profile")
Branch: 1 branch
BranchTrueFalseTotal
if (ref $record eq "Net::Cisco::ISE::Profile") 0 0 0
603 { #$action = $Net::Cisco::ISE::Profile::actions{"getById"};
604 0 $type = "Profile";
605 0 $accepttype = "identity.profilerprofile.1.0";
606 }
607  
608
609 0 $hostname = $hostname . $action.$record->id;
610 0 my $useragent = LWP::UserAgent->new (ssl_opts => $self->ssl_options);
611 0 my $request = HTTP::Request->new(DELETE => $hostname );
612 0 $request->content_type("application/xml");
613 0 $request->header("Authorization" => "Basic $credentials", Accept => "application/vnd.com.cisco.ise.$accepttype+xml");
614 0 my $result = $useragent->request($request);
615 0 my $id = "";
616 0 ▶ if ($result->code ne "204")
Branch: 1 branch
BranchTrueFalseTotal
if ($result->code ne 204) 0 0 0
617 0 { $ERROR = $result->{"code"};
618 }
619 }
620  
621 sub parse_xml
622 0 ▶{ my $self = shift;
Subroutine parse_xml: not called CC=33 SCAR=70.2
Pod undocumented
623 0 my $type = shift;
624 0 my $xml_ref = shift;
625 0 my $xmlsimple = XML::Simple->new();
626 0 my $xmlout = $xmlsimple->XMLin($xml_ref);
627 0 ▶ if ($type eq "InternalUsers")
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "InternalUsers") 0 0 0
628 { #my $users_ref = $xmlout->{"InternalUser"};
629 0 my $users_ref = $xmlout->{"resources"}{"resource"};
630 0 my %users = ();
631 0 for my $key (keys % {$users_ref})
632 0 { my $user = Net::Cisco::ISE::InternalUser->new( name => $key, %{ $users_ref->{$key} } );
633 0 $users{$key} = $user;
634 }
635 0 $self->{"InternalUsers"} = \%users;
636 0 return $self->{"InternalUsers"};
637 }
638 0 ▶ if ($type eq "InternalUser") # userByName and userById DO NOT return hash but a single instance of Net::Cisco::ISE::InternalUser
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "InternalUser") 0 0 0
639 0 { my %user_hash = %{ $xmlout };
640 0 my $user = Net::Cisco::ISE::InternalUser->new( %user_hash );
641 0 $self->{"InternalUsers"} = $user ;
642 0 return $self->{"InternalUsers"};
643 }
644  
645 0 ▶ if ($type eq "IdentityGroups")
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "IdentityGroups") 0 0 0
646 0 { my $identitygroups_ref = $xmlout->{"resources"}{"resource"};
647 0 my %identitygroups = ();
648 0 for my $key (keys % {$identitygroups_ref})
649 0 { my $identitygroup = Net::Cisco::ISE::IdentityGroup->new( name => $key, %{ $identitygroups_ref->{$key} } );
650 0 $identitygroups{$key} = $identitygroup;
651 }
652 0 $self->{"IdentityGroups"} = \%identitygroups;
653 0 return $self->{"IdentityGroups"};
654 }
655 0 ▶ if ($type eq "IdentityGroup") # ByName and ById DO NOT return hash but a single instance of Net::Cisco::ISE::IdentityGroup
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "IdentityGroup") 0 0 0
656 0 { my %identitygroup_hash = %{ $xmlout };
657 0 my $identitygroup = Net::Cisco::ISE::IdentityGroup->new( %identitygroup_hash );
658 0 $self->{"IdentityGroups"} = $identitygroup;
659 0 return $self->{"IdentityGroups"};
660 }
661  
662 0 ▶ if ($type eq "NetworkDevices")
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "NetworkDevices") 0 0 0
663 0 { my $device_ref = $xmlout->{"resources"}{"resource"};
664 0 my %devices = ();
665 0 for my $key (keys % {$device_ref})
666 { #my $device = Net::Cisco::ISE::NetworkDevice->new( name => $key, %{ $device_ref->{$key} } );
667 #$devices{$key} = $device;
668 }
669 0 $self->{"NetworkDevices"} = \%devices;
670 0 return $self->{"NetworkDevices"};
671 }
672 0 ▶ if ($type eq "NetworkDevice") # deviceByName and deviceById DO NOT return hash but a single instance of Net::Cisco::ISE::NetworkDevice
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "NetworkDevice") 0 0 0
673 0 { my %device_hash = %{ $xmlout };
674 #my $device = Net::Cisco::ISE::NetworkDevice->new( %device_hash );
675 #$self->{"NetworkDevices"} = $device;
676 0 return $self->{"NetworkDevices"};
677 }
678  
679 0 ▶ if ($type eq "NetworkDeviceGroups")
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "NetworkDeviceGroups") 0 0 0
680 0 { my $devicegroup_ref = $xmlout->{"resources"}{"resource"};
681 0 my %devicegroups = ();
682 0 for my $key (keys % {$devicegroup_ref})
683 { #my $devicegroup = Net::Cisco::ISE::NetworkDeviceGroup->new( name => $key, %{ $devicegroup_ref->{$key} } );
684 #$devicegroups{$key} = $devicegroup;
685 }
686 0 $self->{"NetworkDeviceGroups"} = \%devicegroups;
687 0 return $self->{"NetworkDeviceGroups"};
688 }
689 0 ▶ if ($type eq "NetworkDeviceGroup") # deviceGroupByName and deviceGroupById DO NOT return hash but a single instance of Net::Cisco::ISE::NetworkDeviceGroup
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "NetworkDeviceGroup") 0 0 0
690 0 { my %devicegroup_hash = %{ $xmlout };
691 #my $devicegroup = Net::Cisco::ISE::NetworkDeviceGroup->new( %devicegroup_hash );
692 #$self->{"NetworkDeviceGroups"} = $devicegroup;
693 0 return $self->{"NetworkDeviceGroups"};
694 }
695
696 0 ▶ if ($type eq "Endpoints")
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "Endpoints") 0 0 0
697 0 { my $host_ref = $xmlout->{"resources"}{"resource"};
698 0 my %hosts = ();
699 0 for my $key (keys % {$host_ref})
700 { #my $host = Net::Cisco::ISE::Endpoint->new( macAddress => $key, %{ $host_ref->{$key} } );
701 #$hosts{$key} = $host;
702 }
703 0 $self->{"Endpoints"} = \%hosts;
704 0 return $self->{"Endpoints"};
705 }
706 0 ▶ if ($type eq "Endpoint") # ByName and ById DO NOT return hash but a single instance of Net::Cisco::ISE::Endpoint
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "Endpoint") 0 0 0
707 0 { my %host_hash = %{ $xmlout };
708 #my $host = Net::Cisco::ISE::Endpoint->new( %host_hash );
709 #$self->{"Endpoints"} = $host;
710 0 return $self->{"Endpoints"};
711 }
712
713 0 ▶ if ($type eq "EndpointCertificates")
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "EndpointCertificates") 0 0 0
714 0 { my $host_ref = $xmlout->{"resources"}{"resource"};
715 0 my %hosts = ();
716 0 for my $key (keys % {$host_ref})
717 { #my $host = Net::Cisco::ISE::EndpointCertificate->new( name => $key, %{ $host_ref->{$key} } );
718 #$hosts{$key} = $host;
719 }
720 0 $self->{"EndpointCertificates"} = \%hosts;
721 0 return $self->{"EndpointCertificates"};
722 }
723 0 ▶ if ($type eq "EndpointCertificate") # ByName and ById DO NOT return hash but a single instance of Net::Cisco::ISE::Endpoint
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "EndpointCertificate") 0 0 0
724 0 { my %host_hash = %{ $xmlout };
725 #my $host = Net::Cisco::ISE::EndpointCertificate->new( %host_hash );
726 #$self->{"EndpointCertificates"} = $host;
727 0 return $self->{"EndpointCertificates"};
728 }
729  
730 0 ▶ if ($type eq "EndpointIdentityGroups")
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "EndpointIdentityGroups") 0 0 0
731 0 { my $host_ref = $xmlout->{"resources"}{"resource"};
732 0 my %hosts = ();
733 0 for my $key (keys % {$host_ref})
734 { #my $host = Net::Cisco::ISE::EndpointIdentityGroup->new( name => $key, %{ $host_ref->{$key} } );
735 #$hosts{$key} = $host;
736 }
737 0 $self->{"EndpointIdentityGroups"} = \%hosts;
738 0 return $self->{"EndpointIdentityGroups"};
739 }
740 0 ▶ if ($type eq "EndpointIdentityGroup") # ByName and ById DO NOT return hash but a single instance of Net::Cisco::ISE::Endpoint
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "EndpointIdentityGroup") 0 0 0
741 0 { my %host_hash = %{ $xmlout };
742 #my $host = Net::Cisco::ISE::EndpointIdentityGroup->new( %host_hash );
743 #$self->{"EndpointIdentityGroups"} = $host;
744 0 return $self->{"EndpointIdentityGroups"};
745 }
746  
747 0 ▶ if ($type eq "Portals")
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "Portals") 0 0 0
748 0 { my $host_ref = $xmlout->{"resources"}{"resource"};
749 0 my %hosts = ();
750 0 for my $key (keys % {$host_ref})
751 { #my $host = Net::Cisco::ISE::Portal->new( name => $key, %{ $host_ref->{$key} } );
752 #$hosts{$key} = $host;
753 }
754 0 $self->{"Portals"} = \%hosts;
755 0 return $self->{"Portals"};
756 }
757 0 ▶ if ($type eq "Portal") # ByName and ById DO NOT return hash but a single instance of Net::Cisco::ISE::Endpoint
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "Portal") 0 0 0
758 0 { my %host_hash = %{ $xmlout };
759 #my $host = Net::Cisco::ISE::Portal->new( %host_hash );
760 #$self->{"Portals"} = $host;
761 0 return $self->{"Portals"};
762 }
763  
764 0 ▶ if ($type eq "Profiles")
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "Profiles") 0 0 0
765 0 { my $host_ref = $xmlout->{"resources"}{"resource"};
766 0 my %hosts = ();
767 0 for my $key (keys % {$host_ref})
768 { #my $host = Net::Cisco::ISE::Profile->new( name => $key, %{ $host_ref->{$key} } );
769 #$hosts{$key} = $host;
770 }
771 0 $self->{"Profiles"} = \%hosts;
772 0 return $self->{"Profiles"};
773 }
774 0 ▶ if ($type eq "Profile") # ByName and ById DO NOT return hash but a single instance of Net::Cisco::ISE::Endpoint
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "Profile") 0 0 0
775 0 { my %host_hash = %{ $xmlout };
776 #my $host = Net::Cisco::ISE::Profile->new( %host_hash );
777 #$self->{"Profiles"} = $host;
778 0 return $self->{"Profiles"};
779 }
780  
781 0 ▶ if ($type eq "result")
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "result") 0 0 0
782 0 { my %result_hash = %{ $xmlout };
783 0 return \%result_hash;
784 }
785 0 ▶ if ($type eq "messages")
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "messages") 0 0 0
786 0 { my %result_hash = %{ $xmlout };
787 0 return \%result_hash;
788 }
789 0 ▶ if ($type eq "Version")
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "Version") 0 0 0
790 0 { my %version_hash = %{ $xmlout };
791 0 return \%version_hash;
792 }
793 0 ▶ if ($type eq "ServiceLocation")
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "ServiceLocation") 0 0 0
794 0 { my %servicelocation_hash = %{ $xmlout };
795 0 return \%servicelocation_hash;
796 }
797 0 ▶ if ($type eq "ErrorMessage")
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "ErrorMessage") 0 0 0
798 0 { my %errormessage_hash = %{ $xmlout };
799 0 return \%errormessage_hash;
800 }
801  
802 }
803  
804 =head1 NAME
805  
806 Net::Cisco::ISE - Access Cisco ISE functionality through REST API
807  
808 =head1 SYNOPSIS
809  
810 use Net::Cisco::ISE;
811 my $ise = Net::Cisco::ISE->new(hostname => '10.0.0.1', username => 'admin', password => 'testPassword');
812 # Options:
813 # hostname - IP or hostname of Cisco ISE 5.x server
814 # username - Username of Administrator user
815 # password - Password of user
816 # port - TCP port 9060 by default
817 # ssl - SSL enabled (1 - default) or disabled (0)
818
819 my %users = $ise->internalusers;
820 # Retrieve all users from ISE
821 # Returns hash with username / Net::Cisco::ISE::InternalUser pairs
822
823 print $ise->internalusers->{"admin"}->toXML;
824 # Dump in XML format (used by ISE for API calls)
825
826 my $user = $ise->internalusers("name","admin");
827 # Faster call to request specific user information by name
828  
829 my $user = $ise->internalusers("id","b74a0ef2-b29c-40e3-a0d1-4c0dfb51ace9");
830 # Faster call to request specific user information by ID (assigned by ISE, present in Net::Cisco::ISE::InternalUser)
831  
832 my %identitygroups = $ise->identitygroups;
833 # Retrieve all identitygroups from ISE
834 # Returns hash with name / Net::Cisco::ISE::IdentityGroup pairs
835
836 print $ise->identitygroups->{"All Groups"}->toXML;
837 # Dump in XML format (used by ISE for API calls)
838
839 my $identitygroup = $ise->identitygroups("name","All Groups");
840 # Faster call to request specific identity group information by name
841  
842 my $identitygroup = $ise->identitygroups("id","4fffc260-9b96-11e6-93fb-005056ad1454");
843 # Faster call to request specific identity group information by ID (assigned by ISE, present in Net::Cisco::ISE::IdentityGroup)
844
845 $user->id(0); # Required for new user!
846 my $id = $ise->create($user);
847 # Create new user based on Net::Cisco::ISE::InternalUser instance
848 # Return value is ID generated by ISE
849 print "Record ID is $id" if $id;
850 print $Net::Cisco::ISE::ERROR unless $id;
851 # $Net::Cisco::ISE::ERROR contains details about failure
852  
853 my $id = $ise->create(@users); # Still requires nullified ID!
854 # Create new users based on Net::Cisco::ISE::InternalUser instances in arguments
855 # Return value is not guaranteed in this case!
856 # print "Record ID is $id" if $id;
857 # print $Net::Cisco::ISE::ERROR unless $id;
858 # $Net::Cisco::ISE::ERROR contains details about failure
859
860 $identitygroup->id(0); # Required for new record!
861 my $id = $ise->create($identitygroup);
862 # Create new identity group based on Net::Cisco::ISE::IdentityGroup instance
863 # Return value is ID generated by ISE
864 print "Record ID is $id" if $id;
865 print $Net::Cisco::ISE::ERROR unless $id;
866 # $Net::Cisco::ISE::ERROR contains details about failure
867  
868 # Cisco ISE does not support modifying an identity group through the API
869
870 my $id = $ise->update($user);
871 # Update existing user based on Net::Cisco::ISE::InternalUser instance
872 # Return value is ID generated by ISE
873 print "Record ID is $id" if $id;
874 print $Net::Cisco::ISE::ERROR unless $id;
875 # $Net::Cisco::ISE::ERROR contains details about failure
876  
877 my $id = $ise->update(@users);
878 # Update existing users based on Net::Cisco::ISE::InternalUser instances in arguments
879 # Return value is not guaranteed in this case!
880 # print "Record ID is $id" if $id;
881 # print $Net::Cisco::ISE::ERROR unless $id;
882 # $Net::Cisco::ISE::ERROR contains details about failure
883
884 $ise->delete($user);
885 # Delete existing user based on Net::Cisco::ISE::InternalUser instance
886
887 =head1 DESCRIPTION
888  
889 Net::Cisco::ISE is an implementation of the Cisco Secure Access Control System (ISE) REST API. Cisco ISE is a application / appliance that can be used for network access policy control. In short, it allows configuration of access policies for specific users onto specific devices and applications (either using RADIUS or TACISE+ authentication). Net::Cisco::ISE currently supports InternalUser and IdentityGroup.
890  
891 =head1 USAGE
892  
893 All calls are handled through an instance of the L<Net::Cisco::ISE> class.
894  
895 use Net::Cisco::ISE;
896 my $ise = Net::Cisco::ISE->new(hostname => '10.0.0.1', username => 'admin', password => 'testPassword');
897  
898 =over 3
899  
900 =item new
901  
902 Class constructor. Returns object of Net::Cisco::ISE on succes. Required fields are:
903  
904 =over 5
905  
906 =item hostname
907  
908 =item username
909  
910 =item password
911  
912 =back
913  
914 Optional fields are
915  
916 =over 5
917  
918 =item ssl
919  
920 =item ssl_options
921  
922 =back
923  
924 =item hostname
925  
926 IP or hostname of Cisco ISE 2.x server. This is a required value in the constructor but can be redefined afterwards.
927  
928 =item username
929  
930 Username of Administrator user. This is a required value in the constructor but can be redefined afterwards.
931  
932 =item password
933  
934 Password of user. This is a required value in the constructor but can be redefined afterwards.
935  
936 =item ssl
937  
938 SSL enabled (1 - default) or disabled (0).
939  
940 =item ssl_options
941  
942 Value is passed directly to LWP::UserAGent as ssl_opt. Default value (hash-ref) is
943  
944 { 'SSL_verify_mode' => SSL_VERIFY_NONE, 'verify_hostname' => '0' }
945  
946 =back
947  
948 From the class instance, call the different methods for retrieving values.
949  
950 =over 3
951  
952 =item users
953  
954 Returns hash or single instance, depending on context.
955  
956 my %users = $ise->internalusers(); # Slow
957 my $user = $ise->internalusers()->{"admin"};
958 print $user->name;
959
960 The returned hash contains instances of L<Net::Cisco::ISE::InternalUser>, using name (typically the username) as the hash key. Using a call to C<users> with no arguments will retrieve all users and can take quite a few seconds (depending on the size of your database). When you know the username or ID, use the L<users> call with arguments as listed below.
961
962 my $user = $ise->internalusers("name","admin"); # Faster
963 # or
964 my $user = $ise->internalusers("id","b74a0ef2-b29c-40e3-a0d1-4c0dfb51ace9"); # Faster
965 print $user->name;
966  
967 The ID is typically generated by Cisco ISE when the entry is created. It can be retrieved by calling the C<id> method on the object.
968  
969 print $user->id;
970  
971 =item identitygroups
972  
973 Returns hash or single instance, depending on context.
974  
975 my %identitygroups = $ise->identitygroups(); # Slow
976 my $identitygroup = $ise->identitygroups()->{"All Groups"};
977 print $identitgroup->name;
978
979 The returned hash contains instances of L<Net::Cisco::ISE::IdentityGroup>, using name (typically the username) as the hash key. Using a call to C<identitygroup> with no arguments will retrieve all identitygroups and can take quite a few seconds (depending on the size of your database). When you know the group name or ID, use the L<identitygroups> call with arguments as listed below.
980
981 my $identitygroup = $ise->identitygroups("name","All Groups"); # Faster
982 # or
983 my $identitygroup = $ise->identitygroups("id","4fffc260-9b96-11e6-93fb-005056ad1454"); # Faster
984 print $identitygroup->name;
985  
986 The ID is typically generated by Cisco ISE when the entry is created. It can be retrieved by calling the C<id> method on the object.
987  
988 print $identitygroup->id;
989
990 =item create
991  
992 This method created a new entry in Cisco ISE, depending on the argument passed. Record type is detected automatically. For all record types, the ID value must be set to 0.
993  
994 my $user = $ise->internalusers("name","admin");
995 $user->id(0); # Required for new user!
996 $user->name("altadmin"); # Required field
997 $user->password("TopSecret"); # Password policies will be enforced!
998 $user->description("Alternate Admin");
999 my $id = $ise->create($user);
1000 # Create new user based on Net::Cisco::ISE::InternalUser instance
1001 # Return value is ID generated by ISE
1002 print "Record ID is $id" if $id;
1003 print $Net::Cisco::ISE::ERROR unless $id;
1004 # $Net::Cisco::ISE::ERROR contains details about failure
1005  
1006 Multiple instances can be passed as an argument. Objects will be created in bulk (one transaction). The returned ID is not guaranteed to be the IDs of the created objects.
1007  
1008 my $user = $ise->internalusers("name","admin");
1009 $user->id(0); # Required for new user!
1010 $user->name("altadmin"); # Required field
1011 $user->password("TopSecret"); # Password policies will be enforced!
1012 $user->description("Alternate Admin");
1013  
1014 my $user2 = $ise->internalusers("name","admin");
1015 $user2->id(0); # Required for new user!
1016 $user2->name("altadmin"); # Required field
1017 $user2->password("TopSecret"); # Password policies will be enforced!
1018 $user2->description("Alternate Admin");
1019  
1020 my $id = $ise->create($user,$user2);
1021 # Create new users based on Net::Cisco::ISE::InternalUser instances in argument.
1022 # Return value is ID generated by ISE but not guaranteed.
1023 # print "Record ID is $id" if $id;
1024 # print $Net::Cisco::ISE::ERROR unless $id;
1025 # $Net::Cisco::ISE::ERROR contains details about failure
1026
1027 =item update
1028  
1029 This method updates an existing entry in Cisco ISE, depending on the argument passed. Record type is detected automatically.
1030  
1031 my $user = $ise->internalusers("name","admin");
1032 $user->password("TopSecret"); # Change password. Password policies will be enforced!
1033 my $id = $ise->update($user);
1034 # Update user based on Net::Cisco::ISE::InternalUser instance
1035 # Return value is ID generated by ISE
1036 print "Record ID is $id" if $id;
1037 print $Net::Cisco::ISE::ERROR unless $id;
1038 # $Net::Cisco::ISE::ERROR contains details about failure
1039  
1040 Multiple instances can be passed as an argument. Objects will be updated in bulk (one transaction). The returned ID is not guaranteed to be the IDs of the created objects.
1041  
1042 my $user = $ise->internalusers("name","admin");
1043 $user->id(0); # Required for new user!
1044 $user->password("TopSecret"); # Password policies will be enforced!
1045  
1046 my $user2 = $ise->internalusers("name","admin2");
1047 $user2->password("TopSecret"); # Password policies will be enforced!
1048  
1049 my $id = $ise->update($user,$user2);
1050 # Update users based on Net::Cisco::ISE::InternalUser instances in arguments
1051 # Return value is ID generated by ISE but not guaranteed.
1052 # print "Record ID is $id" if $id;
1053 # print $Net::Cisco::ISE::ERROR unless $id;
1054 # $Net::Cisco::ISE::ERROR contains details about failure
1055
1056 =item delete
1057  
1058 This method deletes an existing entry in Cisco ISE, depending on the argument passed. Record type is detected automatically.
1059  
1060 my $user = $ise->internalusers("name","admin");
1061 $ise->delete($user);
1062  
1063 =item $ERROR
1064  
1065 This variable will contain detailed error information, based on the REST API answer. This value is reset during every call to C<internalusers> and C<identitygroups>.
1066
1067 =back
1068  
1069 =head1 REQUIREMENTS
1070  
1071 For this library to work, you need an instance with Cisco ISE (obviously) or a simulator like L<Net::Cisco::ISE::Mock>.
1072  
1073 Instructions on enabling Cisco ISE for API access will be added later.
1074  
1075 You will also need
1076  
1077 =over 3
1078  
1079 =item L<Moose>
1080  
1081 =item L<IO::Socket::SSL>
1082  
1083 =item L<LWP::UserAgent>
1084  
1085 =item L<XML::Simple>
1086  
1087 =item L<MIME::Base64>
1088  
1089 =item L<URI::Escape>
1090  
1091 =back
1092
1093 =head1 BUGS
1094  
1095 None so far
1096  
1097 =head1 SUPPORT
1098  
1099 None so far :)
1100  
1101 =head1 AUTHOR
1102  
1103 Hendrik Van Belleghem
1104 CPAN ID: BEATNIK
1105 hendrik.vanbelleghem@gmail.com
1106  
1107 =head1 COPYRIGHT
1108  
1109 This program is free software licensed under the...
1110  
1111 The General Public License (GPL)
1112 Version 2, June 1991
1113  
1114 The full text of the license can be found in the
1115 LICENSE file included with this module.
1116  
1117 =head1 COMPATIBILITY
1118  
1119 Certain API calls are not support from Cisco ISE 5.0 onwards. The current supported versions of Cisco ISE (by Cisco) are 5.6, 5.7 and 5.8 (Active).
1120  
1121 =head1 SEE ALSO
1122  
1123 =over 3
1124  
1125 See L<Net::Cisco::ISE::InternalUser> for more information on User management.
1126  
1127 See L<Net::Cisco::ISE::IdentityGroup> for more information on User Group management.
1128  
1129 See the L<Cisco ISE product page|http://www.cisco.com/c/en/us/products/security/secure-access-control-system/index.html> for more information.
1130  
1131 L<Net::Cisco::ISE> relies on L<Moose>.
1132  
1133 =back
1134  
1135 =cut
1136  
1137 #################### main pod documentation end ###################
1138  
1139 1 __PACKAGE__->meta->make_immutable();
1140  
1141 1 1;
1142 # The preceding line will help the module return a true value
1143  
↑ Summary blib/lib/Net/Cisco/ISE/InternalUser.pm »