Mercurial > pub > Impl
comparison Lib/IMPL/Security/Auth/Simple.pm @ 249:0057f48f7945
fixed simple auth package to work with utf8 strings
| author | sergey |
|---|---|
| date | Tue, 06 Nov 2012 20:00:57 +0400 |
| parents | 23daf2fae33a |
| children |
comparison
equal
deleted
inserted
replaced
| 248:814d755e5d12 | 249:0057f48f7945 |
|---|---|
| 1 package IMPL::Security::Auth::Simple; | 1 package IMPL::Security::Auth::Simple; |
| 2 use strict; | 2 use strict; |
| 3 | 3 |
| 4 use Digest::MD5 qw(md5_hex); | 4 use Digest::MD5 qw(md5_hex); |
| 5 use Encode qw(encode); | |
| 5 | 6 |
| 6 use IMPL::Security::Auth qw(:Const); | 7 use IMPL::Security::Auth qw(:Const); |
| 7 | 8 |
| 8 use IMPL::Const qw(:prop); | 9 use IMPL::Const qw(:prop); |
| 9 use IMPL::declare { | 10 use IMPL::declare { |
| 55 sub DoAuth { | 56 sub DoAuth { |
| 56 my ($this,$challenge) = @_; | 57 my ($this,$challenge) = @_; |
| 57 | 58 |
| 58 my $salt = $this->_salt; | 59 my $salt = $this->_salt; |
| 59 | 60 |
| 60 if (md5_hex($salt, $challenge, $salt) eq $this->_image) { | 61 if (md5_hex($salt,encode('utf-8', $challenge), $salt) eq $this->_image) { |
| 61 if ($this->_stage == STAGE_INIT) { | 62 if ($this->_stage == STAGE_INIT) { |
| 62 $this->_stage(STAGE_DONE); | 63 $this->_stage(STAGE_DONE); |
| 63 } | 64 } |
| 64 return (AUTH_SUCCESS, undef); | 65 return (AUTH_SUCCESS, undef); |
| 65 } else { | 66 } else { |
| 71 my ($self,%args) = @_; | 72 my ($self,%args) = @_; |
| 72 | 73 |
| 73 die new IMPL::InvalidArgumentException("The parameter is required",'password') unless $args{password}; | 74 die new IMPL::InvalidArgumentException("The parameter is required",'password') unless $args{password}; |
| 74 | 75 |
| 75 my $salt = $self->GenSSID(); | 76 my $salt = $self->GenSSID(); |
| 76 return return join ('|',STAGE_INIT, $salt, md5_hex($salt,$args{password},$salt)); | 77 return return join ('|',STAGE_INIT, $salt, md5_hex($salt,encode('utf-8', $args{password}),$salt)); |
| 77 } | 78 } |
| 78 | 79 |
| 79 sub SecDataArgs { | 80 sub SecDataArgs { |
| 80 password => 'SCALAR' | 81 password => 'SCALAR' |
| 81 } | 82 } |
