APISonar


org.elasticsearch.xpack.core.XPackField.SECURITY

> org > elasticsearch > xpack > core > XPackField > SECURITY
org APIs elasticsearch APIs xpack APIs core APIs XPackField APIs SECURITY APIs

Example 1
protected Exception checkFeatureAvailable(RestRequest request) {
        if (XPackSettings.SECURITY_ENABLED.get(settings) == false) {
            return new IllegalStateException("Security is not enabled but a security rest handler is registered");
        } else if (licenseState.isSecurityAvailable() == false) {
            return LicenseUtils.newComplianceException(XPackField.SECURITY);
        } else if (licenseState.isSecurityDisabledByLicenseDefaults()) {
            return new ElasticsearchException("Security must be explicitly enabled when using a [" +
                    licenseState.getOperationMode().description() + "] license. " +
                    "Enable security by setting [xpack.security.enabled] to [true] in the elasticsearch.yml file " +
                    "and restart the node.");
        } else {
            return null;
        }
    }
Example 2
public static ElasticsearchSecurityException authenticationError(String msg, Object... args) {
        ElasticsearchSecurityException e = new ElasticsearchSecurityException(msg, RestStatus.UNAUTHORIZED, args);
        e.addHeader("WWW-Authenticate", "Basic realm=\"" + XPackField.SECURITY + "\" charset=\"UTF-8\"");
        return e;
    }
Example 3
public SecurityFeatureSetUsage(boolean available, boolean enabled, Map<String, Object> realmsUsage,
                                   Map<String, Object> rolesStoreUsage, Map<String, Object> roleMappingStoreUsage,
                                   Map<String, Object> sslUsage, Map<String, Object> auditUsage,
                                   Map<String, Object> ipFilterUsage, Map<String, Object> anonymousUsage) {
        super(XPackField.SECURITY, available, enabled);
        this.realmsUsage = realmsUsage;
        this.rolesStoreUsage = rolesStoreUsage;
        this.roleMappingStoreUsage = roleMappingStoreUsage;
        this.sslUsage = sslUsage;
        this.auditUsage = auditUsage;
        this.ipFilterUsage = ipFilterUsage;
        this.anonymousUsage = anonymousUsage;
    }
Example 4
public void testSecurityAckBasicStandardTrialOrPlatinumToGold() {
        OperationMode from = randomFrom(BASIC, PLATINUM, TRIAL, STANDARD);
        assertAckMesssages(XPackField.SECURITY, from, GOLD, 3);
    }
Example 5
public void testSecurityAckBasicToNotGoldOrStandard() {
        OperationMode toMode = randomFrom(OperationMode.values(), mode -> mode != GOLD && mode != STANDARD);
        assertAckMesssages(XPackField.SECURITY, BASIC, toMode, 0);
    }
Example 6
private static void assertElasticsearchSecurityException(ThrowingRunnable runnable) {
        ElasticsearchSecurityException ee = expectThrows(ElasticsearchSecurityException.class, runnable);
        assertThat(ee.getMetadata(LicenseUtils.EXPIRED_FEATURE_METADATA), hasItem(XPackField.SECURITY));
        assertThat(ee.status(), is(RestStatus.FORBIDDEN));
    }
Example 7
public static void assertContainsWWWAuthenticateHeader(ElasticsearchSecurityException e) {
        assertThat(e.status(), is(RestStatus.UNAUTHORIZED));
        assertThat(e.getHeaderKeys(), hasSize(1));
        assertThat(e.getHeader("WWW-Authenticate"), notNullValue());
        assertThat(e.getHeader("WWW-Authenticate"), contains("Basic realm=\"" + XPackField.SECURITY + "\" charset=\"UTF-8\""));
    }