Skip to content

Commit 1a746ce

Browse files
authored
Remove @UpdateForV9 annotations from Security code (#123176) (#124686)
1 parent f018381 commit 1a746ce

File tree

6 files changed

+11
-39
lines changed

6 files changed

+11
-39
lines changed

libs/core/src/main/java/org/elasticsearch/core/UpdateForV9.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ enum Owner {
2929
ENTERPRISE_SEARCH,
3030
MACHINE_LEARNING,
3131
PROFILING,
32-
SEARCH_ANALYTICS,
33-
SECURITY,
32+
SEARCH_ANALYTICS
3433
}
3534

3635
/**

x-pack/plugin/core/src/main/java/org/elasticsearch/license/License.java

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import org.elasticsearch.common.io.stream.StreamOutput;
1616
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
1717
import org.elasticsearch.common.xcontent.XContentHelper;
18-
import org.elasticsearch.core.UpdateForV9;
1918
import org.elasticsearch.xcontent.ToXContentObject;
2019
import org.elasticsearch.xcontent.XContentBuilder;
2120
import org.elasticsearch.xcontent.XContentParser;
@@ -137,13 +136,6 @@ static boolean isEnterprise(String typeName) {
137136
* to a specific license version
138137
*/
139138
public static final String LICENSE_VERSION_MODE = "license_version";
140-
/**
141-
* Set for RestApiVersion#V_7 requests only
142-
* XContent param name to map the "enterprise" license type to "platinum"
143-
* for backwards compatibility with older clients
144-
*/
145-
@UpdateForV9(owner = UpdateForV9.Owner.SECURITY) // v7 REST API no longer exists: eliminate ref to RestApiVersion.V_7
146-
public static final String XCONTENT_HIDE_ENTERPRISE = "hide_enterprise";
147139

148140
public static final Comparator<License> LATEST_ISSUE_DATE_FIRST = Comparator.comparing(License::issueDate).reversed();
149141

@@ -497,8 +489,6 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
497489
public XContentBuilder toInnerXContent(XContentBuilder builder, Params params) throws IOException {
498490
boolean licenseSpecMode = params.paramAsBoolean(LICENSE_SPEC_VIEW_MODE, false);
499491
boolean restViewMode = params.paramAsBoolean(REST_VIEW_MODE, false);
500-
boolean hideEnterprise = params.paramAsBoolean(XCONTENT_HIDE_ENTERPRISE, false);
501-
502492
boolean previouslyHumanReadable = builder.humanReadable();
503493
if (licenseSpecMode && restViewMode) {
504494
throw new IllegalArgumentException("can have either " + REST_VIEW_MODE + " or " + LICENSE_SPEC_VIEW_MODE);
@@ -517,8 +507,7 @@ public XContentBuilder toInnerXContent(XContentBuilder builder, Params params) t
517507
builder.field(Fields.STATUS, LicenseUtils.status(this).label());
518508
}
519509
builder.field(Fields.UID, uid);
520-
final String bwcType = hideEnterprise && LicenseType.isEnterprise(type) ? LicenseType.PLATINUM.getTypeName() : type;
521-
builder.field(Fields.TYPE, bwcType);
510+
builder.field(Fields.TYPE, type);
522511
if (licenseVersion == VERSION_START) {
523512
builder.field(Fields.SUBSCRIPTION_TYPE, subscriptionType);
524513
}
@@ -534,8 +523,6 @@ public XContentBuilder toInnerXContent(XContentBuilder builder, Params params) t
534523
if (licenseVersion >= VERSION_ENTERPRISE) {
535524
builder.field(Fields.MAX_NODES, maxNodes == -1 ? null : maxNodes);
536525
builder.field(Fields.MAX_RESOURCE_UNITS, maxResourceUnits == -1 ? null : maxResourceUnits);
537-
} else if (hideEnterprise && maxNodes == -1) {
538-
builder.field(Fields.MAX_NODES, maxResourceUnits);
539526
} else {
540527
builder.field(Fields.MAX_NODES, maxNodes);
541528
}

x-pack/plugin/core/src/main/java/org/elasticsearch/license/RestGetLicenseAction.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import org.elasticsearch.common.logging.DeprecationCategory;
1212
import org.elasticsearch.common.logging.DeprecationLogger;
1313
import org.elasticsearch.common.util.Maps;
14-
import org.elasticsearch.core.UpdateForV9;
14+
import org.elasticsearch.core.UpdateForV10;
1515
import org.elasticsearch.protocol.xpack.license.GetLicenseRequest;
1616
import org.elasticsearch.rest.BaseRestHandler;
1717
import org.elasticsearch.rest.RestRequest;
@@ -55,22 +55,21 @@ public String getName() {
5555
* The licenses are sorted by latest issue_date
5656
*/
5757
@Override
58-
@UpdateForV9(owner = UpdateForV9.Owner.SECURITY) // remove support for accept_enterprise param
58+
@UpdateForV10(owner = UpdateForV10.Owner.SECURITY) // remove support for accept_enterprise param
5959
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
6060
final Map<String, String> overrideParams = Maps.newMapWithExpectedSize(2);
6161
overrideParams.put(License.REST_VIEW_MODE, "true");
6262
overrideParams.put(License.LICENSE_VERSION_MODE, String.valueOf(License.VERSION_CURRENT));
6363

64-
// In 7.x, there was an opt-in flag to show "enterprise" licenses. In 8.0 the flag is deprecated and can only be true
65-
// TODO Remove this from 9.0
64+
// In 7.x, there was an opt-in flag to show "enterprise" licenses. In 8.0+ the flag is deprecated and can only be true
6665
if (request.hasParam("accept_enterprise")) {
6766
deprecationLogger.warn(
6867
DeprecationCategory.API,
6968
"get_license_accept_enterprise",
7069
"Including [accept_enterprise] in get license requests is deprecated."
7170
+ " The parameter will be removed in the next major version"
7271
);
73-
if (request.paramAsBoolean("accept_enterprise", true) == false) {
72+
if (request.paramAsBoolean("accept_enterprise", true) == false) { // consumes the parameter to avoid error
7473
throw new IllegalArgumentException("The [accept_enterprise] parameters may not be false");
7574
}
7675
}

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rest/action/RestXPackInfoAction.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import org.elasticsearch.client.internal.node.NodeClient;
1010
import org.elasticsearch.common.logging.DeprecationCategory;
1111
import org.elasticsearch.common.logging.DeprecationLogger;
12-
import org.elasticsearch.core.UpdateForV9;
12+
import org.elasticsearch.core.UpdateForV10;
1313
import org.elasticsearch.protocol.xpack.XPackInfoRequest;
1414
import org.elasticsearch.rest.BaseRestHandler;
1515
import org.elasticsearch.rest.RestRequest;
@@ -41,22 +41,21 @@ public String getName() {
4141
}
4242

4343
@Override
44-
@UpdateForV9(owner = UpdateForV9.Owner.SECURITY) // accept_enterprise parameter no longer supported?
44+
@UpdateForV10(owner = UpdateForV10.Owner.SECURITY) // remove once accept_enterprise parameter no longer supported
4545
public RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException {
4646

4747
// we piggyback verbosity on "human" output
4848
boolean verbose = request.paramAsBoolean("human", true);
4949

5050
// In 7.x, there was an opt-in flag to show "enterprise" licenses. In 8.0 the flag is deprecated and can only be true
51-
// TODO Remove this from 9.0
5251
if (request.hasParam("accept_enterprise")) {
5352
deprecationLogger.warn(
5453
DeprecationCategory.API,
5554
"get_license_accept_enterprise",
5655
"Including [accept_enterprise] in get license requests is deprecated."
5756
+ " The parameter will be removed in the next major version"
5857
);
59-
if (request.paramAsBoolean("accept_enterprise", true) == false) {
58+
if (request.paramAsBoolean("accept_enterprise", true) == false) { // consumes the parameter to avoid error
6059
throw new IllegalArgumentException("The [accept_enterprise] parameters may not be false");
6160
}
6261
}

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/settings/GetSecuritySettingsAction.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import org.elasticsearch.common.io.stream.StreamOutput;
1717
import org.elasticsearch.common.settings.Settings;
1818
import org.elasticsearch.core.TimeValue;
19-
import org.elasticsearch.core.UpdateForV9;
2019
import org.elasticsearch.xcontent.ToXContentObject;
2120
import org.elasticsearch.xcontent.XContentBuilder;
2221

@@ -40,13 +39,8 @@ public Request(TimeValue masterNodeTimeout) {
4039
super(masterNodeTimeout);
4140
}
4241

43-
@UpdateForV9(owner = UpdateForV9.Owner.SECURITY) // no need for bwc any more, this can be inlined
4442
public static Request readFrom(StreamInput in) throws IOException {
45-
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_15_0)) {
46-
return new Request(in);
47-
} else {
48-
return new Request(TimeValue.THIRTY_SECONDS);
49-
}
43+
return new Request(in);
5044
}
5145

5246
private Request(StreamInput in) throws IOException {

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/settings/UpdateSecuritySettingsAction.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import org.elasticsearch.common.io.stream.StreamInput;
1919
import org.elasticsearch.common.io.stream.StreamOutput;
2020
import org.elasticsearch.core.TimeValue;
21-
import org.elasticsearch.core.UpdateForV9;
2221
import org.elasticsearch.xcontent.ConstructingObjectParser;
2322
import org.elasticsearch.xcontent.ParseField;
2423
import org.elasticsearch.xcontent.XContentParser;
@@ -116,13 +115,8 @@ public Request(
116115
this.profilesIndexSettings = Objects.requireNonNullElse(profilesIndexSettings, Collections.emptyMap());
117116
}
118117

119-
@UpdateForV9(owner = UpdateForV9.Owner.SECURITY) // no need for bwc any more, this can be inlined
120118
public static Request readFrom(StreamInput in) throws IOException {
121-
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_15_0)) {
122-
return new Request(in);
123-
} else {
124-
return new Request(TimeValue.THIRTY_SECONDS, TimeValue.THIRTY_SECONDS, in);
125-
}
119+
return new Request(in);
126120
}
127121

128122
private Request(StreamInput in) throws IOException {

0 commit comments

Comments
 (0)