### Question:
AmbariJwtAuthenticationFilter implements AmbariAuthenticationFilter { boolean validateSignature(SignedJWT jwtToken) { boolean valid = false; if (JWSObject.State.SIGNED == jwtToken.getState()) { LOG.debug("JWT token is in a SIGNED state"); if (jwtToken.getSignature() != null) { LOG.debug("JWT token signature is not null"); JwtAuthenticationProperties jwtProperties = propertiesProvider.get(); RSAPublicKey publicKey = (jwtProperties == null) ? null : jwtProperties.getPublicKey(); if (publicKey == null) { LOG.warn("SSO server public key has not be set, validation of the JWT token cannot be performed."); } else { try { JWSVerifier verifier = new RSASSAVerifier(publicKey); if (jwtToken.verify(verifier)) { valid = true; LOG.debug("JWT token has been successfully verified"); } else { LOG.warn("JWT signature verification failed."); } } catch (JOSEException je) { LOG.warn("Error while validating signature", je); } } } } return valid; } AmbariJwtAuthenticationFilter(AuthenticationEntryPoint ambariEntryPoint,
                                JwtAuthenticationPropertiesProvider propertiesProvider,
                                AmbariJwtAuthenticationProvider authenticationProvider,
                                AmbariAuthenticationEventHandler eventHandler); @Override boolean shouldApply(HttpServletRequest httpServletRequest); @Override boolean shouldIncrementFailureCount(); @Override void init(FilterConfig filterConfig); @Override void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain); @Override void destroy();  }### Answer:
@Test public void testValidateSignature() throws Exception { JwtAuthenticationPropertiesProvider jwtAuthenticationPropertiesProvider = createMock(JwtAuthenticationPropertiesProvider.class); expect(jwtAuthenticationPropertiesProvider.get()).andReturn(createTestProperties()).anyTimes(); AmbariAuthenticationEventHandler eventHandler = createNiceMock(AmbariAuthenticationEventHandler.class); replayAll(); AmbariJwtAuthenticationFilter filter = new AmbariJwtAuthenticationFilter(null, jwtAuthenticationPropertiesProvider, null, eventHandler); assertTrue(filter.validateSignature(getSignedToken())); assertFalse(filter.validateSignature(getInvalidToken())); verifyAll(); }