public HashedApiKey update(final HashedApiKey apiKey) {
        return securityContext.secureResult(AppPermission.MANAGE_API_KEYS, () -> {
            checkAdditionalPerms(apiKey.getOwner());
            final HashedApiKey apiKeyBefore = apiKeyDao.fetch(apiKey.getId())
                    .orElseThrow(() -> new RuntimeException("API Key not found with ID " + apiKey.getId()));
            if (apiKeyBefore.getEnabled() != apiKey.getEnabled()) {
                // Enabled state has changed so invalidate the cache
                invalidateApiKeyCacheEntry(apiKeyBefore);
            }
            return apiKeyDao.update(apiKey);
        });
    }
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