|
@@ -16,12 +16,10 @@ import org.elasticsearch.xpack.core.XPackSettings;
|
|
|
import org.elasticsearch.xpack.core.monitoring.MonitoringField;
|
|
|
|
|
|
import java.util.Collections;
|
|
|
-import java.util.EnumSet;
|
|
|
import java.util.LinkedHashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Objects;
|
|
|
-import java.util.Set;
|
|
|
import java.util.concurrent.CopyOnWriteArrayList;
|
|
|
import java.util.function.BiFunction;
|
|
|
|
|
@@ -30,9 +28,6 @@ import java.util.function.BiFunction;
|
|
|
*/
|
|
|
public class XPackLicenseState {
|
|
|
|
|
|
- public static final Set<OperationMode> FIPS_ALLOWED_LICENSE_OPERATION_MODES =
|
|
|
- EnumSet.of(License.OperationMode.PLATINUM, License.OperationMode.TRIAL);
|
|
|
-
|
|
|
/** Messages for each feature which are printed when the license expires. */
|
|
|
static final Map<String, String[]> EXPIRATION_MESSAGES;
|
|
|
static {
|
|
@@ -114,6 +109,7 @@ public class XPackLicenseState {
|
|
|
case TRIAL:
|
|
|
case GOLD:
|
|
|
case PLATINUM:
|
|
|
+ case ENTERPRISE:
|
|
|
return new String[] {
|
|
|
"Security will default to disabled (set " + XPackSettings.SECURITY_ENABLED.getKey() + " to enable security).",
|
|
|
"Authentication will be limited to the native and file realms.",
|
|
@@ -132,6 +128,7 @@ public class XPackLicenseState {
|
|
|
// ^^ though technically it was already disabled, it's not bad to remind them
|
|
|
case TRIAL:
|
|
|
case PLATINUM:
|
|
|
+ case ENTERPRISE:
|
|
|
return new String[] {
|
|
|
"Field and document level access control will be disabled.",
|
|
|
"Custom realms will be ignored.",
|
|
@@ -145,6 +142,7 @@ public class XPackLicenseState {
|
|
|
// ^^ though technically it doesn't change the feature set, it's not bad to remind them
|
|
|
case GOLD:
|
|
|
case PLATINUM:
|
|
|
+ case ENTERPRISE:
|
|
|
case TRIAL:
|
|
|
return new String[] {
|
|
|
"Authentication will be limited to the native realms.",
|
|
@@ -166,6 +164,7 @@ public class XPackLicenseState {
|
|
|
case STANDARD:
|
|
|
case GOLD:
|
|
|
case PLATINUM:
|
|
|
+ case ENTERPRISE:
|
|
|
return new String[] { "Watcher will be disabled" };
|
|
|
}
|
|
|
break;
|
|
@@ -181,6 +180,7 @@ public class XPackLicenseState {
|
|
|
case STANDARD:
|
|
|
case GOLD:
|
|
|
case PLATINUM:
|
|
|
+ case ENTERPRISE:
|
|
|
return new String[] {
|
|
|
LoggerMessageFormat.format(
|
|
|
"Multi-cluster support is disabled for clusters with [{}] license. If you are\n" +
|
|
@@ -206,6 +206,7 @@ public class XPackLicenseState {
|
|
|
switch (currentMode) {
|
|
|
case TRIAL:
|
|
|
case PLATINUM:
|
|
|
+ case ENTERPRISE:
|
|
|
return new String[] { "Graph will be disabled" };
|
|
|
}
|
|
|
break;
|
|
@@ -221,6 +222,7 @@ public class XPackLicenseState {
|
|
|
switch (currentMode) {
|
|
|
case TRIAL:
|
|
|
case PLATINUM:
|
|
|
+ case ENTERPRISE:
|
|
|
return new String[] { "Machine learning will be disabled" };
|
|
|
}
|
|
|
break;
|
|
@@ -258,6 +260,7 @@ public class XPackLicenseState {
|
|
|
switch (currentMode) {
|
|
|
case TRIAL:
|
|
|
case PLATINUM:
|
|
|
+ case ENTERPRISE:
|
|
|
return new String[] {
|
|
|
"JDBC and ODBC support will be disabled, but you can continue to use SQL CLI and REST endpoint" };
|
|
|
}
|
|
@@ -348,41 +351,22 @@ public class XPackLicenseState {
|
|
|
* @return true if authentication and authorization should be enabled. this does not indicate what realms are available
|
|
|
* @see #allowedRealmType() for the enabled realms
|
|
|
*/
|
|
|
- public synchronized boolean isAuthAllowed() {
|
|
|
- OperationMode mode = status.mode;
|
|
|
- final boolean isSecurityCurrentlyEnabled =
|
|
|
- isSecurityEnabled(mode, isSecurityExplicitlyEnabled, isSecurityEnabled);
|
|
|
- if (isSecurityCurrentlyEnabled) {
|
|
|
- switch (mode) {
|
|
|
- case BASIC:
|
|
|
- case STANDARD:
|
|
|
- case GOLD:
|
|
|
- case PLATINUM:
|
|
|
- case TRIAL:
|
|
|
- return true;
|
|
|
- }
|
|
|
- }
|
|
|
- return false;
|
|
|
+ public boolean isAuthAllowed() {
|
|
|
+ return isAllowedByLicenseAndSecurity(OperationMode.BASIC, true, false, true);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @return true if IP filtering should be enabled
|
|
|
*/
|
|
|
- public synchronized boolean isIpFilteringAllowed() {
|
|
|
- OperationMode mode = status.mode;
|
|
|
- final boolean isSecurityCurrentlyEnabled =
|
|
|
- isSecurityEnabled(mode, isSecurityExplicitlyEnabled, isSecurityEnabled);
|
|
|
- return isSecurityCurrentlyEnabled && (mode == OperationMode.GOLD || mode == OperationMode.PLATINUM || mode == OperationMode.TRIAL);
|
|
|
+ public boolean isIpFilteringAllowed() {
|
|
|
+ return isAllowedByLicenseAndSecurity(OperationMode.GOLD, true, false, true);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @return true if auditing should be enabled
|
|
|
*/
|
|
|
- public synchronized boolean isAuditingAllowed() {
|
|
|
- OperationMode mode = status.mode;
|
|
|
- final boolean isSecurityCurrentlyEnabled =
|
|
|
- isSecurityEnabled(mode, isSecurityExplicitlyEnabled, isSecurityEnabled);
|
|
|
- return isSecurityCurrentlyEnabled && (mode == OperationMode.GOLD || mode == OperationMode.PLATINUM || mode == OperationMode.TRIAL);
|
|
|
+ public boolean isAuditingAllowed() {
|
|
|
+ return isAllowedByLicenseAndSecurity(OperationMode.GOLD, true, false, true);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -391,8 +375,8 @@ public class XPackLicenseState {
|
|
|
*
|
|
|
* @return true if the license allows for the stats and health APIs to be used.
|
|
|
*/
|
|
|
- public synchronized boolean isStatsAndHealthAllowed() {
|
|
|
- return status.active;
|
|
|
+ public boolean isStatsAndHealthAllowed() {
|
|
|
+ return isActive();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -407,11 +391,8 @@ public class XPackLicenseState {
|
|
|
*
|
|
|
* @return {@code true} to enable DLS and FLS. Otherwise {@code false}.
|
|
|
*/
|
|
|
- public synchronized boolean isDocumentAndFieldLevelSecurityAllowed() {
|
|
|
- OperationMode mode = status.mode;
|
|
|
- final boolean isSecurityCurrentlyEnabled =
|
|
|
- isSecurityEnabled(mode, isSecurityExplicitlyEnabled, isSecurityEnabled);
|
|
|
- return isSecurityCurrentlyEnabled && (mode == OperationMode.TRIAL || mode == OperationMode.PLATINUM);
|
|
|
+ public boolean isDocumentAndFieldLevelSecurityAllowed() {
|
|
|
+ return isAllowedByLicenseAndSecurity(OperationMode.PLATINUM, true, false, true);
|
|
|
}
|
|
|
|
|
|
/** Classes of realms that may be available based on the license type. */
|
|
@@ -431,6 +412,7 @@ public class XPackLicenseState {
|
|
|
if (isSecurityCurrentlyEnabled) {
|
|
|
switch (status.mode) {
|
|
|
case PLATINUM:
|
|
|
+ case ENTERPRISE:
|
|
|
case TRIAL:
|
|
|
return AllowedRealmType.ALL;
|
|
|
case GOLD:
|
|
@@ -449,51 +431,38 @@ public class XPackLicenseState {
|
|
|
/**
|
|
|
* @return whether custom role providers are allowed based on the license {@link OperationMode}
|
|
|
*/
|
|
|
- public synchronized boolean isCustomRoleProvidersAllowed() {
|
|
|
- final boolean isSecurityCurrentlyEnabled =
|
|
|
- isSecurityEnabled(status.mode, isSecurityExplicitlyEnabled, isSecurityEnabled);
|
|
|
- return isSecurityCurrentlyEnabled && (status.mode == OperationMode.PLATINUM || status.mode == OperationMode.TRIAL)
|
|
|
- && status.active;
|
|
|
+ public boolean isCustomRoleProvidersAllowed() {
|
|
|
+ return isAllowedByLicenseAndSecurity(OperationMode.PLATINUM, true, true, true);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @return whether the Elasticsearch {@code TokenService} is allowed based on the license {@link OperationMode}
|
|
|
*/
|
|
|
- public synchronized boolean isTokenServiceAllowed() {
|
|
|
- final OperationMode mode = status.mode;
|
|
|
- final boolean isSecurityCurrentlyEnabled = isSecurityEnabled(mode, isSecurityExplicitlyEnabled, isSecurityEnabled);
|
|
|
- return isSecurityCurrentlyEnabled && (mode == OperationMode.GOLD || mode == OperationMode.PLATINUM || mode == OperationMode.TRIAL);
|
|
|
+ public boolean isTokenServiceAllowed() {
|
|
|
+ return isAllowedByLicenseAndSecurity(OperationMode.GOLD, true, false, true);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @return whether the Elasticsearch {@code ApiKeyService} is allowed based on the current node/cluster state
|
|
|
*/
|
|
|
- public synchronized boolean isApiKeyServiceAllowed() {
|
|
|
- final OperationMode mode = status.mode;
|
|
|
- final boolean isSecurityCurrentlyEnabled = isSecurityEnabled(mode, isSecurityExplicitlyEnabled, isSecurityEnabled);
|
|
|
- return isSecurityCurrentlyEnabled;
|
|
|
+ public boolean isApiKeyServiceAllowed() {
|
|
|
+ return isAllowedBySecurity();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @return whether "authorization_realms" are allowed based on the license {@link OperationMode}
|
|
|
* @see org.elasticsearch.xpack.core.security.authc.support.DelegatedAuthorizationSettings
|
|
|
*/
|
|
|
- public synchronized boolean isAuthorizationRealmAllowed() {
|
|
|
- final boolean isSecurityCurrentlyEnabled =
|
|
|
- isSecurityEnabled(status.mode, isSecurityExplicitlyEnabled, isSecurityEnabled);
|
|
|
- return isSecurityCurrentlyEnabled && (status.mode == OperationMode.PLATINUM || status.mode == OperationMode.TRIAL)
|
|
|
- && status.active;
|
|
|
+ public boolean isAuthorizationRealmAllowed() {
|
|
|
+ return isAllowedByLicenseAndSecurity(OperationMode.PLATINUM, true, true, true);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @return whether a custom authorization engine is allowed based on the license {@link OperationMode}
|
|
|
* @see org.elasticsearch.xpack.core.security.authc.support.DelegatedAuthorizationSettings
|
|
|
*/
|
|
|
- public synchronized boolean isAuthorizationEngineAllowed() {
|
|
|
- final boolean isSecurityCurrentlyEnabled =
|
|
|
- isSecurityEnabled(status.mode, isSecurityExplicitlyEnabled, isSecurityEnabled);
|
|
|
- return isSecurityCurrentlyEnabled && (status.mode == OperationMode.PLATINUM || status.mode == OperationMode.TRIAL)
|
|
|
- && status.active;
|
|
|
+ public boolean isAuthorizationEngineAllowed() {
|
|
|
+ return isAllowedByLicenseAndSecurity(OperationMode.PLATINUM, true, true, true);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -509,22 +478,8 @@ public class XPackLicenseState {
|
|
|
*
|
|
|
* @return {@code true} as long as the license is valid. Otherwise {@code false}.
|
|
|
*/
|
|
|
- public synchronized boolean isWatcherAllowed() {
|
|
|
- Status localStatus = status;
|
|
|
-
|
|
|
- if (localStatus.active == false) {
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- switch (localStatus.mode) {
|
|
|
- case TRIAL:
|
|
|
- case GOLD:
|
|
|
- case PLATINUM:
|
|
|
- case STANDARD:
|
|
|
- return true;
|
|
|
- default:
|
|
|
- return false;
|
|
|
- }
|
|
|
+ public boolean isWatcherAllowed() {
|
|
|
+ return isAllowedByLicenseAndSecurity(OperationMode.STANDARD, false, true, true);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -532,8 +487,8 @@ public class XPackLicenseState {
|
|
|
*
|
|
|
* @return true if the license is active
|
|
|
*/
|
|
|
- public synchronized boolean isMonitoringAllowed() {
|
|
|
- return status.active;
|
|
|
+ public boolean isMonitoringAllowed() {
|
|
|
+ return isActive();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -542,7 +497,7 @@ public class XPackLicenseState {
|
|
|
* @return {@link #isWatcherAllowed()}
|
|
|
* @see #isWatcherAllowed()
|
|
|
*/
|
|
|
- public synchronized boolean isMonitoringClusterAlertsAllowed() {
|
|
|
+ public boolean isMonitoringClusterAlertsAllowed() {
|
|
|
return isWatcherAllowed();
|
|
|
}
|
|
|
|
|
@@ -555,9 +510,8 @@ public class XPackLicenseState {
|
|
|
*
|
|
|
* @return {@code true} if the user is allowed to modify the retention. Otherwise {@code false}.
|
|
|
*/
|
|
|
- public synchronized boolean isUpdateRetentionAllowed() {
|
|
|
- final OperationMode mode = status.mode;
|
|
|
- return mode != OperationMode.BASIC && mode != OperationMode.MISSING;
|
|
|
+ public boolean isUpdateRetentionAllowed() {
|
|
|
+ return isAllowedByLicenseAndSecurity(OperationMode.STANDARD, false, false, true);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -571,13 +525,8 @@ public class XPackLicenseState {
|
|
|
*
|
|
|
* @return {@code true} as long as the license is valid. Otherwise {@code false}.
|
|
|
*/
|
|
|
- public synchronized boolean isGraphAllowed() {
|
|
|
- Status localStatus = status;
|
|
|
- OperationMode operationMode = localStatus.mode;
|
|
|
-
|
|
|
- boolean licensed = operationMode == OperationMode.TRIAL || operationMode == OperationMode.PLATINUM;
|
|
|
-
|
|
|
- return licensed && localStatus.active;
|
|
|
+ public boolean isGraphAllowed() {
|
|
|
+ return isAllowedByLicenseAndSecurity(OperationMode.PLATINUM, false, true, true);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -593,13 +542,12 @@ public class XPackLicenseState {
|
|
|
* @return {@code true} as long as the license is valid. Otherwise
|
|
|
* {@code false}.
|
|
|
*/
|
|
|
- public synchronized boolean isMachineLearningAllowed() {
|
|
|
- final Status currentStatus = status;
|
|
|
- return currentStatus.active && isMachineLearningAllowedForOperationMode(currentStatus.mode);
|
|
|
+ public boolean isMachineLearningAllowed() {
|
|
|
+ return isAllowedByLicenseAndSecurity(OperationMode.PLATINUM, false, true, true);
|
|
|
}
|
|
|
|
|
|
public static boolean isMachineLearningAllowedForOperationMode(final OperationMode operationMode) {
|
|
|
- return isPlatinumOrTrialOperationMode(operationMode);
|
|
|
+ return isAllowedByOperationMode(operationMode, OperationMode.PLATINUM, true);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -607,8 +555,8 @@ public class XPackLicenseState {
|
|
|
*
|
|
|
* @return true if the license is active
|
|
|
*/
|
|
|
- public synchronized boolean isTransformAllowed() {
|
|
|
- return status.active;
|
|
|
+ public boolean isTransformAllowed() {
|
|
|
+ return isActive();
|
|
|
}
|
|
|
|
|
|
public static boolean isTransformAllowedForOperationMode(final OperationMode operationMode) {
|
|
@@ -616,13 +564,17 @@ public class XPackLicenseState {
|
|
|
return operationMode != License.OperationMode.MISSING;
|
|
|
}
|
|
|
|
|
|
+ public static boolean isFipsAllowedForOperationMode(final OperationMode operationMode) {
|
|
|
+ return isAllowedByOperationMode(operationMode, OperationMode.PLATINUM, true);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Rollup is always available as long as there is a valid license
|
|
|
*
|
|
|
* @return true if the license is active
|
|
|
*/
|
|
|
- public synchronized boolean isRollupAllowed() {
|
|
|
- return status.active;
|
|
|
+ public boolean isRollupAllowed() {
|
|
|
+ return isActive();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -630,80 +582,62 @@ public class XPackLicenseState {
|
|
|
*
|
|
|
* @return true if the license is active
|
|
|
*/
|
|
|
- public synchronized boolean isVotingOnlyAllowed() {
|
|
|
- return status.active;
|
|
|
+ public boolean isVotingOnlyAllowed() {
|
|
|
+ return isActive();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 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
|
|
|
*/
|
|
|
- public synchronized boolean isLogstashAllowed() {
|
|
|
- Status localStatus = status;
|
|
|
- return localStatus.active && (isBasic(localStatus.mode) == false);
|
|
|
+ public boolean isLogstashAllowed() {
|
|
|
+ return isAllowedByLicenseAndSecurity(OperationMode.STANDARD, false, true, true);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 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
|
|
|
*/
|
|
|
- public synchronized boolean isBeatsAllowed() {
|
|
|
- Status localStatus = status;
|
|
|
- return localStatus.active && (isBasic(localStatus.mode) == false);
|
|
|
-
|
|
|
+ public boolean isBeatsAllowed() {
|
|
|
+ return isAllowedByLicenseAndSecurity(OperationMode.STANDARD, false, true, true);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 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 synchronized boolean isDeprecationAllowed() {
|
|
|
- return status.active;
|
|
|
+ public boolean isDeprecationAllowed() {
|
|
|
+ return isActive();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Determine if Upgrade API should be enabled.
|
|
|
- * <p>
|
|
|
- * Upgrade API is not available in for all license types except {@link OperationMode#MISSING}
|
|
|
*
|
|
|
* @return {@code true} as long as the license is valid. Otherwise
|
|
|
* {@code false}.
|
|
|
*/
|
|
|
- public synchronized boolean isUpgradeAllowed() {
|
|
|
- // Should work on all active licenses
|
|
|
- return status.active;
|
|
|
+ public boolean isUpgradeAllowed() {
|
|
|
+ return isActive();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Determine if Index Lifecycle API should be enabled.
|
|
|
- * <p>
|
|
|
- * Index Lifecycle API is available in for all license types except
|
|
|
- * {@link OperationMode#MISSING}
|
|
|
*
|
|
|
* @return {@code true} as long as the license is valid. Otherwise
|
|
|
* {@code false}.
|
|
|
*/
|
|
|
public boolean isIndexLifecycleAllowed() {
|
|
|
- // status is volatile
|
|
|
- Status localStatus = status;
|
|
|
- // Should work on all active licenses
|
|
|
- return localStatus.active;
|
|
|
+ return isActive();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Determine if the enrich processor and related APIs are allowed to be used.
|
|
|
- * <p>
|
|
|
- * This is available in for all license types except
|
|
|
- * {@link OperationMode#MISSING}
|
|
|
*
|
|
|
* @return {@code true} as long as the license is valid. Otherwise
|
|
|
* {@code false}.
|
|
|
*/
|
|
|
public boolean isEnrichAllowed() {
|
|
|
- // status is volatile
|
|
|
- Status localStatus = status;
|
|
|
- // Should work on all active licenses
|
|
|
- return localStatus.active;
|
|
|
+ return isActive();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -717,11 +651,9 @@ public class XPackLicenseState {
|
|
|
|
|
|
/**
|
|
|
* Determine if SQL support should be enabled.
|
|
|
- * <p>
|
|
|
- * SQL is available for all license types except {@link OperationMode#MISSING}
|
|
|
*/
|
|
|
- public synchronized boolean isSqlAllowed() {
|
|
|
- return status.active;
|
|
|
+ public boolean isSqlAllowed() {
|
|
|
+ return isActive();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -729,31 +661,22 @@ public class XPackLicenseState {
|
|
|
* <p>
|
|
|
* JDBC is available only in for {@link OperationMode#PLATINUM} and {@link OperationMode#TRIAL} licences
|
|
|
*/
|
|
|
- public synchronized boolean isJdbcAllowed() {
|
|
|
- Status localStatus = status;
|
|
|
- OperationMode operationMode = localStatus.mode;
|
|
|
-
|
|
|
- boolean licensed = operationMode == OperationMode.TRIAL || operationMode == OperationMode.PLATINUM;
|
|
|
-
|
|
|
- return licensed && localStatus.active;
|
|
|
+ public boolean isJdbcAllowed() {
|
|
|
+ return isAllowedByLicenseAndSecurity(OperationMode.PLATINUM, false, true, true);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Determine if support for flattened object fields should be enabled.
|
|
|
- * <p>
|
|
|
- * Flattened fields are available for all license types except {@link OperationMode#MISSING}.
|
|
|
*/
|
|
|
- public synchronized boolean isFlattenedAllowed() {
|
|
|
- return status.active;
|
|
|
+ public boolean isFlattenedAllowed() {
|
|
|
+ return isActive();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Determine if Vectors support should be enabled.
|
|
|
- * <p>
|
|
|
- * Vectors is available for all license types except {@link OperationMode#MISSING}
|
|
|
*/
|
|
|
- public synchronized boolean isVectorsAllowed() {
|
|
|
- return status.active;
|
|
|
+ public boolean isVectorsAllowed() {
|
|
|
+ return isActive();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -761,29 +684,18 @@ public class XPackLicenseState {
|
|
|
* <p>
|
|
|
* ODBC is available only in for {@link OperationMode#PLATINUM} and {@link OperationMode#TRIAL} licences
|
|
|
*/
|
|
|
- public synchronized boolean isOdbcAllowed() {
|
|
|
- Status localStatus = status;
|
|
|
- OperationMode operationMode = localStatus.mode;
|
|
|
-
|
|
|
- boolean licensed = operationMode == OperationMode.TRIAL || operationMode == OperationMode.PLATINUM;
|
|
|
-
|
|
|
- return licensed && localStatus.active;
|
|
|
+ public boolean isOdbcAllowed() {
|
|
|
+ return isAllowedByLicenseAndSecurity(OperationMode.PLATINUM, false, true, true);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Determine if Spatial features should be enabled.
|
|
|
- * <p>
|
|
|
- * Spatial features are available in for all license types except
|
|
|
- * {@link OperationMode#MISSING}
|
|
|
*
|
|
|
* @return {@code true} as long as the license is valid. Otherwise
|
|
|
* {@code false}.
|
|
|
*/
|
|
|
public boolean isSpatialAllowed() {
|
|
|
- // status is volatile
|
|
|
- Status localStatus = status;
|
|
|
- // Should work on all active licenses
|
|
|
- return localStatus.active;
|
|
|
+ return isActive();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -791,8 +703,8 @@ public class XPackLicenseState {
|
|
|
*
|
|
|
* @return true if the license is active
|
|
|
*/
|
|
|
- public synchronized boolean isDataScienceAllowed() {
|
|
|
- return status.active;
|
|
|
+ public boolean isDataScienceAllowed() {
|
|
|
+ return isActive();
|
|
|
}
|
|
|
|
|
|
public synchronized boolean isTrialLicense() {
|
|
@@ -805,7 +717,7 @@ public class XPackLicenseState {
|
|
|
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.TRIAL || mode == OperationMode.BASIC || mode == OperationMode.ENTERPRISE;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -833,6 +745,7 @@ public class XPackLicenseState {
|
|
|
case STANDARD:
|
|
|
case GOLD:
|
|
|
case PLATINUM:
|
|
|
+ case ENTERPRISE:
|
|
|
return XPackSettings.SECURITY_ENABLED.get(settings);
|
|
|
case BASIC:
|
|
|
return XPackSettings.SECURITY_ENABLED.get(settings) && isSecurityExplicitlyEnabled(settings);
|
|
@@ -866,17 +779,20 @@ public class XPackLicenseState {
|
|
|
*
|
|
|
* @return true is the license is compatible, otherwise false
|
|
|
*/
|
|
|
- public synchronized boolean isCcrAllowed() {
|
|
|
- final Status currentStatus = status;
|
|
|
- return currentStatus.active && isCcrAllowedForOperationMode(currentStatus.mode);
|
|
|
+ public boolean isCcrAllowed() {
|
|
|
+ return isAllowedByLicenseAndSecurity(OperationMode.PLATINUM, false, true, true);
|
|
|
}
|
|
|
|
|
|
public static boolean isCcrAllowedForOperationMode(final OperationMode operationMode) {
|
|
|
- return isPlatinumOrTrialOperationMode(operationMode);
|
|
|
+ return isAllowedByOperationMode(operationMode, OperationMode.PLATINUM, true);
|
|
|
}
|
|
|
|
|
|
- public static boolean isPlatinumOrTrialOperationMode(final OperationMode operationMode) {
|
|
|
- return operationMode == OperationMode.PLATINUM || operationMode == OperationMode.TRIAL;
|
|
|
+ public static boolean isAllowedByOperationMode(
|
|
|
+ final OperationMode operationMode, final OperationMode minimumMode, final boolean allowTrial) {
|
|
|
+ if (allowTrial && OperationMode.TRIAL == operationMode) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return operationMode.compareTo(minimumMode) >= 0;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -889,4 +805,31 @@ public class XPackLicenseState {
|
|
|
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.
|
|
|
+ *
|
|
|
+ * @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)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (needActive && false == status.active) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return isAllowedByOperationMode(status.mode, minimumMode, allowTrial);
|
|
|
+ }
|
|
|
+
|
|
|
}
|