|
@ -98,7 +98,7 @@ public class AuthorizeHandler extends ChannelInboundHandlerAdapter implements Di |
|
|
}, configuration.getFirstDataTimeout(), TimeUnit.MILLISECONDS); |
|
|
}, configuration.getFirstDataTimeout(), TimeUnit.MILLISECONDS); |
|
|
super.channelActive(ctx); |
|
|
super.channelActive(ctx); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { |
|
|
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { |
|
|
SchedulerKey key = new SchedulerKey(Type.PING_TIMEOUT, ctx.channel()); |
|
|
SchedulerKey key = new SchedulerKey(Type.PING_TIMEOUT, ctx.channel()); |
|
@ -159,8 +159,7 @@ public class AuthorizeHandler extends ChannelInboundHandlerAdapter implements Di |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// TODO try to get sessionId from cookie |
|
|
|
|
|
UUID sessionId = UUID.randomUUID(); |
|
|
|
|
|
|
|
|
UUID sessionId = this.generateOrGetSessionIdFromRequest(headers); |
|
|
|
|
|
|
|
|
List<String> transportValue = params.get("transport"); |
|
|
List<String> transportValue = params.get("transport"); |
|
|
if (transportValue == null) { |
|
|
if (transportValue == null) { |
|
@ -193,6 +192,22 @@ public class AuthorizeHandler extends ChannelInboundHandlerAdapter implements Di |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
This method will either generate a new random sessionId or will retrieve the value stored |
|
|
|
|
|
in the "io" cookie. Failures to parse will cause a logging warning to be generated and a |
|
|
|
|
|
random uuid to be generated instead (same as not passing a cookie in the first place). |
|
|
|
|
|
*/ |
|
|
|
|
|
private UUID generateOrGetSessionIdFromRequest(Map<String, List<String>> headers) { |
|
|
|
|
|
if ( headers.containsKey("io") && headers.get("io").size() == 1 ) { |
|
|
|
|
|
try { |
|
|
|
|
|
return UUID.fromString(headers.get("io").get(0)); |
|
|
|
|
|
} catch ( IllegalArgumentException iaex ) { |
|
|
|
|
|
log.warn("Malformed UUID received for session! io=" + headers.get("io")); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return UUID.randomUUID(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public void connect(UUID sessionId) { |
|
|
public void connect(UUID sessionId) { |
|
|
SchedulerKey key = new SchedulerKey(Type.PING_TIMEOUT, sessionId); |
|
|
SchedulerKey key = new SchedulerKey(Type.PING_TIMEOUT, sessionId); |
|
|
disconnectScheduler.cancel(key); |
|
|
disconnectScheduler.cancel(key); |
|
|