Commit 70b8647ef483d194b7fbfcf21c24e2ed4a42a6ae
1 parent
1e443034
Refactoring to use provision data only from device profile
Showing
6 changed files
with
5 additions
and
69 deletions
... | ... | @@ -29,9 +29,7 @@ import org.thingsboard.server.common.data.Device; |
29 | 29 | import org.thingsboard.server.common.data.DeviceProfile; |
30 | 30 | import org.thingsboard.server.common.data.DeviceProfileType; |
31 | 31 | import org.thingsboard.server.common.data.audit.ActionType; |
32 | -import org.thingsboard.server.common.data.device.data.ProvisionDeviceConfiguration; | |
33 | 32 | import org.thingsboard.server.common.data.device.profile.ProvisionDeviceProfileConfiguration; |
34 | -import org.thingsboard.server.common.data.device.profile.ProvisionRequestValidationStrategy; | |
35 | 33 | import org.thingsboard.server.common.data.device.profile.ProvisionRequestValidationStrategyType; |
36 | 34 | import org.thingsboard.server.common.data.id.CustomerId; |
37 | 35 | import org.thingsboard.server.common.data.id.TenantId; | ... | ... |
... | ... | @@ -22,9 +22,7 @@ import com.google.common.util.concurrent.Futures; |
22 | 22 | import com.google.common.util.concurrent.ListenableFuture; |
23 | 23 | import com.google.common.util.concurrent.MoreExecutors; |
24 | 24 | import com.google.protobuf.ByteString; |
25 | -import com.google.protobuf.InvalidProtocolBufferException; | |
26 | 25 | import lombok.extern.slf4j.Slf4j; |
27 | -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; | |
28 | 26 | import org.springframework.stereotype.Service; |
29 | 27 | import org.springframework.util.StringUtils; |
30 | 28 | import org.thingsboard.server.common.data.DataConstants; |
... | ... | @@ -32,7 +30,7 @@ import org.thingsboard.server.common.data.Device; |
32 | 30 | import org.thingsboard.server.common.data.DeviceProfile; |
33 | 31 | import org.thingsboard.server.common.data.TenantProfile; |
34 | 32 | import org.thingsboard.server.common.data.device.credentials.BasicMqttCredentials; |
35 | -import org.thingsboard.server.common.data.device.data.ProvisionDeviceConfiguration; | |
33 | +import org.thingsboard.server.common.data.device.profile.ProvisionDeviceProfileConfiguration; | |
36 | 34 | import org.thingsboard.server.common.data.id.CustomerId; |
37 | 35 | import org.thingsboard.server.common.data.id.DeviceId; |
38 | 36 | import org.thingsboard.server.common.data.id.DeviceProfileId; |
... | ... | @@ -63,7 +61,6 @@ import org.thingsboard.server.gen.transport.TransportProtos.GetOrCreateDeviceFro |
63 | 61 | import org.thingsboard.server.gen.transport.TransportProtos.GetOrCreateDeviceFromGatewayResponseMsg; |
64 | 62 | import org.thingsboard.server.gen.transport.TransportProtos.GetTenantRoutingInfoRequestMsg; |
65 | 63 | import org.thingsboard.server.gen.transport.TransportProtos.GetTenantRoutingInfoResponseMsg; |
66 | -import org.thingsboard.server.gen.transport.TransportProtos.ProvisionDeviceCredentialsMsg; | |
67 | 64 | import org.thingsboard.server.gen.transport.TransportProtos.ProvisionDeviceRequestMsg; |
68 | 65 | import org.thingsboard.server.gen.transport.TransportProtos.TransportApiRequestMsg; |
69 | 66 | import org.thingsboard.server.gen.transport.TransportProtos.TransportApiResponseMsg; |
... | ... | @@ -284,7 +281,7 @@ public class DefaultTransportApiService implements TransportApiService { |
284 | 281 | requestMsg.getDeviceName(), |
285 | 282 | requestMsg.getDeviceType(), |
286 | 283 | requestMsg.getX509CertPubKey(), |
287 | - new ProvisionDeviceConfiguration( | |
284 | + new ProvisionDeviceProfileConfiguration( | |
288 | 285 | requestMsg.getProvisionDeviceCredentialsMsg().getProvisionDeviceKey(), |
289 | 286 | requestMsg.getProvisionDeviceCredentialsMsg().getProvisionDeviceSecret()))); |
290 | 287 | return Futures.transform(provisionResponseFuture, provisionResponse -> { | ... | ... |
... | ... | @@ -17,7 +17,7 @@ package org.thingsboard.server.dao.device.provision; |
17 | 17 | |
18 | 18 | import lombok.AllArgsConstructor; |
19 | 19 | import lombok.Data; |
20 | -import org.thingsboard.server.common.data.device.data.ProvisionDeviceConfiguration; | |
20 | +import org.thingsboard.server.common.data.device.profile.ProvisionDeviceProfileConfiguration; | |
21 | 21 | |
22 | 22 | @Data |
23 | 23 | @AllArgsConstructor |
... | ... | @@ -25,5 +25,5 @@ public class ProvisionRequest { |
25 | 25 | private String deviceName; |
26 | 26 | private String deviceType; |
27 | 27 | private String x509CertPubKey; |
28 | - private ProvisionDeviceConfiguration credentials; | |
28 | + private ProvisionDeviceProfileConfiguration credentials; | |
29 | 29 | } | ... | ... |
... | ... | @@ -28,7 +28,7 @@ import org.thingsboard.server.common.data.DeviceProfileType; |
28 | 28 | property = "type") |
29 | 29 | @JsonSubTypes({ |
30 | 30 | @JsonSubTypes.Type(value = DefaultDeviceConfiguration.class, name = "DEFAULT"), |
31 | - @JsonSubTypes.Type(value = ProvisionDeviceConfiguration.class, name = "PROVISION")}) | |
31 | + @JsonSubTypes.Type(value = DefaultDeviceConfiguration.class, name = "PROVISION")}) | |
32 | 32 | public interface DeviceConfiguration { |
33 | 33 | |
34 | 34 | @JsonIgnore | ... | ... |
common/data/src/main/java/org/thingsboard/server/common/data/device/data/ProvisionDeviceConfiguration.java
deleted
100644 → 0
1 | -/** | |
2 | - * Copyright © 2016-2020 The Thingsboard Authors | |
3 | - * | |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | - * you may not use this file except in compliance with the License. | |
6 | - * You may obtain a copy of the License at | |
7 | - * | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * | |
10 | - * Unless required by applicable law or agreed to in writing, software | |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | - * See the License for the specific language governing permissions and | |
14 | - * limitations under the License. | |
15 | - */ | |
16 | -package org.thingsboard.server.common.data.device.data; | |
17 | - | |
18 | -import com.fasterxml.jackson.annotation.JsonCreator; | |
19 | -import com.fasterxml.jackson.annotation.JsonProperty; | |
20 | -import lombok.Data; | |
21 | -import org.thingsboard.server.common.data.DeviceProfileType; | |
22 | -import org.thingsboard.server.common.data.device.profile.DeviceProfileConfiguration; | |
23 | -import org.thingsboard.server.common.data.device.profile.ProvisionRequestValidationStrategyType; | |
24 | - | |
25 | -import java.util.Objects; | |
26 | - | |
27 | -@Data | |
28 | -public class ProvisionDeviceConfiguration implements DeviceConfiguration { | |
29 | - | |
30 | - private String provisionDeviceKey; | |
31 | - private String provisionDeviceSecret; | |
32 | - | |
33 | - @Override | |
34 | - public DeviceProfileType getType() { | |
35 | - return DeviceProfileType.PROVISION; | |
36 | - } | |
37 | - | |
38 | - @JsonCreator | |
39 | - public ProvisionDeviceConfiguration(@JsonProperty("provisionDeviceKey") String provisionProfileKey, @JsonProperty("provisionDeviceSecret") String provisionProfileSecret) { | |
40 | - this.provisionDeviceKey = provisionProfileKey; | |
41 | - this.provisionDeviceSecret = provisionProfileSecret; | |
42 | - } | |
43 | - | |
44 | - @Override | |
45 | - public boolean equals(Object o) { | |
46 | - if (this == o) return true; | |
47 | - if (o == null || getClass() != o.getClass()) return false; | |
48 | - ProvisionDeviceConfiguration that = (ProvisionDeviceConfiguration) o; | |
49 | - return provisionDeviceKey.equals(that.provisionDeviceKey) && | |
50 | - provisionDeviceSecret.equals(that.provisionDeviceSecret); | |
51 | - } | |
52 | - | |
53 | - @Override | |
54 | - public int hashCode() { | |
55 | - return Objects.hash(provisionDeviceKey, provisionDeviceSecret); | |
56 | - } | |
57 | -} |
... | ... | @@ -19,8 +19,6 @@ import com.fasterxml.jackson.annotation.JsonCreator; |
19 | 19 | import com.fasterxml.jackson.annotation.JsonProperty; |
20 | 20 | import lombok.Data; |
21 | 21 | import org.thingsboard.server.common.data.DeviceProfileType; |
22 | -import org.thingsboard.server.common.data.device.credentials.BasicMqttCredentials; | |
23 | -import org.thingsboard.server.common.data.device.data.ProvisionDeviceConfiguration; | |
24 | 22 | |
25 | 23 | import java.util.Objects; |
26 | 24 | ... | ... |