0

Does the Paho Java client has any callback function called when a new client connection is established? Within that function I want to validate user and if failed refuse connection.

When a new client connect from javascript or any client I should be able to allow or refuse new client.

hardillb
  • 54,545
  • 11
  • 67
  • 105
Manish Kumar
  • 10,214
  • 25
  • 77
  • 147
  • Are you trying to implement a MQTT broker using the Paho Java client or do you want to validate users of the broker from a connected client? – hardillb Jan 02 '17 at 16:41
  • want to validate users of the broker from a connected client. I want to intercept all connection request and validated them with username & password. If username & pwd match then i want to allow them to conect if not then just refuse connecting to my broker – Manish Kumar Jan 02 '17 at 17:39

1 Answers1

0

This is not possible to do from a client, the MQTT protocol has no support for anything other than passing authentication information from a single client to the broker, not the other way round.

You have to do it from within the broker. Different brokers all implement authentication differently so it will depend entirely on which broker you are using.

Mosquitto has an API to write authentication plugins. e.g. https://github.com/jpmens/mosquitto-auth-plug

HiveMQ Also has an API http://www.hivemq.com/blog/mqtt-security-fundamentals-advanced-authentication-mechanisms

Mosca - https://github.com/mcollina/mosca/wiki/Authentication-&-Authorization

hardillb
  • 54,545
  • 11
  • 67
  • 105