File Coverage

blib/lib/Ekahau/License.pm
Criterion Covered Total %
statement 13 15 86.6
branch n/a
condition n/a
subroutine 5 5 100.0
pod n/a
total 18 20 90.0


line stmt bran cond sub pod time code
1             package Ekahau::License;
2 6     6   40 use Ekahau::Base; our $VERSION=$Ekahau::Base::VERSION;
  6         17  
  6         402  
3 6     6   41 use base 'Ekahau::ErrHandler';
  6         14  
  6         751  
4              
5             # Written by Scott Gifford
6             # Copyright (C) 2004 The Regents of the University of Michigan.
7             # See the file LICENSE included with the distribution for license
8             # information.
9              
10 6     6   38 use strict;
  6         13  
  6         379  
11 6     6   37 use warnings;
  6         12  
  6         231  
12              
13             =head1 NAME
14              
15             Ekahau::License - Internal module used to parse and handle Ekahau license files.
16              
17             =head1 SYNOPSIS
18              
19             This module is used internally by the L class; you
20             shouldn't need to use it directly. It provides an interface to handle
21             Ekahau license files, and perform a few simple operations that are
22             necessary for a licensed authentication to an Ekahau server.
23              
24             =head1 DESCRIPTION
25              
26             =cut
27              
28 6     6   4909 use XML::Simple;
  0            
  0            
29             use Digest::MD5 qw(md5_hex);
30              
31             =head2 Constructor
32              
33             =head3 new ( %params )
34              
35             Creates a new object with the given parameters, in a C Value>
36             style list. The only parameter recognized is C, which
37             gives the path to an Ekahau license file.
38              
39             =cut
40              
41             sub new
42             {
43             my $class = shift;
44             my(%p)=@_;
45              
46             my $self = {};
47             bless $self, $class;
48             $self->{_errhandler} = Ekahau::ErrHandler->errhandler_new($class,%p);
49            
50             $self->{LicenseFile}=$p{LicenseFile}
51             or return $self->reterr("No LicenseFile specified");
52             $self->{_license} = XMLin($self->{LicenseFile})
53             or return $self->reterr("Couldn't parse license file");
54              
55             $self->errhandler_constructed();
56             }
57              
58             sub ERROBJ
59             {
60             my $self = shift;
61             $self->{_errhandler};
62             }
63              
64             =head2 Methods
65              
66             =head3 hello_str
67              
68             Generate a string suitable for an Ekahau YAX C authentication
69             step.
70              
71             =cut
72              
73             sub hello_str
74             {
75             my $self = shift;
76              
77             join(" ", map { "$_=$self->{_license}{mandate}{claim}{$_}{value}" } keys %{$self->{_license}{mandate}{claim}});
78             }
79              
80             =head3 talk_str ( %params )
81              
82             Generating a string suitable for an Ekahau YAX C authentication
83             command. This method accepts three parameters, in a C Value>
84             style list:
85              
86             =over 4
87              
88             =item Password
89              
90             Password to connect to Ekahau server
91              
92             =item HelloStr
93              
94             String received from the YAX server in a C message.
95              
96             =back
97              
98             C is required; C defaults to the default Ekahau
99             password.
100              
101             =cut
102              
103             sub talk_str
104             {
105             my $self = shift;
106             my(%p)=@_;
107              
108            
109             defined($p{HelloStr})
110             or return $self->reterr("talk_str method requires HelloStr argument");
111             defined($self->{_license}{mandate}{checksum})
112             or return $self->reterr("Couldn't find mandate checksum in Ekahau license");
113             defined($p{Password}) or $p{Password} = 'Llama';
114              
115             my $str = join("",$p{HelloStr},$p{Password},$self->{_license}{mandate}{checksum});
116             my $digest = md5_hex($str);
117             $digest;
118             }
119              
120             =head1 AUTHOR
121              
122             Scott Gifford Egifford@umich.eduE, Esgifford@suspectclass.comE
123              
124             Copyright (C) 2005 The Regents of the University of Michigan.
125              
126             See the file LICENSE included with the distribution for license
127             information.
128              
129              
130             =head1 SEE ALSO
131              
132             L, L, L.
133              
134             =cut
135              
136             1;
137