EDI Integrator 2016 Java Edition
EDI Integrator 2016 Java Edition
Questions / Feedback?

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.

CertificateThe certificate used for session authentication, signing, and decryption.
ConnectionBacklogThe maximum number of pending connections maintained by the TCP/IP subsystem.
ConnectionsA collection of currently connected clients.
DefaultTimeoutAn initial timeout value to be used by incoming connections.
ListeningIf True, the component accepts incoming connections on LocalPort.
LocalHostThe name of the local host or user-assigned IP interface through which connections are initiated or accepted.
LocalPortThe TCP port in the local host where the component listens.
ServerPasswordThe server's password.
ServerSFIDCodeServer's SFID code.
ServerSSIDCodeThe server's SSID code.
SSLAuthenticateClientsIf true, the server asks the client(s) for a certificate.
SSLCertThe certificate to be used during SSL negotiation.
TrustedCertsA collection of trusted CA certificates.
UseSSLUse 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.

configSets or retrieves a configuration setting .
disconnectDisconnect the specified client.
doEventsProcesses events from the internal message queue.
exchangeCertificateExchange a certificate with the remote host.
importTrustedCertsImports a list of trusted CA certificates.
interruptInterrupts a synchronous send to the remote host.
logoffEnds a session with the connection client.
resetResets the state of the control.
sendEndResponseSends an EERP/NERP asynchronously.
sendFileSends a file to the specified client.
shutdownShuts 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.

AcceptConnectionFired when a client connects.
AcceptFileFired when the client sends a file.
CertificateReceivedFired when a certificate is received from the remote host.
ConnectedFired immediately after a connection completes (or fails).
ConnectionRequestFired when a request for connection comes from a remote host.
DisconnectedFired when a connection is closed.
EndResponseFired every time an end response is received from the client.
EndTransferFired when a file finishes transferring.
ErrorInformation about errors during data delivery.
PITrailFired when any protocol level communication occurs.
ReadyToSendFired when the component is ready to send data.
SSLClientAuthenticationFired when the client presents its credentials to the server.
SSLStatusShows the progress of the secure connection.
StartTransferFired when a document starts transferring.
TransferFired 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.
KeepAliveThis property enables the SO_KEEPALIVE option on the incoming connections. This option prevents long connections from timing out in case of inactivity.
LingerThis 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.
DefaultReceiptHashAlgorithmThe 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.
FriendlyLogFormatDetermines if a more friendly format is applied to PITrail event out.
FailOnUntrustedCertWhether or not to throw an exception when untrusted certificates are used.
FollowRedirectsDetermines behavior when importing trusted certificates and a HTTP redirect is returned.
TrustedCertsDataSpecifies the source to be used when importing trusted certificates.
VirtualFileDateFormatThe DateTime format of received files.
ReceivedFileNameFormatThe name format of received files.
CertificateTypeSpecifies the type of certificate being supplied.
RecipientCertificateTypeSpecifies the type of recipient certificate being supplied.
ExchangeCertStoreTypeSpecifies the store type when loading a certificate to be exchanged.
ExchangeCertSubjectThe subject of the certificate being exchanged.
DisconnectAfterEndSessionDetermines if the connection is closed immediately after ending the session.
FireEndResponseOnSendDetermines if the EndResponse event is fired for outgoing EERP and NERPs.
DeleteOnErrorWhether received files are deleted when there is an error during processing.
SendCDAfterEFPASpecifies whether a CD is always sent after receiving an EFPA.
AllowedClientsA comma-separated list of host names or IP addresses that can access the component.
BindExclusivelyWhether or not the component considers a local port reserved for exclusive use.
DefaultConnectionTimeoutThe inactivity timeout applied to the SSL handshake.
InBufferSizeThe size in bytes of the incoming queue of the socket.
MaxConnectionsThe maximum number of connections available.
OutBufferSizeThe size in bytes of the outgoing queue of the socket.
KeepAliveTimeThe inactivity time in milliseconds before a TCP keep-alive packet is sent.
KeepAliveIntervalThe retry interval, in milliseconds, to be used when a TCP keep-alive packet is sent and no response is received.
UseIPv6Whether to use IPv6.
TcpNoDelayWhether or not to delay when sending packets.
CloseStreamAfterTransferIf true, the component will close the upload or download stream after the transfer.
LogSSLPacketsControls whether SSL packets are logged when using the internal security API.
ReuseSSLSessionDetermines if the SSL session is reused.
SSLCipherStrengthThe minimum cipher strength used for bulk encryption.
SSLEnabledProtocolsUsed to enable/disable the supported security protocols.
SSLIncludeCertChainWhether the entire certificate chain is included in the SSLServerAuthentication event.
SSLProviderThe name of the security provider to use.
SSLSecurityFlagsFlags that control certificate verification.
SSLCACertsA newline separated list of CA certificate to use during SSL client authentication.
SSLContextProtocolThe protocol used when getting an SSLContext instance.
SSLTrustManagerFactoryAlgorithmThe algorithm to be used to create a TrustManager through TrustManagerFactory.
SSLEnabledCipherSuitesThe cipher suite to be used in an SSL negotiation.
TLS12SignatureAlgorithmsDefines the allowed TLS 1.2 signature algorithms when UseInternalSecurityAPI is True.
TLS12SupportedGroupsThe supported groups for ECC.
TLS13KeyShareGroupsThe groups for which to pregenerate key shares.
TLS13SupportedGroupsThe supported groups for (EC)DHE key exchange.
TLS13SignatureAlgorithmsThe allowed certificate signature algorithms.
GUIAvailableTells the component whether or not a message loop is available for processing events.
UseDaemonThreadsWhether threads created by the component are daemon threads.
UseInternalSecurityAPITells the component whether or not to use the system security libraries or an internal implementation.

 
 
Copyright (c) 2020 /n software inc. - All rights reserved.
EDI Integrator 2016 Java Edition - Version 16.0 [Build 7362]