Finance-Bank-IE-PermanentTSB

 view release on metacpan or  search on metacpan

lib/ptsb_util.pm  view on Meta::CPAN

sub usage {
  use Pod::Usage;
  pod2usage(-verbose =>1);
}

# parse config file to retrieve acc_no, password and pan
sub parse_configfile {

    my $cfgfile = shift;

    my $gpg = `which gpg`;
    chop $gpg;

    if($gpg =~ /not found/ or not -x $gpg) {
        print "You need to install and use GnuPG to secure your config file\n";
        print "Please see the documentation on \n".
        "http://search.cpan.org/~pallotron/Finance-Bank-IE-PermanentTSB/ptsb\n";
        exit -1;
    } 

    # encryption dance
    # use the 'file' command to check the cfgfile
    my $res = `file $cfgfile`;
    if($res !~ /GPG encrypted data/is) {
        # not encrypted: encrypt it!
        print("Config file not encrypted. I'm gonna encrypt it!\n");
        print("Executing gpg.. \n");
        print("You'll have to type the name of the key you want to use\n");
        system('gpg -e '.$cfgfile);
        # checking exit status
        if($? != 0 ) {
            # problem with gpg?
            print "Exiting...\n";
            exit -1;
        }
        # If file has been create overwrite the original one
        if(-e $cfgfile.'.gpg') {
            move($cfgfile.'.gpg', $cfgfile);
        }
        # now the config file is crypted!
    }

    # decrypt file in memory
    my @res = `gpg -d $cfgfile`;
    
    # go thru the lines...
    my($user, $pass, $pan);
    foreach my $line (@res) {
        $line =~ s/\n//g;
        $_ = $line;
        if(not /^\s{0,}#/ or not /^\s{0,}/) {
            my ($key, $val) = split '=';
            $val =~ s/^\s+//;
            $val =~ s/\s+$//;

ptsb  view on Meta::CPAN

option -F F</path/to/your/location>.

Lines beginning with # will be interpreted as comment.

Starting from release 0.08 ptsb will use GnuPG to encrypt the
configuration file using the private key of the user.
Therefore you'll have to create your key if you didn't do this yet.

In case you want to decrypt your ptsbrc file use this command:

    $ gpg -d /path/to/your/ptsbrc

This will print the encrypted file on the standard output.

=head1 SEE ALSO

=over

=item * B<Official CPAN page for Finance::Bank::IE::PermanentTSB>

L<http://search.cpan.org/~pallotron/Finance-Bank-IE-PermanentTSB/lib/Finance/Bank/IE/PermanentTSB.pm>



( run in 0.973 second using v1.01-cache-2.11-cpan-e1769b4cff6 )