If you are using the original Mosquitto broker, you may be aware (or not) that there is a plugin called "mosquitto-auth-plug" which is an authentication plugin for the Mosquitto broker with multiple back-ends (MySQL, Redis, CDB, SQLite3). You need to compile it and set it up to work with Mosquitto but it is well worth the effort if you want more flexibility to handle users and topics in real time.
When using this plugin and adding users to the backend database, we need to create a hashed password using the SecretKeyFactory algorithm called PBKDF2WithHmacSHA256. To help me with this in my B4J-client, I compiled a small library based on code found in the Contrib-folder in the original github-project.
You can find this library attached and it has 2 methods:
I also attach a library for B4A but it will only work with SDK 26+ since PBKDF2WithHmacSHA256 was added to Android only with said SDK.
To support this fully on Android and with B4i, you can add the B4J-library to a B4J RDC-server on your VPS and pass on the parameters from your clients by an API-call. If doing so, you should protect the exchange of data with SSL.
When using this plugin and adding users to the backend database, we need to create a hashed password using the SecretKeyFactory algorithm called PBKDF2WithHmacSHA256. To help me with this in my B4J-client, I compiled a small library based on code found in the Contrib-folder in the original github-project.
You can find this library attached and it has 2 methods:
B4X:
-CreateHashPassword(plainPassword as String) as String
-IsValidPassword(plainPassword as String, hashPassword as String) as Boolean
I also attach a library for B4A but it will only work with SDK 26+ since PBKDF2WithHmacSHA256 was added to Android only with said SDK.
To support this fully on Android and with B4i, you can add the B4J-library to a B4J RDC-server on your VPS and pass on the parameters from your clients by an API-call. If doing so, you should protect the exchange of data with SSL.