Browse Source

Improvements

pull/3707/head
Andrii Shvaika 6 years ago
parent
commit
81585f04c8
  1. 3
      application/src/main/java/org/thingsboard/server/service/apiusage/DefaultTbApiUsageStateService.java
  2. 25
      application/src/main/java/org/thingsboard/server/service/transport/DefaultTransportApiService.java
  3. 2
      docker/README.md

3
application/src/main/java/org/thingsboard/server/service/apiusage/DefaultTbApiUsageStateService.java

@ -237,7 +237,7 @@ public class DefaultTbApiUsageStateService implements TbApiUsageStateService {
@Override @Override
public void onTenantUpdate(TenantId tenantId) { public void onTenantUpdate(TenantId tenantId) {
log.info("[{}] On Tenant Update", tenantId); log.info("[{}] On Tenant Update.", tenantId);
TenantProfile tenantProfile = tenantProfileCache.get(tenantId); TenantProfile tenantProfile = tenantProfileCache.get(tenantId);
updateLock.lock(); updateLock.lock();
try { try {
@ -251,7 +251,6 @@ public class DefaultTbApiUsageStateService implements TbApiUsageStateService {
} }
private void updateTenantState(TenantApiUsageState state, TenantProfile profile) { private void updateTenantState(TenantApiUsageState state, TenantProfile profile) {
log.info("[{}] On Tenant Update.", state.getTenantId());
TenantProfileData oldProfileData = state.getTenantProfileData(); TenantProfileData oldProfileData = state.getTenantProfileData();
state.setTenantProfileId(profile.getId()); state.setTenantProfileId(profile.getId());
state.setTenantProfileData(profile.getProfileData()); state.setTenantProfileData(profile.getProfileData());

25
application/src/main/java/org/thingsboard/server/service/transport/DefaultTransportApiService.java

@ -164,22 +164,25 @@ public class DefaultTransportApiService implements TransportApiService {
} }
private ListenableFuture<TransportApiResponseMsg> validateCredentials(TransportProtos.ValidateBasicMqttCredRequestMsg mqtt) { private ListenableFuture<TransportApiResponseMsg> validateCredentials(TransportProtos.ValidateBasicMqttCredRequestMsg mqtt) {
DeviceCredentials credentials = deviceCredentialsService.findDeviceCredentialsByCredentialsId(mqtt.getUserName()); DeviceCredentials credentials = null;
if (credentials != null) { if (mqtt.getUserName() != null) {
if (credentials.getCredentialsType() == DeviceCredentialsType.ACCESS_TOKEN) { credentials = deviceCredentialsService.findDeviceCredentialsByCredentialsId(mqtt.getUserName());
return getDeviceInfo(credentials.getDeviceId(), credentials); if (credentials != null) {
} else if (credentials.getCredentialsType() == DeviceCredentialsType.MQTT_BASIC) { if (credentials.getCredentialsType() == DeviceCredentialsType.ACCESS_TOKEN) {
if (!checkMqttCredentials(mqtt, credentials)) { return getDeviceInfo(credentials.getDeviceId(), credentials);
credentials = null; } else if (credentials.getCredentialsType() == DeviceCredentialsType.MQTT_BASIC) {
if (!checkMqttCredentials(mqtt, credentials)) {
credentials = null;
}
} }
} }
}
if (credentials == null) {
credentials = checkMqttCredentials(mqtt, EncryptionUtil.getSha3Hash("|", mqtt.getClientId(), mqtt.getUserName()));
if (credentials == null) { if (credentials == null) {
credentials = checkMqttCredentials(mqtt, EncryptionUtil.getSha3Hash(mqtt.getClientId())); credentials = checkMqttCredentials(mqtt, EncryptionUtil.getSha3Hash("|", mqtt.getClientId(), mqtt.getUserName()));
} }
} }
if (credentials == null) {
credentials = checkMqttCredentials(mqtt, EncryptionUtil.getSha3Hash(mqtt.getClientId()));
}
if (credentials != null) { if (credentials != null) {
return getDeviceInfo(credentials.getDeviceId(), credentials); return getDeviceInfo(credentials.getDeviceId(), credentials);
} else { } else {

2
docker/README.md

@ -58,7 +58,7 @@ In case of any issues you can examine service logs for errors.
For example to see ThingsBoard node logs execute the following command: For example to see ThingsBoard node logs execute the following command:
` `
$ docker-compose logs -f tb-core1 tb-rule-engine1 $ docker-compose logs -f tb-core1 tb-core2 tb-rule-engine1 tb-rule-engine2 tb-mqtt-transport1 tb-mqtt-transport2
` `
Or use `docker-compose ps` to see the state of all the containers. Or use `docker-compose ps` to see the state of all the containers.

Loading…
Cancel
Save