Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

updated credentials management

  • Loading branch information...
commit 20c128cfdf7e80790f103c421bd20d5869ee1a93 1 parent d1a186c
@wertarbyte authored
View
8 bin/fp-transactions
@@ -93,7 +93,13 @@ unless (lc $output_format eq "csv" || lc $output_format eq "qif") {
}
my $cc = $mods{$module}->new;
-unless ($cc->credentials( @credentials )) {
+
+# feed credential information to module
+for my $name ($cc->required_credentials()) {
+ last unless @credentials;
+ $cc->add_credential( $name, shift @credentials );
+}
+unless ($cc->credentials_sufficient()) {
print STDERR "Insufficient credentials for this Module.\n";
print STDERR "Either specify --credentials or feed them through STDIN using --read-credentials.\n";
exit 1;
View
29 lib/Finance/Barclaycard.pm
@@ -1,6 +1,5 @@
package Finance::Barclaycard;
-require Finance::GenericWebBot;
-@ISA = ("Finance::GenericWebBot");
+use base "Finance::GenericWebBot";
use strict;
@@ -10,27 +9,9 @@ require Digest::MD5;
our $start_url = "https://www.barclaycard.de/";
sub required_credentials {
- my ($class) = @_;
return ("Online ID", "PIN", "Surname", "Password");
}
-sub credentials {
- my ($self, $id, $pin, $surname, $password) = @_;
-
- $self->{credentials}{surname} = $surname if defined $surname;
- $self->{credentials}{password} = $password if defined $password;
-
- return
- $self->SUPER::credentials($id, $pin) &&
- defined $self->{credentials}{surname} &&
- defined $self->{credentials}{password};
-}
-
-sub init {
- my ($self) = @_;
- $self->SUPER::init();
-}
-
sub login {
my ($self) = @_;
$self->SUPER::login();
@@ -43,21 +24,21 @@ sub login {
$m->submit_form(
form_name => "FORM1",
fields => {
- F_CSP1_1_FE_LOGIN_ID => $self->{credentials}{id},
- F_CSP1_1_FE_LOGIN_NAME => $self->{credentials}{surname},
+ F_CSP1_1_FE_LOGIN_ID => $self->{credentials}{"Online ID"},
+ F_CSP1_1_FE_LOGIN_NAME => $self->{credentials}{"Surname"},
}
);
my $data = $m->content();
my @mem;
while ( $data =~ /(for="F_CSP1_2_FE_LOGIN_MEMWORD([12])">Stelle Nr\. ([0-9]+)<\/label>)/g) {
- $mem[$2-1] = substr($self->{credentials}{password}, $3-1, 1);
+ $mem[$2-1] = substr($self->{credentials}{"Password"}, $3-1, 1);
}
$m->submit_form(
form_name => "FORM1",
fields => {
- F_CSP1_2_FE_LOGIN_PIN => $self->{credentials}{pin},
+ F_CSP1_2_FE_LOGIN_PIN => $self->{credentials}{"PIN"},
F_CSP1_2_FE_LOGIN_MEMWORD1 => $mem[0],
F_CSP1_2_FE_LOGIN_MEMWORD2 => $mem[1]
}
View
22 lib/Finance/GenericWebBot.pm
@@ -12,18 +12,24 @@ sub new {
autocheck => 1,
onerror => sub { $being->mech_error(@_) }
);
+ $me->{credentials} = ();
$me->{mech}->agent_alias("Linux Mozilla");
return $being;
}
-sub credentials {
- my ($self, $id, $pin) = @_;
-
- $self->{credentials}{id} = $id if defined $id;
- $self->{credentials}{pin} = $pin if defined $pin;
- return
- defined $self->{credentials}{id} &&
- defined $self->{credentials}{pin};
+sub add_credential {
+ my ($self, $name, $value) = @_;
+ # TODO check the credentials name for validity
+ $self->{credentials}{$name} = $value;
+}
+
+sub credentials_sufficient {
+ my ($self) = @_;
+ # return whether all credentials are entered
+ for my $c ($self->required_credentials()) {
+ return 0 unless defined $self->{credentials}{$c};
+ }
+ return 1;
}
sub required_credentials {
View
13 lib/Finance/MercedesBenzBank.pm
@@ -1,15 +1,14 @@
package Finance::MercedesBenzBank;
-require Finance::GenericWebBot;
+use base "Finance::GenericWebBot";
+
require HTML::TreeBuilder;
require Unicode::String;
-@ISA = ("Finance::GenericWebBot");
use strict;
our $start_url = "https://www.mercedes-benz-bank.de/";
sub required_credentials {
- my ($class) = @_;
return ("customer number", "PIN", "account number");
}
@@ -20,10 +19,10 @@ sub login {
$m->get($start_url);
$m->follow_link( text => "Login Online Banking");
$m->form_number(2);
- $m->field( "username", $self->{credentials}{id} );
- $m->field( "password", $self->{credentials}{pin} );
+ $m->field( "username", $self->{credentials}{"customer number"} );
+ $m->field( "password", $self->{credentials}{"PIN"} );
$m->click( '$$event_login' );
- my $acc = $self->{credentials}{account};
+ my $acc = $self->{credentials}{"account number"};
$m->follow_link( url_regex => qr/accountNo=\Q$acc\E/ );
}
@@ -38,7 +37,7 @@ sub credentials {
sub statements {
my ($self) = @_;
my @s = $self->SUPER::statements();
- return ("48");
+ return (@s, "48");
}
our %key_table = (
View
10 lib/Finance/Paypal.pm
@@ -1,7 +1,8 @@
package Finance::Paypal;
+use base "Finance::GenericWebBot";
+
require Finance::GenericWebBot;
require HTML::TreeBuilder;
-@ISA = ("Finance::GenericWebBot");
use strict;
@@ -19,8 +20,8 @@ sub login {
$m->get($start_url);
$m->follow_link( text => "Einloggen");
$m->form_name("login_form");
- $m->field( "login_email", $self->{credentials}{id} );
- $m->field( "login_password", $self->{credentials}{pin} );
+ $m->field( "login_email", $self->{credentials}{"e-mail address"} );
+ $m->field( "login_password", $self->{credentials}{"password"} );
$m->click( 'submit.x' );
$m->follow_link( url_regex => qr{cmd=_login-done} );
@@ -43,11 +44,12 @@ sub transactions {
$m->form_name( "form1" );
$m->field( "from_b", 1 );
$m->field( "from_a", 1 );
- $m->field( "from_c", 2000 );
+ $m->field( "from_c", 2008 );
$m->select( "custom_file_type", "tabdelim_allactivity" );
$m->click("submit.x");
my $csvdata = $m->content();
+ print $csvdata, "\n";
my $i = 0;
for my $line (split /\n/, $csvdata) {
View
8 lib/Finance/SantanderCC.pm
@@ -1,13 +1,11 @@
package Finance::SantanderCC;
-require Finance::GenericWebBot;
-@ISA = ("Finance::GenericWebBot");
+use base "Finance::GenericWebBot";
use strict;
our $start_url = "https://www.kreditkartenbanking.de/santander";
sub required_credentials {
- my ($class) = @_;
return ("cardnumber", "PIN");
}
@@ -28,8 +26,8 @@ sub login {
$m->form_name("preLogonForm");
__fix_links $m;
- $m->field("user", $self->{credentials}{id} );
- $m->field("password", $self->{credentials}{pin});
+ $m->field("user", $self->{credentials}{"cardnumber"} );
+ $m->field("password", $self->{credentials}{"PIN"});
$m->click_button( name => "bt_LOGON");
__fix_links $m;
Please sign in to comment.
Something went wrong with that request. Please try again.