+ ### validate the payload
+ if ($meth = $self->{'verify_payload'}) {
+ if (! $meth->($self, $data->{'payload'}, $data)) {
+ $data->error('Payload failed custom verification') if ! $data->error;
+ }
+ } else {
+ if (! $self->verify_payload($data->{'payload'}, $data)) {
+ $data->error('Payload failed verification') if ! $data->error;
+ }
+ }
+
+ return $data;
+}
+
+sub new_auth_data {
+ my $self = shift;
+ return $self->{'_last_auth_data'} = CGI::Ex::Auth::Data->new(@_);
+}
+
+sub parse_token {
+ my ($self, $token, $data) = @_;
+ my $found;
+ my $key;
+ for my $armor ('none', 'base64', 'blowfish') { # try with and without base64 encoding
+ my $copy = ($armor eq 'none') ? $token
+ : ($armor eq 'base64') ? eval { local $^W; decode_base64($token) }
+ : ($key = $self->use_blowfish) ? decrypt_blowfish($token, $key)
+ : next;
+ if ($copy =~ m|^ ([^/]+) / (\d+) / (-?\d+) / (.*) / ([a-fA-F0-9]{32}) (?: / (sh\.\d+\.\d+))? $|x) {
+ $data->add_data({
+ user => $1,
+ cram_time => $2,
+ expires_min => $3,
+ payload => $4,
+ test_pass => $5,
+ secure_hash => $6 || '',
+ armor => $armor,
+ });
+ $found = 1;
+ last;
+ } elsif ($copy =~ m|^ ([^/]+) / (.*) $|x) {
+ $data->add_data({
+ user => $1,
+ test_pass => $2,
+ armor => $armor,
+ });
+ $found = 1;
+ last;
+ }
+ }
+ return $found;
+}