[jira] [Commented] (ARTEMIS-3913) MQTTReasonCodes byte loss of precision,must int type

2022-09-15 Thread ASF subversion and git services (Jira)


[ 
https://issues.apache.org/jira/browse/ARTEMIS-3913?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17605549#comment-17605549
 ] 

ASF subversion and git services commented on ARTEMIS-3913:
--

Commit eb52e29b954f020e78b5662ad2bbfb3faf8925fb in activemq-artemis's branch 
refs/heads/2.x from Justin Bertram
[ https://gitbox.apache.org/repos/asf?p=activemq-artemis.git;h=eb52e29b95 ]

ARTEMIS-3913 custom MQTT client ID rejection

Sometimes users want to perform custom client ID validation, and in the
case of an invalid client ID the proper reason code should be returned
in the CONNACK packet.

(cherry picked from commit 6b5a73db8abcdc0fa5de8de63544e58a330c982b)


> MQTTReasonCodes byte loss of precision,must int type
> 
>
> Key: ARTEMIS-3913
> URL: https://issues.apache.org/jira/browse/ARTEMIS-3913
> Project: ActiveMQ Artemis
>  Issue Type: Bug
>Reporter: gongping.zhu
>Assignee: Justin Bertram
>Priority: Major
> Fix For: 3.0.0
>
> Attachments: image-2022-08-02-08-23-52-965.png, 
> image-2022-08-02-08-24-39-288.png, image-2022-08-02-08-31-01-074.png, 
> image-2022-08-02-08-42-24-117.png, image-2022-08-02-08-43-39-442.png, 
> image-2022-08-02-08-45-11-459.png, image-2022-08-02-08-54-34-267.png, 
> image-2022-08-05-08-32-12-492.png
>
>  Time Spent: 20m
>  Remaining Estimate: 0h
>




--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (ARTEMIS-3913) MQTTReasonCodes byte loss of precision,must int type

2022-09-14 Thread ASF subversion and git services (Jira)


[ 
https://issues.apache.org/jira/browse/ARTEMIS-3913?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17604854#comment-17604854
 ] 

ASF subversion and git services commented on ARTEMIS-3913:
--

Commit 6b5a73db8abcdc0fa5de8de63544e58a330c982b in activemq-artemis's branch 
refs/heads/main from Justin Bertram
[ https://gitbox.apache.org/repos/asf?p=activemq-artemis.git;h=6b5a73db8a ]

ARTEMIS-3913 custom MQTT client ID rejection

Sometimes users want to perform custom client ID validation, and in the
case of an invalid client ID the proper reason code should be returned
in the CONNACK packet.


> MQTTReasonCodes byte loss of precision,must int type
> 
>
> Key: ARTEMIS-3913
> URL: https://issues.apache.org/jira/browse/ARTEMIS-3913
> Project: ActiveMQ Artemis
>  Issue Type: Bug
>Reporter: gongping.zhu
>Priority: Major
> Attachments: image-2022-08-02-08-23-52-965.png, 
> image-2022-08-02-08-24-39-288.png, image-2022-08-02-08-31-01-074.png, 
> image-2022-08-02-08-42-24-117.png, image-2022-08-02-08-43-39-442.png, 
> image-2022-08-02-08-45-11-459.png, image-2022-08-02-08-54-34-267.png, 
> image-2022-08-05-08-32-12-492.png
>
>  Time Spent: 10m
>  Remaining Estimate: 0h
>




--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (ARTEMIS-3913) MQTTReasonCodes byte loss of precision,must int type

2022-08-10 Thread gongping.zhu (Jira)


[ 
https://issues.apache.org/jira/browse/ARTEMIS-3913?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17578221#comment-17578221
 ] 

gongping.zhu commented on ARTEMIS-3913:
---

i want receive 133(0x85) when i use a not empty illegal client_id to connect 
server;

> MQTTReasonCodes byte loss of precision,must int type
> 
>
> Key: ARTEMIS-3913
> URL: https://issues.apache.org/jira/browse/ARTEMIS-3913
> Project: ActiveMQ Artemis
>  Issue Type: Bug
>Reporter: gongping.zhu
>Priority: Major
> Attachments: image-2022-08-02-08-23-52-965.png, 
> image-2022-08-02-08-24-39-288.png, image-2022-08-02-08-31-01-074.png, 
> image-2022-08-02-08-42-24-117.png, image-2022-08-02-08-43-39-442.png, 
> image-2022-08-02-08-45-11-459.png, image-2022-08-02-08-54-34-267.png, 
> image-2022-08-05-08-32-12-492.png
>
>




--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (ARTEMIS-3913) MQTTReasonCodes byte loss of precision,must int type

2022-08-10 Thread Justin Bertram (Jira)


[ 
https://issues.apache.org/jira/browse/ARTEMIS-3913?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17578126#comment-17578126
 ] 

Justin Bertram commented on ARTEMIS-3913:
-

I just modified the aforementioned tests to use 
{{org.eclipse.paho.mqttv5.client.MqttAsyncClient}} and they received the 
{{134}} ({{0x86}}) reason code. However, I had to use 
{{org.eclipse.paho.mqttv5.client.IMqttToken#waitForCompletion()}} when 
connecting otherwise the client wouldn't throw an exception even though the 
connection failed.

Regarding the other issues, you'll be best served to open additional Jiras or 
better yet send a question to the [ActiveMQ user's mailing 
list|https://activemq.apache.org/contact]. Each Jira should focus on a single 
issue otherwise it's easy to get things mixed up.

> MQTTReasonCodes byte loss of precision,must int type
> 
>
> Key: ARTEMIS-3913
> URL: https://issues.apache.org/jira/browse/ARTEMIS-3913
> Project: ActiveMQ Artemis
>  Issue Type: Bug
>Reporter: gongping.zhu
>Priority: Major
> Attachments: image-2022-08-02-08-23-52-965.png, 
> image-2022-08-02-08-24-39-288.png, image-2022-08-02-08-31-01-074.png, 
> image-2022-08-02-08-42-24-117.png, image-2022-08-02-08-43-39-442.png, 
> image-2022-08-02-08-45-11-459.png, image-2022-08-02-08-54-34-267.png, 
> image-2022-08-05-08-32-12-492.png
>
>




--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (ARTEMIS-3913) MQTTReasonCodes byte loss of precision,must int type

2022-08-05 Thread gongping.zhu (Jira)


[ 
https://issues.apache.org/jira/browse/ARTEMIS-3913?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17575676#comment-17575676
 ] 

gongping.zhu commented on ARTEMIS-3913:
---

i use the MqttAsyncClient to connect the sever and it can not receive the code

> MQTTReasonCodes byte loss of precision,must int type
> 
>
> Key: ARTEMIS-3913
> URL: https://issues.apache.org/jira/browse/ARTEMIS-3913
> Project: ActiveMQ Artemis
>  Issue Type: Bug
>Reporter: gongping.zhu
>Priority: Major
> Attachments: image-2022-08-02-08-23-52-965.png, 
> image-2022-08-02-08-24-39-288.png, image-2022-08-02-08-31-01-074.png, 
> image-2022-08-02-08-42-24-117.png, image-2022-08-02-08-43-39-442.png, 
> image-2022-08-02-08-45-11-459.png, image-2022-08-02-08-54-34-267.png, 
> image-2022-08-05-08-32-12-492.png
>
>




--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (ARTEMIS-3913) MQTTReasonCodes byte loss of precision,must int type

2022-08-04 Thread Justin Bertram (Jira)


[ 
https://issues.apache.org/jira/browse/ARTEMIS-3913?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17575535#comment-17575535
 ] 

Justin Bertram commented on ARTEMIS-3913:
-

The more you can avoid screen-shots the better. A well-formatted text comment 
is much easier to read and the content is also searchable for folks who may hit 
a similar issue in the future. Obviously screen-shots are preferable in some 
cases, but code and stack-traces are much better as straight text.

> MQTTReasonCodes byte loss of precision,must int type
> 
>
> Key: ARTEMIS-3913
> URL: https://issues.apache.org/jira/browse/ARTEMIS-3913
> Project: ActiveMQ Artemis
>  Issue Type: Bug
>Reporter: gongping.zhu
>Priority: Major
> Attachments: image-2022-08-02-08-23-52-965.png, 
> image-2022-08-02-08-24-39-288.png, image-2022-08-02-08-31-01-074.png, 
> image-2022-08-02-08-42-24-117.png, image-2022-08-02-08-43-39-442.png, 
> image-2022-08-02-08-45-11-459.png, image-2022-08-02-08-54-34-267.png, 
> image-2022-08-05-08-32-12-492.png
>
>




--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (ARTEMIS-3913) MQTTReasonCodes byte loss of precision,must int type

2022-08-04 Thread Justin Bertram (Jira)


[ 
https://issues.apache.org/jira/browse/ARTEMIS-3913?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17575533#comment-17575533
 ] 

Justin Bertram commented on ARTEMIS-3913:
-

I'd need a way to reproduce what you're seeing. At the very least I need a 
[protocol trace 
log|https://activemq.apache.org/components/artemis/documentation/latest/mqtt.html#debug-logging]
 which captures the problem.

There are tests in the test-suite which verify an MQTT 5 client gets a 
{{CONNACK}} packet with a reason code of {{134}} ({{0x86}}) when authentication 
fails, and those tests are succeeding. See:
* 
[{{org.apache.activemq.artemis.tests.integration.mqtt5.spec.controlpackets.ConnectTestsWithSecurity#testAuthenticationFailureWithBadCredentials}}|https://github.com/apache/activemq-artemis/blob/main/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt5/spec/controlpackets/ConnectTestsWithSecurity.java#L51]
* 
[{{org.apache.activemq.artemis.tests.integration.mqtt5.spec.controlpackets.ConnectTestsWithSecurity#testAuthenticationFailureWithNoCredentials}}|https://github.com/apache/activemq-artemis/blob/382267bf6364dec890f27ca1927394499c83a85b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt5/spec/controlpackets/ConnectTestsWithSecurity.java#L64]

For what it's worth, those tests are using the Paho 1.2.5 client as well.

> MQTTReasonCodes byte loss of precision,must int type
> 
>
> Key: ARTEMIS-3913
> URL: https://issues.apache.org/jira/browse/ARTEMIS-3913
> Project: ActiveMQ Artemis
>  Issue Type: Bug
>Reporter: gongping.zhu
>Priority: Major
> Attachments: image-2022-08-02-08-23-52-965.png, 
> image-2022-08-02-08-24-39-288.png, image-2022-08-02-08-31-01-074.png, 
> image-2022-08-02-08-42-24-117.png, image-2022-08-02-08-43-39-442.png, 
> image-2022-08-02-08-45-11-459.png, image-2022-08-02-08-54-34-267.png, 
> image-2022-08-05-08-32-12-492.png
>
>




--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (ARTEMIS-3913) MQTTReasonCodes byte loss of precision,must int type

2022-08-04 Thread gongping.zhu (Jira)


[ 
https://issues.apache.org/jira/browse/ARTEMIS-3913?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17575497#comment-17575497
 ] 

gongping.zhu commented on ARTEMIS-3913:
---

my android device has allready used MQTT 5, and client still received 
(REASON_CODE_NOT_AUTHORIZED = 0x05) to zhe client  after clientId validate fail;

 

!image-2022-08-05-08-32-12-492.png!

> MQTTReasonCodes byte loss of precision,must int type
> 
>
> Key: ARTEMIS-3913
> URL: https://issues.apache.org/jira/browse/ARTEMIS-3913
> Project: ActiveMQ Artemis
>  Issue Type: Bug
>Reporter: gongping.zhu
>Priority: Major
> Attachments: image-2022-08-02-08-23-52-965.png, 
> image-2022-08-02-08-24-39-288.png, image-2022-08-02-08-31-01-074.png, 
> image-2022-08-02-08-42-24-117.png, image-2022-08-02-08-43-39-442.png, 
> image-2022-08-02-08-45-11-459.png, image-2022-08-02-08-54-34-267.png, 
> image-2022-08-05-08-32-12-492.png
>
>




--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (ARTEMIS-3913) MQTTReasonCodes byte loss of precision,must int type

2022-08-04 Thread Justin Bertram (Jira)


[ 
https://issues.apache.org/jira/browse/ARTEMIS-3913?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17575289#comment-17575289
 ] 

Justin Bertram commented on ARTEMIS-3913:
-

As noted previously, the broker will send a {{CONNACK}} with a reason code of 
{{134}} _if and only if_ the client is using MQTT *5*. This is true of every 
broker since support for MQTT 5 was implemented in 2.21.0. This, of course, 
includes 2.23.1.

> MQTTReasonCodes byte loss of precision,must int type
> 
>
> Key: ARTEMIS-3913
> URL: https://issues.apache.org/jira/browse/ARTEMIS-3913
> Project: ActiveMQ Artemis
>  Issue Type: Bug
>Reporter: gongping.zhu
>Priority: Major
> Attachments: image-2022-08-02-08-23-52-965.png, 
> image-2022-08-02-08-24-39-288.png, image-2022-08-02-08-31-01-074.png, 
> image-2022-08-02-08-42-24-117.png, image-2022-08-02-08-43-39-442.png, 
> image-2022-08-02-08-45-11-459.png, image-2022-08-02-08-54-34-267.png
>
>




--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (ARTEMIS-3913) MQTTReasonCodes byte loss of precision,must int type

2022-08-03 Thread gongping.zhu (Jira)


[ 
https://issues.apache.org/jira/browse/ARTEMIS-3913?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17575021#comment-17575021
 ] 

gongping.zhu commented on ARTEMIS-3913:
---

thx a lot

do mind tell me which version can send 134 reason code to clien after clientId 
validate fail; and the apache-artemis-2.23.1 version just send 

(REASON_CODE_NOT_AUTHORIZED = 0x05) to zhe client

> MQTTReasonCodes byte loss of precision,must int type
> 
>
> Key: ARTEMIS-3913
> URL: https://issues.apache.org/jira/browse/ARTEMIS-3913
> Project: ActiveMQ Artemis
>  Issue Type: Bug
>Reporter: gongping.zhu
>Priority: Major
> Attachments: image-2022-08-02-08-23-52-965.png, 
> image-2022-08-02-08-24-39-288.png, image-2022-08-02-08-31-01-074.png, 
> image-2022-08-02-08-42-24-117.png, image-2022-08-02-08-43-39-442.png, 
> image-2022-08-02-08-45-11-459.png, image-2022-08-02-08-54-34-267.png
>
>




--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (ARTEMIS-3913) MQTTReasonCodes byte loss of precision,must int type

2022-08-03 Thread Justin Bertram (Jira)


[ 
https://issues.apache.org/jira/browse/ARTEMIS-3913?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17575009#comment-17575009
 ] 

Justin Bertram commented on ARTEMIS-3913:
-

You're right. 
{{org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager5#authenticate}}
 can't throw an {{{}ActiveMQSecurityException{}}}. It should simply return 
{{null}} and that in turn will trigger an {{ActiveMQSecurityException}}. This 
will send a {{CONNACK}} with a reason code of {{134}} if it's an MQTT 5 client 
or {{5}} otherwise.

> MQTTReasonCodes byte loss of precision,must int type
> 
>
> Key: ARTEMIS-3913
> URL: https://issues.apache.org/jira/browse/ARTEMIS-3913
> Project: ActiveMQ Artemis
>  Issue Type: Bug
>Reporter: gongping.zhu
>Priority: Major
> Attachments: image-2022-08-02-08-23-52-965.png, 
> image-2022-08-02-08-24-39-288.png, image-2022-08-02-08-31-01-074.png, 
> image-2022-08-02-08-42-24-117.png, image-2022-08-02-08-43-39-442.png, 
> image-2022-08-02-08-45-11-459.png, image-2022-08-02-08-54-34-267.png
>
>




--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (ARTEMIS-3913) MQTTReasonCodes byte loss of precision,must int type

2022-08-03 Thread gongping.zhu (Jira)


[ 
https://issues.apache.org/jira/browse/ARTEMIS-3913?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17574971#comment-17574971
 ] 

gongping.zhu commented on ARTEMIS-3913:
---

ActiveMQSecurityManager5 authenticate method can not throw 
ActiveMQSecurityException

> MQTTReasonCodes byte loss of precision,must int type
> 
>
> Key: ARTEMIS-3913
> URL: https://issues.apache.org/jira/browse/ARTEMIS-3913
> Project: ActiveMQ Artemis
>  Issue Type: Bug
>Reporter: gongping.zhu
>Priority: Major
> Attachments: image-2022-08-02-08-23-52-965.png, 
> image-2022-08-02-08-24-39-288.png, image-2022-08-02-08-31-01-074.png, 
> image-2022-08-02-08-42-24-117.png, image-2022-08-02-08-43-39-442.png, 
> image-2022-08-02-08-45-11-459.png, image-2022-08-02-08-54-34-267.png
>
>




--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (ARTEMIS-3913) MQTTReasonCodes byte loss of precision,must int type

2022-08-02 Thread Justin Bertram (Jira)


[ 
https://issues.apache.org/jira/browse/ARTEMIS-3913?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17574269#comment-17574269
 ] 

Justin Bertram commented on ARTEMIS-3913:
-

The problem with the {{catch}} block you've added in {{MQTTProtocolHandler}} is 
that a plugin could throw an {{MQTTRuntimeException}} when handling _any_ kind 
of packet, not just a {{CONNECT}} packet. However, sending a {{CONNACK}} packet 
is _only_ valid when handling a {{CONNECT}} packet.

I would recommend that instead of using a broker plugin you implement your own 
security manager. This is discussed in [the 
documentation|https://activemq.apache.org/components/artemis/documentation/latest/security.html#custom-security-manager],
 and there is an example in {{examples/features/standard/security-manager}} 
that demonstrates how to do this. The {{authenticate}} method of the security 
manager receives a 
{{org.apache.activemq.artemis.spi.core.protocol.RemotingConnection}} which will 
have the client ID set. You can validate the client ID and throw an 
{{org.apache.activemq.artemis.api.core.ActiveMQSecurityException}} if the 
validation fails. This will send a {{CONNACK}} with a reason code of {{134}} if 
it's an MQTT 5 client or {{5}} otherwise. See 
{{org.apache.activemq.artemis.core.protocol.mqtt.MQTTProtocolHandler#validateUser}}
 for reference.

> MQTTReasonCodes byte loss of precision,must int type
> 
>
> Key: ARTEMIS-3913
> URL: https://issues.apache.org/jira/browse/ARTEMIS-3913
> Project: ActiveMQ Artemis
>  Issue Type: Bug
>Reporter: gongping.zhu
>Priority: Major
> Attachments: image-2022-08-02-08-23-52-965.png, 
> image-2022-08-02-08-24-39-288.png, image-2022-08-02-08-31-01-074.png, 
> image-2022-08-02-08-42-24-117.png, image-2022-08-02-08-43-39-442.png, 
> image-2022-08-02-08-45-11-459.png, image-2022-08-02-08-54-34-267.png
>
>




--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (ARTEMIS-3913) MQTTReasonCodes byte loss of precision,must int type

2022-08-02 Thread gongping.zhu (Jira)


[ 
https://issues.apache.org/jira/browse/ARTEMIS-3913?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17574112#comment-17574112
 ] 

gongping.zhu commented on ARTEMIS-3913:
---

yes,I want use plugin to auth client ID value,and if validation fails the 
server disconnect client and response with a specific reason code

> MQTTReasonCodes byte loss of precision,must int type
> 
>
> Key: ARTEMIS-3913
> URL: https://issues.apache.org/jira/browse/ARTEMIS-3913
> Project: ActiveMQ Artemis
>  Issue Type: Bug
>Reporter: gongping.zhu
>Priority: Major
> Attachments: image-2022-08-02-08-23-52-965.png, 
> image-2022-08-02-08-24-39-288.png, image-2022-08-02-08-31-01-074.png, 
> image-2022-08-02-08-42-24-117.png, image-2022-08-02-08-43-39-442.png, 
> image-2022-08-02-08-45-11-459.png, image-2022-08-02-08-54-34-267.png
>
>




--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (ARTEMIS-3913) MQTTReasonCodes byte loss of precision,must int type

2022-08-01 Thread Justin Bertram (Jira)


[ 
https://issues.apache.org/jira/browse/ARTEMIS-3913?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17574027#comment-17574027
 ] 

Justin Bertram commented on ARTEMIS-3913:
-

I'm still not clear on what you're trying to do. Are you trying to modify the 
broker so that you can perform some kind of special validation of MQTT client 
ID values from a broker plugin and if that validation fails the client is 
disconnected with a specific reason code?

For what it's worth, screenshots of code isn't as helpful as actual code. Even 
better is a Maven project or something in a Git repository that can be executed 
to reproduce exactly what you're seeing.

> MQTTReasonCodes byte loss of precision,must int type
> 
>
> Key: ARTEMIS-3913
> URL: https://issues.apache.org/jira/browse/ARTEMIS-3913
> Project: ActiveMQ Artemis
>  Issue Type: Bug
>Reporter: gongping.zhu
>Priority: Major
> Attachments: image-2022-08-02-08-23-52-965.png, 
> image-2022-08-02-08-24-39-288.png, image-2022-08-02-08-31-01-074.png, 
> image-2022-08-02-08-42-24-117.png, image-2022-08-02-08-43-39-442.png, 
> image-2022-08-02-08-45-11-459.png, image-2022-08-02-08-54-34-267.png
>
>




--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (ARTEMIS-3913) MQTTReasonCodes byte loss of precision,must int type

2022-08-01 Thread gongping.zhu (Jira)


[ 
https://issues.apache.org/jira/browse/ARTEMIS-3913?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17573974#comment-17573974
 ] 

gongping.zhu commented on ARTEMIS-3913:
---

my ArtemisBorkderPlugin code 

 

```

package com.yeker.iot.broker.plugin.impl;

import cn.hutool.core.util.ObjectUtil;
import com.yeker.iot.broker.plugin.impl.model.Account;
import com.yeker.iot.broker.plugin.impl.model.DeviceAuth;
import com.yeker.sdk.comm.util.IPUntil;
import org.apache.activemq.artemis.api.core.*;
import org.apache.activemq.artemis.core.persistence.OperationContext;
import org.apache.activemq.artemis.core.postoffice.RoutingStatus;
import org.apache.activemq.artemis.core.protocol.mqtt.MQTTReasonCodes;
import 
org.apache.activemq.artemis.core.protocol.mqtt.exceptions.MQTTRuntimesException;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.ServerSession;
import org.apache.activemq.artemis.core.server.plugin.ActiveMQServerPlugin;
import org.apache.activemq.artemis.core.transaction.Transaction;
import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
import org.apache.activemq.artemis.spi.core.protocol.SessionCallback;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapperResultSetExtractor;

import java.io.Serializable;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class ArtemisBrokerPlugin implements ActiveMQServerPlugin, Serializable {

private Logger log = LoggerFactory.getLogger(ArtemisBrokerPlugin.class);
/**
* 遗言topic前缀
*/
private static final String MISSING_TOPIC_PREFIX = "msg.req.lwt";
/**
* 服务端clientId前缀
*/
private static final String SERVICE_CLIENT_ID_PREFIX = "service-";
/**
* client id 分隔符
*/
private static final String CLIENT_SPLITOR = "@";

/**
* 账号数据库信息
*/
private String accountDriver;
private String accountUrl;
private String accountUsername;
private String accountPassword;
private JdbcTemplate accountJdbcTemplate;

/**
* 授权认证
*/
private boolean accountAuthEnabled = false;
private String accountAuthQuerySQL;

/**
* 设备数据库信息
*/
private String deviceDriver;
private String deviceUrl;
private String deviceUsername;
private String devicePassword;
private JdbcTemplate deviceJdbcTemplate;
/**
* 设备授权
*/
private boolean deviceAuthEnabled = false;
private String deviceAuthCheckSQL;
private String deviceAuthLockerSQL;


private boolean deviceStatusSyncabled = false;
private String connectUpdateSQL;
private String disconnectUpdateSQL;
private String lwtUpdateSQL;

private String resetUpdateSQL;

private Map authConnectTables = new ConcurrentHashMap<>();
private Map authDeviceTables = new ConcurrentHashMap<>();

private boolean debug = false;

@Override
public void init(Map properties) {

this.accountDriver = properties.get("accountDriver");
this.accountUrl = properties.get("accountUrl");
this.accountUsername = properties.get("accountUsername");
this.accountPassword = properties.get("accountPassword");

this.accountAuthEnabled = Boolean.valueOf(properties.get("accountAuthEnabled"));
if(this.accountAuthEnabled){
accountJdbcTemplate = 
build(accountDriver,accountUrl,accountUsername,accountPassword);
}
this.accountAuthQuerySQL = properties.get("accountAuthQuerySQL");


this.deviceDriver = properties.get("deviceDriver");
this.deviceUrl = properties.get("deviceUrl");
this.deviceUsername = properties.get("deviceUsername");
this.devicePassword = properties.get("devicePassword");

this.deviceAuthEnabled = Boolean.valueOf(properties.get("deviceAuthEnabled"));
if(this.deviceAuthEnabled){
deviceJdbcTemplate = 
build(deviceDriver,deviceUrl,deviceUsername,devicePassword);
}
this.deviceAuthCheckSQL = properties.get("deviceAuthCheckSQL");
this.deviceAuthLockerSQL = properties.get("deviceAuthLockerSQL");

this.deviceStatusSyncabled = 
Boolean.valueOf(properties.get("deviceStatusSyncabled"));
this.connectUpdateSQL = properties.get("connectUpdateSQL");
this.disconnectUpdateSQL = properties.get("disconnectUpdateSQL");
this.lwtUpdateSQL = properties.get("lwtUpdateSQL");

this.resetUpdateSQL = properties.get("resetUpdateSQL");



log.info("init :[{}] ",properties);
log.info("AccountAuthEnabled :[{}] ", accountAuthEnabled);
log.info("DeviceAuthEnabled :[{}] ", deviceAuthEnabled);
log.info("DeviceStatusSyncabled :[{}] ", deviceStatusSyncabled);
log.info("{} 插件初始化",this.getClass().getSimpleName());
}

@Override
public void afterCreateConnection(RemotingConnection connection) throws 
ActiveMQException {
if(debug){
log.info("afterCreateConnection 
{},{},{}",connection.getClientID(),connection.getRemoteAddress(),connection.getID());
}
}

/**
*
* @param name
* @param username
* @param minLargeMessageSize
* @param connection
* @param 

[jira] [Commented] (ARTEMIS-3913) MQTTReasonCodes byte loss of precision,must int type

2022-08-01 Thread Justin Bertram (Jira)


[ 
https://issues.apache.org/jira/browse/ARTEMIS-3913?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17573843#comment-17573843
 ] 

Justin Bertram commented on ARTEMIS-3913:
-

Can you elaborate on the problem you're seeing? Could you attach code to 
reproduce the problem?

Without additional details to understand the problem I will be forced to close 
this issue.

> MQTTReasonCodes byte loss of precision,must int type
> 
>
> Key: ARTEMIS-3913
> URL: https://issues.apache.org/jira/browse/ARTEMIS-3913
> Project: ActiveMQ Artemis
>  Issue Type: Bug
>Reporter: gongping.zhu
>Priority: Major
>




--
This message was sent by Atlassian Jira
(v8.20.10#820010)