Commit be3d752007ee5704de16746ebea576209effa706

Authored by xp.Huang
1 parent 47a57cf2

fix: 修改TcpTransportHandler的processAuthTokenConnect鉴权判断

@@ -325,28 +325,25 @@ public class TcpTransportHandler extends ChannelInboundHandlerAdapter implements @@ -325,28 +325,25 @@ public class TcpTransportHandler extends ChannelInboundHandlerAdapter implements
325 if (null != accessToken.getUserName()) { 325 if (null != accessToken.getUserName()) {
326 } 326 }
327 String token = accessToken.getPassword(); 327 String token = accessToken.getPassword();
328 - if (null == token  
329 - || StringUtils.isEmpty(token)  
330 - || token.contains("\000")  
331 - || Pattern.compile(".*[\\s\u0000]+.*").matcher(token).matches()) { 328 + if(StringUtils.isNotEmpty(token)){
  329 + token.trim();
  330 + request.setToken(token);
  331 + transportService.process(DeviceTransportType.TCP, request.build(),
  332 + new TransportServiceCallback<>() {
  333 + @Override
  334 + public void onSuccess(ValidateDeviceCredentialsResponse msg) {
  335 + onValidateDeviceResponse(msg, ctx, accessToken, scriptId);
  336 + }
  337 +
  338 + @Override
  339 + public void onError(Throwable e) {
  340 + log.trace("[{}] Failed to process credentials: {}", address, accessToken, e);
  341 + onValidateFailed(ctx, MqttConnectReturnCode.CONNECTION_REFUSED_SERVER_UNAVAILABLE);
  342 + }
  343 + });
  344 + }else{
332 onValidateFailed(ctx, MqttConnectReturnCode.CONNECTION_REFUSED_PAYLOAD_FORMAT_INVALID); 345 onValidateFailed(ctx, MqttConnectReturnCode.CONNECTION_REFUSED_PAYLOAD_FORMAT_INVALID);
333 - return;  
334 } 346 }
335 - request.setToken(token);  
336 -  
337 - transportService.process(DeviceTransportType.TCP, request.build(),  
338 - new TransportServiceCallback<>() {  
339 - @Override  
340 - public void onSuccess(ValidateDeviceCredentialsResponse msg) {  
341 - onValidateDeviceResponse(msg, ctx, accessToken, scriptId);  
342 - }  
343 -  
344 - @Override  
345 - public void onError(Throwable e) {  
346 - log.trace("[{}] Failed to process credentials: {}", address, accessToken, e);  
347 - onValidateFailed(ctx, MqttConnectReturnCode.CONNECTION_REFUSED_SERVER_UNAVAILABLE);  
348 - }  
349 - });  
350 } 347 }
351 348
352 349