Closed jpwsutton closed 6 years ago
Next Step here is to expose API methods that allow the developer to send AUTH packets, as well as a callback when they are recieved.
Adding to MqttAsyncClient:
/**
* An AUTH Packet is sent from Client to Server or Server to Client as part of
* an extended authentication exchange, such as challenge / response
* authentication. It is a protocol error for the Client or Server to send an
* AUTH packet if the CONNECT packet did not contain the same Authentication
* Method.
*
* @param reasonCode
* The Reason code, can be Success (0), Continue authentication (24)
* or Re-authenticate (25).
* @param userContext
* optional object used to pass context to the callback. Use null if
* not required.
* @param properties
* The {@link MqttProperties} to be sent, containing the
* Authentication Method, Authentication Data and any required User
* Defined Properties.
* @return token used to track and wait for the authentication to complete.
* @throws MqttException
*/
IMqttToken authenticate(int reasonCode, Object userContext, MqttProperties properties) throws MqttException;
And the callback in MqttCallback:
/**
* Called when an AUTH packet is received by the client.
*
* @param reasonCode
* The Reason code, can be Success (0), Continue authentication (24)
* or Re-authenticate (25).
* @param properties
* The {@link MqttProperties} to be sent, containing the
* Authentication Method, Authentication Data and any required User
* Defined Properties.
*/
public void authMessageArrived(int reasonCode, MqttProperties properties);
The Auth packet is a new packet in MQTTv5 and will require a mechanism for it to be sent by the client. Fortunately it does not have a payload and simply has Variable properties. Some investigation will need to be done to see how best to fit it into the flow.
Properties to implement: