Showing
3 changed files
with
16 additions
and
14 deletions
application/src/main/java/org/thingsboard/server/service/apiusage/DefaultTbApiUsageStateService.java
@@ -237,7 +237,7 @@ public class DefaultTbApiUsageStateService implements TbApiUsageStateService { | @@ -237,7 +237,7 @@ public class DefaultTbApiUsageStateService implements TbApiUsageStateService { | ||
237 | 237 | ||
238 | @Override | 238 | @Override |
239 | public void onTenantUpdate(TenantId tenantId) { | 239 | public void onTenantUpdate(TenantId tenantId) { |
240 | - log.info("[{}] On Tenant Update", tenantId); | 240 | + log.info("[{}] On Tenant Update.", tenantId); |
241 | TenantProfile tenantProfile = tenantProfileCache.get(tenantId); | 241 | TenantProfile tenantProfile = tenantProfileCache.get(tenantId); |
242 | updateLock.lock(); | 242 | updateLock.lock(); |
243 | try { | 243 | try { |
@@ -251,7 +251,6 @@ public class DefaultTbApiUsageStateService implements TbApiUsageStateService { | @@ -251,7 +251,6 @@ public class DefaultTbApiUsageStateService implements TbApiUsageStateService { | ||
251 | } | 251 | } |
252 | 252 | ||
253 | private void updateTenantState(TenantApiUsageState state, TenantProfile profile) { | 253 | private void updateTenantState(TenantApiUsageState state, TenantProfile profile) { |
254 | - log.info("[{}] On Tenant Update.", state.getTenantId()); | ||
255 | TenantProfileData oldProfileData = state.getTenantProfileData(); | 254 | TenantProfileData oldProfileData = state.getTenantProfileData(); |
256 | state.setTenantProfileId(profile.getId()); | 255 | state.setTenantProfileId(profile.getId()); |
257 | state.setTenantProfileData(profile.getProfileData()); | 256 | state.setTenantProfileData(profile.getProfileData()); |
@@ -164,22 +164,25 @@ public class DefaultTransportApiService implements TransportApiService { | @@ -164,22 +164,25 @@ public class DefaultTransportApiService implements TransportApiService { | ||
164 | } | 164 | } |
165 | 165 | ||
166 | private ListenableFuture<TransportApiResponseMsg> validateCredentials(TransportProtos.ValidateBasicMqttCredRequestMsg mqtt) { | 166 | private ListenableFuture<TransportApiResponseMsg> validateCredentials(TransportProtos.ValidateBasicMqttCredRequestMsg mqtt) { |
167 | - DeviceCredentials credentials = deviceCredentialsService.findDeviceCredentialsByCredentialsId(mqtt.getUserName()); | ||
168 | - if (credentials != null) { | ||
169 | - if (credentials.getCredentialsType() == DeviceCredentialsType.ACCESS_TOKEN) { | ||
170 | - return getDeviceInfo(credentials.getDeviceId(), credentials); | ||
171 | - } else if (credentials.getCredentialsType() == DeviceCredentialsType.MQTT_BASIC) { | ||
172 | - if (!checkMqttCredentials(mqtt, credentials)) { | ||
173 | - credentials = null; | 167 | + DeviceCredentials credentials = null; |
168 | + if (mqtt.getUserName() != null) { | ||
169 | + credentials = deviceCredentialsService.findDeviceCredentialsByCredentialsId(mqtt.getUserName()); | ||
170 | + if (credentials != null) { | ||
171 | + if (credentials.getCredentialsType() == DeviceCredentialsType.ACCESS_TOKEN) { | ||
172 | + return getDeviceInfo(credentials.getDeviceId(), credentials); | ||
173 | + } else if (credentials.getCredentialsType() == DeviceCredentialsType.MQTT_BASIC) { | ||
174 | + if (!checkMqttCredentials(mqtt, credentials)) { | ||
175 | + credentials = null; | ||
176 | + } | ||
174 | } | 177 | } |
175 | } | 178 | } |
176 | - } | ||
177 | - if (credentials == null) { | ||
178 | - credentials = checkMqttCredentials(mqtt, EncryptionUtil.getSha3Hash("|", mqtt.getClientId(), mqtt.getUserName())); | ||
179 | if (credentials == null) { | 179 | if (credentials == null) { |
180 | - credentials = checkMqttCredentials(mqtt, EncryptionUtil.getSha3Hash(mqtt.getClientId())); | 180 | + credentials = checkMqttCredentials(mqtt, EncryptionUtil.getSha3Hash("|", mqtt.getClientId(), mqtt.getUserName())); |
181 | } | 181 | } |
182 | } | 182 | } |
183 | + if (credentials == null) { | ||
184 | + credentials = checkMqttCredentials(mqtt, EncryptionUtil.getSha3Hash(mqtt.getClientId())); | ||
185 | + } | ||
183 | if (credentials != null) { | 186 | if (credentials != null) { |
184 | return getDeviceInfo(credentials.getDeviceId(), credentials); | 187 | return getDeviceInfo(credentials.getDeviceId(), credentials); |
185 | } else { | 188 | } else { |
@@ -58,7 +58,7 @@ In case of any issues you can examine service logs for errors. | @@ -58,7 +58,7 @@ In case of any issues you can examine service logs for errors. | ||
58 | For example to see ThingsBoard node logs execute the following command: | 58 | For example to see ThingsBoard node logs execute the following command: |
59 | 59 | ||
60 | ` | 60 | ` |
61 | -$ docker-compose logs -f tb-core1 tb-rule-engine1 | 61 | +$ docker-compose logs -f tb-core1 tb-core2 tb-rule-engine1 tb-rule-engine2 tb-mqtt-transport1 tb-mqtt-transport2 |
62 | ` | 62 | ` |
63 | 63 | ||
64 | Or use `docker-compose ps` to see the state of all the containers. | 64 | Or use `docker-compose ps` to see the state of all the containers. |