| 1 | package Ekahau::License; | ||||||||||
| 2 | 15 | ▶ | use Ekahau::Base; our $VERSION=$Ekahau::Base::VERSION; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 15 | ▶ | use base 'Ekahau::ErrHandler'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | # Written by Scott Gifford <gifford@umich.edu> | ||||||||||
| 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 | 15 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 15 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 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<Ekahau::Base|Ekahau::Base> 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 | 15 | ▶ | use XML::Simple; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 29 | 15 | ▶ | use Digest::MD5 qw(md5_hex); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 30 | |||||||||||
| 31 | =head2 Constructor | ||||||||||
| 32 | |||||||||||
| 33 | =head3 new ( %params ) | ||||||||||
| 34 | |||||||||||
| 35 | Creates a new object with the given parameters, in a C<Param => Value> | ||||||||||
| 36 | style list. The only parameter recognized is C<LicenseFile>, which | ||||||||||
| 37 | gives the path to an Ekahau license file. | ||||||||||
| 38 | |||||||||||
| 39 | =cut | ||||||||||
| 40 | |||||||||||
| 41 | sub new | ||||||||||
| 42 | 15 | ▶ | { | ||||||||
|
Subroutine
new: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||
| 43 | 15 | my $class = shift; | |||||||||
| 44 | 15 | my(%p)=@_; | |||||||||
| 45 | |||||||||||
| 46 | 15 | my $self = {}; | |||||||||
| 47 | 15 | bless $self, $class; | |||||||||
| 48 | 15 | $self->{_errhandler} = Ekahau::ErrHandler->errhandler_new($class,%p); | |||||||||
| 49 | |||||||||||
| 50 | $self->{LicenseFile}=$p{LicenseFile} | ||||||||||
| 51 | 15 | ▶ | or return $self->reterr("No LicenseFile specified"); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 52 | $self->{_license} = XMLin($self->{LicenseFile}) | ||||||||||
| 53 | 15 | ▶ | or return $self->reterr("Couldn't parse license file"); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 54 | |||||||||||
| 55 | 15 | $self->errhandler_constructed(); | |||||||||
| 56 | } | ||||||||||
| 57 | |||||||||||
| 58 | sub ERROBJ | ||||||||||
| 59 | 15 | ▶ | { | ||||||||
|
Subroutine
ERROBJ: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 60 | 15 | my $self = shift; | |||||||||
| 61 | 15 | $self->{_errhandler}; | |||||||||
| 62 | } | ||||||||||
| 63 | |||||||||||
| 64 | =head2 Methods | ||||||||||
| 65 | |||||||||||
| 66 | =head3 hello_str | ||||||||||
| 67 | |||||||||||
| 68 | Generate a string suitable for an Ekahau YAX C<HELLO> authentication | ||||||||||
| 69 | step. | ||||||||||
| 70 | |||||||||||
| 71 | =cut | ||||||||||
| 72 | |||||||||||
| 73 | sub hello_str | ||||||||||
| 74 | 6 | ▶ | { | ||||||||
|
Subroutine
hello_str: called CC=1 SCAR=0.2
Pod
documented
| |||||||||||
| 75 | 6 | my $self = shift; | |||||||||
| 76 | |||||||||||
| 77 | 0 | 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<TALK> authentication | ||||||||||
| 83 | command. This method accepts three parameters, in a C<Param => 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<HELLO> message. | ||||||||||
| 95 | |||||||||||
| 96 | =back | ||||||||||
| 97 | |||||||||||
| 98 | C<HelloStr> is required; C<Password> defaults to the default Ekahau | ||||||||||
| 99 | password. | ||||||||||
| 100 | |||||||||||
| 101 | =cut | ||||||||||
| 102 | |||||||||||
| 103 | sub talk_str | ||||||||||
| 104 | 13 | ▶ | { | ||||||||
|
Subroutine
talk_str: called CC=4 SCAR=14.2
Pod
documented
| |||||||||||
| 105 | 13 | my $self = shift; | |||||||||
| 106 | 13 | my(%p)=@_; | |||||||||
| 107 | |||||||||||
| 108 | |||||||||||
| 109 | defined($p{HelloStr}) | ||||||||||
| 110 | 13 | ▶ | or return $self->reterr("talk_str method requires HelloStr argument"); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 111 | defined($self->{_license}{mandate}{checksum}) | ||||||||||
| 112 | 13 | ▶ | or return $self->reterr("Couldn't find mandate checksum in Ekahau license"); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 113 | 13 | ▶ | defined($p{Password}) or $p{Password} = 'Llama'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 114 | |||||||||||
| 115 | 13 | my $str = join("",$p{HelloStr},$p{Password},$self->{_license}{mandate}{checksum}); | |||||||||
| 116 | 13 | my $digest = md5_hex($str); | |||||||||
| 117 | 13 | $digest; | |||||||||
| 118 | } | ||||||||||
| 119 | |||||||||||
| 120 | =head1 AUTHOR | ||||||||||
| 121 | |||||||||||
| 122 | Scott Gifford E<lt>gifford@umich.eduE<gt>, E<lt>sgifford@suspectclass.comE<gt> | ||||||||||
| 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<XML::Simple|XML::Simple>, L<Digest::MD5|Digest::MD5>, L<Ekahau::Base|Ekahau::Base>. | ||||||||||
| 133 | |||||||||||
| 134 | =cut | ||||||||||
| 135 | |||||||||||
| 136 | 15 | 1; | |||||||||
| 137 | |||||||||||