Interface PublishAuthorizerOutput
-
- All Superinterfaces:
AsyncOutput<PublishAuthorizerOutput>
,SimpleAsyncOutput<PublishAuthorizerOutput>
@DoNotImplement public interface PublishAuthorizerOutput extends AsyncOutput<PublishAuthorizerOutput>
This is the output parameter of anyPublishAuthorizer
providing methods to define the outcome of the PUBLISH authorization.It can be used to:
- Authorize the PUBLISH successfully
- Fail the authorization of the PUBLISH
- Disconnect the sender of the PUBLISH
- Delegate the decision to the next extension
Exactly one of the decisive methods must be called:
authorizeSuccessfully()
failAuthorization()
failAuthorization(AckReasonCode)
failAuthorization(AckReasonCode, String)
disconnectClient()
disconnectClient(DisconnectReasonCode)
disconnectClient(DisconnectReasonCode, String)
nextExtensionOrDefault()
UnsupportedOperationException
.- Since:
- 4.0.0, CE 2019.1
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
authorizeSuccessfully()
Successfully authorizes the PUBlISH.void
disconnectClient()
Disconnects the client that sent the PUBLISH.void
disconnectClient(@NotNull DisconnectReasonCode reasonCode)
Disconnects the client that sent the PUBLISH.void
disconnectClient(@NotNull DisconnectReasonCode reasonCode, @NotNull String reasonString)
Disconnects the client that sent the PUBLISH.void
failAuthorization()
Fails the authorization of the PUBLISH.void
failAuthorization(@NotNull AckReasonCode reasonCode)
Fails the authorization of the PUBLISH.void
failAuthorization(@NotNull AckReasonCode reasonCode, @NotNull String reasonString)
Fails the authorization of the PUBLISH.void
nextExtensionOrDefault()
The outcome of the authorization is determined by the next extension with aPublishAuthorizer
.-
Methods inherited from interface com.hivemq.extension.sdk.api.async.AsyncOutput
async
-
Methods inherited from interface com.hivemq.extension.sdk.api.async.SimpleAsyncOutput
async
-
-
-
-
Method Detail
-
authorizeSuccessfully
void authorizeSuccessfully()
Successfully authorizes the PUBlISH.This is a final decision, other extensions or default permissions are ignored.
- Throws:
UnsupportedOperationException
- When authorizeSuccessfully, failAuthorization, disconnectClient or nextExtensionOrDefault has already been called.- Since:
- 4.0.0, CE 2019.1
-
failAuthorization
void failAuthorization()
Fails the authorization of the PUBLISH. The outcome depends on the MQTT version specified by the publishing client.- For an MQTT 3 client the connection is closed.
- For an MQTT 5 client the PUBLISH is completed (if qos > 0) with a PUBACK/PUBREC containing the reason
code
NOT_AUTHORIZED
. After that the client receives a DISCONNECT packet with reason codeNOT_AUTHORIZED
, then the connection is closed.
This is a final decision, other extensions or default permissions are ignored.
- Throws:
UnsupportedOperationException
- When authorizeSuccessfully, failAuthorization, disconnectClient or nextExtensionOrDefault has already been called.- Since:
- 4.0.0, CE 2019.1
-
failAuthorization
void failAuthorization(@NotNull AckReasonCode reasonCode)
Fails the authorization of the PUBLISH. The outcome depends on the MQTT version specified by the publishing client.- For an MQTT 3 client the connection is closed.
- For an MQTT 5 client the PUBLISH is completed (if qos > 0) with a PUBACK/PUBREC containing the specified
reason code. After that the client receives a DISCONNECT packet with reason code
NOT_AUTHORIZED
, then the connection is closed.
This is a final decision, other extensions or default permissions are ignored.
- Parameters:
reasonCode
- Used as the reason code in the PUBACK/PUBREC.- Throws:
IllegalArgumentException
- If the specified reason code is not an error code.UnsupportedOperationException
- When authorizeSuccessfully, failAuthorization, disconnectClient or nextExtensionOrDefault has already been called.- Since:
- 4.0.0, CE 2019.1
-
failAuthorization
void failAuthorization(@NotNull AckReasonCode reasonCode, @NotNull String reasonString)
Fails the authorization of the PUBLISH. The outcome depends on the MQTT version specified by the publishing client.- For an MQTT 3 client the connection is closed.
- For an MQTT 5 client the PUBLISH is completed (if qos > 0) with a PUBACK/PUBREC containing the specified
reason code and reason string. After that the client receives a DISCONNECT packet with reason code
NOT_AUTHORIZED
, then the connection is closed.
This is a final decision, other extensions or default permissions are ignored.
- Parameters:
reasonCode
- Used as the reason code in the PUBACK/PUBREC.reasonString
- Used as the reason string in the PUBACK/PUBREC.- Throws:
IllegalArgumentException
- If the specified reason code is not an error code.UnsupportedOperationException
- When authorizeSuccessfully, failAuthorization, disconnectClient or nextExtensionOrDefault has already been called.- Since:
- 4.0.0, CE 2019.1
-
disconnectClient
void disconnectClient()
Disconnects the client that sent the PUBLISH. The outcome depends on the MQTT version specified by the publishing client.- For an MQTT 3 client the connection is closed.
- An MQTT 5 client receives a DISCONNECT packet with reason code
NOT_AUTHORIZED
, then the connection is closed.
This is a final decision, other extensions or default permissions are ignored.
- Throws:
UnsupportedOperationException
- When authorizeSuccessfully, failAuthorization, disconnectClient or nextExtensionOrDefault has already been called.- Since:
- 4.0.0, CE 2019.1
-
disconnectClient
void disconnectClient(@NotNull DisconnectReasonCode reasonCode)
Disconnects the client that sent the PUBLISH. The outcome depends on the MQTT version specified by the publishing client.- For an MQTT 3 client the connection is closed.
- An MQTT 5 client receives a DISCONNECT packet with the specified reason code, then the connection is closed.
This is a final decision, other extensions or default permissions are ignored.
- Parameters:
reasonCode
- Used as the reason code in the DISCONNECT packet.- Throws:
UnsupportedOperationException
- When authorizeSuccessfully, failAuthorization, disconnectClient or nextExtensionOrDefault has already been called.- Since:
- 4.0.0, CE 2019.1
-
disconnectClient
void disconnectClient(@NotNull DisconnectReasonCode reasonCode, @NotNull String reasonString)
Disconnects the client that sent the PUBLISH. The outcome depends on the MQTT version specified by the publishing client.- For an MQTT 3 client the connection is closed.
- An MQTT 5 client receives a DISCONNECT with the specified reason code and reason string, then the connection is closed.
This is a final decision, other extensions or default permissions are ignored.
- Parameters:
reasonCode
- Used as the reason code in the DISCONNECT packet.reasonString
- Used as the reason string in the DISCONNECT packet.- Throws:
UnsupportedOperationException
- When authorizeSuccessfully, failAuthorization, disconnectClient or nextExtensionOrDefault has already been called.- Since:
- 4.0.0, CE 2019.1
-
nextExtensionOrDefault
void nextExtensionOrDefault()
The outcome of the authorization is determined by the next extension with aPublishAuthorizer
.If no extension with a PublishAuthorizer is left the default permissions (see
ModifiableDefaultPermissions
) are used.- Throws:
UnsupportedOperationException
- When authorizeSuccessfully, failAuthorization, disconnectClient or nextExtensionOrDefault has already been called.- Since:
- 4.0.0, CE 2019.1
-
-