From 8eabbf1d1320faaa0288c846a7979baa823c61f1 Mon Sep 17 00:00:00 2001 From: Yang Wang Date: Mon, 10 Feb 2020 13:22:29 +1100 Subject: [PATCH 1/7] Continue refactor license checking --- .../elasticsearch/license/LicenseService.java | 4 +- .../license/XPackLicenseState.java | 100 ++++++++++-------- .../core/ml/inference/TrainedModelConfig.java | 5 +- .../AbstractLicensesIntegrationTestCase.java | 2 +- .../ml/inference/TrainedModelConfigTests.java | 77 ++++++++------ 5 files changed, 104 insertions(+), 84 deletions(-) diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/LicenseService.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/LicenseService.java index 484f97f4a26ae..3dc3eea374636 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/LicenseService.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/LicenseService.java @@ -255,9 +255,7 @@ && isProductionMode(settings, clusterService.localNode())) { throw new IllegalStateException("Cannot install a [" + newLicense.operationMode() + "] license unless TLS is configured or security is disabled"); } else if (XPackSettings.FIPS_MODE_ENABLED.get(settings) - && newLicense.operationMode() != License.OperationMode.PLATINUM - && newLicense.operationMode() != License.OperationMode.ENTERPRISE - && newLicense.operationMode() != License.OperationMode.TRIAL) { + && XPackLicenseState.isAllowedByOperationMode(newLicense.operationMode(), License.OperationMode.PLATINUM, true)) { throw new IllegalStateException("Cannot install a [" + newLicense.operationMode() + "] license unless FIPS mode is disabled"); } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/XPackLicenseState.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/XPackLicenseState.java index 51d1a6d24525f..20bc976998602 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/XPackLicenseState.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/XPackLicenseState.java @@ -343,7 +343,7 @@ public synchronized OperationMode getOperationMode() { } /** Return true if the license is currently within its time boundaries, false otherwise. */ - public synchronized boolean isActive() { + public synchronized boolean allowForAllLicenses() { return status.active; } @@ -352,21 +352,21 @@ public synchronized boolean isActive() { * @see #allowedRealmType() for the enabled realms */ public boolean isAuthAllowed() { - return isAllowedByLicenseAndSecurity(OperationMode.BASIC, true, false, true); + return isAllowedBySecurityAndLicense(OperationMode.BASIC, false, true); } /** * @return true if IP filtering should be enabled */ public boolean isIpFilteringAllowed() { - return isAllowedByLicenseAndSecurity(OperationMode.GOLD, true, false, true); + return isAllowedBySecurityAndLicense(OperationMode.GOLD, false, true); } /** * @return true if auditing should be enabled */ public boolean isAuditingAllowed() { - return isAllowedByLicenseAndSecurity(OperationMode.GOLD, true, false, true); + return isAllowedBySecurityAndLicense(OperationMode.GOLD, false, true); } /** @@ -376,7 +376,7 @@ public boolean isAuditingAllowed() { * @return true if the license allows for the stats and health APIs to be used. */ public boolean isStatsAndHealthAllowed() { - return isActive(); + return allowForAllLicenses(); } /** @@ -392,7 +392,7 @@ public boolean isStatsAndHealthAllowed() { * @return {@code true} to enable DLS and FLS. Otherwise {@code false}. */ public boolean isDocumentAndFieldLevelSecurityAllowed() { - return isAllowedByLicenseAndSecurity(OperationMode.PLATINUM, true, false, true); + return isAllowedBySecurityAndLicense(OperationMode.PLATINUM, false, true); } /** Classes of realms that may be available based on the license type. */ @@ -432,21 +432,21 @@ public synchronized AllowedRealmType allowedRealmType() { * @return whether custom role providers are allowed based on the license {@link OperationMode} */ public boolean isCustomRoleProvidersAllowed() { - return isAllowedByLicenseAndSecurity(OperationMode.PLATINUM, true, true, true); + return isAllowedBySecurityAndLicense(OperationMode.PLATINUM, true, true); } /** * @return whether the Elasticsearch {@code TokenService} is allowed based on the license {@link OperationMode} */ public boolean isTokenServiceAllowed() { - return isAllowedByLicenseAndSecurity(OperationMode.GOLD, true, false, true); + return isAllowedBySecurityAndLicense(OperationMode.GOLD, false, true); } /** * @return whether the Elasticsearch {@code ApiKeyService} is allowed based on the current node/cluster state */ public boolean isApiKeyServiceAllowed() { - return isAllowedBySecurity(); + return isAllowedBySecurityAndLicense(OperationMode.MISSING, false, true); } /** @@ -454,7 +454,7 @@ public boolean isApiKeyServiceAllowed() { * @see org.elasticsearch.xpack.core.security.authc.support.DelegatedAuthorizationSettings */ public boolean isAuthorizationRealmAllowed() { - return isAllowedByLicenseAndSecurity(OperationMode.PLATINUM, true, true, true); + return isAllowedBySecurityAndLicense(OperationMode.PLATINUM, true, true); } /** @@ -462,7 +462,7 @@ public boolean isAuthorizationRealmAllowed() { * @see org.elasticsearch.xpack.core.security.authc.support.DelegatedAuthorizationSettings */ public boolean isAuthorizationEngineAllowed() { - return isAllowedByLicenseAndSecurity(OperationMode.PLATINUM, true, true, true); + return isAllowedBySecurityAndLicense(OperationMode.PLATINUM, true, true); } /** @@ -479,7 +479,7 @@ public boolean isAuthorizationEngineAllowed() { * @return {@code true} as long as the license is valid. Otherwise {@code false}. */ public boolean isWatcherAllowed() { - return isAllowedByLicenseAndSecurity(OperationMode.STANDARD, false, true, true); + return isAllowedByLicense(OperationMode.STANDARD, true, true); } /** @@ -488,7 +488,7 @@ public boolean isWatcherAllowed() { * @return true if the license is active */ public boolean isMonitoringAllowed() { - return isActive(); + return allowForAllLicenses(); } /** @@ -511,7 +511,7 @@ public boolean isMonitoringClusterAlertsAllowed() { * @return {@code true} if the user is allowed to modify the retention. Otherwise {@code false}. */ public boolean isUpdateRetentionAllowed() { - return isAllowedByLicenseAndSecurity(OperationMode.STANDARD, false, false, true); + return isAllowedByLicense(OperationMode.STANDARD, false, true); } /** @@ -526,7 +526,7 @@ public boolean isUpdateRetentionAllowed() { * @return {@code true} as long as the license is valid. Otherwise {@code false}. */ public boolean isGraphAllowed() { - return isAllowedByLicenseAndSecurity(OperationMode.PLATINUM, false, true, true); + return isAllowedByLicense(OperationMode.PLATINUM, true, true); } /** @@ -543,7 +543,7 @@ public boolean isGraphAllowed() { * {@code false}. */ public boolean isMachineLearningAllowed() { - return isAllowedByLicenseAndSecurity(OperationMode.PLATINUM, false, true, true); + return isAllowedByLicense(OperationMode.PLATINUM, true, true); } public static boolean isMachineLearningAllowedForOperationMode(final OperationMode operationMode) { @@ -556,7 +556,7 @@ public static boolean isMachineLearningAllowedForOperationMode(final OperationMo * @return true if the license is active */ public boolean isTransformAllowed() { - return isActive(); + return allowForAllLicenses(); } public static boolean isTransformAllowedForOperationMode(final OperationMode operationMode) { @@ -574,7 +574,7 @@ public static boolean isFipsAllowedForOperationMode(final OperationMode operatio * @return true if the license is active */ public boolean isRollupAllowed() { - return isActive(); + return allowForAllLicenses(); } /** @@ -583,7 +583,7 @@ public boolean isRollupAllowed() { * @return true if the license is active */ public boolean isVotingOnlyAllowed() { - return isActive(); + return allowForAllLicenses(); } /** @@ -591,7 +591,7 @@ public boolean isVotingOnlyAllowed() { * @return {@code true} as long as there is a valid license */ public boolean isLogstashAllowed() { - return isAllowedByLicenseAndSecurity(OperationMode.STANDARD, false, true, true); + return isAllowedByLicense(OperationMode.STANDARD, true, true); } /** @@ -599,7 +599,7 @@ public boolean isLogstashAllowed() { * @return {@code true} as long as there is a valid license */ public boolean isBeatsAllowed() { - return isAllowedByLicenseAndSecurity(OperationMode.STANDARD, false, true, true); + return isAllowedByLicense(OperationMode.STANDARD, true, true); } /** @@ -607,7 +607,7 @@ public boolean isBeatsAllowed() { * @return {@code true} as long as there is a valid license */ public boolean isDeprecationAllowed() { - return isActive(); + return allowForAllLicenses(); } /** @@ -617,7 +617,7 @@ public boolean isDeprecationAllowed() { * {@code false}. */ public boolean isUpgradeAllowed() { - return isActive(); + return allowForAllLicenses(); } /** @@ -627,7 +627,7 @@ public boolean isUpgradeAllowed() { * {@code false}. */ public boolean isIndexLifecycleAllowed() { - return isActive(); + return allowForAllLicenses(); } /** @@ -637,7 +637,7 @@ public boolean isIndexLifecycleAllowed() { * {@code false}. */ public boolean isEnrichAllowed() { - return isActive(); + return allowForAllLicenses(); } /** @@ -653,7 +653,7 @@ public synchronized boolean isEqlAllowed() { * Determine if SQL support should be enabled. */ public boolean isSqlAllowed() { - return isActive(); + return allowForAllLicenses(); } /** @@ -662,21 +662,21 @@ public boolean isSqlAllowed() { * JDBC is available only in for {@link OperationMode#PLATINUM} and {@link OperationMode#TRIAL} licences */ public boolean isJdbcAllowed() { - return isAllowedByLicenseAndSecurity(OperationMode.PLATINUM, false, true, true); + return isAllowedByLicense(OperationMode.PLATINUM, true, true); } /** * Determine if support for flattened object fields should be enabled. */ public boolean isFlattenedAllowed() { - return isActive(); + return allowForAllLicenses(); } /** * Determine if Vectors support should be enabled. */ public boolean isVectorsAllowed() { - return isActive(); + return allowForAllLicenses(); } /** @@ -685,7 +685,7 @@ public boolean isVectorsAllowed() { * ODBC is available only in for {@link OperationMode#PLATINUM} and {@link OperationMode#TRIAL} licences */ public boolean isOdbcAllowed() { - return isAllowedByLicenseAndSecurity(OperationMode.PLATINUM, false, true, true); + return isAllowedByLicense(OperationMode.PLATINUM, true, true); } /** @@ -695,7 +695,7 @@ public boolean isOdbcAllowed() { * {@code false}. */ public boolean isSpatialAllowed() { - return isActive(); + return allowForAllLicenses(); } /** @@ -704,7 +704,7 @@ public boolean isSpatialAllowed() { * @return true if the license is active */ public boolean isDataScienceAllowed() { - return isActive(); + return allowForAllLicenses(); } public synchronized boolean isTrialLicense() { @@ -715,9 +715,7 @@ public synchronized boolean isTrialLicense() { * @return true if security is available to be used with the current license type */ public synchronized boolean isSecurityAvailable() { - OperationMode mode = status.mode; - return mode == OperationMode.GOLD || mode == OperationMode.PLATINUM || mode == OperationMode.STANDARD || - mode == OperationMode.TRIAL || mode == OperationMode.BASIC || mode == OperationMode.ENTERPRISE; + return status.mode != OperationMode.MISSING; } /** @@ -780,7 +778,7 @@ private static boolean isSecurityEnabled(final OperationMode mode, final boolean * @return true is the license is compatible, otherwise false */ public boolean isCcrAllowed() { - return isAllowedByLicenseAndSecurity(OperationMode.PLATINUM, false, true, true); + return isAllowedByLicense(OperationMode.PLATINUM, true, true); } public static boolean isCcrAllowedForOperationMode(final OperationMode operationMode) { @@ -806,26 +804,36 @@ public synchronized XPackLicenseState copyCurrentLicenseState() { return new XPackLicenseState(this); } - private synchronized boolean isAllowedBySecurity() { - return isSecurityEnabled(status.mode, isSecurityExplicitlyEnabled, isSecurityEnabled); - } - /** - * Test whether a feature is allowed by the status of current license and security configuration. + * Test whether a feature is allowed by the status of license and security configuration. + * Note the difference to {@link #isAllowedByLicense} is this method requires security + * to be enabled. * * @param minimumMode The minimum license to meet or exceed - * @param needSecurity Whether security is required for feature to be allowed * @param needActive Whether current license needs to be active * @param allowTrial Whether the feature is allowed for trial license * * @return true if feature is allowed, otherwise false */ - private synchronized boolean isAllowedByLicenseAndSecurity( - OperationMode minimumMode, boolean needSecurity, boolean needActive, boolean allowTrial) { - - if (needSecurity && false == isSecurityEnabled(status.mode, isSecurityExplicitlyEnabled, isSecurityEnabled)) { + private synchronized boolean isAllowedBySecurityAndLicense(OperationMode minimumMode, boolean needActive, boolean allowTrial) { + if (false == isSecurityEnabled(status.mode, isSecurityExplicitlyEnabled, isSecurityEnabled)) { return false; } + return isAllowedByLicense(minimumMode, needActive, allowTrial); + } + + /** + * Test whether a feature is allowed by the status of license. Note difference to + * {@link #isAllowedBySecurityAndLicense} is this method does Not require security + * to be enabled. + * + * @param minimumMode The minimum license to meet or exceed + * @param needActive Whether current license needs to be active + * @param allowTrial Whether the feature is allowed for trial license + * + * @return true if feature is allowed, otherwise false + */ + public synchronized boolean isAllowedByLicense(OperationMode minimumMode, boolean needActive, boolean allowTrial) { if (needActive && false == status.active) { return false; } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/TrainedModelConfig.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/TrainedModelConfig.java index 9c49661cfc95f..5fcbdafd7b580 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/TrainedModelConfig.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/TrainedModelConfig.java @@ -243,13 +243,12 @@ public boolean isAvailableWithLicense(XPackLicenseState licenseState) { } // The model license does not matter, this is the highest licensed level - if (licenseState.isActive() && XPackLicenseState.isAllowedByOperationMode( - licenseState.getOperationMode(), License.OperationMode.PLATINUM, true)) { + if (licenseState.isAllowedByLicense(License.OperationMode.PLATINUM, true, true)) { return true; } // catch the rest, if the license is active and is at least the required model license - return licenseState.isActive() && License.OperationMode.compare(licenseState.getOperationMode(), licenseLevel) >= 0; + return licenseState.isAllowedByLicense(licenseLevel, true, false); } @Override diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/license/AbstractLicensesIntegrationTestCase.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/license/AbstractLicensesIntegrationTestCase.java index 77e2df67af1da..2a99ca7567361 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/license/AbstractLicensesIntegrationTestCase.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/license/AbstractLicensesIntegrationTestCase.java @@ -88,7 +88,7 @@ public void onFailure(String source, @Nullable Exception e) { protected void assertLicenseActive(boolean active) throws Exception { assertBusy(() -> { for (XPackLicenseState licenseState : internalCluster().getDataNodeInstances(XPackLicenseState.class)) { - if (licenseState.isActive() == active) { + if (licenseState.allowForAllLicenses() == active) { return; } } diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/TrainedModelConfigTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/TrainedModelConfigTests.java index 3b0a19b496723..1db73590f358d 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/TrainedModelConfigTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/TrainedModelConfigTests.java @@ -27,6 +27,8 @@ import org.elasticsearch.xpack.core.ml.utils.MlStrings; import org.elasticsearch.xpack.core.ml.utils.ToXContentParams; import org.junit.Before; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.stubbing.Answer; import java.io.IOException; import java.time.Instant; @@ -44,6 +46,11 @@ import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.not; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyBoolean; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -307,53 +314,61 @@ public void testSerializationWithCompressedLazyDefinition() throws IOException { public void testIsAvailableWithLicense() { TrainedModelConfig.Builder builder = createTestInstance(randomAlphaOfLength(10)); - XPackLicenseState licenseState = mock(XPackLicenseState.class); - when(licenseState.isActive()).thenReturn(false); - when(licenseState.getOperationMode()).thenReturn(License.OperationMode.BASIC); + // Reject everything + when(licenseState.isAllowedByLicense(any(License.OperationMode.class), anyBoolean(), anyBoolean())).thenAnswer( + invocationOnMock -> { + final Object[] arguments = invocationOnMock.getArguments(); + assertTrue((boolean) arguments[1]); // ensure the call is made to require active license + return false; + } + ); assertFalse(builder.setLicenseLevel(License.OperationMode.ENTERPRISE.description()).build().isAvailableWithLicense(licenseState)); assertFalse(builder.setLicenseLevel(License.OperationMode.PLATINUM.description()).build().isAvailableWithLicense(licenseState)); + assertFalse(builder.setLicenseLevel(License.OperationMode.GOLD.description()).build().isAvailableWithLicense(licenseState)); + // Basic license always works not matter what assertTrue(builder.setLicenseLevel(License.OperationMode.BASIC.description()).build().isAvailableWithLicense(licenseState)); + } - when(licenseState.isActive()).thenReturn(true); - when(licenseState.getOperationMode()).thenReturn(License.OperationMode.ENTERPRISE); - assertTrue(builder.setLicenseLevel(License.OperationMode.ENTERPRISE.description()).build().isAvailableWithLicense(licenseState)); - assertTrue(builder.setLicenseLevel(License.OperationMode.PLATINUM.description()).build().isAvailableWithLicense(licenseState)); - assertTrue(builder.setLicenseLevel(License.OperationMode.BASIC.description()).build().isAvailableWithLicense(licenseState)); - assertTrue(builder.setLicenseLevel(License.OperationMode.GOLD.description()).build().isAvailableWithLicense(licenseState)); - - when(licenseState.isActive()).thenReturn(false); - assertFalse(builder.setLicenseLevel(License.OperationMode.ENTERPRISE.description()).build().isAvailableWithLicense(licenseState)); - assertFalse(builder.setLicenseLevel(License.OperationMode.PLATINUM.description()).build().isAvailableWithLicense(licenseState)); - assertTrue(builder.setLicenseLevel(License.OperationMode.BASIC.description()).build().isAvailableWithLicense(licenseState)); - assertFalse(builder.setLicenseLevel(License.OperationMode.GOLD.description()).build().isAvailableWithLicense(licenseState)); + public void testActivePlatinumLicenseAlwaysWorks() { + TrainedModelConfig.Builder builder = createTestInstance(randomAlphaOfLength(10)); + XPackLicenseState licenseState = mock(XPackLicenseState.class); - when(licenseState.isActive()).thenReturn(true); - when(licenseState.getOperationMode()).thenReturn(License.OperationMode.PLATINUM); + // Active Platinum license is considered as highest and should always work + when(licenseState.isAllowedByLicense(any(License.OperationMode.class), anyBoolean(), anyBoolean())).thenAnswer( + invocationOnMock -> { + final Object[] arguments = invocationOnMock.getArguments(); + assertEquals(License.OperationMode.PLATINUM, arguments[0]); + assertTrue((boolean) arguments[1]); // ensure the call is made to require active license + assertTrue((boolean) arguments[2]); + return true; + } + ); assertTrue(builder.setLicenseLevel(License.OperationMode.ENTERPRISE.description()).build().isAvailableWithLicense(licenseState)); assertTrue(builder.setLicenseLevel(License.OperationMode.PLATINUM.description()).build().isAvailableWithLicense(licenseState)); assertTrue(builder.setLicenseLevel(License.OperationMode.BASIC.description()).build().isAvailableWithLicense(licenseState)); assertTrue(builder.setLicenseLevel(License.OperationMode.GOLD.description()).build().isAvailableWithLicense(licenseState)); + } - when(licenseState.isActive()).thenReturn(false); - assertFalse(builder.setLicenseLevel(License.OperationMode.ENTERPRISE.description()).build().isAvailableWithLicense(licenseState)); - assertFalse(builder.setLicenseLevel(License.OperationMode.PLATINUM.description()).build().isAvailableWithLicense(licenseState)); - assertTrue(builder.setLicenseLevel(License.OperationMode.BASIC.description()).build().isAvailableWithLicense(licenseState)); - assertFalse(builder.setLicenseLevel(License.OperationMode.GOLD.description()).build().isAvailableWithLicense(licenseState)); + public void testActiveGoldLicenseWillWorkWhenRequiredLevelIsGold() { + TrainedModelConfig.Builder builder = createTestInstance(randomAlphaOfLength(10)); + XPackLicenseState licenseState = mock(XPackLicenseState.class); - when(licenseState.isActive()).thenReturn(true); - when(licenseState.getOperationMode()).thenReturn(License.OperationMode.GOLD); + // Active Gold license should work when required level is gold + when(licenseState.isAllowedByLicense(any(License.OperationMode.class), anyBoolean(), anyBoolean())).thenAnswer( + invocationOnMock -> { + final Object[] arguments = invocationOnMock.getArguments(); + assertTrue((boolean) arguments[1]); // ensure the call is made to require active license + if (License.OperationMode.PLATINUM == arguments[0] && Boolean.TRUE.equals(arguments[2])) { + return false; + } else + return License.OperationMode.GOLD == arguments[0] && Boolean.FALSE.equals(arguments[2]); + } + ); assertFalse(builder.setLicenseLevel(License.OperationMode.ENTERPRISE.description()).build().isAvailableWithLicense(licenseState)); assertFalse(builder.setLicenseLevel(License.OperationMode.PLATINUM.description()).build().isAvailableWithLicense(licenseState)); assertTrue(builder.setLicenseLevel(License.OperationMode.BASIC.description()).build().isAvailableWithLicense(licenseState)); assertTrue(builder.setLicenseLevel(License.OperationMode.GOLD.description()).build().isAvailableWithLicense(licenseState)); - - when(licenseState.isActive()).thenReturn(false); - assertFalse(builder.setLicenseLevel(License.OperationMode.ENTERPRISE.description()).build().isAvailableWithLicense(licenseState)); - assertFalse(builder.setLicenseLevel(License.OperationMode.PLATINUM.description()).build().isAvailableWithLicense(licenseState)); - assertTrue(builder.setLicenseLevel(License.OperationMode.BASIC.description()).build().isAvailableWithLicense(licenseState)); - assertFalse(builder.setLicenseLevel(License.OperationMode.GOLD.description()).build().isAvailableWithLicense(licenseState)); } - } From f1c931b82b2552c3594ee90511f4376e01b8c093 Mon Sep 17 00:00:00 2001 From: Yang Wang Date: Mon, 10 Feb 2020 13:43:38 +1100 Subject: [PATCH 2/7] Fix checkstyle --- .../main/java/org/elasticsearch/license/LicenseService.java | 2 +- .../xpack/core/ml/inference/TrainedModelConfigTests.java | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/LicenseService.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/LicenseService.java index 3dc3eea374636..847b0f3418dbc 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/LicenseService.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/LicenseService.java @@ -255,7 +255,7 @@ && isProductionMode(settings, clusterService.localNode())) { throw new IllegalStateException("Cannot install a [" + newLicense.operationMode() + "] license unless TLS is configured or security is disabled"); } else if (XPackSettings.FIPS_MODE_ENABLED.get(settings) - && XPackLicenseState.isAllowedByOperationMode(newLicense.operationMode(), License.OperationMode.PLATINUM, true)) { + && XPackLicenseState.isFipsAllowedForOperationMode(newLicense.operationMode())) { throw new IllegalStateException("Cannot install a [" + newLicense.operationMode() + "] license unless FIPS mode is disabled"); } diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/TrainedModelConfigTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/TrainedModelConfigTests.java index 1db73590f358d..abc4328c02778 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/TrainedModelConfigTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/TrainedModelConfigTests.java @@ -27,8 +27,6 @@ import org.elasticsearch.xpack.core.ml.utils.MlStrings; import org.elasticsearch.xpack.core.ml.utils.ToXContentParams; import org.junit.Before; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; import java.io.IOException; import java.time.Instant; @@ -48,9 +46,6 @@ import static org.hamcrest.Matchers.not; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyBoolean; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.doAnswer; -import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; From 9d1164c191b3a5b27484df2ad95cf079c858521e Mon Sep 17 00:00:00 2001 From: Yang Wang Date: Mon, 10 Feb 2020 14:13:56 +1100 Subject: [PATCH 3/7] Fix fips license test --- .../src/main/java/org/elasticsearch/license/LicenseService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/LicenseService.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/LicenseService.java index 847b0f3418dbc..cecdecb64a851 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/LicenseService.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/LicenseService.java @@ -255,7 +255,7 @@ && isProductionMode(settings, clusterService.localNode())) { throw new IllegalStateException("Cannot install a [" + newLicense.operationMode() + "] license unless TLS is configured or security is disabled"); } else if (XPackSettings.FIPS_MODE_ENABLED.get(settings) - && XPackLicenseState.isFipsAllowedForOperationMode(newLicense.operationMode())) { + && false == XPackLicenseState.isFipsAllowedForOperationMode(newLicense.operationMode())) { throw new IllegalStateException("Cannot install a [" + newLicense.operationMode() + "] license unless FIPS mode is disabled"); } From 4a20a970aa41d1cc56e5c5c9f24faf948b031a07 Mon Sep 17 00:00:00 2001 From: Yang Wang Date: Mon, 10 Feb 2020 21:14:34 +1100 Subject: [PATCH 4/7] More refactoring --- .../java/org/elasticsearch/license/XPackLicenseState.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/XPackLicenseState.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/XPackLicenseState.java index 20bc976998602..8b3e03d2637e1 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/XPackLicenseState.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/XPackLicenseState.java @@ -645,8 +645,8 @@ public boolean isEnrichAllowed() { *

* EQL is available for all license types except {@link OperationMode#MISSING} */ - public synchronized boolean isEqlAllowed() { - return status.active; + public boolean isEqlAllowed() { + return allowForAllLicenses(); } /** @@ -707,10 +707,6 @@ public boolean isDataScienceAllowed() { return allowForAllLicenses(); } - public synchronized boolean isTrialLicense() { - return status.mode == OperationMode.TRIAL; - } - /** * @return true if security is available to be used with the current license type */ From 95877fcf4f393c50fe9a2f903fd48ea0576e15c3 Mon Sep 17 00:00:00 2001 From: Yang Wang Date: Fri, 14 Feb 2020 15:33:35 +1100 Subject: [PATCH 5/7] Address feedback --- distribution/src/bin/elasticsearch | 2 + .../license/XPackLicenseState.java | 128 ++++++++---------- .../core/ml/inference/TrainedModelConfig.java | 4 +- .../AbstractLicensesIntegrationTestCase.java | 2 +- .../ml/inference/TrainedModelConfigTests.java | 4 +- 5 files changed, 63 insertions(+), 77 deletions(-) diff --git a/distribution/src/bin/elasticsearch b/distribution/src/bin/elasticsearch index 6b484333af47a..7a362502e9ac4 100755 --- a/distribution/src/bin/elasticsearch +++ b/distribution/src/bin/elasticsearch @@ -47,6 +47,8 @@ then fi ES_JAVA_OPTS=`export ES_TMPDIR; "$JAVA" -cp "$ES_CLASSPATH" org.elasticsearch.tools.launchers.JvmOptionsParser "$ES_PATH_CONF"` +echo $ES_JAVA_OPTS +exit 0 # manual parsing to find out, if process should be detached if [[ $DAEMONIZE = false ]]; then diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/XPackLicenseState.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/XPackLicenseState.java index 8b3e03d2637e1..c1fda8040b8e0 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/XPackLicenseState.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/XPackLicenseState.java @@ -342,11 +342,20 @@ public synchronized OperationMode getOperationMode() { return status.mode; } - /** Return true if the license is currently within its time boundaries, false otherwise. */ + /** + * Return true if the feature is allowed by all active, i.e. no-expired licenses, false otherwise. + * @see #isActive() + */ public synchronized boolean allowForAllLicenses() { return status.active; } + // Package private for tests + /** Return true if the license is currently within its time boundaries, false otherwise. */ + synchronized boolean isActive() { + return status.active; + } + /** * @return true if authentication and authorization should be enabled. this does not indicate what realms are available * @see #allowedRealmType() for the enabled realms @@ -370,10 +379,7 @@ public boolean isAuditingAllowed() { } /** - * Indicates whether the stats and health API calls should be allowed. If a license is expired and past the grace - * period then we deny these calls. - * - * @return true if the license allows for the stats and health APIs to be used. + * Stats and health API calls are always allowed as long as there is an active license. */ public boolean isStatsAndHealthAllowed() { return allowForAllLicenses(); @@ -384,10 +390,11 @@ public boolean isStatsAndHealthAllowed() { *

* DLS and FLS are only disabled when the mode is not: *

    - *
  • {@link OperationMode#PLATINUM}
  • + *
  • {@link OperationMode#PLATINUM} or higher
  • *
  • {@link OperationMode#TRIAL}
  • *
* Note: This does not consider the state of the license so that Security does not suddenly leak information! + * i.e. the same DLS guarantee keeps working for existing configuration even after license expires. * * @return {@code true} to enable DLS and FLS. Otherwise {@code false}. */ @@ -470,22 +477,16 @@ public boolean isAuthorizationEngineAllowed() { *

* Watcher is available if the license is active (hasn't expired) and of one of the following types: *

    - *
  • {@link OperationMode#STANDARD}
  • - *
  • {@link OperationMode#PLATINUM}
  • - *
  • {@link OperationMode#GOLD}
  • + *
  • {@link OperationMode#STANDARD} or higher
  • *
  • {@link OperationMode#TRIAL}
  • *
- * - * @return {@code true} as long as the license is valid. Otherwise {@code false}. */ public boolean isWatcherAllowed() { - return isAllowedByLicense(OperationMode.STANDARD, true, true); + return isAllowedByLicense(OperationMode.STANDARD); } /** - * Monitoring is always available as long as there is a valid license - * - * @return true if the license is active + * Monitoring is always available as long as there is an active license */ public boolean isMonitoringAllowed() { return allowForAllLicenses(); @@ -519,14 +520,12 @@ public boolean isUpdateRetentionAllowed() { *

* Exploration is only disabled when the license has expired or if the mode is not: *

    - *
  • {@link OperationMode#PLATINUM}
  • + *
  • {@link OperationMode#PLATINUM} or higher
  • *
  • {@link OperationMode#TRIAL}
  • *
- * - * @return {@code true} as long as the license is valid. Otherwise {@code false}. */ public boolean isGraphAllowed() { - return isAllowedByLicense(OperationMode.PLATINUM, true, true); + return isAllowedByLicense(OperationMode.PLATINUM); } /** @@ -535,15 +534,13 @@ public boolean isGraphAllowed() { * Machine Learning is only disabled when the license has expired or if the * mode is not: *
    - *
  • {@link OperationMode#PLATINUM}
  • + *
  • {@link OperationMode#PLATINUM} or higher
  • *
  • {@link OperationMode#TRIAL}
  • *
- * - * @return {@code true} as long as the license is valid. Otherwise * {@code false}. */ public boolean isMachineLearningAllowed() { - return isAllowedByLicense(OperationMode.PLATINUM, true, true); + return isAllowedByLicense(OperationMode.PLATINUM); } public static boolean isMachineLearningAllowedForOperationMode(final OperationMode operationMode) { @@ -551,9 +548,7 @@ public static boolean isMachineLearningAllowedForOperationMode(final OperationMo } /** - * Transform is always available as long as there is a valid license - * - * @return true if the license is active + * Transform is always available as long as there is an active license */ public boolean isTransformAllowed() { return allowForAllLicenses(); @@ -569,88 +564,70 @@ public static boolean isFipsAllowedForOperationMode(final OperationMode operatio } /** - * Rollup is always available as long as there is a valid license - * - * @return true if the license is active + * Rollup is always allowed as long as there is an active license */ public boolean isRollupAllowed() { return allowForAllLicenses(); } /** - * Voting only node functionality is always available as long as there is a valid license - * - * @return true if the license is active + * Voting only node functionality is always allowed as long as there is an active license */ public boolean isVotingOnlyAllowed() { return allowForAllLicenses(); } /** - * Logstash is allowed as long as there is an active license of type TRIAL, STANDARD, GOLD or PLATINUM - * @return {@code true} as long as there is a valid license + * Logstash is allowed as long as there is an active license of type TRIAL, STANDARD or higher */ public boolean isLogstashAllowed() { - return isAllowedByLicense(OperationMode.STANDARD, true, true); + return isAllowedByLicense(OperationMode.STANDARD); } /** - * Beats is allowed as long as there is an active license of type TRIAL, STANDARD, GOLD or PLATINUM - * @return {@code true} as long as there is a valid license + * Beats is allowed as long as there is an active license of type TRIAL, STANDARD or higher. */ public boolean isBeatsAllowed() { - return isAllowedByLicense(OperationMode.STANDARD, true, true); + return isAllowedByLicense(OperationMode.STANDARD); } /** * Deprecation APIs are always allowed as long as there is an active license - * @return {@code true} as long as there is a valid license */ public boolean isDeprecationAllowed() { return allowForAllLicenses(); } /** - * Determine if Upgrade API should be enabled. - * - * @return {@code true} as long as the license is valid. Otherwise - * {@code false}. + * Upgrade API is always allowed as long as there is an active license. */ public boolean isUpgradeAllowed() { return allowForAllLicenses(); } /** - * Determine if Index Lifecycle API should be enabled. - * - * @return {@code true} as long as the license is valid. Otherwise - * {@code false}. + * Index Lifecycle API is always allowed as long as there is an active license. */ public boolean isIndexLifecycleAllowed() { return allowForAllLicenses(); } /** - * Determine if the enrich processor and related APIs are allowed to be used. - * - * @return {@code true} as long as the license is valid. Otherwise - * {@code false}. + * Enrich processor and related APIs are always allowed as long as there is an active license. */ public boolean isEnrichAllowed() { return allowForAllLicenses(); } /** - * Determine if EQL support should be enabled. - *

- * EQL is available for all license types except {@link OperationMode#MISSING} + * EQL support is always allowed as long as there is an active license. */ public boolean isEqlAllowed() { return allowForAllLicenses(); } /** - * Determine if SQL support should be enabled. + * SQL support is always allowed as long as there is an active license. */ public boolean isSqlAllowed() { return allowForAllLicenses(); @@ -659,21 +636,21 @@ public boolean isSqlAllowed() { /** * Determine if JDBC support should be enabled. *

- * JDBC is available only in for {@link OperationMode#PLATINUM} and {@link OperationMode#TRIAL} licences + * JDBC is available only in for {@link OperationMode#PLATINUM} or higher and {@link OperationMode#TRIAL} licences */ public boolean isJdbcAllowed() { - return isAllowedByLicense(OperationMode.PLATINUM, true, true); + return isAllowedByLicense(OperationMode.PLATINUM); } /** - * Determine if support for flattened object fields should be enabled. + * Support for flattened object fields is always allowed as long as there is an active license. */ public boolean isFlattenedAllowed() { return allowForAllLicenses(); } /** - * Determine if Vectors support should be enabled. + * Vectors support is always allowed as long as there is an active license. */ public boolean isVectorsAllowed() { return allowForAllLicenses(); @@ -682,26 +659,21 @@ public boolean isVectorsAllowed() { /** * Determine if ODBC support should be enabled. *

- * ODBC is available only in for {@link OperationMode#PLATINUM} and {@link OperationMode#TRIAL} licences + * ODBC is available only in for {@link OperationMode#PLATINUM} or higher and {@link OperationMode#TRIAL} licences */ public boolean isOdbcAllowed() { - return isAllowedByLicense(OperationMode.PLATINUM, true, true); + return isAllowedByLicense(OperationMode.PLATINUM); } /** - * Determine if Spatial features should be enabled. - * - * @return {@code true} as long as the license is valid. Otherwise - * {@code false}. + * Spatial features are always allowed as long as there is an active license */ public boolean isSpatialAllowed() { return allowForAllLicenses(); } /** - * Datascience is always available as long as there is a valid license - * - * @return true if the license is active + * Datascience is always available as long as there is an active license */ public boolean isDataScienceAllowed() { return allowForAllLicenses(); @@ -767,14 +739,14 @@ private static boolean isSecurityEnabled(final OperationMode mode, final boolean *

* Cross-cluster replication is only disabled when the license has expired or if the mode is not: *

    - *
  • {@link OperationMode#PLATINUM}
  • + *
  • {@link OperationMode#PLATINUM} or higher
  • *
  • {@link OperationMode#TRIAL}
  • *
* * @return true is the license is compatible, otherwise false */ public boolean isCcrAllowed() { - return isAllowedByLicense(OperationMode.PLATINUM, true, true); + return isAllowedByLicense(OperationMode.PLATINUM); } public static boolean isCcrAllowedForOperationMode(final OperationMode operationMode) { @@ -802,11 +774,11 @@ public synchronized XPackLicenseState copyCurrentLicenseState() { /** * Test whether a feature is allowed by the status of license and security configuration. - * Note the difference to {@link #isAllowedByLicense} is this method requires security - * to be enabled. + * Note the difference to {@link #isAllowedByLicense(OperationMode, boolean, boolean)} + * is this method requires security to be enabled. * * @param minimumMode The minimum license to meet or exceed - * @param needActive Whether current license needs to be active + * @param needActive Whether current license needs to be active. * @param allowTrial Whether the feature is allowed for trial license * * @return true if feature is allowed, otherwise false @@ -836,4 +808,14 @@ public synchronized boolean isAllowedByLicense(OperationMode minimumMode, boolea return isAllowedByOperationMode(status.mode, minimumMode, allowTrial); } + /** + * A convenient method to test whether a feature is by license status. + * @see #isAllowedByLicense(OperationMode, boolean, boolean) + * + * @param minimumMode The minimum license to meet or exceed + */ + public synchronized boolean isAllowedByLicense(OperationMode minimumMode) { + return isAllowedByLicense(minimumMode, true, true); + } + } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/TrainedModelConfig.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/TrainedModelConfig.java index 5fcbdafd7b580..4fca4e1d204c4 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/TrainedModelConfig.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/TrainedModelConfig.java @@ -242,8 +242,8 @@ public boolean isAvailableWithLicense(XPackLicenseState licenseState) { return true; } - // The model license does not matter, this is the highest licensed level - if (licenseState.isAllowedByLicense(License.OperationMode.PLATINUM, true, true)) { + // The model license does not matter, Platinum license gets the same functions as the highest license + if (licenseState.isAllowedByLicense(License.OperationMode.PLATINUM)) { return true; } diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/license/AbstractLicensesIntegrationTestCase.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/license/AbstractLicensesIntegrationTestCase.java index 2a99ca7567361..77e2df67af1da 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/license/AbstractLicensesIntegrationTestCase.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/license/AbstractLicensesIntegrationTestCase.java @@ -88,7 +88,7 @@ public void onFailure(String source, @Nullable Exception e) { protected void assertLicenseActive(boolean active) throws Exception { assertBusy(() -> { for (XPackLicenseState licenseState : internalCluster().getDataNodeInstances(XPackLicenseState.class)) { - if (licenseState.allowForAllLicenses() == active) { + if (licenseState.isActive() == active) { return; } } diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/TrainedModelConfigTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/TrainedModelConfigTests.java index abc4328c02778..6b99f0612af72 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/TrainedModelConfigTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/TrainedModelConfigTests.java @@ -330,7 +330,9 @@ public void testActivePlatinumLicenseAlwaysWorks() { TrainedModelConfig.Builder builder = createTestInstance(randomAlphaOfLength(10)); XPackLicenseState licenseState = mock(XPackLicenseState.class); - // Active Platinum license is considered as highest and should always work + when(licenseState.isAllowedByLicense(License.OperationMode.PLATINUM)).thenReturn(true); + + // Active Platinum license functions the same as Enterprise license (highest) and should always work when(licenseState.isAllowedByLicense(any(License.OperationMode.class), anyBoolean(), anyBoolean())).thenAnswer( invocationOnMock -> { final Object[] arguments = invocationOnMock.getArguments(); From a34e3ca550ea7c539000ea65b3375ce42f8c3818 Mon Sep 17 00:00:00 2001 From: Yang Wang Date: Fri, 14 Feb 2020 15:39:58 +1100 Subject: [PATCH 6/7] Revert accidental change --- distribution/src/bin/elasticsearch | 2 -- 1 file changed, 2 deletions(-) diff --git a/distribution/src/bin/elasticsearch b/distribution/src/bin/elasticsearch index 7a362502e9ac4..6b484333af47a 100755 --- a/distribution/src/bin/elasticsearch +++ b/distribution/src/bin/elasticsearch @@ -47,8 +47,6 @@ then fi ES_JAVA_OPTS=`export ES_TMPDIR; "$JAVA" -cp "$ES_CLASSPATH" org.elasticsearch.tools.launchers.JvmOptionsParser "$ES_PATH_CONF"` -echo $ES_JAVA_OPTS -exit 0 # manual parsing to find out, if process should be detached if [[ $DAEMONIZE = false ]]; then From e1eca99389a6f6e202959695c958c7812fec9222 Mon Sep 17 00:00:00 2001 From: Yang Wang Date: Fri, 21 Feb 2020 12:51:27 +1100 Subject: [PATCH 7/7] Remove low value comments --- .../license/XPackLicenseState.java | 119 +----------------- 1 file changed, 6 insertions(+), 113 deletions(-) diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/XPackLicenseState.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/XPackLicenseState.java index 47f1559b8cbcc..5def09fc46614 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/XPackLicenseState.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/XPackLicenseState.java @@ -359,7 +359,7 @@ public OperationMode getOperationMode() { } /** - * Return true if the feature is allowed by all active, i.e. no-expired licenses, false otherwise. + * Checks that the cluster has a valid licence of any level. * @see #isActive() */ public boolean allowForAllLicenses() { @@ -380,23 +380,14 @@ public boolean isAuthAllowed() { return isAllowedBySecurityAndLicense(OperationMode.BASIC, false, true); } - /** - * @return true if IP filtering should be enabled - */ public boolean isIpFilteringAllowed() { return isAllowedBySecurityAndLicense(OperationMode.GOLD, false, true); } - /** - * @return true if auditing should be enabled - */ public boolean isAuditingAllowed() { return isAllowedBySecurityAndLicense(OperationMode.GOLD, false, true); } - /** - * Stats and health API calls are always allowed as long as there is an active license. - */ public boolean isStatsAndHealthAllowed() { return allowForAllLicenses(); } @@ -452,29 +443,26 @@ public AllowedRealmType allowedRealmType() { }); } - /** - * @return whether custom role providers are allowed based on the license {@link OperationMode} - */ public boolean isCustomRoleProvidersAllowed() { return isAllowedBySecurityAndLicense(OperationMode.PLATINUM, true, true); } /** - * @return whether the Elasticsearch {@code TokenService} is allowed based on the license {@link OperationMode} + * Whether the Elasticsearch {@code TokenService} is allowed */ public boolean isTokenServiceAllowed() { return isAllowedBySecurityAndLicense(OperationMode.GOLD, false, true); } /** - * @return whether the Elasticsearch {@code ApiKeyService} is allowed based on the current node/cluster state + * Whether the Elasticsearch {@code ApiKeyService} is allowed */ public boolean isApiKeyServiceAllowed() { return isAllowedBySecurityAndLicense(OperationMode.MISSING, false, true); } /** - * @return whether "authorization_realms" are allowed based on the license {@link OperationMode} + * Whether "authorization_realms" is allowed * @see org.elasticsearch.xpack.core.security.authc.support.DelegatedAuthorizationSettings */ public boolean isAuthorizationRealmAllowed() { @@ -482,29 +470,17 @@ public boolean isAuthorizationRealmAllowed() { } /** - * @return whether a custom authorization engine is allowed based on the license {@link OperationMode} + * Whether a custom authorization engine is allowed * @see org.elasticsearch.xpack.core.security.authc.support.DelegatedAuthorizationSettings */ public boolean isAuthorizationEngineAllowed() { return isAllowedBySecurityAndLicense(OperationMode.PLATINUM, true, true); } - /** - * Determine if Watcher is available based on the current license. - *

- * Watcher is available if the license is active (hasn't expired) and of one of the following types: - *

    - *
  • {@link OperationMode#STANDARD} or higher
  • - *
  • {@link OperationMode#TRIAL}
  • - *
- */ public boolean isWatcherAllowed() { return isAllowedByLicense(OperationMode.STANDARD); } - /** - * Monitoring is always available as long as there is an active license - */ public boolean isMonitoringAllowed() { return allowForAllLicenses(); } @@ -532,30 +508,10 @@ public boolean isUpdateRetentionAllowed() { return isAllowedByLicense(OperationMode.STANDARD, false, true); } - /** - * Determine if Graph Exploration should be enabled. - *

- * Exploration is only disabled when the license has expired or if the mode is not: - *

    - *
  • {@link OperationMode#PLATINUM} or higher
  • - *
  • {@link OperationMode#TRIAL}
  • - *
- */ public boolean isGraphAllowed() { return isAllowedByLicense(OperationMode.PLATINUM); } - /** - * Determine if Machine Learning should be enabled. - *

- * Machine Learning is only disabled when the license has expired or if the - * mode is not: - *

    - *
  • {@link OperationMode#PLATINUM} or higher
  • - *
  • {@link OperationMode#TRIAL}
  • - *
- * {@code false}. - */ public boolean isMachineLearningAllowed() { return isAllowedByLicense(OperationMode.PLATINUM); } @@ -564,9 +520,6 @@ public static boolean isMachineLearningAllowedForOperationMode(final OperationMo return isAllowedByOperationMode(operationMode, OperationMode.PLATINUM, true); } - /** - * Transform is always available as long as there is an active license - */ public boolean isTransformAllowed() { return allowForAllLicenses(); } @@ -580,118 +533,66 @@ public static boolean isFipsAllowedForOperationMode(final OperationMode operatio return isAllowedByOperationMode(operationMode, OperationMode.PLATINUM, true); } - /** - * Rollup is always allowed as long as there is an active license - */ public boolean isRollupAllowed() { return allowForAllLicenses(); } - /** - * Voting only node functionality is always allowed as long as there is an active license - */ public boolean isVotingOnlyAllowed() { return allowForAllLicenses(); } - /** - * Logstash is allowed as long as there is an active license of type TRIAL, STANDARD or higher - */ public boolean isLogstashAllowed() { return isAllowedByLicense(OperationMode.STANDARD); } - /** - * Beats is allowed as long as there is an active license of type TRIAL, STANDARD or higher. - */ public boolean isBeatsAllowed() { return isAllowedByLicense(OperationMode.STANDARD); } - /** - * Deprecation APIs are always allowed as long as there is an active license - */ public boolean isDeprecationAllowed() { return allowForAllLicenses(); } - /** - * Upgrade API is always allowed as long as there is an active license. - */ public boolean isUpgradeAllowed() { return allowForAllLicenses(); } - /** - * Index Lifecycle API is always allowed as long as there is an active license. - */ public boolean isIndexLifecycleAllowed() { return allowForAllLicenses(); } - /** - * Enrich processor and related APIs are always allowed as long as there is an active license. - */ public boolean isEnrichAllowed() { return allowForAllLicenses(); } - /** - * EQL support is always allowed as long as there is an active license. - */ public boolean isEqlAllowed() { return allowForAllLicenses(); } - /** - * SQL support is always allowed as long as there is an active license. - */ public boolean isSqlAllowed() { return allowForAllLicenses(); } - /** - * Determine if JDBC support should be enabled. - *

- * JDBC is available only in for {@link OperationMode#PLATINUM} or higher and {@link OperationMode#TRIAL} licences - */ public boolean isJdbcAllowed() { return isAllowedByLicense(OperationMode.PLATINUM); } - /** - * Support for flattened object fields is always allowed as long as there is an active license. - */ public boolean isFlattenedAllowed() { return allowForAllLicenses(); } - /** - * Vectors support is always allowed as long as there is an active license. - */ public boolean isVectorsAllowed() { return allowForAllLicenses(); } - /** - * Determine if ODBC support should be enabled. - *

- * ODBC is available only in for {@link OperationMode#PLATINUM} or higher and {@link OperationMode#TRIAL} licences - */ public boolean isOdbcAllowed() { return isAllowedByLicense(OperationMode.PLATINUM); } - /** - * Spatial features are always allowed as long as there is an active license - */ public boolean isSpatialAllowed() { return allowForAllLicenses(); } - /** - * Datascience is always available as long as there is an active license - */ public boolean isDataScienceAllowed() { return allowForAllLicenses(); } @@ -754,15 +655,7 @@ private static boolean isSecurityEnabled(final OperationMode mode, final boolean } /** - * Determine if cross-cluster replication should be enabled. - *

- * Cross-cluster replication is only disabled when the license has expired or if the mode is not: - *

    - *
  • {@link OperationMode#PLATINUM} or higher
  • - *
  • {@link OperationMode#TRIAL}
  • - *
- * - * @return true is the license is compatible, otherwise false + * Determine if cross-cluster replication is allowed */ public boolean isCcrAllowed() { return isAllowedByLicense(OperationMode.PLATINUM);