Refactoring
This commit is contained in:
parent
6df9219790
commit
17ca3cfab4
@ -263,7 +263,7 @@ public class DeviceProvisionServiceImpl implements DeviceProvisionService {
|
||||
!StringUtils.isEmpty(provisionRequest.getCredentialsData().getUsername()) ||
|
||||
!StringUtils.isEmpty(provisionRequest.getCredentialsData().getPassword()) ||
|
||||
!StringUtils.isEmpty(provisionRequest.getCredentialsData().getClientId())) {
|
||||
DeviceCredentials deviceCredentials = new DeviceCredentials();
|
||||
DeviceCredentials deviceCredentials = deviceCredentialsService.findDeviceCredentialsByDeviceId(savedDevice.getTenantId(), savedDevice.getId());
|
||||
deviceCredentials.setCredentialsType(provisionRequest.getCredentialsType());
|
||||
switch (provisionRequest.getCredentialsType()) {
|
||||
case ACCESS_TOKEN:
|
||||
@ -281,6 +281,7 @@ public class DeviceProvisionServiceImpl implements DeviceProvisionService {
|
||||
deviceCredentials.setCredentialsValue(provisionRequest.getCredentialsData().getHash());
|
||||
break;
|
||||
}
|
||||
deviceCredentials.setCredentialsType(provisionRequest.getCredentialsType());
|
||||
deviceCredentialsService.updateDeviceCredentials(savedDevice.getTenantId(), deviceCredentials);
|
||||
}
|
||||
return savedDevice;
|
||||
|
||||
@ -315,8 +315,7 @@ public class DefaultTransportApiService implements TransportApiService {
|
||||
return TransportProtos.DeviceCredentialsProto.newBuilder()
|
||||
.setDeviceIdMSB(deviceCredentials.getDeviceId().getId().getMostSignificantBits())
|
||||
.setDeviceIdLSB(deviceCredentials.getDeviceId().getId().getLeastSignificantBits())
|
||||
.setCredentialsType(deviceCredentials.getCredentialsType() == DeviceCredentialsType.ACCESS_TOKEN ?
|
||||
CredentialsType.ACCESS_TOKEN : CredentialsType.X509_CERTIFICATE)
|
||||
.setCredentialsType(TransportProtos.CredentialsType.valueOf(deviceCredentials.getCredentialsType().name()))
|
||||
.setCredentialsId(deviceCredentials.getCredentialsId())
|
||||
.setCredentialsValue(deviceCredentials.getCredentialsValue() != null ? deviceCredentials.getCredentialsValue() : "")
|
||||
.build();
|
||||
|
||||
@ -76,7 +76,7 @@ enum KeyValueType {
|
||||
enum CredentialsType {
|
||||
ACCESS_TOKEN = 0;
|
||||
X509_CERTIFICATE = 1;
|
||||
BASIC_MQTT = 2;
|
||||
MQTT_BASIC = 2;
|
||||
}
|
||||
|
||||
message KeyValueProto {
|
||||
|
||||
@ -567,7 +567,7 @@ public class JsonConverter {
|
||||
.setPassword(getStrValue(jo, DataConstants.PASSWORD, false))
|
||||
.build())
|
||||
.setValidateDeviceX509CertRequestMsg(ValidateDeviceX509CertRequestMsg.newBuilder()
|
||||
.setHash(getStrValue(jo, DataConstants.PASSWORD, false)).build())
|
||||
.setHash(getStrValue(jo, DataConstants.HASH, false)).build())
|
||||
.build())
|
||||
.setProvisionDeviceCredentialsMsg(buildProvisionDeviceCredentialsMsg(
|
||||
getStrValue(jo, DataConstants.PROVISION_KEY, true),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user