OFTPServer Bean
Properties Methods Events Configuration Settings Errors
The OFTPServer component implements the server side of the Odette File Transfer Protocol.
Syntax
InEDI.Oftpserver
Remarks
The OFTPServer component implements an OFTP server. It is a lightweight server that supports version 1.2, 1.3, 1.4, and 2.0 of OFTP.
Sending and Receiving Files
To use the bean first decide if you will support TLS/SSL connections or not. If UseSSL is set to true, all clients will be expected to connect in TLS/SSL. If UseSSL is set to false (default), all clients are expected to connect in plaintext. If UseSSL is true, only clients that support Version 2.0 of the protocol can connect.
Once you have decided whether or not to support TLS/SSL, specify the port you wish the server to listen on in LocalPort. By default this value is 3305.
Next, specify values for ServerSSIDCode, ServerSFIDCode, ServerPassword.
Then set Listening to true to start listening for incoming requests.
When a client connects, you will have an opportunity to authenticate the client before continuing the connection.
This is done when the AcceptConnection event fires. Within this event you can validate that the connecting client
has access based on rules you determine. If you wish to reject the connection set the Accept parameter to false.
Within this event you can also specify the directory to which files sent by the client to the server are saved.
It is necessary to specify the directory within this event, as the client can start sending files as soon as the connection is complete. To specify
the download directory set the DownloadDirectory field. For instance:
oftpserver1.Connections.get(e.ConnectionId).setDownloadDirectory("C:\\Downloads");
When the connection is complete, the client may send files. If the client does send a file the AcceptFile event will fire and you will have the opportunity to reject the file by setting the Accept parameter of the event. In addition you will have a chance to change the filename by setting the Filename parameter if desired.
After the client has sent all the files it is configured to send, it will pass control to the server. At that time the ReadyToSend event will fire, and the ReadyToSend field will be set to true. After this, you can either end the session with the client by calling Logoff or send files to the client. To send files to the client simply call the SendFile method with the specified parameters.
TLS/SSL Notes
When UseSSL is set to true, the server must be configured with a TLS/SSL certificate before it is started. Set SSLCert to a valid certificate with corresponding private key before setting Listening to true. This may be a PFX file, PEM key, or a certificate in a windows certificate store. See the SSLCert property for more information.
After SSLCert is set to a valid certificate and Listening is set to true, when a client connects the SSLStatus event will fire during the TLS/SSL negotiation. This is purely informational, if there is an error the Error event will fire.
If you want to require TLS/SSL client authentication, set SSLAuthenticateClients to true before setting Listening to true. This will force clients to present a certificate during TLS/SSL negotiation to be used for authorization. In this case the SSLClientAuthentication event will fire and you must set the Accept parameter within the event to true in order to accept the client's certificate and proceed with the connection.
Example Code
Oftpserver server = new Oftpserver(); server.OnAcceptConnection += new Oftpserver.OnAcceptConnectionHandler(server_OnAcceptConnection); server.OnAcceptFile += new Oftpserver.OnAcceptFileHandler(server_OnAcceptFile); server.OnReadyToSend += new Oftpserver.OnReadyToSendHandler(server_OnReadyToSend); server.OnPITrail += new Oftpserver.OnPITrailHandler(server_OnPITrail); server.OnError += new Oftpserver.OnErrorHandler(server_OnError); server.ServerSSIDCode = "SERVERSSID"; server.ServerSFIDCode = "SERVERSFID"; server.ServerPassword = "SERVER"; server.Listening = true; ... //Within the main loop of the application call server.DoEvents() in a loop to process events. //When the ReadyToSend event fires the server can then send files to the client. To do this call the SendFile method from a worker thread. //Alternatively, monitor the server.Connections[<ConnectionId>].ReadyToSend field to determine when files can be sent. void server_OnAcceptConnection(object sender, OftpserverAcceptConnectionEventArgs e) { server.Connections[e.ConnectionId].DownloadDirectory = myIncomingDir; } void server_OnAcceptFile(object sender, OftpserverAcceptFileEventArgs e) { //e.Accept = false; //To reject a file set e.Accept to false } void server_OnPITrail(object sender, OftpserverPITrailEventArgs e) { string direction = ""; if(e.Direction == 0) direction = "CLIENT"; else direction = "SERVER"; Console.WriteLine(direction + ": " + e.CommandId + ": " + e.CommandDescription); } void server_OnError(object sender, OftpserverErrorEventArgs e) { Console.WriteLine("Error: " + e.ErrorCode + ": " + e.Description); }
Property List
The following is the full list of the properties of the bean with short descriptions. Click on the links for further details.
Certificate | The certificate used for session authentication, signing, and decryption. |
ConnectionBacklog | The maximum number of pending connections maintained by the TCP/IP subsystem. |
Connections | A collection of currently connected clients. |
DefaultTimeout | An initial timeout value to be used by incoming connections. |
Listening | If True, the component accepts incoming connections on LocalPort. |
LocalHost | The name of the local host or user-assigned IP interface through which connections are initiated or accepted. |
LocalPort | The TCP port in the local host where the component listens. |
ServerPassword | The server's password. |
ServerSFIDCode | Server's SFID code. |
ServerSSIDCode | The server's SSID code. |
SSLAuthenticateClients | If true, the server asks the client(s) for a certificate. |
SSLCert | The certificate to be used during SSL negotiation. |
TrustedCerts | A collection of trusted CA certificates. |
UseSSL | Use SSL to access the RemoteHost . |
Method List
The following is the full list of the methods of the bean with short descriptions. Click on the links for further details.
config | Sets or retrieves a configuration setting . |
disconnect | Disconnect the specified client. |
doEvents | Processes events from the internal message queue. |
exchangeCertificate | Exchange a certificate with the remote host. |
importTrustedCerts | Imports a list of trusted CA certificates. |
interrupt | Interrupts a synchronous send to the remote host. |
logoff | Ends a session with the connection client. |
reset | Resets the state of the control. |
sendEndResponse | Sends an EERP/NERP asynchronously. |
sendFile | Sends a file to the specified client. |
shutdown | Shuts down the server. |
Event List
The following is the full list of the events fired by the bean with short descriptions. Click on the links for further details.
AcceptConnection | Fired when a client connects. |
AcceptFile | Fired when the client sends a file. |
CertificateReceived | Fired when a certificate is received from the remote host. |
Connected | Fired immediately after a connection completes (or fails). |
ConnectionRequest | Fired when a request for connection comes from a remote host. |
Disconnected | Fired when a connection is closed. |
EndResponse | Fired every time an end response is received from the client. |
EndTransfer | Fired when a file finishes transferring. |
Error | Information about errors during data delivery. |
PITrail | Fired when any protocol level communication occurs. |
ReadyToSend | Fired when the component is ready to send data. |
SSLClientAuthentication | Fired when the client presents its credentials to the server. |
SSLStatus | Shows the progress of the secure connection. |
StartTransfer | Fired when a document starts transferring. |
Transfer | Fired while a document transfers (delivers document). |
Configuration Settings
The following is a list of configuration settings for the bean with short descriptions. Click on the links for further details.
AllowRetry[ConnectionId] | Whether to send a retry indicator when rejecting a file. |
ChangeDirection[ConnectionId] | Issues the Change Direction command when set. |
CDAfterSendEndResponse[ConnectionId] | Whether to issue a CD command after sending an asynchronous EERP. |
TempPath[ConnectionId] | The path of a directory where temporary files will be created. |
KeepAlive | This property enables the SO_KEEPALIVE option on the incoming connections. This option prevents long connections from timing out in case of inactivity. |
Linger | This property controls how a connection is closed. The default is True. In this case the connection is closed only after all the data is sent. Setting it to False forces an abrupt (hard) disconnection. Any data that was in the sending queue may be lost. |
ConnectionType[ConnectionId] | Specifies the type of connection that will be created. |
CreditCount[ConnectionId] | Specifies the maximum credit value. |
DefaultReceiptHashAlgorithm | The receipt hash algorithm to request when sending a file. |
ExchangeBufferSize[ConnectionId] | Specifies the data exchange buffer size in bytes. |
FileDescription[ConnectionId] | Additional description information sent with the file. |
ReceivedConnectionType[ConnectionId] | Returns the connection type specified by the client. |
ReceivedFileDescription[ConnectionId] | Additional description information received with the file. |
ReceivedFileName[ConnectionId] | Returns the name of the received file. |
ReceivedFileNameFormat[ConnectionId] | The name format of received files. |
Retry[ConnectionId] | Indicates whether the recipient allows the send to be retried. |
ServerPassword[ConnectionId] | Sets or gets the ServerPassword for a particular connection. |
ServerSFIDCode[ConnectionId] | Sets or gets the ServerSFIDCode for a particular connection. |
ServerSSIDCode[ConnectionId] | Sets the ServerSSIDCode for a particular connection. |
CertificateStoreType[ConnectionId] | The type of certificate store. |
CertificateStore[ConnectionId] | The name of the certificate store. |
CertificateStorePassword[ConnectionId] | The certificate password. |
CertificateSubject[ConnectionId] | The certificate subject. |
CertificateType[ConnectionId] | Specifies the type of certificate being supplied. |
FriendlyLogFormat | Determines if a more friendly format is applied to PITrail event out. |
FailOnUntrustedCert | Whether or not to throw an exception when untrusted certificates are used. |
FollowRedirects | Determines behavior when importing trusted certificates and a HTTP redirect is returned. |
TrustedCertsData | Specifies the source to be used when importing trusted certificates. |
VirtualFileDateFormat | The DateTime format of received files. |
ReceivedFileNameFormat | The name format of received files. |
CertificateType | Specifies the type of certificate being supplied. |
RecipientCertificateType | Specifies the type of recipient certificate being supplied. |
ExchangeCertStoreType | Specifies the store type when loading a certificate to be exchanged. |
ExchangeCertSubject | The subject of the certificate being exchanged. |
DisconnectAfterEndSession | Determines if the connection is closed immediately after ending the session. |
FireEndResponseOnSend | Determines if the EndResponse event is fired for outgoing EERP and NERPs. |
DeleteOnError | Whether received files are deleted when there is an error during processing. |
SendCDAfterEFPA | Specifies whether a CD is always sent after receiving an EFPA. |
AllowedClients | A comma-separated list of host names or IP addresses that can access the component. |
BindExclusively | Whether or not the component considers a local port reserved for exclusive use. |
DefaultConnectionTimeout | The inactivity timeout applied to the SSL handshake. |
InBufferSize | The size in bytes of the incoming queue of the socket. |
MaxConnections | The maximum number of connections available. |
OutBufferSize | The size in bytes of the outgoing queue of the socket. |
KeepAliveTime | The inactivity time in milliseconds before a TCP keep-alive packet is sent. |
KeepAliveInterval | The retry interval, in milliseconds, to be used when a TCP keep-alive packet is sent and no response is received. |
UseIPv6 | Whether to use IPv6. |
TcpNoDelay | Whether or not to delay when sending packets. |
CloseStreamAfterTransfer | If true, the component will close the upload or download stream after the transfer. |
LogSSLPackets | Controls whether SSL packets are logged when using the internal security API. |
ReuseSSLSession | Determines if the SSL session is reused. |
SSLCipherStrength | The minimum cipher strength used for bulk encryption. |
SSLEnabledProtocols | Used to enable/disable the supported security protocols. |
SSLIncludeCertChain | Whether the entire certificate chain is included in the SSLServerAuthentication event. |
SSLProvider | The name of the security provider to use. |
SSLSecurityFlags | Flags that control certificate verification. |
SSLCACerts | A newline separated list of CA certificate to use during SSL client authentication. |
SSLContextProtocol | The protocol used when getting an SSLContext instance. |
SSLTrustManagerFactoryAlgorithm | The algorithm to be used to create a TrustManager through TrustManagerFactory. |
SSLEnabledCipherSuites | The cipher suite to be used in an SSL negotiation. |
TLS12SignatureAlgorithms | Defines the allowed TLS 1.2 signature algorithms when UseInternalSecurityAPI is True. |
TLS12SupportedGroups | The supported groups for ECC. |
TLS13KeyShareGroups | The groups for which to pregenerate key shares. |
TLS13SupportedGroups | The supported groups for (EC)DHE key exchange. |
TLS13SignatureAlgorithms | The allowed certificate signature algorithms. |
GUIAvailable | Tells the component whether or not a message loop is available for processing events. |
UseDaemonThreads | Whether threads created by the component are daemon threads. |
UseInternalSecurityAPI | Tells the component whether or not to use the system security libraries or an internal implementation. |