Skip to content

Commit 03fa3a6

Browse files
committed
Merge branch 'master' into security_api_keys
2 parents 5b6c3a2 + baf33b3 commit 03fa3a6

File tree

102 files changed

+2174
-1002
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+2174
-1002
lines changed

buildSrc/src/main/resources/checkstyle_suppressions.xml

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -45,38 +45,6 @@
4545

4646
<!-- Hopefully temporary suppression of LineLength on files that don't pass it. We should remove these when we the
4747
files start to pass. -->
48-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]admin[/\\]cluster[/\\]health[/\\]ClusterHealthRequestBuilder.java" checks="LineLength" />
49-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]admin[/\\]cluster[/\\]health[/\\]TransportClusterHealthAction.java" checks="LineLength" />
50-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]admin[/\\]cluster[/\\]node[/\\]hotthreads[/\\]NodesHotThreadsRequestBuilder.java" checks="LineLength" />
51-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]admin[/\\]cluster[/\\]node[/\\]stats[/\\]NodesStatsRequestBuilder.java" checks="LineLength" />
52-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]admin[/\\]cluster[/\\]repositories[/\\]delete[/\\]DeleteRepositoryRequestBuilder.java" checks="LineLength" />
53-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]admin[/\\]cluster[/\\]repositories[/\\]delete[/\\]TransportDeleteRepositoryAction.java" checks="LineLength" />
54-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]admin[/\\]cluster[/\\]repositories[/\\]get[/\\]GetRepositoriesRequestBuilder.java" checks="LineLength" />
55-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]admin[/\\]cluster[/\\]repositories[/\\]get[/\\]TransportGetRepositoriesAction.java" checks="LineLength" />
56-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]admin[/\\]cluster[/\\]repositories[/\\]put[/\\]PutRepositoryRequestBuilder.java" checks="LineLength" />
57-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]admin[/\\]cluster[/\\]repositories[/\\]put[/\\]TransportPutRepositoryAction.java" checks="LineLength" />
58-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]admin[/\\]cluster[/\\]repositories[/\\]verify[/\\]TransportVerifyRepositoryAction.java" checks="LineLength" />
59-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]admin[/\\]cluster[/\\]repositories[/\\]verify[/\\]VerifyRepositoryRequestBuilder.java" checks="LineLength" />
60-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]admin[/\\]cluster[/\\]reroute[/\\]TransportClusterRerouteAction.java" checks="LineLength" />
61-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]admin[/\\]cluster[/\\]settings[/\\]ClusterUpdateSettingsRequestBuilder.java" checks="LineLength" />
62-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]admin[/\\]cluster[/\\]shards[/\\]ClusterSearchShardsRequestBuilder.java" checks="LineLength" />
63-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]admin[/\\]cluster[/\\]shards[/\\]TransportClusterSearchShardsAction.java" checks="LineLength" />
64-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]admin[/\\]cluster[/\\]snapshots[/\\]create[/\\]CreateSnapshotRequestBuilder.java" checks="LineLength" />
65-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]admin[/\\]cluster[/\\]snapshots[/\\]create[/\\]TransportCreateSnapshotAction.java" checks="LineLength" />
66-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]admin[/\\]cluster[/\\]snapshots[/\\]delete[/\\]DeleteSnapshotRequestBuilder.java" checks="LineLength" />
67-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]admin[/\\]cluster[/\\]snapshots[/\\]delete[/\\]TransportDeleteSnapshotAction.java" checks="LineLength" />
68-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]admin[/\\]cluster[/\\]snapshots[/\\]get[/\\]GetSnapshotsRequestBuilder.java" checks="LineLength" />
69-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]admin[/\\]cluster[/\\]snapshots[/\\]restore[/\\]RestoreSnapshotRequestBuilder.java" checks="LineLength" />
70-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]admin[/\\]cluster[/\\]snapshots[/\\]restore[/\\]TransportRestoreSnapshotAction.java" checks="LineLength" />
71-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]admin[/\\]cluster[/\\]snapshots[/\\]status[/\\]SnapshotsStatusRequestBuilder.java" checks="LineLength" />
72-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]admin[/\\]cluster[/\\]snapshots[/\\]status[/\\]TransportSnapshotsStatusAction.java" checks="LineLength" />
73-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]admin[/\\]cluster[/\\]state[/\\]ClusterStateRequestBuilder.java" checks="LineLength" />
74-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]admin[/\\]cluster[/\\]state[/\\]TransportClusterStateAction.java" checks="LineLength" />
75-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]admin[/\\]cluster[/\\]stats[/\\]ClusterStatsNodeResponse.java" checks="LineLength" />
76-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]admin[/\\]cluster[/\\]stats[/\\]ClusterStatsRequestBuilder.java" checks="LineLength" />
77-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]admin[/\\]cluster[/\\]stats[/\\]TransportClusterStatsAction.java" checks="LineLength" />
78-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]admin[/\\]cluster[/\\]tasks[/\\]PendingClusterTasksRequestBuilder.java" checks="LineLength" />
79-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]admin[/\\]cluster[/\\]tasks[/\\]TransportPendingClusterTasksAction.java" checks="LineLength" />
8048
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]search[/\\]MultiSearchRequestBuilder.java" checks="LineLength" />
8149
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]search[/\\]SearchPhaseController.java" checks="LineLength" />
8250
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]termvectors[/\\]MultiTermVectorsRequest.java" checks="LineLength" />
@@ -185,12 +153,6 @@
185153
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]VersionTests.java" checks="LineLength" />
186154
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]RejectionActionIT.java" checks="LineLength" />
187155
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]admin[/\\]HotThreadsIT.java" checks="LineLength" />
188-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]admin[/\\]cluster[/\\]health[/\\]ClusterHealthResponsesTests.java" checks="LineLength" />
189-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]admin[/\\]cluster[/\\]repositories[/\\]RepositoryBlocksIT.java" checks="LineLength" />
190-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]admin[/\\]cluster[/\\]settings[/\\]SettingsUpdaterTests.java" checks="LineLength" />
191-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]admin[/\\]cluster[/\\]snapshots[/\\]SnapshotBlocksIT.java" checks="LineLength" />
192-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]admin[/\\]cluster[/\\]state[/\\]ClusterStateRequestTests.java" checks="LineLength" />
193-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]admin[/\\]cluster[/\\]stats[/\\]ClusterStatsIT.java" checks="LineLength" />
194156
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]search[/\\]SearchRequestBuilderTests.java" checks="LineLength" />
195157
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]termvectors[/\\]AbstractTermVectorsTestCase.java" checks="LineLength" />
196158
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]termvectors[/\\]GetTermVectorsIT.java" checks="LineLength" />

buildSrc/src/test/java/org/elasticsearch/gradle/BuildExamplePluginsIT.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import org.elasticsearch.gradle.test.GradleIntegrationTestCase;
2424
import org.gradle.testkit.runner.GradleRunner;
2525
import org.junit.BeforeClass;
26-
import org.junit.Ignore;
2726
import org.junit.Rule;
2827
import org.junit.rules.TemporaryFolder;
2928

@@ -39,7 +38,6 @@
3938
import java.util.Objects;
4039
import java.util.stream.Collectors;
4140

42-
@Ignore
4341
public class BuildExamplePluginsIT extends GradleIntegrationTestCase {
4442

4543
private static List<File> EXAMPLE_PLUGINS = Collections.unmodifiableList(

client/rest-high-level/src/main/java/org/elasticsearch/client/RollupClient.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
package org.elasticsearch.client;
2121

2222
import org.elasticsearch.action.ActionListener;
23+
import org.elasticsearch.client.core.AcknowledgedResponse;
2324
import org.elasticsearch.client.rollup.DeleteRollupJobRequest;
24-
import org.elasticsearch.client.rollup.DeleteRollupJobResponse;
2525
import org.elasticsearch.client.rollup.GetRollupIndexCapsRequest;
2626
import org.elasticsearch.client.rollup.GetRollupIndexCapsResponse;
2727
import org.elasticsearch.client.rollup.GetRollupJobRequest;
@@ -31,7 +31,6 @@
3131
import org.elasticsearch.client.rollup.GetRollupJobRequest;
3232
import org.elasticsearch.client.rollup.GetRollupJobResponse;
3333
import org.elasticsearch.client.rollup.PutRollupJobRequest;
34-
import org.elasticsearch.client.rollup.PutRollupJobResponse;
3534
import org.elasticsearch.client.rollup.StartRollupJobRequest;
3635
import org.elasticsearch.client.rollup.StartRollupJobResponse;
3736
import org.elasticsearch.client.rollup.StopRollupJobRequest;
@@ -64,11 +63,11 @@ public class RollupClient {
6463
* @return the response
6564
* @throws IOException in case there is a problem sending the request or parsing back the response
6665
*/
67-
public PutRollupJobResponse putRollupJob(PutRollupJobRequest request, RequestOptions options) throws IOException {
66+
public AcknowledgedResponse putRollupJob(PutRollupJobRequest request, RequestOptions options) throws IOException {
6867
return restHighLevelClient.performRequestAndParseEntity(request,
6968
RollupRequestConverters::putJob,
7069
options,
71-
PutRollupJobResponse::fromXContent,
70+
AcknowledgedResponse::fromXContent,
7271
Collections.emptySet());
7372
}
7473

@@ -80,11 +79,11 @@ public PutRollupJobResponse putRollupJob(PutRollupJobRequest request, RequestOpt
8079
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
8180
* @param listener the listener to be notified upon request completion
8281
*/
83-
public void putRollupJobAsync(PutRollupJobRequest request, RequestOptions options, ActionListener<PutRollupJobResponse> listener) {
82+
public void putRollupJobAsync(PutRollupJobRequest request, RequestOptions options, ActionListener<AcknowledgedResponse> listener) {
8483
restHighLevelClient.performRequestAsyncAndParseEntity(request,
8584
RollupRequestConverters::putJob,
8685
options,
87-
PutRollupJobResponse::fromXContent,
86+
AcknowledgedResponse::fromXContent,
8887
listener, Collections.emptySet());
8988
}
9089

@@ -165,11 +164,11 @@ public void stopRollupJobAsync(StopRollupJobRequest request, RequestOptions opti
165164
* @return the response
166165
* @throws IOException in case there is a problem sending the request or parsing back the response
167166
*/
168-
public DeleteRollupJobResponse deleteRollupJob(DeleteRollupJobRequest request, RequestOptions options) throws IOException {
167+
public AcknowledgedResponse deleteRollupJob(DeleteRollupJobRequest request, RequestOptions options) throws IOException {
169168
return restHighLevelClient.performRequestAndParseEntity(request,
170169
RollupRequestConverters::deleteJob,
171170
options,
172-
DeleteRollupJobResponse::fromXContent,
171+
AcknowledgedResponse::fromXContent,
173172
Collections.emptySet());
174173
}
175174
/**
@@ -182,11 +181,11 @@ public DeleteRollupJobResponse deleteRollupJob(DeleteRollupJobRequest request, R
182181
*/
183182
public void deleteRollupJobAsync(DeleteRollupJobRequest request,
184183
RequestOptions options,
185-
ActionListener<DeleteRollupJobResponse> listener) {
184+
ActionListener<AcknowledgedResponse> listener) {
186185
restHighLevelClient.performRequestAsyncAndParseEntity(request,
187186
RollupRequestConverters::deleteJob,
188187
options,
189-
DeleteRollupJobResponse::fromXContent,
188+
AcknowledgedResponse::fromXContent,
190189
listener, Collections.emptySet());
191190
}
192191

client/rest-high-level/src/main/java/org/elasticsearch/client/SecurityClient.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
import org.elasticsearch.client.security.GetRoleMappingsResponse;
4343
import org.elasticsearch.client.security.GetSslCertificatesRequest;
4444
import org.elasticsearch.client.security.GetSslCertificatesResponse;
45+
import org.elasticsearch.client.security.HasPrivilegesRequest;
46+
import org.elasticsearch.client.security.HasPrivilegesResponse;
4547
import org.elasticsearch.client.security.InvalidateTokenRequest;
4648
import org.elasticsearch.client.security.InvalidateTokenResponse;
4749
import org.elasticsearch.client.security.PutRoleMappingRequest;
@@ -244,6 +246,34 @@ public void authenticateAsync(RequestOptions options, ActionListener<Authenticat
244246
AuthenticateResponse::fromXContent, listener, emptySet());
245247
}
246248

249+
/**
250+
* Determine whether the current user has a specified list of privileges
251+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-has-privileges.html">
252+
* the docs</a> for more.
253+
*
254+
* @param request the request with the privileges to check
255+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
256+
* @return the response from the has privileges call
257+
*/
258+
public HasPrivilegesResponse hasPrivileges(HasPrivilegesRequest request, RequestOptions options) throws IOException {
259+
return restHighLevelClient.performRequestAndParseEntity(request, SecurityRequestConverters::hasPrivileges, options,
260+
HasPrivilegesResponse::fromXContent, emptySet());
261+
}
262+
263+
/**
264+
* Asynchronously determine whether the current user has a specified list of privileges
265+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-has-privileges.html">
266+
* the docs</a> for more.
267+
*
268+
* @param request the request with the privileges to check
269+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
270+
* @param listener the listener to be notified upon request completion
271+
*/
272+
public void hasPrivilegesAsync(HasPrivilegesRequest request, RequestOptions options, ActionListener<HasPrivilegesResponse> listener) {
273+
restHighLevelClient.performRequestAsyncAndParseEntity(request, SecurityRequestConverters::hasPrivileges, options,
274+
HasPrivilegesResponse::fromXContent, listener, emptySet());
275+
}
276+
247277
/**
248278
* Clears the cache in one or more realms.
249279
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-clear-cache.html">

client/rest-high-level/src/main/java/org/elasticsearch/client/SecurityRequestConverters.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.elasticsearch.client.security.DeletePrivilegesRequest;
3131
import org.elasticsearch.client.security.DeleteRoleMappingRequest;
3232
import org.elasticsearch.client.security.DeleteRoleRequest;
33+
import org.elasticsearch.client.security.HasPrivilegesRequest;
3334
import org.elasticsearch.client.security.DisableUserRequest;
3435
import org.elasticsearch.client.security.EnableUserRequest;
3536
import org.elasticsearch.client.security.GetRoleMappingsRequest;
@@ -114,6 +115,12 @@ private static Request setUserEnabled(SetUserEnabledRequest setUserEnabledReques
114115
return request;
115116
}
116117

118+
static Request hasPrivileges(HasPrivilegesRequest hasPrivilegesRequest) throws IOException {
119+
Request request = new Request(HttpGet.METHOD_NAME, "/_xpack/security/user/_has_privileges");
120+
request.setEntity(createEntity(hasPrivilegesRequest, REQUEST_BODY_CONTENT_TYPE));
121+
return request;
122+
}
123+
117124
static Request clearRealmCache(ClearRealmCacheRequest clearRealmCacheRequest) {
118125
RequestConverters.EndpointBuilder builder = new RequestConverters.EndpointBuilder()
119126
.addPathPartAsIs("_xpack/security/realm");

client/rest-high-level/src/main/java/org/elasticsearch/client/core/AcknowledgedResponse.java

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@
2121

2222
import org.elasticsearch.common.ParseField;
2323
import org.elasticsearch.common.xcontent.ConstructingObjectParser;
24-
import org.elasticsearch.common.xcontent.ToXContent;
25-
import org.elasticsearch.common.xcontent.ToXContentObject;
26-
import org.elasticsearch.common.xcontent.XContentBuilder;
2724
import org.elasticsearch.common.xcontent.XContentParser;
2825

2926
import java.io.IOException;
@@ -32,7 +29,7 @@
3229

3330
import static org.elasticsearch.common.xcontent.ConstructingObjectParser.constructorArg;
3431

35-
public class AcknowledgedResponse implements ToXContentObject {
32+
public class AcknowledgedResponse {
3633

3734
protected static final String PARSE_FIELD_NAME = "acknowledged";
3835
private static final ConstructingObjectParser<AcknowledgedResponse, Void> PARSER = AcknowledgedResponse
@@ -75,16 +72,6 @@ public int hashCode() {
7572
return Objects.hash(acknowledged);
7673
}
7774

78-
@Override
79-
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException {
80-
builder.startObject();
81-
{
82-
builder.field(getFieldName(), isAcknowledged());
83-
}
84-
builder.endObject();
85-
return builder;
86-
}
87-
8875
/**
8976
* @return the field name this response uses to output the acknowledged flag
9077
*/

client/rest-high-level/src/main/java/org/elasticsearch/client/rollup/DeleteRollupJobResponse.java

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)