Lines 20-35
package Koha::Edifact::Transport;
Link Here
|
20 |
use strict; |
20 |
use strict; |
21 |
use warnings; |
21 |
use warnings; |
22 |
use utf8; |
22 |
use utf8; |
23 |
use DateTime; |
23 |
|
|
|
24 |
use C4::Context; |
25 |
use Koha::Database; |
26 |
use Koha::DateUtils qw( dt_from_string ); |
27 |
use Koha::Crypt; |
28 |
|
24 |
use Carp qw( carp ); |
29 |
use Carp qw( carp ); |
|
|
30 |
use Crypt::Simple passfile => C4::Context->config('secret'); |
31 |
use DateTime; |
32 |
use Encode qw( from_to ); |
25 |
use English qw{ -no_match_vars }; |
33 |
use English qw{ -no_match_vars }; |
|
|
34 |
use File::Copy qw( copy move ); |
35 |
use File::Slurp qw( read_file ); |
26 |
use Net::FTP; |
36 |
use Net::FTP; |
27 |
use Net::SFTP::Foreign; |
37 |
use Net::SFTP::Foreign; |
28 |
use File::Slurp qw( read_file ); |
|
|
29 |
use File::Copy qw( copy move ); |
30 |
use Koha::Database; |
31 |
use Koha::DateUtils qw( dt_from_string ); |
32 |
use Encode qw( from_to ); |
33 |
|
38 |
|
34 |
sub new { |
39 |
sub new { |
35 |
my ( $class, $account_id ) = @_; |
40 |
my ( $class, $account_id ) = @_; |
Lines 136-142
sub sftp_download {
Link Here
|
136 |
my $sftp = Net::SFTP::Foreign->new( |
141 |
my $sftp = Net::SFTP::Foreign->new( |
137 |
host => $self->{account}->host, |
142 |
host => $self->{account}->host, |
138 |
user => $self->{account}->username, |
143 |
user => $self->{account}->username, |
139 |
password => $self->{account}->password, |
144 |
password => Koha::Crypt->decrypt_if_needed($self->{account}->password), |
140 |
timeout => 10, |
145 |
timeout => 10, |
141 |
); |
146 |
); |
142 |
if ( $sftp->error ) { |
147 |
if ( $sftp->error ) { |
Lines 221-227
sub ftp_download {
Link Here
|
221 |
) |
226 |
) |
222 |
or return $self->_abort_download( undef, |
227 |
or return $self->_abort_download( undef, |
223 |
"Cannot connect to $self->{account}->host: $EVAL_ERROR" ); |
228 |
"Cannot connect to $self->{account}->host: $EVAL_ERROR" ); |
224 |
$ftp->login( $self->{account}->username, $self->{account}->password ) |
229 |
$ftp->login( $self->{account}->username, Koha::Crypt->decrypt_if_needed($self->{account}->password)i ) |
225 |
or return $self->_abort_download( $ftp, "Cannot login: $ftp->message()" ); |
230 |
or return $self->_abort_download( $ftp, "Cannot login: $ftp->message()" ); |
226 |
$ftp->cwd( $self->{account}->download_directory ) |
231 |
$ftp->cwd( $self->{account}->download_directory ) |
227 |
or return $self->_abort_download( $ftp, |
232 |
or return $self->_abort_download( $ftp, |
Lines 262-268
sub ftp_upload {
Link Here
|
262 |
) |
267 |
) |
263 |
or return $self->_abort_download( undef, |
268 |
or return $self->_abort_download( undef, |
264 |
"Cannot connect to $self->{account}->host: $EVAL_ERROR" ); |
269 |
"Cannot connect to $self->{account}->host: $EVAL_ERROR" ); |
265 |
$ftp->login( $self->{account}->username, $self->{account}->password ) |
270 |
$ftp->login( $self->{account}->username, Koha::Crypt->decrypt_if_needed($self->{account}->password) ) |
266 |
or return $self->_abort_download( $ftp, "Cannot login: $ftp->message()" ); |
271 |
or return $self->_abort_download( $ftp, "Cannot login: $ftp->message()" ); |
267 |
$ftp->cwd( $self->{account}->upload_directory ) |
272 |
$ftp->cwd( $self->{account}->upload_directory ) |
268 |
or return $self->_abort_download( $ftp, |
273 |
or return $self->_abort_download( $ftp, |
Lines 293-299
sub sftp_upload {
Link Here
|
293 |
my $sftp = Net::SFTP::Foreign->new( |
298 |
my $sftp = Net::SFTP::Foreign->new( |
294 |
host => $self->{account}->host, |
299 |
host => $self->{account}->host, |
295 |
user => $self->{account}->username, |
300 |
user => $self->{account}->username, |
296 |
password => $self->{account}->password, |
301 |
password => Koha::Crypt->decrypt_if_needed($self->{account}->password), |
297 |
timeout => 10, |
302 |
timeout => 10, |
298 |
); |
303 |
); |
299 |
$sftp->die_on_error("Cannot ssh to $self->{account}->host"); |
304 |
$sftp->die_on_error("Cannot ssh to $self->{account}->host"); |