JWTAuthenticator implements WebappAuthenticator { @Override public boolean canHandle(Request request) { String authorizationHeader = request.getHeader(JWTAuthenticator.JWT_ASSERTION_HEADER); return (authorizationHeader != null) && !authorizationHeader.isEmpty(); }  @Override void init(); @Override boolean canHandle(Request request); @Override AuthenticationInfo authenticate(Request request, Response response); @Override String getName(); @Override Properties getProperties(); @Override void setProperties(Properties properties); @Override String getProperty(String name);  }
@Test(description = "This method tests the canHandle method under different conditions of request") public void testHandle() throws IllegalAccessException, NoSuchFieldException { Request request = new Request(); org.apache.coyote.Request coyoteRequest = new org.apache.coyote.Request(); request.setCoyoteRequest(coyoteRequest); Assert.assertFalse(jwtAuthenticator.canHandle(request)); MimeHeaders mimeHeaders = new MimeHeaders(); MessageBytes bytes = mimeHeaders.addValue(JWT_HEADER); bytes.setString("test"); headersField.set(coyoteRequest, mimeHeaders); request.setCoyoteRequest(coyoteRequest); Assert.assertTrue(jwtAuthenticator.canHandle(request)); }