|
2 | 2 |
|
3 | 3 | import java.net.InetSocketAddress; |
4 | 4 | import java.util.Collection; |
| 5 | +import java.util.List; |
5 | 6 | import javasabr.mqtt.model.MqttProperties; |
6 | 7 | import javasabr.mqtt.model.MqttServerConnectionConfig; |
7 | 8 | import javasabr.mqtt.model.QoS; |
8 | 9 | import javasabr.mqtt.network.MqttConnection; |
9 | 10 | import javasabr.mqtt.network.MqttConnectionFactory; |
10 | 11 | import javasabr.mqtt.network.handler.NetworkMqttUserReleaseHandler; |
11 | 12 | import javasabr.mqtt.network.impl.ExternalNetworkMqttUser; |
| 13 | +import javasabr.mqtt.network.message.in.PublishMqttInMessage; |
12 | 14 | import javasabr.mqtt.network.user.NetworkMqttUserFactory; |
| 15 | +import javasabr.mqtt.service.AuthorizationService; |
13 | 16 | import javasabr.mqtt.service.AuthenticationService; |
14 | 17 | import javasabr.mqtt.service.ClientIdRegistry; |
15 | 18 | import javasabr.mqtt.service.ConnectionService; |
|
26 | 29 | import javasabr.mqtt.service.impl.DefaultPublishDeliveringService; |
27 | 30 | import javasabr.mqtt.service.impl.DefaultPublishReceivingService; |
28 | 31 | import javasabr.mqtt.service.impl.DefaultTopicService; |
| 32 | +import javasabr.mqtt.service.impl.DisabledAuthorizationService; |
29 | 33 | import javasabr.mqtt.service.impl.ExternalNetworkMqttUserFactory; |
30 | 34 | import javasabr.mqtt.service.impl.FileCredentialsSource; |
31 | 35 | import javasabr.mqtt.service.impl.InMemoryClientIdRegistry; |
|
44 | 48 | import javasabr.mqtt.service.message.out.factory.Mqtt311MessageOutFactory; |
45 | 49 | import javasabr.mqtt.service.message.out.factory.Mqtt5MessageOutFactory; |
46 | 50 | import javasabr.mqtt.service.message.out.factory.MqttMessageOutFactory; |
| 51 | +import javasabr.mqtt.service.message.validator.MqttInMessageFieldValidator; |
| 52 | +import javasabr.mqtt.service.message.validator.PublishMessageExpiryIntervalMqttInMessageFieldValidator; |
| 53 | +import javasabr.mqtt.service.message.validator.PublishPayloadMqttInMessageFieldValidator; |
| 54 | +import javasabr.mqtt.service.message.validator.PublishQosMqttInMessageFieldValidator; |
| 55 | +import javasabr.mqtt.service.message.validator.PublishResponseTopicMqttInMessageFieldValidator; |
| 56 | +import javasabr.mqtt.service.message.validator.PublishRetainMqttInMessageFieldValidator; |
| 57 | +import javasabr.mqtt.service.message.validator.PublishTopicAliasMqttInMessageFieldValidator; |
47 | 58 | import javasabr.mqtt.service.publish.handler.MqttPublishInMessageHandler; |
48 | 59 | import javasabr.mqtt.service.publish.handler.MqttPublishOutMessageHandler; |
49 | 60 | import javasabr.mqtt.service.publish.handler.impl.Qos0MqttPublishInMessageHandler; |
@@ -96,6 +107,11 @@ AuthenticationService authenticationService( |
96 | 107 | @Value("${authentication.allow.anonymous:false}") boolean allowAnonymousAuth) { |
97 | 108 | return new SimpleAuthenticationService(credentialSource, allowAnonymousAuth); |
98 | 109 | } |
| 110 | + |
| 111 | + @Bean |
| 112 | + AuthorizationService authorizationService() { |
| 113 | + return new DisabledAuthorizationService(); |
| 114 | + } |
99 | 115 |
|
100 | 116 | @Bean |
101 | 117 | SubscriptionService subscriptionService() { |
@@ -147,16 +163,55 @@ MqttInMessageHandler publishAckMqttInMessageHandler(MessageOutFactoryService mes |
147 | 163 | MqttInMessageHandler publishCompleteMqttInMessageHandler(MessageOutFactoryService messageOutFactoryService) { |
148 | 164 | return new PublishCompleteMqttInMessageHandler(messageOutFactoryService); |
149 | 165 | } |
| 166 | + |
| 167 | + @Bean |
| 168 | + PublishPayloadMqttInMessageFieldValidator publishPayloadMqttInMessageFieldValidator( |
| 169 | + MessageOutFactoryService messageOutFactoryService) { |
| 170 | + return new PublishPayloadMqttInMessageFieldValidator(messageOutFactoryService); |
| 171 | + } |
| 172 | + |
| 173 | + @Bean |
| 174 | + PublishQosMqttInMessageFieldValidator publishQosMqttInMessageFieldValidator( |
| 175 | + MessageOutFactoryService messageOutFactoryService) { |
| 176 | + return new PublishQosMqttInMessageFieldValidator(messageOutFactoryService); |
| 177 | + } |
| 178 | + |
| 179 | + @Bean |
| 180 | + PublishRetainMqttInMessageFieldValidator publishRetainMqttInMessageFieldValidator( |
| 181 | + MessageOutFactoryService messageOutFactoryService) { |
| 182 | + return new PublishRetainMqttInMessageFieldValidator(messageOutFactoryService); |
| 183 | + } |
| 184 | + |
| 185 | + @Bean |
| 186 | + PublishMessageExpiryIntervalMqttInMessageFieldValidator publishMessageExpiryIntervalMqttInMessageFieldValidator( |
| 187 | + MessageOutFactoryService messageOutFactoryService) { |
| 188 | + return new PublishMessageExpiryIntervalMqttInMessageFieldValidator(messageOutFactoryService); |
| 189 | + } |
| 190 | + |
| 191 | + @Bean |
| 192 | + PublishResponseTopicMqttInMessageFieldValidator publishResponseTopicMqttInMessageFieldValidator( |
| 193 | + MessageOutFactoryService messageOutFactoryService) { |
| 194 | + return new PublishResponseTopicMqttInMessageFieldValidator(messageOutFactoryService); |
| 195 | + } |
| 196 | + |
| 197 | + @Bean |
| 198 | + PublishTopicAliasMqttInMessageFieldValidator publishTopicAliasMqttInMessageFieldValidator( |
| 199 | + MessageOutFactoryService messageOutFactoryService) { |
| 200 | + return new PublishTopicAliasMqttInMessageFieldValidator(messageOutFactoryService); |
| 201 | + } |
150 | 202 |
|
151 | 203 | @Bean |
152 | 204 | MqttInMessageHandler publishMqttInMessageHandler( |
153 | 205 | PublishReceivingService publishReceivingService, |
154 | 206 | MessageOutFactoryService messageOutFactoryService, |
155 | | - TopicService topicService) { |
| 207 | + TopicService topicService, |
| 208 | + AuthorizationService authorizationService, |
| 209 | + List<? extends MqttInMessageFieldValidator<? super ExternalNetworkMqttUser, PublishMqttInMessage>> fieldValidators) { |
156 | 210 | return new PublishMqttInMessageHandler( |
157 | 211 | publishReceivingService, |
158 | 212 | messageOutFactoryService, |
159 | | - topicService); |
| 213 | + topicService, authorizationService, |
| 214 | + fieldValidators); |
160 | 215 | } |
161 | 216 |
|
162 | 217 | @Bean |
|
0 commit comments