| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# ================================================================ |
|
2
|
|
|
|
|
|
|
package App::iTan::Command::Get; |
|
3
|
|
|
|
|
|
|
# ================================================================ |
|
4
|
1
|
|
|
1
|
|
934
|
use utf8; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
6
|
|
|
5
|
1
|
|
|
1
|
|
32
|
use Moose; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
6
|
|
|
6
|
1
|
|
|
1
|
|
5627
|
use 5.0100; |
|
|
1
|
|
|
|
|
3
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
608
|
use MooseX::App::Command; |
|
|
1
|
|
|
|
|
1534
|
|
|
|
1
|
|
|
|
|
4
|
|
|
9
|
|
|
|
|
|
|
with qw(App::iTan::Utils); |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
option 'next' => ( |
|
12
|
|
|
|
|
|
|
is => 'ro', |
|
13
|
|
|
|
|
|
|
isa => 'Bool', |
|
14
|
|
|
|
|
|
|
documentation => q[Get the next available iTAN], |
|
15
|
|
|
|
|
|
|
); |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
option 'index' => ( |
|
18
|
|
|
|
|
|
|
is => 'ro', |
|
19
|
|
|
|
|
|
|
isa => 'Int', |
|
20
|
|
|
|
|
|
|
documentation => q[iTAN index number that should be fetched], |
|
21
|
|
|
|
|
|
|
); |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
option 'lowerinvalid' => ( |
|
24
|
|
|
|
|
|
|
is => 'ro', |
|
25
|
|
|
|
|
|
|
isa => 'Bool', |
|
26
|
|
|
|
|
|
|
documentation => q[Mark all iTANs with a lower index as invalid (only in combination with --index)], |
|
27
|
|
|
|
|
|
|
); |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
option 'memo' => ( |
|
30
|
|
|
|
|
|
|
is => 'ro', |
|
31
|
|
|
|
|
|
|
isa => 'Str', |
|
32
|
|
|
|
|
|
|
documentation => q[Optional memo on iTAN usage], |
|
33
|
|
|
|
|
|
|
); |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub execute { |
|
36
|
0
|
|
|
0
|
0
|
|
my ( $self, $opts, $args ) = @_; |
|
37
|
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
my $index; |
|
39
|
0
|
0
|
|
|
|
|
if ($self->next) { |
|
40
|
0
|
|
|
|
|
|
($index) = $self->dbh->selectrow_array("SELECT tindex |
|
41
|
|
|
|
|
|
|
FROM itan |
|
42
|
|
|
|
|
|
|
WHERE used IS NULL |
|
43
|
|
|
|
|
|
|
AND valid = 1 |
|
44
|
|
|
|
|
|
|
ORDER BY tindex |
|
45
|
|
|
|
|
|
|
LIMIT 1"); |
|
46
|
|
|
|
|
|
|
|
|
47
|
0
|
0
|
|
|
|
|
unless (defined $index) { |
|
48
|
0
|
|
|
|
|
|
say 'No more iTANs left'; |
|
49
|
0
|
|
|
|
|
|
return; |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
} else { |
|
52
|
0
|
|
|
|
|
|
$index = $self->index; |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
0
|
0
|
|
|
|
|
unless (defined $index) { |
|
56
|
0
|
|
|
|
|
|
say 'Option --index or --next must be set'; |
|
57
|
|
|
|
|
|
|
} else { |
|
58
|
0
|
|
|
|
|
|
my $tan_data = $self->get($index); |
|
59
|
0
|
|
|
|
|
|
my $itan = $self->decrypt_string($tan_data->{itan}); |
|
60
|
0
|
|
|
|
|
|
say 'iTAN '.$index.' marked as used'; |
|
61
|
0
|
|
|
|
|
|
say 'iTAN '.$itan; |
|
62
|
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
eval { |
|
64
|
0
|
0
|
|
|
|
|
if ($^O eq 'darwin') { |
|
65
|
0
|
|
|
|
|
|
Class::Load::load_class('Mac::Pasteboard'); |
|
66
|
0
|
|
|
|
|
|
my $pb = Mac::Pasteboard->new(); |
|
67
|
0
|
|
|
|
|
|
$pb->clear; |
|
68
|
0
|
|
|
|
|
|
$pb->copy($itan); |
|
69
|
|
|
|
|
|
|
} else { |
|
70
|
0
|
|
|
|
|
|
Class::Load::load_class('Clipboard'); |
|
71
|
0
|
|
|
|
|
|
Clipboard->copy($itan); |
|
72
|
|
|
|
|
|
|
} |
|
73
|
0
|
|
|
|
|
|
say 'iTan has been coppied to the clipboard'; |
|
74
|
|
|
|
|
|
|
}; |
|
75
|
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
$self->mark($index,$self->memo); |
|
77
|
0
|
0
|
|
|
|
|
if ($self->lowerinvalid) { |
|
78
|
0
|
0
|
|
|
|
|
$self->dbh->do('UPDATE itan SET valid = 0 WHERE tindex < '.$index) |
|
79
|
|
|
|
|
|
|
or die "ERROR: Cannot execute: " . $self->dbh->errstr(); |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
return; |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
87
|
|
|
|
|
|
|
1; |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=pod |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=encoding utf8 |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 NAME |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
App::iTan::Command::Get - Fetches selected iTAN |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
itan get [--next] OR [--index INDEX [--lowerinactive]] [--memo MEMO] |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Fetches an iTan an marks it as used. If possible the iTAN is also copied |
|
104
|
|
|
|
|
|
|
to the clipboard. |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
You will be prompted a password to decrypt the selected iTan. |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 OPTIONS |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head2 next |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Get the next available iTAN |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head2 index |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
iTAN index number that should be fetched |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head2 lowerinvalid |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Mark all iTANs with a lower index as invalid (only in combination with |
|
121
|
|
|
|
|
|
|
--index) |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head2 memo |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Optional memo on iTAN usage |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=cut |