@Override
    public void filter(ContainerRequestContext context)
    {
        if (internalAuthenticationManager.isInternalRequest(context) ||
                (internalAuthenticationManager.isInternalJwtEnabled() && isAccessingInternalEndpoint(resourceInfo))) {
            Principal authenticatedPrincipal = internalAuthenticationManager.authenticateInternalRequest(context);
            if (authenticatedPrincipal == null) {
                ResponseBuilder responseBuilder = Response.serverError();
                responseBuilder.status(SC_UNAUTHORIZED, "Unauthorized");
                context.abortWith(responseBuilder.build());
            }
            else {
                principal = Optional.of(authenticatedPrincipal);
            }
        }
    }
@Test
    public void testJwtAuthenticationRejectsWithNoBearerTokenJwtEnabled()
    {
        String sharedSecret = "secret";
        boolean internalJwtEnabled = true;

        InternalAuthenticationManager internalAuthenticationManager = new InternalAuthenticationManager(Optional.of(sharedSecret), "nodeId", internalJwtEnabled);
        InternalAuthenticationFilter internalAuthenticationFilter =
                new InternalAuthenticationFilter(internalAuthenticationManager, new ResourceInfoBuilder(TaskResource.class, null, null).build());

        MockContainerRequestContext containerRequestContext = new MockContainerRequestContext(ImmutableListMultimap.of());

        internalAuthenticationFilter.filter(containerRequestContext);

        assertEquals(containerRequestContext.getResponse().getStatus(), SC_UNAUTHORIZED);
        assertEquals("Unauthorized", containerRequestContext.getResponse().getStatusInfo().getReasonPhrase());
    }