Commit 81585f04c833805c3d05416ee1de46c83aa6af45

Authored by Andrii Shvaika
1 parent 3d8b2cbb

Improvements

... ... @@ -237,7 +237,7 @@ public class DefaultTbApiUsageStateService implements TbApiUsageStateService {
237 237
238 238 @Override
239 239 public void onTenantUpdate(TenantId tenantId) {
240   - log.info("[{}] On Tenant Update", tenantId);
  240 + log.info("[{}] On Tenant Update.", tenantId);
241 241 TenantProfile tenantProfile = tenantProfileCache.get(tenantId);
242 242 updateLock.lock();
243 243 try {
... ... @@ -251,7 +251,6 @@ public class DefaultTbApiUsageStateService implements TbApiUsageStateService {
251 251 }
252 252
253 253 private void updateTenantState(TenantApiUsageState state, TenantProfile profile) {
254   - log.info("[{}] On Tenant Update.", state.getTenantId());
255 254 TenantProfileData oldProfileData = state.getTenantProfileData();
256 255 state.setTenantProfileId(profile.getId());
257 256 state.setTenantProfileData(profile.getProfileData());
... ...
... ... @@ -164,22 +164,25 @@ public class DefaultTransportApiService implements TransportApiService {
164 164 }
165 165
166 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 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 186 if (credentials != null) {
184 187 return getDeviceInfo(credentials.getDeviceId(), credentials);
185 188 } else {
... ...
... ... @@ -58,7 +58,7 @@ In case of any issues you can examine service logs for errors.
58 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 64 Or use `docker-compose ps` to see the state of all the containers.
... ...