Security configuration
FEJ uses Spring Security for authentication purposes. Security configuration is stored in fej-security.xml
file.
In-Memory Authentication
By default, for testing purposes, FEJ container uses simple in-memory authentication with NoOpPasswordEncoder encoder and plain-text credentials.
For other password encoder options please check Spring Security 5.0 DelegatingPasswordEncoder. If you need more complex authentication solution please refer to Spring Security documentation.
<bean id="passwordEncoder" class="org.springframework.security.crypto.password.NoOpPasswordEncoder" factory-method="getInstance"/> <sec:authentication-manager id="authenticationManager"> <sec:authentication-provider> <sec:password-encoder ref="passwordEncoder"/> <sec:user-service id="userDetailsService" properties="users.properties"/> </sec:authentication-provider> </sec:authentication-manager>
Users are stored in the external properties file named users.properties
. It contains single user test
with password test
and role ROLE_ADMIN
:
$ pwd /usr/share/fixedgej-1.0.0/conf $ cat users.properties test=test,ROLE_ADMIN,enabled
LDAP authentication
FEJ also supports authentication against an LDAP server.
Before getting deep into LDAP authentication, let’s get familiar with some LDAP terms.
Term | Description |
---|---|
Dn | Distinguished name, a unique name which is used to find user in LDAP server e.g. Microsoft Active Directory. |
Ou | Organization Unit. |
Bind | LDAP Bind is an operation in which LDAP clients sends bindRequest to LDAP user including username and password and if |
Search | LDAP search is the operation which is performed to retrieve Dn of user by using some user credentials. |
Root | LDAP directory’s top element, like root of a tree. |
BaseDn | a branch in LDAP tree which can be used as base for LDAP search operation. |
When the LDAP authentication option is activated, the default single user mode is turned off.
FIX Session configuration
FIX Antenna java is used for establishing and managing FIX sessions. But FEJ introduce per-file base configuration for each FIX session. All such configuration files are placed into subdirectories of session
directory and should follow s_fix_[SESSION_ID].properties
mask (this behaviour can be changed with 'sessionConfigManager' bean into fej-server.xml
). Additional each subfolder may have SESSION_GROUP_s_fixDefault.properties
configuration file which define common option for all group of FIX sessions.
Main options for FIX session(advanced options for FIX session you can find on FIX Antenna Java configuration page):
Property name | Default value | Description |
---|---|---|
sessionType | acceptor | Session type. If type is not defined then session will be resolved as acceptor. Valid values: acceptor/initiator. |
host | The connecting host for initiator session | |
port | The connecting port for initiator session | |
senderCompID | Assigned value used to identify firm sending message | |
senderSubID | Assigned value used to identify specific message originator (desk, trader, etc.) | |
senderLocationID | Assigned value used to identify specific message originator’s location (i.e. geographic location and/or desk, trader) | |
targetCompID | Assigned value used to identify receiving firm | |
targetSubID | Assigned value used to identify specific individual or unit intended to receive message | |
targetLocationID | Assigned value used to identify specific message destination’s location (i.e. geographic location and/or desk, trader) | |
fixVersion | Version of the FIX protocol | |
appVersion | ||
backupHost | Backup host for initiator session | |
backupPort | Backup port for initiator session | |
incomingSequenceNumber | 0 | Incoming sequence number |
outgoingSequenceNumber | 0 | Outgoing sequence number |
processedIncomingSequenceNumber | 0 | Last valid incoming sequence number |
heartbeatInterval | 30 | Heartbeat interval (in seconds) |
lastSeqNumResetTimestamp | ||
fixFieldList | User-defined fields for messages. If this list is not empty, Engine adds it to each outgoing message. | |
outgoingLoginFixFieldList | Additional fields for outgoing Logon message | |
groups | A comma-separated list of routing groups | |
username | The assigned value used to identify a username to send in Logon message for initiator session and username to validate with user name from Logon request for acceptor session. The session will be accepted if the username is not defined. | |
password | The assigned value used to identify a password to send in Logon message for initiator session and password to validate with password from logon request for acceptor session. The session will be accepted if the password is not defined | |
disposeOnDisconnect | false | Disposes FIX session when another side breaks the connection or in case of disconnect. More details about session statuses can be found in the FIX Antenna java documentation. note: If the property is set to 'true' then reconnect logic will be suppressed. |
Custom FIX dictionaries setup
Custom FIX dictionaries setup in FIXEdge Java product based on FIX Antenna custom FIX dictionaries setup (FIX Antenna Java custom dictionaries), but it is FIXEdge Java configuration specific (FIXEdge Java FIX session configuration).
First place 'customFIXVersions' section first into default 'fixengine.properties' file (in conf dir) to set up custom FIX version info for all FIX sessions.
# comma separated list of custom FIX dictionary aliases customFixVersions=FIX44Custom,FIX50Custom # pair of 'fixVersion' and 'fileName' for each FIX dictionary alias with pattern: # customFixVersion.<custom FIX version alias>.fixVersion=<base standard FIX version> # customFixVersion.<custom FIX version alias>.fileName=<custom FIX dictionary file name> # example of custom FIX dictionary based on FIX.4.4 customFixVersion.FIX44Custom.fixVersion=FIX.4.4 customFixVersion.FIX44Custom.fileName=classpath:fixdic44-custom.xml # examples of custom FIX dictionary based on FIX.5.0 customFixVersion.FIX50Custom.fixVersion=FIX.5.0 customFixVersion.FIX50Custom.fileName=classpath:fixdic50-custom.xml
The next step is to set defined dictionary aliases as a session's fixVersion or appVersion in the appropriate FIXEdge Java session configuration file 's_fix_[SESSION_ID].properties':
# FIXEdge Java session configuration properties fixVersion=FIX44Custom
# FIXEdge Java session configuration properties fixVersion=FIX50Custom
Scheduling
Background and business purpose
Exchanges have business hours and there cannot be possible to keep a session up all the time. We should use scheduling in the case when we need to start or stop our session by timetable.
Overview
FEJ supports two modes of managing session - immediately while starting and postponed using cron expression. Managing of the timetable can be defined in schedules.xml that is located in the configuration folder.
Deployment and Maintenance
Configuration
The configuration has the following skillet
<?xml version="1.0" encoding="UTF-8"?> <schedules xmlns="http://epam.com/fej/schedules"> <schedule id="..."> <task name="..." onLoad="..." timeZone=""> <event cron="..."/> <properties> <property key="..." value="..."/> </properties> </task> <task name="..." > .. </task> </schedule> </schedules>
- schedule
- id - id of schedule. This parameter will be used as the name of a session if properties are not defined. Required. Id of a session is taken from files with its parameters by the regexp - " s_fix_(.*)\.properties". It can be changed in fej-server.xml. parameter sessionNamePattern of sessionConfigManager.
- task - there can be many tasks - two (start and stop) for one session where properties block is not defined or many tasks for many sessions but in this case properties block should be defined to specify on which session the task will be applied.
- name - name[type] of task
Valid values:
start
stop - onLoad - whether a session should start during FEJ initialization. If true, the event block will be ignored.
- timeZone - time zone for cron expression. Valid values are below. Required for cron expression.
- name - name[type] of task
- event - used only when onLoad is not defined or false.
- cron - cron expression
- property
- key - valid value:
'sessionName' - used for determining session name. If the properties section is not defined then the id of schedule will be used as a session name.
- key - valid value:
Examples
Timetable for a session that should start right after initialization of FEJ
The file with a session's parameters has the following name: s_fix_session1.properties
<?xml version="1.0" encoding="UTF-8"?> <schedules xmlns="http://epam.com/fej/schedules"> <schedule id="session1"> <task name="start" onLoad="true"/> </schedule> </schedules>
Timetable for a session that should start at 9 am and stop at 6 pm
The file with a session's parameters has the following name: s_fix_Exchange.properties
<?xml version="1.0" encoding="UTF-8"?> <schedules xmlns="http://epam.com/fej/schedules"> <schedule id="Exchange"> <task name="start" timeZone="Europe/Samara"> <event cron="0 0 09 ? * *"/> </task> <task name="stop" timeZone="Europe/Samara"> <event cron="0 0 18 ? * *"/> </task> </schedule> </schedules>
Triggering routing rules by the scheduler
Scheduler configuration
<?xml version="1.0" encoding="UTF-8"?> <schedule id="every10Seconds"> <task name="event" timeZone="Europe/Samara"> <event cron="*/10 * * ? * *"/> </task> </schedule>
Rule configuration
eventRule("Catching scheduler events", SchedulerEvent.class, { appEvent -> return true//does nothing but there can be additional logic }, { schedulerEvent -> logger.info("I'm rule for schedule events, id - {}.", schedulerEvent.getId()) } )
Routing Rules Configuration
FIX Edge Java provides an RoutingRule
unit as an abstraction for internal message routing element. FEJ supports pure Java and Groovy implementations for routing rules. Please find additional information in the article FIXEdge Java - Groovy rules
Logging configuration
FEJ uses Log4j 2 as a logging framework. Its configuration is stored in log4j2.xml
file. For more information about configuration please refer Log4j 2 official documentation.
Administrative shell configuration
Shell configuration properties are stored in shell.properties
file.
Name | Default value | Description |
---|---|---|
crash.auth | spring | Authentication mechanism |
crash.ssh.port | 2000 | SSH server port |
crash.ssh.auth_timeout | 300000 | Authentication timeout of the SSH server (in milliseconds) |
crash.ssh.idle_timeout | 300000 | Idle timeout of the SSH server (in milliseconds) |
crash.ssh.default_encoding | UTF-8 | Character encoding |
FEJ uses Java shell called ‘CRaSH’. For more information about it configuration properties please refer to the CRaSH reference documentation.
Wrapper configuration
FEJ uses YAJSW to run the application as a Windows Service or UNIX Daemon. It configuration is stored in wrapper.conf
file. Please refer to the YAJSW reference documentation for more information about available configuration properties.