class KnoxAuthenticationFilter extends NiFiAuthenticationFilter {

    @Override
    public Authentication attemptAuthentication(final HttpServletRequest request) {
        // only support knox login when running securely
        if (!request.isSecure()) {
            return null;
        }

        // ensure knox sso support is enabled
        final NiFiProperties properties = getProperties();
        if (!properties.isKnoxSsoEnabled()) {
            return null;
        }

        // get the principal out of the user token
        final String knoxJwt = getJwtFromCookie(request, properties.getKnoxCookieName());

        // if there is no cookie, return null to attempt another authentication
        if (knoxJwt == null) {
            return null;
        } else {
            // otherwise create the authentication request token
            return new KnoxAuthenticationRequestToken(knoxJwt, request.getRemoteAddr());
        }
    }

}