Download from http://www.infinitel.es/productos/infin ... to_en.html
As an example, the hotel has a SQL Server from the hotel management software that, logically, has a list of rooms and their respective guests. The service executes periodically a sql query over that database and takes the room number as the username for User Manager and the surname of the guest as the password. As soon as a guest checks in, the service updates the User Manager's user for that room number. The hotel's staff does not need to mantain the User Manager's users, neither has to generate vouchers for their guests.
The service can connect to any database that has a JDBC driver. Or use a CSV file as the user/password source with the open source CSVJDBC driver.
It connects to Mikrotik User Manager through the API service.
A configuration example looks like this:
Code: Select all
spring.datasource.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver #The JDBC Driver (MS SQL Server in this case)
spring.datasource.url=jdbc:sqlserver://server;databaseName=HOTEL #The DB connection URL
spring.datasource.username=sa #The DB username
spring.datasource.password=password #The DB password
data.query=select room as username, surname as password from guests #The executed query
update.rate=* 0/5 * * * ? #The update rate in CRON format (every 5 minutes here)
hotspot.address=192.168.0.1 # The Mikrotik device IP
hotspot.user=admin #The mikrotik API user
hotspot.password=password #The mikrotik API user's password
hotspot.port=8728 # The mikrotik API service port
hotspot.customer=admin # The User Manager's customer
hotspot.profile=default # The profile assigned to the newly created users
hotspot.remove=true # Option to delete unused users
hotspot.remove.skip= # List of excluded user's profiles to skip delete
When the update process runs it checks that each username returned from the query does not exist on User Manager. If it doesn't exists it creates the user on the User Manager. If it exists, it checks if the password returned from the query equals the password from the user on the User Manager, if it's the same, it leaves the user untouched, if it's different, it removes the old user and creates a new one with the same username and the new password. If the hotspot.remove is enabled it will remove all the users on the User Manager that does not appear on the database query excluding the users with an assigned profile included on the hotspot.remove.skip parameter.
After all, as the hotel's guest checks in, the welcome card that usually is given with the room key has a note that says that, to access the internet the username is the room number and the password is the guest's surname.
That's how we are using it now, but the query and the source database could be whatever you need and I think it can be used in many different scenarios.
The service is developed in Java, so it needs a Java Runtime installed version 1.7 or higher. It includes a Windows service wrapper to install it as a service on Windows. It can also run on any other OS with Java support (Linux, Mac, whatever...) as it's a self contained executable jar file that can be executed by calling java -jar HotSpotAuto.jar.
README file included:
Usage:
Uncompress to a folder. Place the JDBC driver jar file for your database on the lib subfolder.
Modify application.properties to match your settings.
To test the application it comes with the CSVJDBC driver included, a data sample file placed on the data subfolder and an update rate of 2 minutes configured. Just set up hotspot.* values yo match your Mikrotik settings.
You can find the output log on log\hotspotauto.log, where you can see the created/removed users or any error produced during execution.
To install Windows service:
HotSpotAuto.exe install
To start Windows service:
HotSpotAuto.exe start
To stop Windows service:
HotSpotAuto.exe stop
To uninstall Windows service:
HotSpotAuto.exe uninstall
To run it from command line without installing the Windows service:
java -jar HotSpotAuto-1.0.jar