public Optional<UserIdentity> fetchVerifiedIdentity(final HttpServletRequest request) {
        final String token = NullSafe.get(
                request.getHeader(HttpHeaders.AUTHORIZATION),
                header -> header.replace(JwtUtil.BEARER_PREFIX, ""));

        // We need to do a basic check to see if it looks like an API key else we will fill the cache with
        // JWT tokens mapped to empty Optionals.
        if (!NullSafe.isBlankString(token)
            && token.startsWith(ApiKeyGenerator.API_KEY_STATIC_PREFIX)) {

            final Optional<UserIdentity> optUserIdentity = apiKeyToAuthenticatedUserCache.get(token);

            if (optUserIdentity.isEmpty() && apiKeyGenerator.isApiKey(token)) {
                // Stops the next filter from trying to authenticate it
                throw new AuthenticationException("API key failed authentication");
            }
            return optUserIdentity;
        } else {
            return Optional.empty();
        }
    }
Fetch the verified {@link UserIdentity} for the passed API key.
If the hash of the API key matches one in the database and that key is enabled
and not expired then the {@link UserIdentity} will be returned, else an empty {@link Optional}
is returned.
stroom-security/stroom-security-impl/src/main/java/stroom/security/impl/apikey/ApiKeyService.java