Commit cb3353a32d3ea39b1645f8ee9f3368219b417435
1 parent
17700fe1
Lwm2m: backEnd: refactoring start server/bootstrap without different secure
Showing
5 changed files
with
21 additions
and
15 deletions
... | ... | @@ -635,7 +635,7 @@ transport: |
635 | 635 | private_s: "${LWM2M_SERVER_PRIVATE_S_BS:9dbdbb073fc63570693a9aaf1013414e261c571f27e27fc6a8c1c2ad9347875a}" |
636 | 636 | # Only Certificate_x509: |
637 | 637 | alias: "${LWM2M_KEYSTORE_ALIAS_BOOTSTRAP:bootstrap}" |
638 | - # Redis | |
638 | + # Redis | |
639 | 639 | redis_url: "${LWM2M_REDIS_URL:''}" |
640 | 640 | |
641 | 641 | swagger: | ... | ... |
... | ... | @@ -61,7 +61,7 @@ import static org.thingsboard.server.transport.lwm2m.server.LwM2MTransportHandle |
61 | 61 | |
62 | 62 | @Slf4j |
63 | 63 | @Component |
64 | -@ConditionalOnExpression("('${service.type:null}'=='tb-transport' && '${transport.lwm2m.enabled:false}'=='true'&& '${transport.lwm2m.bootstrap.enable:false}'=='true') || ('${service.type:null}'=='monolith' && '${transport.lwm2m.enabled}'=='true'&& '${transport.lwm2m.bootstrap.enable}'=='true')") | |
64 | +@ConditionalOnExpression("('${service.type:null}'=='tb-transport' && '${transport.lwm2m.enabled:false}'=='true'&& '${transport.lwm2m.bootstrap.enable:false}'=='true') || ('${service.type:null}'=='monolith' && '${transport.lwm2m.enabled:false}'=='true'&& '${transport.lwm2m.bootstrap.enable:false}'=='true')") | |
65 | 65 | public class LwM2MTransportBootstrapServerConfiguration { |
66 | 66 | private PublicKey publicKey; |
67 | 67 | private PrivateKey privateKey; |
... | ... | @@ -80,18 +80,21 @@ public class LwM2MTransportBootstrapServerConfiguration { |
80 | 80 | |
81 | 81 | @Primary |
82 | 82 | @Bean(name = "leshanBootstrapX509") |
83 | + @ConditionalOnExpression("('${transport.lwm2m.bootstrap.secure.start_x509:false}'=='true')") | |
83 | 84 | public LeshanBootstrapServer getLeshanBootstrapServerX509() { |
84 | 85 | log.info("Prepare and start BootstrapServerX509... PostConstruct"); |
85 | 86 | return getLeshanBootstrapServer(this.contextBs.getCtxBootStrap().getBootstrapPortNoSecX509(), this.contextBs.getCtxBootStrap().getBootstrapSecurePortX509(), X509); |
86 | 87 | } |
87 | 88 | |
88 | 89 | @Bean(name = "leshanBootstrapPsk") |
90 | + @ConditionalOnExpression("('${transport.lwm2m.bootstrap.secure.start_psk:false}'=='true')") | |
89 | 91 | public LeshanBootstrapServer getLeshanBootstrapServerPsk() { |
90 | 92 | log.info("Prepare and start BootstrapServerRsk... PostConstruct"); |
91 | 93 | return getLeshanBootstrapServer(this.contextBs.getCtxBootStrap().getBootstrapPortNoSecPsk(), this.contextBs.getCtxBootStrap().getBootstrapSecurePortPsk(), PSK); |
92 | 94 | } |
93 | 95 | |
94 | 96 | @Bean(name = "leshanBootstrapRpk") |
97 | + @ConditionalOnExpression("('${transport.lwm2m.bootstrap.secure.start_rpk:false}'=='true')") | |
95 | 98 | public LeshanBootstrapServer getLeshanBootstrapServerRpk() { |
96 | 99 | log.info("Prepare and start BootstrapServerRpk... PostConstruct"); |
97 | 100 | return getLeshanBootstrapServer(this.contextBs.getCtxBootStrap().getBootstrapPortNoSecRpk(), this.contextBs.getCtxBootStrap().getBootstrapSecurePortRpk(), RPK); | ... | ... |
... | ... | @@ -27,18 +27,18 @@ import javax.annotation.PreDestroy; |
27 | 27 | |
28 | 28 | @Slf4j |
29 | 29 | @Service |
30 | -@ConditionalOnExpression("('${service.type:null}'=='tb-transport' && '${transport.lwm2m.enabled}'=='true'&& '${transport.lwm2m.bootstrap.enable}'=='true') || ('${service.type:null}'=='monolith' && '${transport.lwm2m.enabled}'=='true'&& '${transport.lwm2m.bootstrap.enable}'=='true')") | |
30 | +@ConditionalOnExpression("('${service.type:null}'=='tb-transport' && '${transport.lwm2m.enabled:false}'=='true'&& '${transport.lwm2m.bootstrap.enable:false}'=='true') || ('${service.type:null}'=='monolith' && '${transport.lwm2m.enabled:false}'=='true'&& '${transport.lwm2m.bootstrap.enable:false}'=='true')") | |
31 | 31 | public class LwM2MTransportBootstrapServerInitializer { |
32 | 32 | |
33 | - @Autowired | |
33 | + @Autowired(required = false) | |
34 | 34 | @Qualifier("leshanBootstrapX509") |
35 | 35 | private LeshanBootstrapServer lhBServerCert; |
36 | 36 | |
37 | - @Autowired | |
37 | + @Autowired(required = false) | |
38 | 38 | @Qualifier("leshanBootstrapPsk") |
39 | 39 | private LeshanBootstrapServer lhBServerPsk; |
40 | 40 | |
41 | - @Autowired | |
41 | + @Autowired(required = false) | |
42 | 42 | @Qualifier("leshanBootstrapRpk") |
43 | 43 | private LeshanBootstrapServer lhBServerRpk; |
44 | 44 | ... | ... |
... | ... | @@ -85,24 +85,27 @@ public class LwM2MTransportServerConfiguration { |
85 | 85 | private LwM2mInMemorySecurityStore lwM2mInMemorySecurityStore; |
86 | 86 | |
87 | 87 | @Primary |
88 | - @Bean(name = "leshanServerX509") | |
89 | - public LeshanServer getLeshanServerX509() { | |
90 | - log.info("Starting LwM2M transport ServerX509... PostConstruct"); | |
91 | - return getLeshanServer(this.context.getCtxServer().getServerPortNoSecX509(), this.context.getCtxServer().getServerPortX509(), X509); | |
92 | - } | |
93 | - | |
94 | 88 | @Bean(name = "leshanServerPsk") |
89 | + @ConditionalOnExpression("('${transport.lwm2m.server.secure.start_psk:false}'=='true')") | |
95 | 90 | public LeshanServer getLeshanServerPsk() { |
96 | 91 | log.info("Starting LwM2M transport ServerPsk... PostConstruct"); |
97 | 92 | return getLeshanServer(this.context.getCtxServer().getServerPortNoSecPsk(), this.context.getCtxServer().getServerPortPsk(), PSK); |
98 | 93 | } |
99 | 94 | |
100 | 95 | @Bean(name = "leshanServerRpk") |
96 | + @ConditionalOnExpression("('${transport.lwm2m.server.secure.start_rpk:false}'=='true')") | |
101 | 97 | public LeshanServer getLeshanServerRpk() { |
102 | 98 | log.info("Starting LwM2M transport ServerRpk... PostConstruct"); |
103 | 99 | return getLeshanServer(this.context.getCtxServer().getServerPortNoSecRpk(), this.context.getCtxServer().getServerPortRpk(), RPK); |
104 | 100 | } |
105 | 101 | |
102 | + @Bean(name = "leshanServerX509") | |
103 | + @ConditionalOnExpression("('${transport.lwm2m.server.secure.start_x509:false}'=='true')") | |
104 | + public LeshanServer getLeshanServerX509() { | |
105 | + log.info("Starting LwM2M transport ServerX509... PostConstruct"); | |
106 | + return getLeshanServer(this.context.getCtxServer().getServerPortNoSecX509(), this.context.getCtxServer().getServerPortX509(), X509); | |
107 | + } | |
108 | + | |
106 | 109 | private LeshanServer getLeshanServer(Integer serverPortNoSec, Integer serverSecurePort, LwM2MSecurityMode dtlsMode) { |
107 | 110 | LeshanServerBuilder builder = new LeshanServerBuilder(); |
108 | 111 | builder.setLocalAddress(this.context.getCtxServer().getServerHost(), serverPortNoSec); | ... | ... |
... | ... | @@ -35,15 +35,15 @@ public class LwM2MTransportServerInitializer { |
35 | 35 | @Autowired |
36 | 36 | private LwM2MTransportServiceImpl service; |
37 | 37 | |
38 | - @Autowired | |
38 | + @Autowired(required = false) | |
39 | 39 | @Qualifier("leshanServerX509") |
40 | 40 | private LeshanServer lhServerX509; |
41 | 41 | |
42 | - @Autowired | |
42 | + @Autowired(required = false) | |
43 | 43 | @Qualifier("leshanServerPsk") |
44 | 44 | private LeshanServer lhServerPsk; |
45 | 45 | |
46 | - @Autowired | |
46 | + @Autowired(required = false) | |
47 | 47 | @Qualifier("leshanServerRpk") |
48 | 48 | private LeshanServer lhServerRpk; |
49 | 49 | ... | ... |