Class ConnectPacketAuthHandler

    • 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_IDENTIFIER property 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 ServiceInvocationException indicating the cause of the failure.
        Throws:
        NullPointerException - if the context is null
        IllegalArgumentException - if the context does not contain an MQTT endpoint.