Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.clipper.visual-objects > #8301 > unrolled thread

Secure FTP or SFTP support in VO

Started by"Dirk (Belgium)" <dirk.dot.herijgers@pbprojects.dot.be>
First post2015-07-24 06:23 +0000
Last post2015-08-04 07:12 +0000
Articles 10 — 5 participants

Back to article view | Back to comp.lang.clipper.visual-objects


Contents

  Secure FTP or SFTP support in VO "Dirk (Belgium)" <dirk.dot.herijgers@pbprojects.dot.be> - 2015-07-24 06:23 +0000
    Re: Secure FTP or SFTP support in VO "Wolfgang Riedmann" <wriedmann@gmail.com> - 2015-07-24 09:14 +0200
      Re: Secure FTP or SFTP support in VO "Dirk (Belgium)" <dirk.dot.herijgers@pbprojects.dot.be> - 2015-07-27 06:25 +0000
        Re: Secure FTP or SFTP support in VO "Philippe Bayard (Belgium)" <philbayard@gmail.com> - 2015-07-28 03:35 -0700
          Re: Secure FTP or SFTP support in VO "Marc Verkade [MITCon]" <marc@mitNOSPAMconDELETE.nl> - 2015-07-28 18:16 +0200
          Re: Secure FTP or SFTP support in VO "Dirk (Belgium)" <dirk.dot.herijgers@pbprojects.dot.be> - 2015-07-29 07:27 +0000
            Re: Secure FTP or SFTP support in VO "Philippe Bayard (Belgium)" <philbayard@gmail.com> - 2015-07-29 02:10 -0700
              Re: Secure FTP or SFTP support in VO "Arne Ortlinghaus" <Arne.Ortlinghaus@acs.it> - 2015-07-29 16:42 +0200
              Re: Secure FTP or SFTP support in VO "Marc Verkade [MITCon]" <marc@mitNOSPAMconDELETE.nl> - 2015-08-04 07:01 +0200
              Re: Secure FTP or SFTP support in VO "Dirk (Belgium)" <dirk.dot.herijgers@pbprojects.dot.be> - 2015-08-04 07:12 +0000

#8301 — Secure FTP or SFTP support in VO

From"Dirk (Belgium)" <dirk.dot.herijgers@pbprojects.dot.be>
Date2015-07-24 06:23 +0000
SubjectSecure FTP or SFTP support in VO
Message-ID<moslls$gr3$1@dont-email.me>
Hi All,

I suppose that this question is already asked many times, but I have to
ask it again:

Has someone a SFTP-class for VO?
Or how to implement the secure property of a FTP connection?

Already thanks for any suggestion.

Dirk, Belgium

=====================================

[toc] | [next] | [standalone]


#8302

From"Wolfgang Riedmann" <wriedmann@gmail.com>
Date2015-07-24 09:14 +0200
Message-ID<d1e6ufFpqi6U1@mid.individual.net>
In reply to#8301
Hi Dirk,

> I suppose that this question is already asked many times, but I have
> to ask it again:
> 
> Has someone a SFTP-class for VO?
> Or how to implement the secure property of a FTP connection?

AFAIK there is nothing. 

VO's Internet classes are using the WinInet functionality of the
Windows API, and there is nothing about SFTP.

You need to look for a 3rd party tool, or maybe better, to look if is
possible with Vulcan.NET, and create your own component to use from VO.

There is someone using such things for secure POP3/SMTP access and to
workaround about some glitches in VOs SMTP classes.

Wolfgang

-- 

[toc] | [prev] | [next] | [standalone]


#8303

From"Dirk (Belgium)" <dirk.dot.herijgers@pbprojects.dot.be>
Date2015-07-27 06:25 +0000
Message-ID<mp4isp$el4$1@dont-email.me>
In reply to#8302
Hi Wolfgang,

Tanks for your reply.
I think I gonna try to use FTPS (FTP over SSL connection).
I have a SSL class, so manupulating the standard FTP to use the SSL
socket cannot be so difficult.

Thanks for sharing your ideas.

Dirk

=================================

Wolfgang Riedmann wrote:

> Hi Dirk,
> 
> > I suppose that this question is already asked many times, but I have
> > to ask it again:
> > 
> > Has someone a SFTP-class for VO?
> > Or how to implement the secure property of a FTP connection?
> 
> AFAIK there is nothing. 
> 
> VO's Internet classes are using the WinInet functionality of the
> Windows API, and there is nothing about SFTP.
> 
> You need to look for a 3rd party tool, or maybe better, to look if is
> possible with Vulcan.NET, and create your own component to use from
> VO.
> 
> There is someone using such things for secure POP3/SMTP access and to
> workaround about some glitches in VOs SMTP classes.
> 
> Wolfgang



-- 

[toc] | [prev] | [next] | [standalone]


#8304

From"Philippe Bayard (Belgium)" <philbayard@gmail.com>
Date2015-07-28 03:35 -0700
Message-ID<3ddcfeca-eede-448a-bca7-323f00259335@googlegroups.com>
In reply to#8303
Dear Dirk,

I did it with WinSCP ( https://winscp.net/eng/docs/library ).
With an interface in .NET, then use it in VO through a wrapper.

Works really nice in sftp, ftps, ... ;)

Best regards,
Philippe

Le lundi 27 juillet 2015 08:27:03 UTC+2, Dirk (Belgium) a écrit :
> Hi Wolfgang,
> 
> Tanks for your reply.
> I think I gonna try to use FTPS (FTP over SSL connection).
> I have a SSL class, so manupulating the standard FTP to use the SSL
> socket cannot be so difficult.
> 
> Thanks for sharing your ideas.
> 
> Dirk
> 
> =================================
> 
> Wolfgang Riedmann wrote:
> 
> > Hi Dirk,
> > 
> > > I suppose that this question is already asked many times, but I have
> > > to ask it again:
> > > 
> > > Has someone a SFTP-class for VO?
> > > Or how to implement the secure property of a FTP connection?
> > 
> > AFAIK there is nothing. 
> > 
> > VO's Internet classes are using the WinInet functionality of the
> > Windows API, and there is nothing about SFTP.
> > 
> > You need to look for a 3rd party tool, or maybe better, to look if is
> > possible with Vulcan.NET, and create your own component to use from
> > VO.
> > 
> > There is someone using such things for secure POP3/SMTP access and to
> > workaround about some glitches in VOs SMTP classes.
> > 
> > Wolfgang
> 
> 
> 
> --

[toc] | [prev] | [next] | [standalone]


#8305

From"Marc Verkade [MITCon]" <marc@mitNOSPAMconDELETE.nl>
Date2015-07-28 18:16 +0200
Message-ID<3WNtx.839563$JA.313856@fx04.am1>
In reply to#8304
Hai Philippe,
Any change to see the code (.NET and VO)?
Regards, Marc

"Philippe Bayard (Belgium)"  schreef in bericht 
news:3ddcfeca-eede-448a-bca7-323f00259335@googlegroups.com...

Dear Dirk,

I did it with WinSCP ( https://winscp.net/eng/docs/library ).
With an interface in .NET, then use it in VO through a wrapper.

Works really nice in sftp, ftps, ... ;)

Best regards,
Philippe

Le lundi 27 juillet 2015 08:27:03 UTC+2, Dirk (Belgium) a écrit :
> Hi Wolfgang,
>
> Tanks for your reply.
> I think I gonna try to use FTPS (FTP over SSL connection).
> I have a SSL class, so manupulating the standard FTP to use the SSL
> socket cannot be so difficult.
>
> Thanks for sharing your ideas.
>
> Dirk
>
> =================================
>
> Wolfgang Riedmann wrote:
>
> > Hi Dirk,
> >
> > > I suppose that this question is already asked many times, but I have
> > > to ask it again:
> > >
> > > Has someone a SFTP-class for VO?
> > > Or how to implement the secure property of a FTP connection?
> >
> > AFAIK there is nothing.
> >
> > VO's Internet classes are using the WinInet functionality of the
> > Windows API, and there is nothing about SFTP.
> >
> > You need to look for a 3rd party tool, or maybe better, to look if is
> > possible with Vulcan.NET, and create your own component to use from
> > VO.
> >
> > There is someone using such things for secure POP3/SMTP access and to
> > workaround about some glitches in VOs SMTP classes.
> >
> > Wolfgang
>
>
>
> --

[toc] | [prev] | [next] | [standalone]


#8306

From"Dirk (Belgium)" <dirk.dot.herijgers@pbprojects.dot.be>
Date2015-07-29 07:27 +0000
Message-ID<mp9v9n$ca0$1@dont-email.me>
In reply to#8304
Hi Philippe,

I'm also interested in this sources.
Any possibility to have a copy?

Dirk

========================================

Philippe Bayard (Belgium) wrote:

> Dear Dirk,
> 
> I did it with WinSCP ( https://winscp.net/eng/docs/library ).
> With an interface in .NET, then use it in VO through a wrapper.
> 
> Works really nice in sftp, ftps, ... ;)
> 
> Best regards,
> Philippe
> 
> Le lundi 27 juillet 2015 08:27:03 UTC+2, Dirk (Belgium) a écrit :
> > Hi Wolfgang,
> > 
> > Tanks for your reply.
> > I think I gonna try to use FTPS (FTP over SSL connection).
> > I have a SSL class, so manupulating the standard FTP to use the SSL
> > socket cannot be so difficult.
> > 
> > Thanks for sharing your ideas.
> > 
> > Dirk
> > 
> > =================================
> > 
> > Wolfgang Riedmann wrote:
> > 
> > > Hi Dirk,
> > > 
> > > > I suppose that this question is already asked many times, but I
> > > > have to ask it again:
> > > > 
> > > > Has someone a SFTP-class for VO?
> > > > Or how to implement the secure property of a FTP connection?
> > > 
> > > AFAIK there is nothing. 
> > > 
> > > VO's Internet classes are using the WinInet functionality of the
> > > Windows API, and there is nothing about SFTP.
> > > 
> > > You need to look for a 3rd party tool, or maybe better, to look
> > > if is possible with Vulcan.NET, and create your own component to
> > > use from VO.
> > > 
> > > There is someone using such things for secure POP3/SMTP access
> > > and to workaround about some glitches in VOs SMTP classes.
> > > 
> > > Wolfgang
> > 
> > 
> > 
> > --



-- 

[toc] | [prev] | [next] | [standalone]


#8307

From"Philippe Bayard (Belgium)" <philbayard@gmail.com>
Date2015-07-29 02:10 -0700
Message-ID<11919010-a31e-4ca9-be6a-e895bab1877e@googlegroups.com>
In reply to#8306
Here a shared folder : https://owncloud.webless.be/index.php/s/BsWDgKRh3bJGxlb

You have the c# class and an VO App library (which include the Json Parser found on this newsgroup). You must get the WinSCP.exe et WinSCP.dll (which seems to call WinSCPNet.dll now) from the website. This class used an old version of WinSCP, i think that sessionOptions.SslHostCertificateFingerprint doesn't exists anymore also.

Check the readme ( in french, sorry for this ) for more detail. You got a ftps demo in WFTP Unitary test, but the sftp version must be a small difference.

Setting mode to stfp and adapt the key to "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx" should do the trick.

Check https://winscp.net/eng/docs/library#csharp for a c#sample ;)

You must just maybe remove the debug part i used ( if SysObject():cUsername == "DEBUG"  ) to avoid some errors ;)

There may be some mistake but i just use this class to upload zip files to our server sometimes but it's a basis anyway.

Best regards,
Philippe

Le mercredi 29 juillet 2015 09:29:26 UTC+2, Dirk (Belgium) a écrit :
> Hi Philippe,
> 
> I'm also interested in this sources.
> Any possibility to have a copy?
> 
> Dirk
> 
> ========================================
> 
> Philippe Bayard (Belgium) wrote:
> 
> > Dear Dirk,
> > 
> > I did it with WinSCP ( https://winscp.net/eng/docs/library ).
> > With an interface in .NET, then use it in VO through a wrapper.
> > 
> > Works really nice in sftp, ftps, ... ;)
> > 
> > Best regards,
> > Philippe
> > 
> > Le lundi 27 juillet 2015 08:27:03 UTC+2, Dirk (Belgium) a écrit :
> > > Hi Wolfgang,
> > > 
> > > Tanks for your reply.
> > > I think I gonna try to use FTPS (FTP over SSL connection).
> > > I have a SSL class, so manupulating the standard FTP to use the SSL
> > > socket cannot be so difficult.
> > > 
> > > Thanks for sharing your ideas.
> > > 
> > > Dirk
> > > 
> > > =================================
> > > 
> > > Wolfgang Riedmann wrote:
> > > 
> > > > Hi Dirk,
> > > > 
> > > > > I suppose that this question is already asked many times, but I
> > > > > have to ask it again:
> > > > > 
> > > > > Has someone a SFTP-class for VO?
> > > > > Or how to implement the secure property of a FTP connection?
> > > > 
> > > > AFAIK there is nothing. 
> > > > 
> > > > VO's Internet classes are using the WinInet functionality of the
> > > > Windows API, and there is nothing about SFTP.
> > > > 
> > > > You need to look for a 3rd party tool, or maybe better, to look
> > > > if is possible with Vulcan.NET, and create your own component to
> > > > use from VO.
> > > > 
> > > > There is someone using such things for secure POP3/SMTP access
> > > > and to workaround about some glitches in VOs SMTP classes.
> > > > 
> > > > Wolfgang
> > > 
> > > 
> > > 
> > > --
> 
> 
> 
> --

[toc] | [prev] | [next] | [standalone]


#8308

From"Arne Ortlinghaus" <Arne.Ortlinghaus@acs.it>
Date2015-07-29 16:42 +0200
Message-ID<mpaola$8nc$1@dont-email.me>
In reply to#8307
I use also WinSCP. currently in VO calling WINSCP with a batchjob created at 
runtime. Better would be a dotnet solution but this has to wait a little 
bit.

Arne Ortlinghaus
ACS Data Systems

---------------------- Example 
class -----------------------------------------------------------

class clsFTPWinSCP
protect _nerror as int
protect _cLastStatusMsg, _cerror, _ccommands as string
protect _oOwner as CFTPUniversal
protect _aresult as array
protect _cparams, _cmode, _cftp, _cuser, _cpassword, _cdir as string
protect _nport as int
protect _adeletetempfiles, _adirstackNew , _adirstack as array
protect _ldebug, _laddcommandsbefore as logic
protect _cPutmodeparam, _cPutmode, _cExecutionimmediatemode as string
declare method AddCommand, CheckExecute, setconnectionparameters, Execute, 
decoderesult, seterror, AddDirstack
declare method AddOpen, PostExecute, SetCurDir, SetCurDirInternal, 
__DeleteTempfiles, __Createtempfile
declare assign lSafeFTPFileTransfer

access Error class clsFTPWinSCP
return _nerror

method Axit         ()                                  class clsFTPWinSCP

self:Close()
return nil
method Close() class clsFTPWinSCP
self:__DeleteTempfiles()
UnRegisterAxit(self)
return nil

method CreateDir (cRemoteDir) class clsFTPWinSCP
// mkdir  Creates remote directory
self:AddCommand('mkdir "'+cRemoteDir+'"')
return self:CheckExecute("CreateDir")

method DeleteFile (cRemoteFile) class clsFTPWinSCP
//rm  Removes remote file
self:AddCommand('rm "'+cRemoteFile+'"')
return self:CheckExecute("DELETEFILE")

method AddCommand(ccommand as string) as void pascal class clsFTPWinSCP
if _laddcommandsbefore
   _ccommands := ccommand + crlf+_ccommands
else
   _ccommands += ccommand + crlf
endif
return

access ErrorMsg class clsFTPWinSCP
return _cerror
method Reset() class clsFTPWinSCP
_cerror := ""
_nerror := 0
_adirstack := {}
_adirstackNew := {}
_adeletetempfiles := {}
return nil
access aresult class clsFTPWinSCP
return _aresult

method Directory    (cFile) class clsFTPWinSCP
// ls  Lists the contents of remote directory
local aret as array
aret := {}
// Todo 91901 AO 2015-06-10 17:42 Vulcan, Ersatz ACSINET
// Fehler, wenn z.B. Directory ("Updcat.ini")
if !Instr("*", cFile)
   cFile := cFile+"*"
endif
self:AddCommand('ls '+cFile)
if self:CheckExecute("Directory")
   aret := self:aresult
endif
return aret
method GetFile (cRemoteFile, cNewFile) class clsFTPWinSCP
// Downloads one or more files from remote directory to local directory.
// get <file> [ [ <file2> ... ] <directory>\[ <newname> ] ]
self:AddCommand('get "'+cRemoteFile+'" "'+cNewFile+'"')
return self:CheckExecute("GetFile")

method GetCurDir () class clsFTPWinSCP
return "?"

method PutFileEx (cLocalFile, cRemoteFile) class clsFTPWinSCP
// put  Uploads file from local directory to remote directory
//put <file> [ [ <file2> ... ] <directory>/[ <newname> ] ]
// {"Rename if possible", "RENAME"},;
// {"No control", "NONE"},;
// {"Additional zero byte file same name, different extension", 
"ADDFILEEXT"},;
// {"Additional zero byte file same name, different directory", 
"ADDFILEDIR"};
local cTempFile as string
local i, nsubdirs as dword

if _cPutmode == "NONE"
   // Todo 90524 AO 2015-05-13 09:14 McD USA FTP->SFTP
   // resumesupport=off notwendig, wenn rename nicht erlaubt
   // -nopreservetime -nopermissions wenn setzen von Datetime und Setzen von 
Permissions nicht möglich
   // beides zusammengemacht, weil ausgegangen werden kann, dass es ein 
restriver FTP-Server ist
   self:AddCommand('put "'+cLocalFile+'" "'+cRemoteFile+'"'+ 
" -resumesupport=off -nopreservetime -nopermissions")
elseif _cPutmode == "RENAME"
   cTempFile := cRemoteFile+"*" // Löschen einer Datei, die möglicherweise 
da ist. * damit keine Fehlermeldung, falls nicht existiert
   self:AddCommand('rm "'+cTempFile+'"')
   cTempFile := "-"+FGetFileName(cRemoteFile) + ".TMP"
   self:AddCommand('put "'+cLocalFile+'" "'+cTempFile+'"')  // Schreiben mit 
anderem Namen
   self:AddCommand('mv "'+cTempFile+'" "'+cRemoteFile+'"')  // umbenennen
elseif _cPutmode == "ADDFILEEXT"
   cTempFile := Fgettempdir()+fchangeext(FGetFileNameAndext(cLocalFile), 
_cPutmodeparam)
   self:__Createtempfile(cTempFile)
   self:AddCommand('put "'+cLocalFile+'" "'+cRemoteFile+'"')
   self:AddCommand('put "'+cTempFile+'" "'+FChangeExt(cRemoteFile, 
_cPutmodeparam)+'"')
elseif _cPutmode == "ADDFILEDIR"
   self:AddCommand('put "'+cLocalFile+'" "'+cRemoteFile+'"')
   if !Empty(_cdir)
      nsubdirs := Occurs("/", _cdir)+1
      for i := 1 upto nsubdirs
         self:AddCommand('cd ..')
      next
   endif
   self:AddCommand('cd "'+_cPutmodeparam+'"')
   cTempFile := FGetTempDir()+FGetFileNameandExt(cLocalFile)
   self:__Createtempfile(cTempFile)
   self:AddCommand('put "'+cTempFile+'" 
"'+FGetFileNameandExt(cTempFile)+'"')
   nsubdirs := Occurs("/", _cPutmodeparam)+1
   for i := 1 upto nsubdirs
      self:AddCommand('cd ..')
   next
   if !Empty(_cdir)
      self:AddCommand('cd "'+_cdir+'"')
   endif
else
   self:seterror ("Missing parameter Putmode " + 
TypeValue2String(_cPutmode))
endif
return self:CheckExecute("PUTFILE")


method RemoveDir (cRemoteDir) class clsFTPWinSCP
// rmdir  Removes remote directory
self:AddCommand('rmdir "'+cRemoteDir+'"')
return self:CheckExecute("RemoveDir")


method RenameFile (cRemoteFile, cNewName) class clsFTPWinSCP
// Moves or renames one or more remote files.
// mv <file> [ <file2> ... ] [ <directory>/ ][ <newname> ]

self:AddCommand('mv "'+cRemoteFile+'" "'+cNewName+'"')
return self:CheckExecute("RENAMEFILE")


method SetCurDir (cRemoteDir as string) as logic pascal class clsFTPWinSCP
// cd  Changes remote working directory
local i as dword
local a as array
a := String2Array(cRemoteDir, "/")
for i := 1 upto ALen(a)
   if !Empty(a[i])
      AAdd (_adirstackNew, a[i])
   endif
next
return self:SetCurDirInternal(cRemoteDir)

method Init(oOwner) class clsFTPWinSCP
_oOwner := oOwner
self:Reset()
return self

method setconnectionparameters (cmode as string, cftp as string, cuser as 
string, cpassword as string, cdir as string, cparams as string, nport as 
int, lDebug as logic, cExecutionimmediatemode as string, cPutmode as string, 
cPutmodeparam as string) as void pascal class clsFTPWinSCP
self:Reset()
_cmode := cmode
_cftp := cftp
_cuser := cuser
_cpassword := cpassword
_cdir := cdir
_cparams := cparams
_nport := nport
_ldebug := lDebug
_cExecutionimmediatemode := cExecutionimmediatemode
_cPutmode := cPutmode
_cPutmodeparam := cPutmodeparam

if !Empty(_cdir)
   self:SetCurDir(_cdir)
endif
return
method CheckExecute(ccommand as string) as logic pascal class clsFTPWinSCP
local l, lok as logic
lok := true
ccommand := Upper (ccommand)
if _ldebug
   DebugOut ("FTPWinSCP:CheckExecute: " + ccommand)
endif
if _cExecutionimmediatemode == "ALL"
   l := InList (ccommand, "ALL", "GETFILE", "DIRECTORY", "PUTFILE", 
"DELETEFILE", "RENAMEFILE")
else
   l := InList (ccommand, "ALL", "GETFILE", "DIRECTORY")
endif
if l .and. !Empty(_ccommands)
   lok := self:Execute(ccommand)
endif
return lok

access LastStatusMsg class clsFTPWinSCP
return _cLastStatusMsg
method Execute(ccommand as string) as logic pascal class clsFTPWinSCP
local c, cargs, cfilelog, cfileparams, cexefile as string
local lok as logic
//local oSpawnProcess as object

lok := true
_aresult := {}
cexefile := FGetExeDir() +"WinSCP.exe"
if !FExist(cexefile)
   self:seterror("FTP Exefile not found: " +cexefile)
   return false
endif
sncounter_WinSCP += 1
cfileparams := fgettempdir() +"FTP" +getserverdatetime(5) 
+ntrim(sncounter_WinSCP) +".txt"


self:AddDirstack()
self:AddOpen()
self:AddCommand("exit")
if !fFileWrite(cfileparams, _ccommands)
   self:seterror("Temporary Parameter file could not be written")
   return false
endif

cfilelog := FChangeExt(cfileparams, ".log")
if FExist(cfilelog)
   if !FDeleteFile(cfilelog)
      self:seterror("Temporary Parameter file could not be written")
      return false
   endif
endif

cargs := '/console ' +'/script="' +cfileparams +'" /xmllog="' +cfilelog +'" 
/ini=nul'
if _ldebug
   MsgInfo ("FTP Debug before calling 
Winscp.exe"+crlf+cfileparams+crlf+_ccommands+crlf+cexefile+crlf+cargs)
endif
lok := fspawnprocess(cexefile, cargs, nil, fgettempdir(), "WAIT")


// oSpawnProcess := CreateInstance(#SpawnProcess,nil,cexefile+ " " + cargs, 
nil, FGetTempDir())
// lok := oSpawnProcess:spawnedOk


FDeleteFile(cfileparams)
if !lok
   self:seterror("FTP Exe could not be started" + crlf+cexefile+crlf+cargs)
   return false
endif
// lok := oSpawnProcess:waitUntilFinishedProgress(_oOwner, "FTP Access", 
cfilelog, {})
// oSpawnProcess:Destroy()
// if !lok
//    self:seterror("FTP Execution cancelled" + crlf+cexefile+crlf+cargs)
//    return false
// endif


if !FExist(cfilelog)
   self:seterror("Logfile from FTP Exe file not found" + 
crlf+cexefile+crlf+cargs+crlf+cfilelog)
   return false
endif
c := fFileRead(cfilelog)
c := ConvertUnicodeString(c,#CodepageToAnsi, 65001)

if _ldebug
   MsgInfo ("FTP Debug after calling Winscp.exe analyzing 
logfile"+crlf+c+crlf+cfilelog)
endif
FDeleteFile(cfilelog)
lok := self:decoderesult(ccommand, c)

self:PostExecute()

return lok

static global sncounter_WinSCP as int
method decoderesult (ccommand as string, c as string) as logic pascal class 
clsFTPWinSCP
local afile, a as array
local i as dword
local ct as string
local d as date
if At("<failure>", c) > 0
   a := StringExtract2Array(c, "<failure>", "</failure>", "")
   _cerror := a[1]
   _cerror := StrTran(_cerror, "<message>", "")
   _cerror := StrTran(_cerror, "</message>", "")

   a := StringExtract2Array(_cerror, "Host key fingerprint is ", ".", 
"EMPTYIFERRORS")
   if !Empty(a)
      if ALen(a) >= 1 .and. !Empty(a[1])
      _cerror += crlf+"This is an SFTP connection that should be fixed to an 
exact implementation of the SFTP server to not to be routed to a fake server 
one day."
      _cerror += " Therefore you have to add a 'fingerprint' in the 
connection parameters."
      _cerror += crlf+"Please add the following text under 'Additional 
connection parameters' and try again:"
      _cerror += crlf+crlf+'-hostkey="'+a[1]+'"'+crlf+crlf
      endif

   endif

   self:seterror(_cerror)
   return false
elseif ccommand == "DIRECTORY"
   a := StringExtract2Array(c, "<file>", "</file>", "")
   for i := 1 upto ALen(a)
      afile := StringExtract2Array(a[i], '="', '" />', "")
      if ALen(afile) >= 4
         if afile[2] =="-"
            ct := afile[4]
            d := MakeDate(SubStr(ct, 1, 4), SubStr(ct, 9, 2), SubStr(ct, 6, 
2))
            ct := SubStr(ct, 12, 8)
            AAdd(_aresult,{afile[1], Val(afile[3]), d, ct, ""})
         elseif afile[2] =="D"
            if !(afile[1] == "..")
               ct := afile[4]
               d := MakeDate(SubStr(ct, 1, 4), SubStr(ct, 9, 2), SubStr(ct, 
6, 2))
               ct := SubStr(ct, 12, 8)
               AAdd(_aresult,{afile[1], 0, d, ct, "D"})
            endif
         endif
      endif
   next
elseif InList (ccommand, "GETFILE", "PUTFILE")
   if !Instr('result success="true"', c)
      self:seterror ("Missing transfer result text "+  crlf+c)
   endif
else
   // NOP
endif

return true

method seterror (cerror as string) as void pascal class clsFTPWinSCP
_cerror := cerror
_nerror := 98765
return
method AddDirstack () as void pascal class clsFTPWinSCP
local i as dword
_laddcommandsbefore := true
for i := ALen(_adirstack) downto 1
   self:SetCurDirInternal(_adirstack[i])
next
_laddcommandsbefore := false
return
method AddOpen() as void pascal class clsFTPWinSCP
// Beispiel open ftp://Reseller:KgT66mW3@ftp.acs.it
local c as string
c := ""
c += "option batch abort" +crlf
c += "option confirm off" +crlf
c += "open "
if _cmode == "FTPWSCP"
   c += "ftp://"
elseif _cmode == "SFTPWSCP"
   c += "sftp://"
elseif _cmode == "FTPSWSCP"
   c += "ftps://"
else
   self:seterror ("Not allowed parameter (cmode) " + _cmode)
   return
endif
c += _cuser
c += ":"
c += _cpassword
c += "@"
c += _cftp
if !Empty(_nport)
   c += ":"+NTrim(_nport)
endif
c += "/"
if !Empty(_cparams)
   c += " "+_cparams
endif
c += crlf
_laddcommandsbefore := true
self:AddCommand(c)
_laddcommandsbefore := false
return
method PostExecute() as void pascal class clsFTPWinSCP
local i as dword
local cdir as string
_ccommands := ""
for i := 1 upto ALen(_adirstackNew)
   cdir := _adirstackNew[i]
   // Doppeltes zurück fehlt noch
   if cdir == ".." .and. alen(_adirstack) >= 1 .and. 
!(_adirstack[alen(_adirstack)]== "..")
      AAUS (_adirstack,ALen(_adirstack))
   else
      AAdd (_adirstack, cdir)
   endif
next
_adirstackNew := {}
self:__DeleteTempfiles()

return
method SetCurDirInternal (cRemoteDir as string) as logic pascal class 
clsFTPWinSCP
// Darf nicht aufgerufen werden von außen!
self:AddCommand('cd "'+cRemoteDir+'"')
return self:CheckExecute("SetCurDir")

method CloseRemote () class clsFTPWinSCP
local lok as logic
lok := true
if !Empty(_ccommands)
   lok := false
   self:seterror ("Not all commands executed")
endif
return lok
method CheckExecutedAll() class clsFTPWinSCP
return self:CheckExecute("ALL")
assign lSafeFTPFileTransfer   (l as logic) as void pascal class clsFTPWinSCP
if !l
   if _cPutmode == "RENAME"
      _cPutmode := "NONE"
   endif
endif
return

method __Createtempfile(cTempFile as string) as void pascal class 
clsFTPWinSCP
if !ffilewrite (ctempfile, getserverdatetime(5))
   self:seterror ("TempFile Creation")
endif
AAdd (_adeletetempfiles, cTempFile)
return
method __DeleteTempfiles() as void pascal class clsFTPWinSCP
local i as dword
for i := 1 upto ALen(_adeletetempfiles)
   FDeleteFile (_adeletetempfiles[i], true)
next

_adeletetempfiles := {}
return
method __GetVersion() class clsFTPWinSCP
return " Todo 91901 AO 2015-06-05 18:11 Vulcan, Ersatz ACSINET"


[toc] | [prev] | [next] | [standalone]


#8319

From"Marc Verkade [MITCon]" <marc@mitNOSPAMconDELETE.nl>
Date2015-08-04 07:01 +0200
Message-ID<QGXvx.451925$8B.92624@fe13.am1>
In reply to#8307
Major Thanx!
Grtz, Marc

"Philippe Bayard (Belgium)"  schreef in bericht 
news:11919010-a31e-4ca9-be6a-e895bab1877e@googlegroups.com...

Here a shared folder : 
https://owncloud.webless.be/index.php/s/BsWDgKRh3bJGxlb

You have the c# class and an VO App library (which include the Json Parser 
found on this newsgroup). You must get the WinSCP.exe et WinSCP.dll (which 
seems to call WinSCPNet.dll now) from the website. This class used an old 
version of WinSCP, i think that sessionOptions.SslHostCertificateFingerprint 
doesn't exists anymore also.

Check the readme ( in french, sorry for this ) for more detail. You got a 
ftps demo in WFTP Unitary test, but the sftp version must be a small 
difference.

Setting mode to stfp and adapt the key to "ssh-rsa 2048 
xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx" should do the trick.

Check https://winscp.net/eng/docs/library#csharp for a c#sample ;)

You must just maybe remove the debug part i used ( if SysObject():cUsername 
== "DEBUG"  ) to avoid some errors ;)

There may be some mistake but i just use this class to upload zip files to 
our server sometimes but it's a basis anyway.

Best regards,
Philippe

Le mercredi 29 juillet 2015 09:29:26 UTC+2, Dirk (Belgium) a écrit :
> Hi Philippe,
>
> I'm also interested in this sources.
> Any possibility to have a copy?
>
> Dirk
>
> ========================================
>
> Philippe Bayard (Belgium) wrote:
>
> > Dear Dirk,
> >
> > I did it with WinSCP ( https://winscp.net/eng/docs/library ).
> > With an interface in .NET, then use it in VO through a wrapper.
> >
> > Works really nice in sftp, ftps, ... ;)
> >
> > Best regards,
> > Philippe
> >
> > Le lundi 27 juillet 2015 08:27:03 UTC+2, Dirk (Belgium) a écrit :
> > > Hi Wolfgang,
> > >
> > > Tanks for your reply.
> > > I think I gonna try to use FTPS (FTP over SSL connection).
> > > I have a SSL class, so manupulating the standard FTP to use the SSL
> > > socket cannot be so difficult.
> > >
> > > Thanks for sharing your ideas.
> > >
> > > Dirk
> > >
> > > =================================
> > >
> > > Wolfgang Riedmann wrote:
> > >
> > > > Hi Dirk,
> > > >
> > > > > I suppose that this question is already asked many times, but I
> > > > > have to ask it again:
> > > > >
> > > > > Has someone a SFTP-class for VO?
> > > > > Or how to implement the secure property of a FTP connection?
> > > >
> > > > AFAIK there is nothing.
> > > >
> > > > VO's Internet classes are using the WinInet functionality of the
> > > > Windows API, and there is nothing about SFTP.
> > > >
> > > > You need to look for a 3rd party tool, or maybe better, to look
> > > > if is possible with Vulcan.NET, and create your own component to
> > > > use from VO.
> > > >
> > > > There is someone using such things for secure POP3/SMTP access
> > > > and to workaround about some glitches in VOs SMTP classes.
> > > >
> > > > Wolfgang
> > >
> > >
> > >
> > > --
>
>
>
> --

[toc] | [prev] | [next] | [standalone]


#8321

From"Dirk (Belgium)" <dirk.dot.herijgers@pbprojects.dot.be>
Date2015-08-04 07:12 +0000
Message-ID<mppok2$7af$1@dont-email.me>
In reply to#8307
Philippe,

Also thanks for this sources.
I gonna try this the next 2 weeks.

Dirk, Belgium

=================================================

Philippe Bayard (Belgium) wrote:

> Here a shared folder :
> https://owncloud.webless.be/index.php/s/BsWDgKRh3bJGxlb
> 
> You have the c# class and an VO App library (which include the Json
> Parser found on this newsgroup). You must get the WinSCP.exe et
> WinSCP.dll (which seems to call WinSCPNet.dll now) from the website.
> This class used an old version of WinSCP, i think that
> sessionOptions.SslHostCertificateFingerprint doesn't exists anymore
> also.
> 
> Check the readme ( in french, sorry for this ) for more detail. You
> got a ftps demo in WFTP Unitary test, but the sftp version must be a
> small difference.
> 
> Setting mode to stfp and adapt the key to "ssh-rsa 2048
> xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx" should do the trick.
> 
> Check https://winscp.net/eng/docs/library#csharp for a c#sample ;)
> 
> You must just maybe remove the debug part i used ( if
> SysObject():cUsername == "DEBUG"  ) to avoid some errors ;)
> 
> There may be some mistake but i just use this class to upload zip
> files to our server sometimes but it's a basis anyway.
> 
> Best regards,
> Philippe
> 
> Le mercredi 29 juillet 2015 09:29:26 UTC+2, Dirk (Belgium) a écrit :
> > Hi Philippe,
> > 
> > I'm also interested in this sources.
> > Any possibility to have a copy?
> > 
> > Dirk
> > 
> > ========================================
> > 
> > Philippe Bayard (Belgium) wrote:
> > 
> > > Dear Dirk,
> > > 
> > > I did it with WinSCP ( https://winscp.net/eng/docs/library ).
> > > With an interface in .NET, then use it in VO through a wrapper.
> > > 
> > > Works really nice in sftp, ftps, ... ;)
> > > 
> > > Best regards,
> > > Philippe
> > > 
> > > Le lundi 27 juillet 2015 08:27:03 UTC+2, Dirk (Belgium) a écrit :
> > > > Hi Wolfgang,
> > > > 
> > > > Tanks for your reply.
> > > > I think I gonna try to use FTPS (FTP over SSL connection).
> > > > I have a SSL class, so manupulating the standard FTP to use the
> > > > SSL socket cannot be so difficult.
> > > > 
> > > > Thanks for sharing your ideas.
> > > > 
> > > > Dirk
> > > > 
> > > > =================================
> > > > 
> > > > Wolfgang Riedmann wrote:
> > > > 
> > > > > Hi Dirk,
> > > > > 
> > > > > > I suppose that this question is already asked many times,
> > > > > > but I have to ask it again:
> > > > > > 
> > > > > > Has someone a SFTP-class for VO?
> > > > > > Or how to implement the secure property of a FTP connection?
> > > > > 
> > > > > AFAIK there is nothing. 
> > > > > 
> > > > > VO's Internet classes are using the WinInet functionality of
> > > > > the Windows API, and there is nothing about SFTP.
> > > > > 
> > > > > You need to look for a 3rd party tool, or maybe better, to
> > > > > look if is possible with Vulcan.NET, and create your own
> > > > > component to use from VO.
> > > > > 
> > > > > There is someone using such things for secure POP3/SMTP access
> > > > > and to workaround about some glitches in VOs SMTP classes.
> > > > > 
> > > > > Wolfgang
> > > > 
> > > > 
> > > > 
> > > > --
> > 
> > 
> > 
> > --



-- 

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.clipper.visual-objects


csiph-web