@Test public void testHttpChannelReadWhenAuthenticatorHasNotBeenAdded() throws Exception { final HMACAuthenticator hmacAuth = createMock(HMACAuthenticator.class); final SaslAndHMACAuthenticator authenticator = createMock(SaslAndHMACAuthenticator.class); final ChannelHandlerContext ctx = createMock(ChannelHandlerContext.class); final ChannelPipeline pipeline = createMock(ChannelPipeline.class); final HttpMessage msg = createMock(HttpMessage.class); final HttpHeaders headers = createMock(HttpHeaders.class); expect(authenticator.getHMACAuthenticator()).andReturn(hmacAuth); expect(authenticator.getSimpleAuthenticator()).andReturn(createMock(JanusGraphSimpleAuthenticator.class)); expect(ctx.pipeline()).andReturn(pipeline).times(2); expect(pipeline.get("hmac_authenticator")).andReturn(null); expect(pipeline.addAfter(eq(PIPELINE_AUTHENTICATOR), eq("hmac_authenticator"), isA(ChannelHandler.class))).andReturn(null); expect(msg.headers()).andReturn(headers).times(2); expect(headers.get(isA(String.class))).andReturn(null).times(2); expect(ctx.fireChannelRead(eq(msg))).andReturn(ctx); replayAll(); final SaslAndHMACAuthenticationHandler handler = new SaslAndHMACAuthenticationHandler(authenticator, null); handler.channelRead(ctx, msg); }
@Override public void channelRead(final ChannelHandlerContext ctx, final Object obj) throws Exception { if (obj instanceof HttpMessage && !isWebSocket((HttpMessage)obj)) { if (null == ctx.pipeline().get(HMAC_AUTH)) { final HttpHMACAuthenticationHandler authHandler = new HttpHMACAuthenticationHandler(hmacAuthenticator); ctx.pipeline().addAfter(PIPELINE_AUTHENTICATOR, HMAC_AUTH, authHandler); } ctx.fireChannelRead(obj); } else { super.channelRead(ctx, obj); } }
SaslAndHMACAuthenticationHandler extends SaslAuthenticationHandler { @Override public void channelRead(final ChannelHandlerContext ctx, final Object obj) throws Exception { if (obj instanceof HttpMessage && !isWebSocket((HttpMessage)obj)) { if (null == ctx.pipeline().get(HMAC_AUTH)) { final HttpHMACAuthenticationHandler authHandler = new HttpHMACAuthenticationHandler(hmacAuthenticator); ctx.pipeline().addAfter(PIPELINE_AUTHENTICATOR, HMAC_AUTH, authHandler); } ctx.fireChannelRead(obj); } else { super.channelRead(ctx, obj); } } }
SaslAndHMACAuthenticationHandler extends SaslAuthenticationHandler { @Override public void channelRead(final ChannelHandlerContext ctx, final Object obj) throws Exception { if (obj instanceof HttpMessage && !isWebSocket((HttpMessage)obj)) { if (null == ctx.pipeline().get(HMAC_AUTH)) { final HttpHMACAuthenticationHandler authHandler = new HttpHMACAuthenticationHandler(hmacAuthenticator); ctx.pipeline().addAfter(PIPELINE_AUTHENTICATOR, HMAC_AUTH, authHandler); } ctx.fireChannelRead(obj); } else { super.channelRead(ctx, obj); } } SaslAndHMACAuthenticationHandler(final Authenticator authenticator, final Settings.AuthenticationSettings authenticationSettings); }
SaslAndHMACAuthenticationHandler extends SaslAuthenticationHandler { @Override public void channelRead(final ChannelHandlerContext ctx, final Object obj) throws Exception { if (obj instanceof HttpMessage && !isWebSocket((HttpMessage)obj)) { if (null == ctx.pipeline().get(HMAC_AUTH)) { final HttpHMACAuthenticationHandler authHandler = new HttpHMACAuthenticationHandler(hmacAuthenticator); ctx.pipeline().addAfter(PIPELINE_AUTHENTICATOR, HMAC_AUTH, authHandler); } ctx.fireChannelRead(obj); } else { super.channelRead(ctx, obj); } } SaslAndHMACAuthenticationHandler(final Authenticator authenticator, final Settings.AuthenticationSettings authenticationSettings); @Override void channelRead(final ChannelHandlerContext ctx, final Object obj); }
SaslAndHMACAuthenticationHandler extends SaslAuthenticationHandler { @Override public void channelRead(final ChannelHandlerContext ctx, final Object obj) throws Exception { if (obj instanceof HttpMessage && !isWebSocket((HttpMessage)obj)) { if (null == ctx.pipeline().get(HMAC_AUTH)) { final HttpHMACAuthenticationHandler authHandler = new HttpHMACAuthenticationHandler(hmacAuthenticator); ctx.pipeline().addAfter(PIPELINE_AUTHENTICATOR, HMAC_AUTH, authHandler); } ctx.fireChannelRead(obj); } else { super.channelRead(ctx, obj); } } SaslAndHMACAuthenticationHandler(final Authenticator authenticator, final Settings.AuthenticationSettings authenticationSettings); @Override void channelRead(final ChannelHandlerContext ctx, final Object obj);  }