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