### Description

The [Get API key information API](https://www.elastic.co/guide/en/elasticsearch/reference/master/security-api-get-api-key.html) can currently filter the returned keys by:
 * key id/name
 * keys owned by the calling user
 * keys owned by other users, by `realm_name` and `username`

Irrespective of the filtering used, both invalidated and expired (but not yet deleted) keys will be included in the response.
In the response, keys have the `invalidated` boolean property, as well as the `expiration` property that contains the UNIX timestamp past of which the key is no longer valid for authentication.

I propose we introduce a way for the API to support retrieving:
* only valid API keys (not return invalidated keys) - using a boolean request parameter
* keys not expired before a certain timestamp - using a timestamp parameter that defaults to "now" - also note that keys' experiation date is always checked against the local node's clock
x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/ApiKeyServiceTests.java
),
            metadataBytes
        );
    }
    @SuppressWarnings("unchecked")
    private void checkAuthApiKeyMetadata(Object metadata, AuthenticationResult<User> authResult1) throws IOException {
        if (metadata == null) {
            assertThat(authResult1.getMetadata().containsKey(API_KEY_METADATA_KEY), is(false));
        } else {
            assertThat(
                authResult1.getMetadata().get(API_KEY_METADATA_KEY),
                equalTo(XContentTestUtils.convertToXContent((Map<String, Object>) metadata, XContentType.JSON))
            );
        }
    }
    private RoleReference.ApiKeyRoleType randomApiKeyRoleType() {
        return randomFrom(RoleReference.ApiKeyRoleType.values());
    }
    private ApiKeyCredentials getApiKeyCredentials(String id, String key, ApiKey.Type type) {
        return new ApiKeyCredentials(id, new SecureString(key.toCharArray()), type);
    }
    private ApiKey.Type parseTypeFromSourceMap(Map<String, Object> sourceMap) {
        if (sourceMap.containsKey("type")) {
            return ApiKey.Type.parse((String) sourceMap.get("type"));
        } else {
            return ApiKey.Type.REST;
        }
    }
}