Package org.eclipse.hono.adapter.mqtt
Class ConnectPacketAuthHandler
- java.lang.Object
-
- org.eclipse.hono.adapter.auth.device.ExecutionContextAuthHandler<MqttConnectContext>
-
- org.eclipse.hono.adapter.mqtt.ConnectPacketAuthHandler
-
- All Implemented Interfaces:
AuthHandler<MqttConnectContext>
public class ConnectPacketAuthHandler extends ExecutionContextAuthHandler<MqttConnectContext>
An auth handler for extracting a username and password from an MQTT CONNECT packet.
-
-
Field Summary
-
Fields inherited from class org.eclipse.hono.adapter.auth.device.ExecutionContextAuthHandler
log, PROPERTY_CLIENT_IDENTIFIER
-
-
Constructor Summary
Constructors Constructor Description ConnectPacketAuthHandler(DeviceCredentialsAuthProvider<UsernamePasswordCredentials> authProvider)Creates a new handler for a Hono client based auth provider.ConnectPacketAuthHandler(DeviceCredentialsAuthProvider<UsernamePasswordCredentials> authProvider, PreCredentialsValidationHandler<MqttConnectContext> preCredentialsValidationHandler)Creates a new handler for a Hono client based auth provider.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description io.vertx.core.Future<io.vertx.core.json.JsonObject>parseCredentials(MqttConnectContext context)Extracts credentials from a client's MQTT CONNECT packet.-
Methods inherited from class org.eclipse.hono.adapter.auth.device.ExecutionContextAuthHandler
authenticateDevice, getAuthProvider
-
-
-
-
Constructor Detail
-
ConnectPacketAuthHandler
public ConnectPacketAuthHandler(DeviceCredentialsAuthProvider<UsernamePasswordCredentials> authProvider)
Creates a new handler for a Hono client based auth provider.- Parameters:
authProvider- The provider to use for verifying a device's credentials.
-
ConnectPacketAuthHandler
public ConnectPacketAuthHandler(DeviceCredentialsAuthProvider<UsernamePasswordCredentials> authProvider, PreCredentialsValidationHandler<MqttConnectContext> preCredentialsValidationHandler)
Creates a new handler for a Hono client based auth provider.- Parameters:
authProvider- The provider to use for verifying a device's credentials.preCredentialsValidationHandler- An optional handler to invoke after the credentials got determined and before they get validated. Can be used to perform checks using the credentials and tenant information before the potentially expensive credentials validation is done. A failed future returned by the handler will fail the corresponding authentication attempt.
-
-
Method Detail
-
parseCredentials
public io.vertx.core.Future<io.vertx.core.json.JsonObject> parseCredentials(MqttConnectContext context)
Extracts credentials from a client's MQTT CONNECT packet.The JSON object returned will contain
- a username property containing the corresponding value from the MQTT CONNECT packet,
- a password property containing the corresponding value from the MQTT CONNECT packet and
- a
ExecutionContextAuthHandler.PROPERTY_CLIENT_IDENTIFIERproperty containing the MQTT client identifier
- Parameters:
context- The MQTT context for the client's CONNECT packet.- Returns:
- A future indicating the outcome of the operation.
The future will succeed with the client's credentials extracted from the CONNECT packet
or it will fail with a
ServiceInvocationExceptionindicating the cause of the failure. - Throws:
NullPointerException- if the context isnullIllegalArgumentException- if the context does not contain an MQTT endpoint.
-
-