diff --git a/build.gradle b/build.gradle
index 164f980f661..cd69373a7e0 100644
--- a/build.gradle
+++ b/build.gradle
@@ -53,8 +53,16 @@ subprojects {
approvedLicenses = ['Elasticsearch Confidential']
additionalLicense 'ESCON', 'Elasticsearch Confidential', 'ELASTICSEARCH CONFIDENTIAL'
}
- ext.projectSubstitutions += [ "org.elasticsearch.plugin:x-pack-api:${version}": ':x-pack-elasticsearch:plugin']
+ ext.projectSubstitutions += [ "org.elasticsearch.plugin:x-pack-api:${version}": ':x-pack-elasticsearch:plugin:core']
ext.projectSubstitutions += [ "org.elasticsearch.plugin:x-pack-core:${version}": ':x-pack-elasticsearch:plugin:core']
+ ext.projectSubstitutions += [ "org.elasticsearch.plugin:x-pack-deprecation:${version}": ':x-pack-elasticsearch:plugin:deprecation']
+ ext.projectSubstitutions += [ "org.elasticsearch.plugin:x-pack-graph:${version}": ':x-pack-elasticsearch:plugin:graph']
+ ext.projectSubstitutions += [ "org.elasticsearch.plugin:x-pack-logstash:${version}": ':x-pack-elasticsearch:plugin:logstash']
+ ext.projectSubstitutions += [ "org.elasticsearch.plugin:x-pack-ml:${version}": ':x-pack-elasticsearch:plugin:ml']
+ ext.projectSubstitutions += [ "org.elasticsearch.plugin:x-pack-monitoring:${version}": ':x-pack-elasticsearch:plugin:monitoring']
+ ext.projectSubstitutions += [ "org.elasticsearch.plugin:x-pack-security:${version}": ':x-pack-elasticsearch:plugin:security']
+ ext.projectSubstitutions += [ "org.elasticsearch.plugin:x-pack-upgrade:${version}": ':x-pack-elasticsearch:plugin:upgrade']
+ ext.projectSubstitutions += [ "org.elasticsearch.plugin:x-pack-watcher:${version}": ':x-pack-elasticsearch:plugin:watcher']
for (final Version version : versionCollection.versionsIndexCompatibleWithCurrent) {
if (version.branch != null) {
diff --git a/dev-tools/checkstyle_suppressions.xml b/dev-tools/checkstyle_suppressions.xml
index ea7537e6a0e..2301cdeeb84 100644
--- a/dev-tools/checkstyle_suppressions.xml
+++ b/dev-tools/checkstyle_suppressions.xml
@@ -5,23 +5,21 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/docs/build.gradle b/docs/build.gradle
index f6835aa0c8a..cd76b620863 100644
--- a/docs/build.gradle
+++ b/docs/build.gradle
@@ -93,7 +93,8 @@ buildRestTests.expectedUnconvertedCandidates = [
]
dependencies {
- testCompile project(path: ':x-pack-elasticsearch:plugin', configuration: 'runtime')
+ testCompile project(path: ':x-pack-elasticsearch:plugin:core', configuration: 'runtime')
+ testCompile project(path: ':x-pack-elasticsearch:plugin:core', configuration: 'testArtifacts')
testCompile project(path: ':x-pack-elasticsearch:plugin', configuration: 'testArtifacts')
}
diff --git a/license-tools/build.gradle b/license-tools/build.gradle
index 5c47e0045dc..125f09cf932 100644
--- a/license-tools/build.gradle
+++ b/license-tools/build.gradle
@@ -1,7 +1,7 @@
apply plugin: 'elasticsearch.build'
dependencies {
- compile project(':x-pack-elasticsearch:plugin')
+ compile project(':x-pack-elasticsearch:plugin:core')
compile "org.elasticsearch:elasticsearch:${version}"
testCompile "org.elasticsearch.test:framework:${version}"
}
diff --git a/plugin/bin/x-pack/x-pack-env b/plugin/bin/x-pack/x-pack-env
deleted file mode 100644
index db28c03d1fd..00000000000
--- a/plugin/bin/x-pack/x-pack-env
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/bash
-
-# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
-# or more contributor license agreements. Licensed under the Elastic License;
-# you may not use this file except in compliance with the Elastic License.
-
-ES_CLASSPATH="$ES_CLASSPATH:$ES_HOME/plugins/x-pack/*"
diff --git a/plugin/bin/x-pack/x-pack-env.bat b/plugin/bin/x-pack/x-pack-env.bat
deleted file mode 100644
index d6642fe2e34..00000000000
--- a/plugin/bin/x-pack/x-pack-env.bat
+++ /dev/null
@@ -1,5 +0,0 @@
-rem Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
-rem or more contributor license agreements. Licensed under the Elastic License;
-rem you may not use this file except in compliance with the Elastic License.
-
-set ES_CLASSPATH=!ES_CLASSPATH!;!ES_HOME!/plugins/x-pack/*
diff --git a/plugin/build.gradle b/plugin/build.gradle
index 4dce3291361..1631552836c 100644
--- a/plugin/build.gradle
+++ b/plugin/build.gradle
@@ -6,200 +6,63 @@ import java.nio.charset.StandardCharsets
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.StandardCopyOption
+import org.elasticsearch.gradle.test.RunTask;
-group 'org.elasticsearch.plugin'
+apply plugin: 'elasticsearch.es-meta-plugin'
-apply plugin: 'elasticsearch.esplugin'
-esplugin {
- name 'x-pack'
- description 'Elasticsearch Expanded Pack Plugin'
- classname 'org.elasticsearch.xpack.XPackPlugin'
- hasNativeController true
- requiresKeystore true
- licenseFile project(':x-pack-elasticsearch').file('LICENSE.txt')
- noticeFile project(':x-pack-elasticsearch').file('NOTICE.txt')
-}
archivesBaseName = 'x-pack' // for api jar
-// TODO: fix this! https://github.com/elastic/x-plugins/issues/1066
-ext.compactProfile = 'full'
+//dependencyLicenses {
+// mapping from: /netty-.*/, to: 'netty'
+// mapping from: /bc.*/, to: 'bouncycastle'
+// mapping from: /owasp-java-html-sanitizer.*/, to: 'owasp-java-html-sanitizer'
+// mapping from: /transport-netty.*/, to: 'elasticsearch'
+// mapping from: /transport-nio.*/, to: 'elasticsearch'
+// mapping from: /elasticsearch-nio.*/, to: 'elasticsearch'
+// mapping from: /elasticsearch-rest-client.*/, to: 'elasticsearch'
+// mapping from: /http.*/, to: 'httpclient' // pulled in by rest client
+// mapping from: /commons-.*/, to: 'commons' // pulled in by rest client
+// ignoreSha 'elasticsearch-rest-client'
+// ignoreSha 'transport-netty4'
+// ignoreSha 'transport-nio'
+// ignoreSha 'elasticsearch-nio'
+// ignoreSha 'elasticsearch-rest-client-sniffer'
+// ignoreSha 'x-pack-core'
+//}
-dependencyLicenses {
- mapping from: /netty-.*/, to: 'netty'
- mapping from: /bc.*/, to: 'bouncycastle'
- mapping from: /owasp-java-html-sanitizer.*/, to: 'owasp-java-html-sanitizer'
- mapping from: /transport-netty.*/, to: 'elasticsearch'
- mapping from: /transport-nio.*/, to: 'elasticsearch'
- mapping from: /elasticsearch-nio.*/, to: 'elasticsearch'
- mapping from: /elasticsearch-rest-client.*/, to: 'elasticsearch'
- mapping from: /http.*/, to: 'httpclient' // pulled in by rest client
- mapping from: /commons-.*/, to: 'commons' // pulled in by rest client
- ignoreSha 'elasticsearch-rest-client'
- ignoreSha 'transport-netty4'
- ignoreSha 'transport-nio'
- ignoreSha 'elasticsearch-nio'
- ignoreSha 'elasticsearch-rest-client-sniffer'
- ignoreSha 'x-pack-core'
+es_meta_plugin {
+ name = 'x-pack'
+ description = 'Elasticsearch Expanded Pack Plugin'
+ plugins = ['core', 'deprecation', 'graph', 'logstash',
+ 'ml', 'monitoring', 'security', 'upgrade', 'watcher']
}
-configurations {
- nativeBundle {
- resolutionStrategy.dependencySubstitution {
- if (findProject(':machine-learning-cpp') != null) {
- substitute module("org.elasticsearch.ml:ml-cpp") with project(":machine-learning-cpp")
- } else {
- substitute module("org.elasticsearch.ml:ml-cpp") with project("${project.path}:ml-cpp-snapshot")
- }
- }
- }
-}
-
-dependencies {
- // CLI deps
- compile project(path: ':server:cli', configuration: 'runtime')
-
- // Core project deps (this is temporary)
- compile project(':x-pack-elasticsearch:plugin:core')
-
- // security deps
- compile project(path: ':modules:transport-netty4', configuration: 'runtime')
- compile project(path: ':plugins:transport-nio', configuration: 'runtime')
- compile 'com.unboundid:unboundid-ldapsdk:3.2.0'
- compile 'org.bouncycastle:bcprov-jdk15on:1.58'
- compile 'org.bouncycastle:bcpkix-jdk15on:1.58'
- testCompile 'com.google.jimfs:jimfs:1.1'
-
- // watcher deps
- compile 'com.googlecode.owasp-java-html-sanitizer:owasp-java-html-sanitizer:r239'
- compile 'com.google.guava:guava:16.0.1' // needed by watcher for the html sanitizer and security tests for jimfs
- compile 'com.sun.mail:javax.mail:1.5.6'
- // HACK: java 9 removed javax.activation from the default modules, so instead of trying to add modules, which would have
- // to be conditionalized for java 8/9, we pull in the classes directly
- compile 'javax.activation:activation:1.1.1'
-
- testCompile 'org.subethamail:subethasmtp:3.1.7'
- // needed for subethasmtp, has @GuardedBy annotation
- testCompile 'com.google.code.findbugs:jsr305:3.0.1'
-
- // monitoring deps
- compile "org.elasticsearch.client:elasticsearch-rest-client:${version}"
- compile "org.elasticsearch.client:elasticsearch-rest-client-sniffer:${version}"
-
- // ml deps
- compile 'net.sf.supercsv:super-csv:2.4.0'
- nativeBundle "org.elasticsearch.ml:ml-cpp:${project.version}@zip"
- testCompile 'org.ini4j:ini4j:0.5.2'
-
- // common test deps
- testCompile 'org.elasticsearch:securemock:1.2'
- testCompile "org.elasticsearch:mocksocket:${versions.mocksocket}"
- testCompile 'org.slf4j:slf4j-log4j12:1.6.2'
- testCompile 'org.slf4j:slf4j-api:1.6.2'
- testCompile project(path: ':modules:reindex', configuration: 'runtime')
- testCompile project(path: ':modules:parent-join', configuration: 'runtime')
- testCompile project(path: ':modules:analysis-common', configuration: 'runtime')
-}
-
-// make LicenseSigner available for testing signed licenses
-sourceSets.test.java {
- srcDir '../license-tools/src/main/java'
-}
-
-compileJava.options.compilerArgs << "-Xlint:-deprecation,-rawtypes,-serial,-try,-unchecked"
-compileTestJava.options.compilerArgs << "-Xlint:-deprecation,-rawtypes,-serial,-try,-unchecked"
-
ext.expansions = [
- 'project.version': version,
+ 'project.version': version,
]
-processResources {
- from(sourceSets.main.resources.srcDirs) {
- exclude '**/public.key'
- inputs.properties(expansions)
- MavenFilteringHack.filter(it, expansions)
- }
- boolean snapshot = "true".equals(System.getProperty("build.snapshot", "true"))
- if (snapshot) {
- from 'keys/dev/public.key'
- } else {
- from 'keys/prod/public.key'
- }
+dependencies {
+ testCompile project(path: ':x-pack-elasticsearch:plugin:core', configuration: 'testArtifacts')
+ testCompile project(path: ':x-pack-elasticsearch:plugin:deprecation')
+ testCompile project(path: ':x-pack-elasticsearch:plugin:graph')
+ testCompile project(path: ':x-pack-elasticsearch:plugin:logstash')
+ testCompile project(path: ':x-pack-elasticsearch:plugin:ml')
+ testCompile project(path: ':x-pack-elasticsearch:plugin:monitoring')
+ testCompile project(path: ':x-pack-elasticsearch:plugin:security')
+ testCompile project(path: ':x-pack-elasticsearch:plugin:upgrade')
+ testCompile project(path: ':x-pack-elasticsearch:plugin:watcher')
}
-forbiddenPatterns {
- exclude '**/*.key'
- exclude '**/*.p12'
- exclude '**/*.der'
- exclude '**/*.zip'
+// https://github.com/elastic/x-plugins/issues/724
+configurations {
+ testArtifacts.extendsFrom testRuntime
}
-
-forbiddenApisMain {
- signaturesURLs += file('forbidden/ldap-signatures.txt').toURI().toURL()
+task testJar(type: Jar) {
+ appendix 'test'
+ from sourceSets.test.output
}
-
-task extractNativeLicenses(type: Copy) {
- dependsOn configurations.nativeBundle
- into "${buildDir}"
- from {
- project.zipTree(configurations.nativeBundle.singleFile)
- }
- include 'platform/licenses/**'
- // This is to reduce the risk of credentials used to access the native bundle not
- // having propagated throughout AWS by the time it's downloaded; the time needed
- // to compile the Java is extra time during which the propagation can take place
- shouldRunAfter compileJava
-}
-
-// TODO: standardize packaging config for plugins
-bundlePlugin {
- dependsOn configurations.nativeBundle
- from('bin/x-pack') {
- into 'bin'
- }
- from('config/x-pack') {
- into 'config'
- }
- from {
- project.zipTree(configurations.nativeBundle.singleFile)
- }
- // We don't ship the individual nativeBundle licenses - instead
- // they get combined into the top level NOTICES file we ship
- exclude 'platform/licenses/**'
-}
-
-// add api jar for extension authors to compile against
-// note this is just the normal x-pack jar for now, with a different name
-project.afterEvaluate {
- task apiJar {
- dependsOn('generatePomFileForApijarPublication', project.jar)
- doFirst {
- Path jarFile = project.jar.outputs.files.singleFile.toPath()
- String apiFileName = jarFile.fileName.toString().replace(project.version, "api-${project.version}")
- Files.copy(jarFile, jarFile.resolveSibling(apiFileName), StandardCopyOption.REPLACE_EXISTING)
-
- String pomFileName = jarFile.fileName.toString().replace('.jar', '.pom')
- String apiPomFileName = apiFileName.replace('.jar', '.pom')
- Files.copy(jarFile.resolveSibling(pomFileName), jarFile.resolveSibling(apiPomFileName),
- StandardCopyOption.REPLACE_EXISTING)
- }
- }
- assemble.dependsOn(apiJar)
- project.publishing {
- publications {
- apijar(MavenPublication) {
- from project.components.java
- artifactId = 'x-pack-api'
- pom.withXml { XmlProvider xml ->
- Node root = xml.asNode()
- root.appendNode('name', project.pluginProperties.extension.name)
- root.appendNode('description', project.pluginProperties.extension.description)
- }
- }
- }
- }
- // Add an extra licenses directory to the combined notices
- project.tasks.findByName('generateNotice').dependsOn extractNativeLicenses
- project.tasks.findByName('generateNotice').licensesDir new File("${project.buildDir}/platform/licenses")
+artifacts {
+ testArtifacts testJar
}
integTestRunner {
@@ -303,14 +166,6 @@ integTestCluster {
}
}
-test {
- /*
- * We have to disable setting the number of available processors as tests in the same JVM randomize processors and will step on each
- * other if we allow them to set the number of available processors as it's set-once in Netty.
- */
- systemProperty 'es.set.netty.runtime.available.processors', 'false'
-}
-
integTestRunner {
/*
* We have to disable setting the number of available processors as tests in the same JVM randomize processors and will step on each
@@ -319,73 +174,6 @@ integTestRunner {
systemProperty 'es.set.netty.runtime.available.processors', 'false'
}
-// TODO: don't publish test artifacts just to run messy tests, fix the tests!
-// https://github.com/elastic/x-plugins/issues/724
-configurations {
- testArtifacts.extendsFrom testRuntime
-}
-task testJar(type: Jar) {
- appendix 'test'
- from sourceSets.test.output
-}
-artifacts {
- // normal es plugins do not publish the jar but we need to since users need it for Transport Clients and extensions
- archives jar
- testArtifacts testJar
-}
-
-// classes are missing, e.g. com.ibm.icu.lang.UCharacter
-thirdPartyAudit.excludes = [
- // uses internal java api: sun.misc.Unsafe
- 'com.google.common.cache.Striped64',
- 'com.google.common.cache.Striped64$1',
- 'com.google.common.cache.Striped64$Cell',
- 'com.google.common.primitives.UnsignedBytes$LexicographicalComparatorHolder$UnsafeComparator',
- 'com.google.common.primitives.UnsignedBytes$LexicographicalComparatorHolder$UnsafeComparator$1',
-
- // pulled in as external dependency to work on java 9
- 'com.sun.activation.registries.LineTokenizer',
- 'com.sun.activation.registries.LogSupport',
- 'com.sun.activation.registries.MailcapFile',
- 'com.sun.activation.registries.MailcapTokenizer',
- 'com.sun.activation.registries.MimeTypeEntry',
- 'com.sun.activation.registries.MimeTypeFile',
- 'javax.activation.MailcapCommandMap',
- 'javax.activation.MimetypesFileTypeMap',
-]
-
-// pulled in as external dependency to work on java 9
-if (JavaVersion.current() <= JavaVersion.VERSION_1_8) {
- thirdPartyAudit.excludes += [
- 'com.sun.activation.registries.MailcapParseException',
- 'javax.activation.ActivationDataFlavor',
- 'javax.activation.CommandInfo',
- 'javax.activation.CommandMap',
- 'javax.activation.CommandObject',
- 'javax.activation.DataContentHandler',
- 'javax.activation.DataContentHandlerFactory',
- 'javax.activation.DataHandler$1',
- 'javax.activation.DataHandler',
- 'javax.activation.DataHandlerDataSource',
- 'javax.activation.DataSource',
- 'javax.activation.DataSourceDataContentHandler',
- 'javax.activation.FileDataSource',
- 'javax.activation.FileTypeMap',
- 'javax.activation.MimeType',
- 'javax.activation.MimeTypeParameterList',
- 'javax.activation.MimeTypeParseException',
- 'javax.activation.ObjectDataContentHandler',
- 'javax.activation.SecuritySupport$1',
- 'javax.activation.SecuritySupport$2',
- 'javax.activation.SecuritySupport$3',
- 'javax.activation.SecuritySupport$4',
- 'javax.activation.SecuritySupport$5',
- 'javax.activation.SecuritySupport',
- 'javax.activation.URLDataSource',
- 'javax.activation.UnsupportedDataTypeException'
- ]
-}
-
run {
setting 'xpack.ml.enabled', 'true'
setting 'xpack.graph.enabled', 'true'
diff --git a/plugin/core/build.gradle b/plugin/core/build.gradle
index b79df34e746..71d7a45e688 100644
--- a/plugin/core/build.gradle
+++ b/plugin/core/build.gradle
@@ -1,22 +1,300 @@
-apply plugin: 'elasticsearch.build'
+import org.elasticsearch.gradle.MavenFilteringHack
+
+apply plugin: 'elasticsearch.esplugin'
+esplugin {
+ name 'x-pack-core'
+ description 'Elasticsearch Expanded Pack Plugin - Core'
+ classname 'org.elasticsearch.xpack.XPackPlugin'
+ hasNativeController true
+ requiresKeystore true
+ licenseFile project(':x-pack-elasticsearch').file('LICENSE.txt')
+ noticeFile project(':x-pack-elasticsearch').file('NOTICE.txt')
+}
+
+integTest.enabled = false
+
+dependencyLicenses {
+ mapping from: /netty-.*/, to: 'netty'
+ mapping from: /bc.*/, to: 'bouncycastle'
+ mapping from: /owasp-java-html-sanitizer.*/, to: 'owasp-java-html-sanitizer'
+ mapping from: /transport-netty.*/, to: 'elasticsearch'
+ mapping from: /transport-nio.*/, to: 'elasticsearch'
+ mapping from: /elasticsearch-nio.*/, to: 'elasticsearch'
+ mapping from: /elasticsearch-rest-client.*/, to: 'elasticsearch'
+ mapping from: /http.*/, to: 'httpclient' // pulled in by rest client
+ mapping from: /commons-.*/, to: 'commons' // pulled in by rest client
+ ignoreSha 'elasticsearch-rest-client'
+ ignoreSha 'transport-netty4'
+ ignoreSha 'transport-nio'
+ ignoreSha 'elasticsearch-nio'
+ ignoreSha 'elasticsearch-rest-client-sniffer'
+ ignoreSha 'x-pack-core'
+}
dependencies {
provided "org.elasticsearch:elasticsearch:${version}"
+ compile "org.apache.httpcomponents:httpclient:${versions.httpclient}"
+ compile "org.apache.httpcomponents:httpcore:${versions.httpcore}"
+ compile "org.apache.httpcomponents:httpasyncclient:${versions.httpasyncclient}"
+
+ compile "commons-logging:commons-logging:${versions.commonslogging}"
+ compile "commons-codec:commons-codec:${versions.commonscodec}"
+
+ // security deps
+ compile 'com.unboundid:unboundid-ldapsdk:3.2.0'
+ compile 'org.bouncycastle:bcprov-jdk15on:1.58'
+ compile 'org.bouncycastle:bcpkix-jdk15on:1.58'
+ compile project(path: ':modules:transport-netty4', configuration: 'runtime')
+
+ //testCompile project(path: ':core:cli', configuration: 'runtime')
+ testCompile 'org.elasticsearch:securemock:1.2'
+ testCompile "org.elasticsearch:mocksocket:${versions.mocksocket}"
+ testCompile 'org.slf4j:slf4j-log4j12:1.6.2'
+ testCompile 'org.slf4j:slf4j-api:1.6.2'
+ testCompile project(path: ':modules:reindex', configuration: 'runtime')
+ testCompile project(path: ':modules:parent-join', configuration: 'runtime')
+ testCompile project(path: ':modules:analysis-common', configuration: 'runtime')
+}
+
+processResources {
+ from(sourceSets.main.resources.srcDirs) {
+ exclude '**/public.key'
+ inputs.properties(expansions)
+ MavenFilteringHack.filter(it, expansions)
+ }
+ boolean snapshot = "true".equals(System.getProperty("build.snapshot", "true"))
+ if (snapshot) {
+ from '../keys/dev/public.key'
+ } else {
+ from '../keys/prod/public.key'
+ }
+}
+
+forbiddenPatterns {
+ exclude '**/*.key'
+ exclude '**/*.p12'
+ exclude '**/*.der'
+ exclude '**/*.zip'
}
archivesBaseName = 'x-pack-core'
compileJava.options.compilerArgs << "-Xlint:-deprecation,-rawtypes,-serial,-try,-unchecked"
-//compileTestJava.options.compilerArgs << "-Xlint:-deprecation,-rawtypes,-serial,-try,-unchecked"
+compileTestJava.options.compilerArgs << "-Xlint:-deprecation,-rawtypes,-serial,-try,-unchecked"
-// TODO: enable this once we have tests
-test.enabled=false
+// TODO: fix these!
+thirdPartyAudit.enabled = false
licenseHeaders {
approvedLicenses << 'BCrypt (BSD-like)'
additionalLicense 'BCRYP', 'BCrypt (BSD-like)', 'Copyright (c) 2006 Damien Miller '
+ enabled = false
}
-parent.bundlePlugin {
- from jar
+// make LicenseSigner available for testing signed licenses
+sourceSets.test.java {
+ srcDir '../../license-tools/src/main/java'
+}
+
+//// add api jar for extension authors to compile against
+//// note this is just the normal x-pack jar for now, with a different name
+//project.afterEvaluate {
+// task apiJar {
+// dependsOn('generatePomFileForApijarPublication', project.jar)
+// doFirst {
+// Path jarFile = project.jar.outputs.files.singleFile.toPath()
+// String apiFileName = jarFile.fileName.toString().replace(project.version, "api-${project.version}")
+// Files.copy(jarFile, jarFile.resolveSibling(apiFileName), StandardCopyOption.REPLACE_EXISTING)
+//
+// String pomFileName = jarFile.fileName.toString().replace('.jar', '.pom')
+// String apiPomFileName = apiFileName.replace('.jar', '.pom')
+// Files.copy(jarFile.resolveSibling(pomFileName), jarFile.resolveSibling(apiPomFileName),
+// StandardCopyOption.REPLACE_EXISTING)
+// }
+// }
+// assemble.dependsOn(apiJar)
+// project.publishing {
+// publications {
+// apijar(MavenPublication) {
+// from project.components.java
+// artifactId = 'x-pack-api'
+// pom.withXml { XmlProvider xml ->
+// Node root = xml.asNode()
+// root.appendNode('name', project.pluginProperties.extension.name)
+// root.appendNode('description', project.pluginProperties.extension.description)
+// }
+// }
+// }
+// }
+// // Add an extra licenses directory to the combined notices
+// project.tasks.findByName('generateNotice').dependsOn extractNativeLicenses
+// project.tasks.findByName('generateNotice').licensesDir new File("${project.buildDir}/platform/licenses")
+//}
+//
+// integTestRunner {
+// // TODO: fix this rest test to not depend on a hardcoded port!
+// def blacklist = ['getting_started/10_monitor_cluster_health/*']
+// boolean snapshot = "true".equals(System.getProperty("build.snapshot", "true"))
+// if (!snapshot) {
+// // these tests attempt to install basic/internal licenses signed against the dev/public.key
+// // Since there is no infrastructure in place (anytime soon) to generate licenses using the production
+// // private key, these tests are whitelisted in non-snapshot test runs
+// blacklist.addAll(['xpack/15_basic/*', 'license/20_put_license/*'])
+// }
+// systemProperty 'tests.rest.blacklist', blacklist.join(',')
+// }
+
+// // location of generated keystores and certificates
+// File keystoreDir = new File(project.buildDir, 'keystore')
+
+// // Generate the node's keystore
+// File nodeKeystore = new File(keystoreDir, 'test-node.jks')
+// task createNodeKeyStore(type: LoggedExec) {
+// doFirst {
+// if (nodeKeystore.parentFile.exists() == false) {
+// nodeKeystore.parentFile.mkdirs()
+// }
+// if (nodeKeystore.exists()) {
+// delete nodeKeystore
+// }
+// }
+// executable = new File(project.javaHome, 'bin/keytool')
+// standardInput = new ByteArrayInputStream('FirstName LastName\nUnit\nOrganization\nCity\nState\nNL\nyes\n\n'.getBytes('UTF-8'))
+// args '-genkey',
+// '-alias', 'test-node',
+// '-keystore', nodeKeystore,
+// '-keyalg', 'RSA',
+// '-keysize', '2048',
+// '-validity', '712',
+// '-dname', 'CN=smoke-test-plugins-ssl',
+// '-keypass', 'keypass',
+// '-storepass', 'keypass'
+// }
+
+// Add keystores to test classpath: it expects it there
+//sourceSets.test.resources.srcDir(keystoreDir)
+//processTestResources.dependsOn(createNodeKeyStore)
+
+// integTestCluster {
+// dependsOn createNodeKeyStore
+// setting 'xpack.ml.enabled', 'true'
+// setting 'logger.org.elasticsearch.xpack.ml.datafeed', 'TRACE'
+// // Integration tests are supposed to enable/disable exporters before/after each test
+// setting 'xpack.monitoring.exporters._local.type', 'local'
+// setting 'xpack.monitoring.exporters._local.enabled', 'false'
+// setting 'xpack.monitoring.collection.interval', '-1'
+// setting 'xpack.security.authc.token.enabled', 'true'
+// setting 'xpack.security.transport.ssl.enabled', 'true'
+// setting 'xpack.security.transport.ssl.keystore.path', nodeKeystore.name
+// setting 'xpack.security.transport.ssl.verification_mode', 'certificate'
+// setting 'xpack.security.audit.enabled', 'true'
+// keystoreSetting 'bootstrap.password', 'x-pack-test-password'
+// keystoreSetting 'xpack.security.transport.ssl.keystore.secure_password', 'keypass'
+// distribution = 'zip' // this is important since we use the reindex module in ML
+
+// setupCommand 'setupTestUser', 'bin/x-pack/users', 'useradd', 'x_pack_rest_user', '-p', 'x-pack-test-password', '-r', 'superuser'
+
+// extraConfigFile nodeKeystore.name, nodeKeystore
+
+// waitCondition = { NodeInfo node, AntBuilder ant ->
+// File tmpFile = new File(node.cwd, 'wait.success')
+
+// for (int i = 0; i < 10; i++) {
+// // we use custom wait logic here as the elastic user is not available immediately and ant.get will fail when a 401 is returned
+// HttpURLConnection httpURLConnection = null;
+// try {
+// httpURLConnection = (HttpURLConnection) new URL("http://${node.httpUri()}/_cluster/health?wait_for_nodes=${numNodes}&wait_for_status=yellow").openConnection();
+// httpURLConnection.setRequestProperty("Authorization", "Basic " +
+// Base64.getEncoder().encodeToString("x_pack_rest_user:x-pack-test-password".getBytes(StandardCharsets.UTF_8)));
+// httpURLConnection.setRequestMethod("GET");
+// httpURLConnection.connect();
+// if (httpURLConnection.getResponseCode() == 200) {
+// tmpFile.withWriter StandardCharsets.UTF_8.name(), {
+// it.write(httpURLConnection.getInputStream().getText(StandardCharsets.UTF_8.name()))
+// }
+// }
+// } catch (Exception e) {
+// if (i == 9) {
+// logger.error("final attempt of calling cluster health failed", e)
+// } else {
+// logger.debug("failed to call cluster health", e)
+// }
+// } finally {
+// if (httpURLConnection != null) {
+// httpURLConnection.disconnect();
+// }
+// }
+
+// // did not start, so wait a bit before trying again
+// Thread.sleep(500L);
+// }
+// return tmpFile.exists()
+// }
+//}
+
+test {
+ /*
+ * We have to disable setting the number of available processors as tests in the same JVM randomize processors and will step on each
+ * other if we allow them to set the number of available processors as it's set-once in Netty.
+ */
+ systemProperty 'es.set.netty.runtime.available.processors', 'false'
+}
+
+integTestRunner {
+ /*
+ * We have to disable setting the number of available processors as tests in the same JVM randomize processors and will step on each
+ * other if we allow them to set the number of available processors as it's set-once in Netty.
+ */
+ systemProperty 'es.set.netty.runtime.available.processors', 'false'
+}
+
+// TODO: don't publish test artifacts just to run messy tests, fix the tests!
+// https://github.com/elastic/x-plugins/issues/724
+configurations {
+ testArtifacts.extendsFrom testRuntime
+}
+task testJar(type: Jar) {
+ appendix 'test'
+ from sourceSets.test.output
+}
+artifacts {
+ // normal es plugins do not publish the jar but we need to since users need it for Transport Clients and extensions
+ archives jar
+ testArtifacts testJar
+}
+
+// pulled in as external dependency to work on java 9
+if (JavaVersion.current() <= JavaVersion.VERSION_1_8) {
+ thirdPartyAudit.excludes += [
+ 'com.sun.activation.registries.MailcapParseException',
+ 'javax.activation.ActivationDataFlavor',
+ 'javax.activation.CommandInfo',
+ 'javax.activation.CommandMap',
+ 'javax.activation.CommandObject',
+ 'javax.activation.DataContentHandler',
+ 'javax.activation.DataContentHandlerFactory',
+ 'javax.activation.DataHandler$1',
+ 'javax.activation.DataHandler',
+ 'javax.activation.DataHandlerDataSource',
+ 'javax.activation.DataSource',
+ 'javax.activation.DataSourceDataContentHandler',
+ 'javax.activation.FileDataSource',
+ 'javax.activation.FileTypeMap',
+ 'javax.activation.MimeType',
+ 'javax.activation.MimeTypeParameterList',
+ 'javax.activation.MimeTypeParseException',
+ 'javax.activation.ObjectDataContentHandler',
+ 'javax.activation.SecuritySupport$1',
+ 'javax.activation.SecuritySupport$2',
+ 'javax.activation.SecuritySupport$3',
+ 'javax.activation.SecuritySupport$4',
+ 'javax.activation.SecuritySupport$5',
+ 'javax.activation.SecuritySupport',
+ 'javax.activation.URLDataSource',
+ 'javax.activation.UnsupportedDataTypeException'
+ ]
+}
+
+run {
+ distribution = 'zip'
}
diff --git a/plugin/security/licenses/bcpkix-jdk15on-1.58.jar.sha1 b/plugin/core/licenses/bcpkix-jdk15on-1.58.jar.sha1
similarity index 100%
rename from plugin/security/licenses/bcpkix-jdk15on-1.58.jar.sha1
rename to plugin/core/licenses/bcpkix-jdk15on-1.58.jar.sha1
diff --git a/plugin/security/licenses/bcprov-jdk15on-1.58.jar.sha1 b/plugin/core/licenses/bcprov-jdk15on-1.58.jar.sha1
similarity index 100%
rename from plugin/security/licenses/bcprov-jdk15on-1.58.jar.sha1
rename to plugin/core/licenses/bcprov-jdk15on-1.58.jar.sha1
diff --git a/plugin/security/licenses/bouncycastle-LICENSE.txt b/plugin/core/licenses/bouncycastle-LICENSE.txt
similarity index 100%
rename from plugin/security/licenses/bouncycastle-LICENSE.txt
rename to plugin/core/licenses/bouncycastle-LICENSE.txt
diff --git a/plugin/security/licenses/bouncycastle-NOTICE.txt b/plugin/core/licenses/bouncycastle-NOTICE.txt
similarity index 100%
rename from plugin/security/licenses/bouncycastle-NOTICE.txt
rename to plugin/core/licenses/bouncycastle-NOTICE.txt
diff --git a/plugin/core/licenses/commons-LICENSE.txt b/plugin/core/licenses/commons-LICENSE.txt
new file mode 100644
index 00000000000..d6456956733
--- /dev/null
+++ b/plugin/core/licenses/commons-LICENSE.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/plugin/core/licenses/commons-NOTICE.txt b/plugin/core/licenses/commons-NOTICE.txt
new file mode 100644
index 00000000000..1da9af50f60
--- /dev/null
+++ b/plugin/core/licenses/commons-NOTICE.txt
@@ -0,0 +1,17 @@
+Apache Commons Codec
+Copyright 2002-2014 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+src/test/org/apache/commons/codec/language/DoubleMetaphoneTest.java
+contains test data from http://aspell.net/test/orig/batch0.tab.
+Copyright (C) 2002 Kevin Atkinson (kevina@gnu.org)
+
+===============================================================================
+
+The content of package org.apache.commons.codec.language.bm has been translated
+from the original php source code available at http://stevemorse.org/phoneticinfo.htm
+with permission from the original authors.
+Original source copyright:
+Copyright (c) 2008 Alexander Beider & Stephen P. Morse.
diff --git a/plugin/core/licenses/commons-codec-1.10.jar.sha1 b/plugin/core/licenses/commons-codec-1.10.jar.sha1
new file mode 100644
index 00000000000..3fe8682a1b0
--- /dev/null
+++ b/plugin/core/licenses/commons-codec-1.10.jar.sha1
@@ -0,0 +1 @@
+4b95f4897fa13f2cd904aee711aeafc0c5295cd8
\ No newline at end of file
diff --git a/plugin/core/licenses/commons-logging-1.1.3.jar.sha1 b/plugin/core/licenses/commons-logging-1.1.3.jar.sha1
new file mode 100644
index 00000000000..5b8f029e582
--- /dev/null
+++ b/plugin/core/licenses/commons-logging-1.1.3.jar.sha1
@@ -0,0 +1 @@
+f6f66e966c70a83ffbdb6f17a0919eaf7c8aca7f
\ No newline at end of file
diff --git a/plugin/core/licenses/httpasyncclient-4.1.2.jar.sha1 b/plugin/core/licenses/httpasyncclient-4.1.2.jar.sha1
new file mode 100644
index 00000000000..065ed920a17
--- /dev/null
+++ b/plugin/core/licenses/httpasyncclient-4.1.2.jar.sha1
@@ -0,0 +1 @@
+95aa3e6fb520191a0970a73cf09f62948ee614be
\ No newline at end of file
diff --git a/plugin/core/licenses/httpclient-4.5.2.jar.sha1 b/plugin/core/licenses/httpclient-4.5.2.jar.sha1
new file mode 100644
index 00000000000..6937112a09f
--- /dev/null
+++ b/plugin/core/licenses/httpclient-4.5.2.jar.sha1
@@ -0,0 +1 @@
+733db77aa8d9b2d68015189df76ab06304406e50
\ No newline at end of file
diff --git a/plugin/core/licenses/httpclient-LICENSE.txt b/plugin/core/licenses/httpclient-LICENSE.txt
new file mode 100644
index 00000000000..32f01eda18f
--- /dev/null
+++ b/plugin/core/licenses/httpclient-LICENSE.txt
@@ -0,0 +1,558 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+=========================================================================
+
+This project includes Public Suffix List copied from
+
+licensed under the terms of the Mozilla Public License, v. 2.0
+
+Full license text:
+
+Mozilla Public License Version 2.0
+==================================
+
+1. Definitions
+--------------
+
+1.1. "Contributor"
+ means each individual or legal entity that creates, contributes to
+ the creation of, or owns Covered Software.
+
+1.2. "Contributor Version"
+ means the combination of the Contributions of others (if any) used
+ by a Contributor and that particular Contributor's Contribution.
+
+1.3. "Contribution"
+ means Covered Software of a particular Contributor.
+
+1.4. "Covered Software"
+ means Source Code Form to which the initial Contributor has attached
+ the notice in Exhibit A, the Executable Form of such Source Code
+ Form, and Modifications of such Source Code Form, in each case
+ including portions thereof.
+
+1.5. "Incompatible With Secondary Licenses"
+ means
+
+ (a) that the initial Contributor has attached the notice described
+ in Exhibit B to the Covered Software; or
+
+ (b) that the Covered Software was made available under the terms of
+ version 1.1 or earlier of the License, but not also under the
+ terms of a Secondary License.
+
+1.6. "Executable Form"
+ means any form of the work other than Source Code Form.
+
+1.7. "Larger Work"
+ means a work that combines Covered Software with other material, in
+ a separate file or files, that is not Covered Software.
+
+1.8. "License"
+ means this document.
+
+1.9. "Licensable"
+ means having the right to grant, to the maximum extent possible,
+ whether at the time of the initial grant or subsequently, any and
+ all of the rights conveyed by this License.
+
+1.10. "Modifications"
+ means any of the following:
+
+ (a) any file in Source Code Form that results from an addition to,
+ deletion from, or modification of the contents of Covered
+ Software; or
+
+ (b) any new file in Source Code Form that contains any Covered
+ Software.
+
+1.11. "Patent Claims" of a Contributor
+ means any patent claim(s), including without limitation, method,
+ process, and apparatus claims, in any patent Licensable by such
+ Contributor that would be infringed, but for the grant of the
+ License, by the making, using, selling, offering for sale, having
+ made, import, or transfer of either its Contributions or its
+ Contributor Version.
+
+1.12. "Secondary License"
+ means either the GNU General Public License, Version 2.0, the GNU
+ Lesser General Public License, Version 2.1, the GNU Affero General
+ Public License, Version 3.0, or any later versions of those
+ licenses.
+
+1.13. "Source Code Form"
+ means the form of the work preferred for making modifications.
+
+1.14. "You" (or "Your")
+ means an individual or a legal entity exercising rights under this
+ License. For legal entities, "You" includes any entity that
+ controls, is controlled by, or is under common control with You. For
+ purposes of this definition, "control" means (a) the power, direct
+ or indirect, to cause the direction or management of such entity,
+ whether by contract or otherwise, or (b) ownership of more than
+ fifty percent (50%) of the outstanding shares or beneficial
+ ownership of such entity.
+
+2. License Grants and Conditions
+--------------------------------
+
+2.1. Grants
+
+Each Contributor hereby grants You a world-wide, royalty-free,
+non-exclusive license:
+
+(a) under intellectual property rights (other than patent or trademark)
+ Licensable by such Contributor to use, reproduce, make available,
+ modify, display, perform, distribute, and otherwise exploit its
+ Contributions, either on an unmodified basis, with Modifications, or
+ as part of a Larger Work; and
+
+(b) under Patent Claims of such Contributor to make, use, sell, offer
+ for sale, have made, import, and otherwise transfer either its
+ Contributions or its Contributor Version.
+
+2.2. Effective Date
+
+The licenses granted in Section 2.1 with respect to any Contribution
+become effective for each Contribution on the date the Contributor first
+distributes such Contribution.
+
+2.3. Limitations on Grant Scope
+
+The licenses granted in this Section 2 are the only rights granted under
+this License. No additional rights or licenses will be implied from the
+distribution or licensing of Covered Software under this License.
+Notwithstanding Section 2.1(b) above, no patent license is granted by a
+Contributor:
+
+(a) for any code that a Contributor has removed from Covered Software;
+ or
+
+(b) for infringements caused by: (i) Your and any other third party's
+ modifications of Covered Software, or (ii) the combination of its
+ Contributions with other software (except as part of its Contributor
+ Version); or
+
+(c) under Patent Claims infringed by Covered Software in the absence of
+ its Contributions.
+
+This License does not grant any rights in the trademarks, service marks,
+or logos of any Contributor (except as may be necessary to comply with
+the notice requirements in Section 3.4).
+
+2.4. Subsequent Licenses
+
+No Contributor makes additional grants as a result of Your choice to
+distribute the Covered Software under a subsequent version of this
+License (see Section 10.2) or under the terms of a Secondary License (if
+permitted under the terms of Section 3.3).
+
+2.5. Representation
+
+Each Contributor represents that the Contributor believes its
+Contributions are its original creation(s) or it has sufficient rights
+to grant the rights to its Contributions conveyed by this License.
+
+2.6. Fair Use
+
+This License is not intended to limit any rights You have under
+applicable copyright doctrines of fair use, fair dealing, or other
+equivalents.
+
+2.7. Conditions
+
+Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
+in Section 2.1.
+
+3. Responsibilities
+-------------------
+
+3.1. Distribution of Source Form
+
+All distribution of Covered Software in Source Code Form, including any
+Modifications that You create or to which You contribute, must be under
+the terms of this License. You must inform recipients that the Source
+Code Form of the Covered Software is governed by the terms of this
+License, and how they can obtain a copy of this License. You may not
+attempt to alter or restrict the recipients' rights in the Source Code
+Form.
+
+3.2. Distribution of Executable Form
+
+If You distribute Covered Software in Executable Form then:
+
+(a) such Covered Software must also be made available in Source Code
+ Form, as described in Section 3.1, and You must inform recipients of
+ the Executable Form how they can obtain a copy of such Source Code
+ Form by reasonable means in a timely manner, at a charge no more
+ than the cost of distribution to the recipient; and
+
+(b) You may distribute such Executable Form under the terms of this
+ License, or sublicense it under different terms, provided that the
+ license for the Executable Form does not attempt to limit or alter
+ the recipients' rights in the Source Code Form under this License.
+
+3.3. Distribution of a Larger Work
+
+You may create and distribute a Larger Work under terms of Your choice,
+provided that You also comply with the requirements of this License for
+the Covered Software. If the Larger Work is a combination of Covered
+Software with a work governed by one or more Secondary Licenses, and the
+Covered Software is not Incompatible With Secondary Licenses, this
+License permits You to additionally distribute such Covered Software
+under the terms of such Secondary License(s), so that the recipient of
+the Larger Work may, at their option, further distribute the Covered
+Software under the terms of either this License or such Secondary
+License(s).
+
+3.4. Notices
+
+You may not remove or alter the substance of any license notices
+(including copyright notices, patent notices, disclaimers of warranty,
+or limitations of liability) contained within the Source Code Form of
+the Covered Software, except that You may alter any license notices to
+the extent required to remedy known factual inaccuracies.
+
+3.5. Application of Additional Terms
+
+You may choose to offer, and to charge a fee for, warranty, support,
+indemnity or liability obligations to one or more recipients of Covered
+Software. However, You may do so only on Your own behalf, and not on
+behalf of any Contributor. You must make it absolutely clear that any
+such warranty, support, indemnity, or liability obligation is offered by
+You alone, and You hereby agree to indemnify every Contributor for any
+liability incurred by such Contributor as a result of warranty, support,
+indemnity or liability terms You offer. You may include additional
+disclaimers of warranty and limitations of liability specific to any
+jurisdiction.
+
+4. Inability to Comply Due to Statute or Regulation
+---------------------------------------------------
+
+If it is impossible for You to comply with any of the terms of this
+License with respect to some or all of the Covered Software due to
+statute, judicial order, or regulation then You must: (a) comply with
+the terms of this License to the maximum extent possible; and (b)
+describe the limitations and the code they affect. Such description must
+be placed in a text file included with all distributions of the Covered
+Software under this License. Except to the extent prohibited by statute
+or regulation, such description must be sufficiently detailed for a
+recipient of ordinary skill to be able to understand it.
+
+5. Termination
+--------------
+
+5.1. The rights granted under this License will terminate automatically
+if You fail to comply with any of its terms. However, if You become
+compliant, then the rights granted under this License from a particular
+Contributor are reinstated (a) provisionally, unless and until such
+Contributor explicitly and finally terminates Your grants, and (b) on an
+ongoing basis, if such Contributor fails to notify You of the
+non-compliance by some reasonable means prior to 60 days after You have
+come back into compliance. Moreover, Your grants from a particular
+Contributor are reinstated on an ongoing basis if such Contributor
+notifies You of the non-compliance by some reasonable means, this is the
+first time You have received notice of non-compliance with this License
+from such Contributor, and You become compliant prior to 30 days after
+Your receipt of the notice.
+
+5.2. If You initiate litigation against any entity by asserting a patent
+infringement claim (excluding declaratory judgment actions,
+counter-claims, and cross-claims) alleging that a Contributor Version
+directly or indirectly infringes any patent, then the rights granted to
+You by any and all Contributors for the Covered Software under Section
+2.1 of this License shall terminate.
+
+5.3. In the event of termination under Sections 5.1 or 5.2 above, all
+end user license agreements (excluding distributors and resellers) which
+have been validly granted by You or Your distributors under this License
+prior to termination shall survive termination.
+
+************************************************************************
+* *
+* 6. Disclaimer of Warranty *
+* ------------------------- *
+* *
+* Covered Software is provided under this License on an "as is" *
+* basis, without warranty of any kind, either expressed, implied, or *
+* statutory, including, without limitation, warranties that the *
+* Covered Software is free of defects, merchantable, fit for a *
+* particular purpose or non-infringing. The entire risk as to the *
+* quality and performance of the Covered Software is with You. *
+* Should any Covered Software prove defective in any respect, You *
+* (not any Contributor) assume the cost of any necessary servicing, *
+* repair, or correction. This disclaimer of warranty constitutes an *
+* essential part of this License. No use of any Covered Software is *
+* authorized under this License except under this disclaimer. *
+* *
+************************************************************************
+
+************************************************************************
+* *
+* 7. Limitation of Liability *
+* -------------------------- *
+* *
+* Under no circumstances and under no legal theory, whether tort *
+* (including negligence), contract, or otherwise, shall any *
+* Contributor, or anyone who distributes Covered Software as *
+* permitted above, be liable to You for any direct, indirect, *
+* special, incidental, or consequential damages of any character *
+* including, without limitation, damages for lost profits, loss of *
+* goodwill, work stoppage, computer failure or malfunction, or any *
+* and all other commercial damages or losses, even if such party *
+* shall have been informed of the possibility of such damages. This *
+* limitation of liability shall not apply to liability for death or *
+* personal injury resulting from such party's negligence to the *
+* extent applicable law prohibits such limitation. Some *
+* jurisdictions do not allow the exclusion or limitation of *
+* incidental or consequential damages, so this exclusion and *
+* limitation may not apply to You. *
+* *
+************************************************************************
+
+8. Litigation
+-------------
+
+Any litigation relating to this License may be brought only in the
+courts of a jurisdiction where the defendant maintains its principal
+place of business and such litigation shall be governed by laws of that
+jurisdiction, without reference to its conflict-of-law provisions.
+Nothing in this Section shall prevent a party's ability to bring
+cross-claims or counter-claims.
+
+9. Miscellaneous
+----------------
+
+This License represents the complete agreement concerning the subject
+matter hereof. If any provision of this License is held to be
+unenforceable, such provision shall be reformed only to the extent
+necessary to make it enforceable. Any law or regulation which provides
+that the language of a contract shall be construed against the drafter
+shall not be used to construe this License against a Contributor.
+
+10. Versions of the License
+---------------------------
+
+10.1. New Versions
+
+Mozilla Foundation is the license steward. Except as provided in Section
+10.3, no one other than the license steward has the right to modify or
+publish new versions of this License. Each version will be given a
+distinguishing version number.
+
+10.2. Effect of New Versions
+
+You may distribute the Covered Software under the terms of the version
+of the License under which You originally received the Covered Software,
+or under the terms of any subsequent version published by the license
+steward.
+
+10.3. Modified Versions
+
+If you create software not governed by this License, and you want to
+create a new license for such software, you may create and use a
+modified version of this License if you rename the license and remove
+any references to the name of the license steward (except to note that
+such modified license differs from this License).
+
+10.4. Distributing Source Code Form that is Incompatible With Secondary
+Licenses
+
+If You choose to distribute Source Code Form that is Incompatible With
+Secondary Licenses under the terms of this version of the License, the
+notice described in Exhibit B of this License must be attached.
+
+Exhibit A - Source Code Form License Notice
+-------------------------------------------
+
+ This Source Code Form is subject to the terms of the Mozilla Public
+ License, v. 2.0. If a copy of the MPL was not distributed with this
+ file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+If it is not possible or desirable to put the notice in a particular
+file, then You may include the notice in a location (such as a LICENSE
+file in a relevant directory) where a recipient would be likely to look
+for such a notice.
+
+You may add additional accurate notices of copyright ownership.
+
+Exhibit B - "Incompatible With Secondary Licenses" Notice
+---------------------------------------------------------
+
+ This Source Code Form is "Incompatible With Secondary Licenses", as
+ defined by the Mozilla Public License, v. 2.0.
diff --git a/plugin/core/licenses/httpclient-NOTICE.txt b/plugin/core/licenses/httpclient-NOTICE.txt
new file mode 100644
index 00000000000..91e5c40c4c6
--- /dev/null
+++ b/plugin/core/licenses/httpclient-NOTICE.txt
@@ -0,0 +1,6 @@
+Apache HttpComponents Client
+Copyright 1999-2016 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/plugin/core/licenses/httpcore-4.4.5.jar.sha1 b/plugin/core/licenses/httpcore-4.4.5.jar.sha1
new file mode 100644
index 00000000000..58172660174
--- /dev/null
+++ b/plugin/core/licenses/httpcore-4.4.5.jar.sha1
@@ -0,0 +1 @@
+e7501a1b34325abb00d17dde96150604a0658b54
\ No newline at end of file
diff --git a/plugin/security/licenses/unboundid-ldapsdk-3.2.0.jar.sha1 b/plugin/core/licenses/unboundid-ldapsdk-3.2.0.jar.sha1
similarity index 100%
rename from plugin/security/licenses/unboundid-ldapsdk-3.2.0.jar.sha1
rename to plugin/core/licenses/unboundid-ldapsdk-3.2.0.jar.sha1
diff --git a/plugin/security/licenses/unboundid-ldapsdk-LICENSE.txt b/plugin/core/licenses/unboundid-ldapsdk-LICENSE.txt
similarity index 100%
rename from plugin/security/licenses/unboundid-ldapsdk-LICENSE.txt
rename to plugin/core/licenses/unboundid-ldapsdk-LICENSE.txt
diff --git a/plugin/security/licenses/unboundid-ldapsdk-NOTICE.txt b/plugin/core/licenses/unboundid-ldapsdk-NOTICE.txt
similarity index 100%
rename from plugin/security/licenses/unboundid-ldapsdk-NOTICE.txt
rename to plugin/core/licenses/unboundid-ldapsdk-NOTICE.txt
diff --git a/plugin/bin/x-pack/extension b/plugin/core/src/main/bin/extension
similarity index 100%
rename from plugin/bin/x-pack/extension
rename to plugin/core/src/main/bin/extension
diff --git a/plugin/bin/x-pack/extension.bat b/plugin/core/src/main/bin/extension.bat
similarity index 100%
rename from plugin/bin/x-pack/extension.bat
rename to plugin/core/src/main/bin/extension.bat
diff --git a/plugin/core/src/main/bin/x-pack-env b/plugin/core/src/main/bin/x-pack-env
new file mode 100644
index 00000000000..504014acc4b
--- /dev/null
+++ b/plugin/core/src/main/bin/x-pack-env
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+# or more contributor license agreements. Licensed under the Elastic License;
+# you may not use this file except in compliance with the Elastic License.
+
+ES_CLASSPATH="$ES_CLASSPATH:$ES_HOME/plugins/x-pack/x-pack-core/*"
+ES_CLASSPATH="$ES_CLASSPATH:$ES_HOME/plugins/x-pack/x-pack-logstash/*"
+ES_CLASSPATH="$ES_CLASSPATH:$ES_HOME/plugins/x-pack/x-pack-ml/*"
+ES_CLASSPATH="$ES_CLASSPATH:$ES_HOME/plugins/x-pack/x-pack-monitoring/*"
+ES_CLASSPATH="$ES_CLASSPATH:$ES_HOME/plugins/x-pack/x-pack-security/*"
+ES_CLASSPATH="$ES_CLASSPATH:$ES_HOME/plugins/x-pack/x-pack-watcher/*"
diff --git a/plugin/core/src/main/bin/x-pack-env.bat b/plugin/core/src/main/bin/x-pack-env.bat
new file mode 100644
index 00000000000..f40a0b9b53c
--- /dev/null
+++ b/plugin/core/src/main/bin/x-pack-env.bat
@@ -0,0 +1,10 @@
+rem Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+rem or more contributor license agreements. Licensed under the Elastic License;
+rem you may not use this file except in compliance with the Elastic License.
+
+set ES_CLASSPATH=!ES_CLASSPATH!;!ES_HOME!/plugins/x-pack/x-pack-core/*
+set ES_CLASSPATH=!ES_CLASSPATH!;!ES_HOME!/plugins/x-pack/x-pack-logstash*
+set ES_CLASSPATH=!ES_CLASSPATH!;!ES_HOME!/plugins/x-pack/x-pack-ml/*
+set ES_CLASSPATH=!ES_CLASSPATH!;!ES_HOME!/plugins/x-pack/x-pack-monitoring/*
+set ES_CLASSPATH=!ES_CLASSPATH!;!ES_HOME!/plugins/x-pack/x-pack-security/*
+set ES_CLASSPATH=!ES_CLASSPATH!;!ES_HOME!/plugins/x-pack/x-pack-watcher/*
diff --git a/plugin/config/x-pack/log4j2.properties b/plugin/core/src/main/config/log4j2.properties
similarity index 100%
rename from plugin/config/x-pack/log4j2.properties
rename to plugin/core/src/main/config/log4j2.properties
diff --git a/plugin/src/main/java/org/elasticsearch/common/network/InetAddressHelper.java b/plugin/core/src/main/java/org/elasticsearch/common/network/InetAddressHelper.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/common/network/InetAddressHelper.java
rename to plugin/core/src/main/java/org/elasticsearch/common/network/InetAddressHelper.java
diff --git a/plugin/src/main/java/org/elasticsearch/license/CryptUtils.java b/plugin/core/src/main/java/org/elasticsearch/license/CryptUtils.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/license/CryptUtils.java
rename to plugin/core/src/main/java/org/elasticsearch/license/CryptUtils.java
diff --git a/plugin/src/main/java/org/elasticsearch/license/ExpirationCallback.java b/plugin/core/src/main/java/org/elasticsearch/license/ExpirationCallback.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/license/ExpirationCallback.java
rename to plugin/core/src/main/java/org/elasticsearch/license/ExpirationCallback.java
diff --git a/plugin/src/main/java/org/elasticsearch/license/LicenseService.java b/plugin/core/src/main/java/org/elasticsearch/license/LicenseService.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/license/LicenseService.java
rename to plugin/core/src/main/java/org/elasticsearch/license/LicenseService.java
diff --git a/plugin/src/main/java/org/elasticsearch/license/LicenseUtils.java b/plugin/core/src/main/java/org/elasticsearch/license/LicenseUtils.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/license/LicenseUtils.java
rename to plugin/core/src/main/java/org/elasticsearch/license/LicenseUtils.java
diff --git a/plugin/src/main/java/org/elasticsearch/license/LicenseVerifier.java b/plugin/core/src/main/java/org/elasticsearch/license/LicenseVerifier.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/license/LicenseVerifier.java
rename to plugin/core/src/main/java/org/elasticsearch/license/LicenseVerifier.java
diff --git a/plugin/src/main/java/org/elasticsearch/license/LicensesMetaData.java b/plugin/core/src/main/java/org/elasticsearch/license/LicensesMetaData.java
similarity index 97%
rename from plugin/src/main/java/org/elasticsearch/license/LicensesMetaData.java
rename to plugin/core/src/main/java/org/elasticsearch/license/LicensesMetaData.java
index d0a5b6e3307..ffb9faab44e 100644
--- a/plugin/src/main/java/org/elasticsearch/license/LicensesMetaData.java
+++ b/plugin/core/src/main/java/org/elasticsearch/license/LicensesMetaData.java
@@ -23,7 +23,7 @@ import java.util.EnumSet;
/**
* Contains metadata about registered licenses
*/
-class LicensesMetaData extends AbstractNamedDiffable implements MetaData.Custom,
+public class LicensesMetaData extends AbstractNamedDiffable implements MetaData.Custom,
MergableCustomMetaData {
public static final String TYPE = "licenses";
@@ -170,7 +170,7 @@ class LicensesMetaData extends AbstractNamedDiffable implements
}
}
- LicensesMetaData(StreamInput streamInput) throws IOException {
+ public LicensesMetaData(StreamInput streamInput) throws IOException {
if (streamInput.readBoolean()) {
license = License.readLicense(streamInput);
} else {
diff --git a/plugin/src/main/java/org/elasticsearch/license/Licensing.java b/plugin/core/src/main/java/org/elasticsearch/license/Licensing.java
similarity index 88%
rename from plugin/src/main/java/org/elasticsearch/license/Licensing.java
rename to plugin/core/src/main/java/org/elasticsearch/license/Licensing.java
index 08c864d6cf9..7df8a264d2e 100644
--- a/plugin/src/main/java/org/elasticsearch/license/Licensing.java
+++ b/plugin/core/src/main/java/org/elasticsearch/license/Licensing.java
@@ -7,6 +7,7 @@ package org.elasticsearch.license;
import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionResponse;
+import org.elasticsearch.action.GenericAction;
import org.elasticsearch.cluster.NamedDiff;
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.metadata.MetaData;
@@ -39,6 +40,8 @@ public class Licensing implements ActionPlugin {
private final boolean isTransportClient;
private final boolean isTribeNode;
+ // Until this is moved out to its own plugin (its currently in XPackPlugin.java, we need to make sure that any edits to this file
+ // are also carried out in XPackClientPlugin.java
public List getNamedWriteables() {
List entries = new ArrayList<>();
entries.add(new NamedWriteableRegistry.Entry(MetaData.Custom.class, LicensesMetaData.TYPE, LicensesMetaData::new));
@@ -46,6 +49,8 @@ public class Licensing implements ActionPlugin {
return entries;
}
+ // Until this is moved out to its own plugin (its currently in XPackPlugin.java, we need to make sure that any edits to this file
+ // are also carried out in XPackClientPlugin.java
public List getNamedXContent() {
List entries = new ArrayList<>();
// Metadata
@@ -87,6 +92,8 @@ public class Licensing implements ActionPlugin {
return handlers;
}
+ // Until this is moved out to its own plugin (its currently in XPackPlugin.java, we need to make sure that any edits to this file
+ // are also carried out in XPackClientPlugin.java
public List> getSettings() {
// TODO convert this wildcard to a real setting
return Collections.singletonList(Setting.groupSetting("license.", Setting.Property.NodeScope));
diff --git a/plugin/src/main/java/org/elasticsearch/license/LicensingClient.java b/plugin/core/src/main/java/org/elasticsearch/license/LicensingClient.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/license/LicensingClient.java
rename to plugin/core/src/main/java/org/elasticsearch/license/LicensingClient.java
diff --git a/plugin/src/main/java/org/elasticsearch/license/RestDeleteLicenseAction.java b/plugin/core/src/main/java/org/elasticsearch/license/RestDeleteLicenseAction.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/license/RestDeleteLicenseAction.java
rename to plugin/core/src/main/java/org/elasticsearch/license/RestDeleteLicenseAction.java
diff --git a/plugin/src/main/java/org/elasticsearch/license/RestGetLicenseAction.java b/plugin/core/src/main/java/org/elasticsearch/license/RestGetLicenseAction.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/license/RestGetLicenseAction.java
rename to plugin/core/src/main/java/org/elasticsearch/license/RestGetLicenseAction.java
diff --git a/plugin/src/main/java/org/elasticsearch/license/RestGetTrialStatus.java b/plugin/core/src/main/java/org/elasticsearch/license/RestGetTrialStatus.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/license/RestGetTrialStatus.java
rename to plugin/core/src/main/java/org/elasticsearch/license/RestGetTrialStatus.java
diff --git a/plugin/src/main/java/org/elasticsearch/license/RestPostStartTrialLicense.java b/plugin/core/src/main/java/org/elasticsearch/license/RestPostStartTrialLicense.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/license/RestPostStartTrialLicense.java
rename to plugin/core/src/main/java/org/elasticsearch/license/RestPostStartTrialLicense.java
diff --git a/plugin/src/main/java/org/elasticsearch/license/RestPutLicenseAction.java b/plugin/core/src/main/java/org/elasticsearch/license/RestPutLicenseAction.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/license/RestPutLicenseAction.java
rename to plugin/core/src/main/java/org/elasticsearch/license/RestPutLicenseAction.java
diff --git a/plugin/src/main/java/org/elasticsearch/license/SelfGeneratedLicense.java b/plugin/core/src/main/java/org/elasticsearch/license/SelfGeneratedLicense.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/license/SelfGeneratedLicense.java
rename to plugin/core/src/main/java/org/elasticsearch/license/SelfGeneratedLicense.java
diff --git a/plugin/src/main/java/org/elasticsearch/license/TransportDeleteLicenseAction.java b/plugin/core/src/main/java/org/elasticsearch/license/TransportDeleteLicenseAction.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/license/TransportDeleteLicenseAction.java
rename to plugin/core/src/main/java/org/elasticsearch/license/TransportDeleteLicenseAction.java
diff --git a/plugin/src/main/java/org/elasticsearch/license/TransportGetLicenseAction.java b/plugin/core/src/main/java/org/elasticsearch/license/TransportGetLicenseAction.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/license/TransportGetLicenseAction.java
rename to plugin/core/src/main/java/org/elasticsearch/license/TransportGetLicenseAction.java
diff --git a/plugin/src/main/java/org/elasticsearch/license/TransportGetTrialStatusAction.java b/plugin/core/src/main/java/org/elasticsearch/license/TransportGetTrialStatusAction.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/license/TransportGetTrialStatusAction.java
rename to plugin/core/src/main/java/org/elasticsearch/license/TransportGetTrialStatusAction.java
diff --git a/plugin/src/main/java/org/elasticsearch/license/TransportPostStartTrialAction.java b/plugin/core/src/main/java/org/elasticsearch/license/TransportPostStartTrialAction.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/license/TransportPostStartTrialAction.java
rename to plugin/core/src/main/java/org/elasticsearch/license/TransportPostStartTrialAction.java
diff --git a/plugin/src/main/java/org/elasticsearch/license/TransportPutLicenseAction.java b/plugin/core/src/main/java/org/elasticsearch/license/TransportPutLicenseAction.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/license/TransportPutLicenseAction.java
rename to plugin/core/src/main/java/org/elasticsearch/license/TransportPutLicenseAction.java
diff --git a/plugin/core/src/main/java/org/elasticsearch/license/XPackLicenseState.java b/plugin/core/src/main/java/org/elasticsearch/license/XPackLicenseState.java
index 0e6d191494d..756688660a6 100644
--- a/plugin/core/src/main/java/org/elasticsearch/license/XPackLicenseState.java
+++ b/plugin/core/src/main/java/org/elasticsearch/license/XPackLicenseState.java
@@ -9,7 +9,7 @@ import org.elasticsearch.common.Strings;
import org.elasticsearch.common.logging.LoggerMessageFormat;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.license.License.OperationMode;
-import org.elasticsearch.xpack.XpackField;
+import org.elasticsearch.xpack.XPackField;
import org.elasticsearch.xpack.monitoring.MonitoringField;
import java.util.Collections;
@@ -29,32 +29,32 @@ public class XPackLicenseState {
static final Map EXPIRATION_MESSAGES;
static {
Map messages = new LinkedHashMap<>();
- messages.put(XpackField.SECURITY, new String[] {
+ messages.put(XPackField.SECURITY, new String[] {
"Cluster health, cluster stats and indices stats operations are blocked",
"All data operations (read and write) continue to work"
});
- messages.put(XpackField.WATCHER, new String[] {
+ messages.put(XPackField.WATCHER, new String[] {
"PUT / GET watch APIs are disabled, DELETE watch API continues to work",
"Watches execute and write to the history",
"The actions of the watches don't execute"
});
- messages.put(XpackField.MONITORING, new String[] {
+ messages.put(XPackField.MONITORING, new String[] {
"The agent will stop collecting cluster and indices metrics",
"The agent will stop automatically cleaning indices older than [xpack.monitoring.history.duration]"
});
- messages.put(XpackField.GRAPH, new String[] {
+ messages.put(XPackField.GRAPH, new String[] {
"Graph explore APIs are disabled"
});
- messages.put(XpackField.MACHINE_LEARNING, new String[] {
+ messages.put(XPackField.MACHINE_LEARNING, new String[] {
"Machine learning APIs are disabled"
});
- messages.put(XpackField.LOGSTASH, new String[] {
+ messages.put(XPackField.LOGSTASH, new String[] {
"Logstash will continue to poll centrally-managed pipelines"
});
- messages.put(XpackField.DEPRECATION, new String[] {
+ messages.put(XPackField.DEPRECATION, new String[] {
"Deprecation APIs are disabled"
});
- messages.put(XpackField.UPGRADE, new String[] {
+ messages.put(XPackField.UPGRADE, new String[] {
"Upgrade API is disabled"
});
EXPIRATION_MESSAGES = Collections.unmodifiableMap(messages);
@@ -67,12 +67,12 @@ public class XPackLicenseState {
static final Map> ACKNOWLEDGMENT_MESSAGES;
static {
Map> messages = new LinkedHashMap<>();
- messages.put(XpackField.SECURITY, XPackLicenseState::securityAcknowledgementMessages);
- messages.put(XpackField.WATCHER, XPackLicenseState::watcherAcknowledgementMessages);
- messages.put(XpackField.MONITORING, XPackLicenseState::monitoringAcknowledgementMessages);
- messages.put(XpackField.GRAPH, XPackLicenseState::graphAcknowledgementMessages);
- messages.put(XpackField.MACHINE_LEARNING, XPackLicenseState::machineLearningAcknowledgementMessages);
- messages.put(XpackField.LOGSTASH, XPackLicenseState::logstashAcknowledgementMessages);
+ messages.put(XPackField.SECURITY, XPackLicenseState::securityAcknowledgementMessages);
+ messages.put(XPackField.WATCHER, XPackLicenseState::watcherAcknowledgementMessages);
+ messages.put(XPackField.MONITORING, XPackLicenseState::monitoringAcknowledgementMessages);
+ messages.put(XPackField.GRAPH, XPackLicenseState::graphAcknowledgementMessages);
+ messages.put(XPackField.MACHINE_LEARNING, XPackLicenseState::machineLearningAcknowledgementMessages);
+ messages.put(XPackField.LOGSTASH, XPackLicenseState::logstashAcknowledgementMessages);
ACKNOWLEDGMENT_MESSAGES = Collections.unmodifiableMap(messages);
}
diff --git a/plugin/src/main/java/org/elasticsearch/license/package-info.java b/plugin/core/src/main/java/org/elasticsearch/license/package-info.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/license/package-info.java
rename to plugin/core/src/main/java/org/elasticsearch/license/package-info.java
diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/EmptyXPackFeatureSet.java b/plugin/core/src/main/java/org/elasticsearch/xpack/EmptyXPackFeatureSet.java
new file mode 100644
index 00000000000..20c5642cb43
--- /dev/null
+++ b/plugin/core/src/main/java/org/elasticsearch/xpack/EmptyXPackFeatureSet.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+package org.elasticsearch.xpack;
+
+import org.elasticsearch.action.ActionListener;
+
+import java.util.Collections;
+import java.util.Map;
+
+public class EmptyXPackFeatureSet implements XPackFeatureSet {
+ @Override
+ public String name() {
+ return "Empty XPackFeatureSet";
+ }
+
+ @Override
+ public String description() {
+ return "Core will not function without this empty featureset compliments of the way the TransportXPackInfoAction Guice works";
+ }
+
+ @Override
+ public boolean available() {
+ return false;
+ }
+
+ @Override
+ public boolean enabled() {
+ return false;
+ }
+
+ @Override
+ public Map nativeCodeInfo() {
+ return Collections.emptyMap();
+ }
+
+ @Override
+ public void usage(ActionListener listener) {
+
+ }
+}
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/XPackClient.java b/plugin/core/src/main/java/org/elasticsearch/xpack/XPackClient.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/xpack/XPackClient.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/XPackClient.java
diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/XPackClientPlugin.java b/plugin/core/src/main/java/org/elasticsearch/xpack/XPackClientPlugin.java
new file mode 100644
index 00000000000..055ff176c02
--- /dev/null
+++ b/plugin/core/src/main/java/org/elasticsearch/xpack/XPackClientPlugin.java
@@ -0,0 +1,384 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+package org.elasticsearch.xpack;
+
+import org.elasticsearch.action.GenericAction;
+import org.elasticsearch.cluster.ClusterState;
+import org.elasticsearch.cluster.NamedDiff;
+import org.elasticsearch.cluster.metadata.MetaData;
+import org.elasticsearch.common.ParseField;
+import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
+import org.elasticsearch.common.network.NetworkModule;
+import org.elasticsearch.common.network.NetworkService;
+import org.elasticsearch.common.settings.SecureString;
+import org.elasticsearch.common.settings.Setting;
+import org.elasticsearch.common.settings.Settings;
+import org.elasticsearch.common.util.BigArrays;
+import org.elasticsearch.common.util.PageCacheRecycler;
+import org.elasticsearch.common.util.concurrent.ThreadContext;
+import org.elasticsearch.common.xcontent.NamedXContentRegistry;
+import org.elasticsearch.indices.breaker.CircuitBreakerService;
+import org.elasticsearch.license.DeleteLicenseAction;
+import org.elasticsearch.license.GetLicenseAction;
+import org.elasticsearch.license.GetTrialStatusAction;
+import org.elasticsearch.license.LicenseService;
+import org.elasticsearch.license.LicensesMetaData;
+import org.elasticsearch.license.PostStartTrialAction;
+import org.elasticsearch.license.PutLicenseAction;
+import org.elasticsearch.plugins.ActionPlugin;
+import org.elasticsearch.plugins.NetworkPlugin;
+import org.elasticsearch.plugins.Plugin;
+import org.elasticsearch.tasks.Task;
+import org.elasticsearch.threadpool.ThreadPool;
+import org.elasticsearch.transport.Transport;
+import org.elasticsearch.xpack.action.XPackInfoAction;
+import org.elasticsearch.xpack.action.XPackUsageAction;
+import org.elasticsearch.xpack.deprecation.DeprecationInfoAction;
+import org.elasticsearch.xpack.graph.GraphFeatureSetUsage;
+import org.elasticsearch.xpack.graph.action.GraphExploreAction;
+import org.elasticsearch.xpack.ml.MachineLearningFeatureSetUsage;
+import org.elasticsearch.xpack.ml.MlMetadata;
+import org.elasticsearch.xpack.ml.action.CloseJobAction;
+import org.elasticsearch.xpack.ml.action.DeleteCalendarAction;
+import org.elasticsearch.xpack.ml.action.DeleteCalendarEventAction;
+import org.elasticsearch.xpack.ml.action.DeleteDatafeedAction;
+import org.elasticsearch.xpack.ml.action.DeleteExpiredDataAction;
+import org.elasticsearch.xpack.ml.action.DeleteFilterAction;
+import org.elasticsearch.xpack.ml.action.DeleteJobAction;
+import org.elasticsearch.xpack.ml.action.DeleteModelSnapshotAction;
+import org.elasticsearch.xpack.ml.action.FinalizeJobExecutionAction;
+import org.elasticsearch.xpack.ml.action.FlushJobAction;
+import org.elasticsearch.xpack.ml.action.ForecastJobAction;
+import org.elasticsearch.xpack.ml.action.GetBucketsAction;
+import org.elasticsearch.xpack.ml.action.GetCalendarEventsAction;
+import org.elasticsearch.xpack.ml.action.GetCalendarsAction;
+import org.elasticsearch.xpack.ml.action.GetCategoriesAction;
+import org.elasticsearch.xpack.ml.action.GetDatafeedsAction;
+import org.elasticsearch.xpack.ml.action.GetDatafeedsStatsAction;
+import org.elasticsearch.xpack.ml.action.GetFiltersAction;
+import org.elasticsearch.xpack.ml.action.GetInfluencersAction;
+import org.elasticsearch.xpack.ml.action.GetJobsAction;
+import org.elasticsearch.xpack.ml.action.GetJobsStatsAction;
+import org.elasticsearch.xpack.ml.action.GetModelSnapshotsAction;
+import org.elasticsearch.xpack.ml.action.GetOverallBucketsAction;
+import org.elasticsearch.xpack.ml.action.GetRecordsAction;
+import org.elasticsearch.xpack.ml.action.IsolateDatafeedAction;
+import org.elasticsearch.xpack.ml.action.KillProcessAction;
+import org.elasticsearch.xpack.ml.action.OpenJobAction;
+import org.elasticsearch.xpack.ml.action.PostCalendarEventsAction;
+import org.elasticsearch.xpack.ml.action.PostDataAction;
+import org.elasticsearch.xpack.ml.action.PreviewDatafeedAction;
+import org.elasticsearch.xpack.ml.action.PutCalendarAction;
+import org.elasticsearch.xpack.ml.action.PutDatafeedAction;
+import org.elasticsearch.xpack.ml.action.PutFilterAction;
+import org.elasticsearch.xpack.ml.action.PutJobAction;
+import org.elasticsearch.xpack.ml.action.RevertModelSnapshotAction;
+import org.elasticsearch.xpack.ml.action.StartDatafeedAction;
+import org.elasticsearch.xpack.ml.action.StopDatafeedAction;
+import org.elasticsearch.xpack.ml.action.UpdateCalendarJobAction;
+import org.elasticsearch.xpack.ml.action.UpdateDatafeedAction;
+import org.elasticsearch.xpack.ml.action.UpdateJobAction;
+import org.elasticsearch.xpack.ml.action.UpdateModelSnapshotAction;
+import org.elasticsearch.xpack.ml.action.UpdateProcessAction;
+import org.elasticsearch.xpack.ml.action.ValidateDetectorAction;
+import org.elasticsearch.xpack.ml.action.ValidateJobConfigAction;
+import org.elasticsearch.xpack.ml.datafeed.DatafeedState;
+import org.elasticsearch.xpack.ml.job.config.JobTaskStatus;
+import org.elasticsearch.xpack.monitoring.MonitoringFeatureSetUsage;
+import org.elasticsearch.xpack.persistent.CompletionPersistentTaskAction;
+import org.elasticsearch.xpack.persistent.PersistentTaskParams;
+import org.elasticsearch.xpack.persistent.PersistentTasksCustomMetaData;
+import org.elasticsearch.xpack.persistent.PersistentTasksNodeService;
+import org.elasticsearch.xpack.persistent.RemovePersistentTaskAction;
+import org.elasticsearch.xpack.persistent.StartPersistentTaskAction;
+import org.elasticsearch.xpack.persistent.UpdatePersistentTaskStatusAction;
+import org.elasticsearch.xpack.security.SecurityFeatureSetUsage;
+import org.elasticsearch.xpack.security.SecurityField;
+import org.elasticsearch.xpack.security.SecuritySettings;
+import org.elasticsearch.xpack.security.action.realm.ClearRealmCacheAction;
+import org.elasticsearch.xpack.security.action.role.ClearRolesCacheAction;
+import org.elasticsearch.xpack.security.action.role.DeleteRoleAction;
+import org.elasticsearch.xpack.security.action.role.GetRolesAction;
+import org.elasticsearch.xpack.security.action.role.PutRoleAction;
+import org.elasticsearch.xpack.security.action.rolemapping.DeleteRoleMappingAction;
+import org.elasticsearch.xpack.security.action.rolemapping.GetRoleMappingsAction;
+import org.elasticsearch.xpack.security.action.rolemapping.PutRoleMappingAction;
+import org.elasticsearch.xpack.security.action.token.CreateTokenAction;
+import org.elasticsearch.xpack.security.action.token.InvalidateTokenAction;
+import org.elasticsearch.xpack.security.action.token.RefreshTokenAction;
+import org.elasticsearch.xpack.security.action.user.AuthenticateAction;
+import org.elasticsearch.xpack.security.action.user.ChangePasswordAction;
+import org.elasticsearch.xpack.security.action.user.DeleteUserAction;
+import org.elasticsearch.xpack.security.action.user.GetUsersAction;
+import org.elasticsearch.xpack.security.action.user.HasPrivilegesAction;
+import org.elasticsearch.xpack.security.action.user.PutUserAction;
+import org.elasticsearch.xpack.security.action.user.SetEnabledAction;
+import org.elasticsearch.xpack.security.authc.TokenMetaData;
+import org.elasticsearch.xpack.security.authc.support.UsernamePasswordToken;
+import org.elasticsearch.xpack.security.authc.support.mapper.expressiondsl.AllExpression;
+import org.elasticsearch.xpack.security.authc.support.mapper.expressiondsl.AnyExpression;
+import org.elasticsearch.xpack.security.authc.support.mapper.expressiondsl.ExceptExpression;
+import org.elasticsearch.xpack.security.authc.support.mapper.expressiondsl.FieldExpression;
+import org.elasticsearch.xpack.security.authc.support.mapper.expressiondsl.RoleMapperExpression;
+import org.elasticsearch.xpack.security.transport.netty4.SecurityNetty4Transport;
+import org.elasticsearch.xpack.ssl.SSLService;
+import org.elasticsearch.xpack.ssl.action.GetCertificateInfoAction;
+import org.elasticsearch.xpack.upgrade.actions.IndexUpgradeAction;
+import org.elasticsearch.xpack.upgrade.actions.IndexUpgradeInfoAction;
+import org.elasticsearch.xpack.watcher.WatcherFeatureSetUsage;
+import org.elasticsearch.xpack.watcher.WatcherMetaData;
+import org.elasticsearch.xpack.watcher.transport.actions.ack.AckWatchAction;
+import org.elasticsearch.xpack.watcher.transport.actions.activate.ActivateWatchAction;
+import org.elasticsearch.xpack.watcher.transport.actions.delete.DeleteWatchAction;
+import org.elasticsearch.xpack.watcher.transport.actions.execute.ExecuteWatchAction;
+import org.elasticsearch.xpack.watcher.transport.actions.get.GetWatchAction;
+import org.elasticsearch.xpack.watcher.transport.actions.put.PutWatchAction;
+import org.elasticsearch.xpack.watcher.transport.actions.service.WatcherServiceAction;
+import org.elasticsearch.xpack.watcher.transport.actions.stats.WatcherStatsAction;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.function.Supplier;
+
+public class XPackClientPlugin extends Plugin implements ActionPlugin, NetworkPlugin {
+
+ private final Settings settings;
+
+ public XPackClientPlugin(final Settings settings) {
+ this.settings = settings;
+ }
+
+ @Override
+ public List> getSettings() {
+ ArrayList> settings = new ArrayList<>();
+ // the only licensing one
+ settings.add(Setting.groupSetting("license.", Setting.Property.NodeScope));
+
+ //TODO split these settings up
+ settings.addAll(XPackSettings.getAllSettings());
+
+ settings.add(LicenseService.SELF_GENERATED_LICENSE_TYPE);
+
+ // we add the `xpack.version` setting to all internal indices
+ settings.add(Setting.simpleString("index.xpack.version", Setting.Property.IndexScope));
+
+ return settings;
+ }
+
+ @Override
+ public Settings additionalSettings() {
+ return additionalSettings(settings, XPackSettings.SECURITY_ENABLED.get(settings), XPackPlugin.transportClientMode(settings));
+ }
+
+ static Settings additionalSettings(final Settings settings, final boolean enabled, final boolean transportClientMode) {
+ if (enabled && transportClientMode) {
+ final Settings.Builder builder = Settings.builder();
+ builder.put(SecuritySettings.addTransportSettings(settings));
+ builder.put(SecuritySettings.addUserSettings(settings));
+ return builder.build();
+ } else {
+ return Settings.EMPTY;
+ }
+ }
+
+ @Override
+ public List getClientActions() {
+ return Arrays.asList(
+ // deprecation
+ DeprecationInfoAction.INSTANCE,
+ // graph
+ GraphExploreAction.INSTANCE,
+ // ML
+ GetJobsAction.INSTANCE,
+ GetJobsStatsAction.INSTANCE,
+ PutJobAction.INSTANCE,
+ UpdateJobAction.INSTANCE,
+ DeleteJobAction.INSTANCE,
+ OpenJobAction.INSTANCE,
+ GetFiltersAction.INSTANCE,
+ PutFilterAction.INSTANCE,
+ DeleteFilterAction.INSTANCE,
+ KillProcessAction.INSTANCE,
+ GetBucketsAction.INSTANCE,
+ GetInfluencersAction.INSTANCE,
+ GetOverallBucketsAction.INSTANCE,
+ GetRecordsAction.INSTANCE,
+ PostDataAction.INSTANCE,
+ CloseJobAction.INSTANCE,
+ FinalizeJobExecutionAction.INSTANCE,
+ FlushJobAction.INSTANCE,
+ ValidateDetectorAction.INSTANCE,
+ ValidateJobConfigAction.INSTANCE,
+ GetCategoriesAction.INSTANCE,
+ GetModelSnapshotsAction.INSTANCE,
+ RevertModelSnapshotAction.INSTANCE,
+ UpdateModelSnapshotAction.INSTANCE,
+ GetDatafeedsAction.INSTANCE,
+ GetDatafeedsStatsAction.INSTANCE,
+ PutDatafeedAction.INSTANCE,
+ UpdateDatafeedAction.INSTANCE,
+ DeleteDatafeedAction.INSTANCE,
+ PreviewDatafeedAction.INSTANCE,
+ StartDatafeedAction.INSTANCE,
+ StopDatafeedAction.INSTANCE,
+ IsolateDatafeedAction.INSTANCE,
+ DeleteModelSnapshotAction.INSTANCE,
+ UpdateProcessAction.INSTANCE,
+ DeleteExpiredDataAction.INSTANCE,
+ ForecastJobAction.INSTANCE,
+ GetCalendarsAction.INSTANCE,
+ PutCalendarAction.INSTANCE,
+ DeleteCalendarAction.INSTANCE,
+ DeleteCalendarEventAction.INSTANCE,
+ UpdateCalendarJobAction.INSTANCE,
+ GetCalendarEventsAction.INSTANCE,
+ PostCalendarEventsAction.INSTANCE,
+ // licensing
+ StartPersistentTaskAction.INSTANCE,
+ UpdatePersistentTaskStatusAction.INSTANCE,
+ RemovePersistentTaskAction.INSTANCE,
+ CompletionPersistentTaskAction.INSTANCE,
+ // security
+ ClearRealmCacheAction.INSTANCE,
+ ClearRolesCacheAction.INSTANCE,
+ GetUsersAction.INSTANCE,
+ PutUserAction.INSTANCE,
+ DeleteUserAction.INSTANCE,
+ GetRolesAction.INSTANCE,
+ PutRoleAction.INSTANCE,
+ DeleteRoleAction.INSTANCE,
+ ChangePasswordAction.INSTANCE,
+ AuthenticateAction.INSTANCE,
+ SetEnabledAction.INSTANCE,
+ HasPrivilegesAction.INSTANCE,
+ GetRoleMappingsAction.INSTANCE,
+ PutRoleMappingAction.INSTANCE,
+ DeleteRoleMappingAction.INSTANCE,
+ CreateTokenAction.INSTANCE,
+ InvalidateTokenAction.INSTANCE,
+ GetCertificateInfoAction.INSTANCE,
+ RefreshTokenAction.INSTANCE,
+ // upgrade
+ IndexUpgradeInfoAction.INSTANCE,
+ IndexUpgradeAction.INSTANCE,
+ // watcher
+ PutWatchAction.INSTANCE,
+ DeleteWatchAction.INSTANCE,
+ GetWatchAction.INSTANCE,
+ WatcherStatsAction.INSTANCE,
+ AckWatchAction.INSTANCE,
+ ActivateWatchAction.INSTANCE,
+ WatcherServiceAction.INSTANCE,
+ ExecuteWatchAction.INSTANCE,
+ // license
+ PutLicenseAction.INSTANCE,
+ GetLicenseAction.INSTANCE,
+ DeleteLicenseAction.INSTANCE,
+ PostStartTrialAction.INSTANCE,
+ GetTrialStatusAction.INSTANCE,
+ // x-pack
+ XPackInfoAction.INSTANCE,
+ XPackUsageAction.INSTANCE
+ );
+ }
+
+ @Override
+ public List getNamedWriteables() {
+ return Arrays.asList(
+ // graph
+ new NamedWriteableRegistry.Entry(XPackFeatureSet.Usage.class, XPackField.GRAPH, GraphFeatureSetUsage::new),
+ // ML - Custom metadata
+ new NamedWriteableRegistry.Entry(MetaData.Custom.class, "ml", MlMetadata::new),
+ new NamedWriteableRegistry.Entry(NamedDiff.class, "ml", MlMetadata.MlMetadataDiff::new),
+ new NamedWriteableRegistry.Entry(MetaData.Custom.class, PersistentTasksCustomMetaData.TYPE,
+ PersistentTasksCustomMetaData::new),
+ new NamedWriteableRegistry.Entry(NamedDiff.class, PersistentTasksCustomMetaData.TYPE,
+ PersistentTasksCustomMetaData::readDiffFrom),
+ // ML - Persistent action requests
+ new NamedWriteableRegistry.Entry(PersistentTaskParams.class, StartDatafeedAction.TASK_NAME,
+ StartDatafeedAction.DatafeedParams::new),
+ new NamedWriteableRegistry.Entry(PersistentTaskParams.class, OpenJobAction.TASK_NAME,
+ OpenJobAction.JobParams::new),
+ // ML - Task statuses
+ new NamedWriteableRegistry.Entry(Task.Status.class, PersistentTasksNodeService.Status.NAME,
+ PersistentTasksNodeService.Status::new),
+ new NamedWriteableRegistry.Entry(Task.Status.class, JobTaskStatus.NAME, JobTaskStatus::new),
+ new NamedWriteableRegistry.Entry(Task.Status.class, DatafeedState.NAME, DatafeedState::fromStream),
+ new NamedWriteableRegistry.Entry(XPackFeatureSet.Usage.class, XPackField.MACHINE_LEARNING,
+ MachineLearningFeatureSetUsage::new),
+ // monitoring
+ new NamedWriteableRegistry.Entry(XPackFeatureSet.Usage.class, XPackField.MONITORING, MonitoringFeatureSetUsage::new),
+ // security
+ new NamedWriteableRegistry.Entry(ClusterState.Custom.class, TokenMetaData.TYPE, TokenMetaData::new),
+ new NamedWriteableRegistry.Entry(NamedDiff.class, TokenMetaData.TYPE, TokenMetaData::readDiffFrom),
+ new NamedWriteableRegistry.Entry(XPackFeatureSet.Usage.class, XPackField.SECURITY, SecurityFeatureSetUsage::new),
+ new NamedWriteableRegistry.Entry(RoleMapperExpression.class, AllExpression.NAME, AllExpression::new),
+ new NamedWriteableRegistry.Entry(RoleMapperExpression.class, AnyExpression.NAME, AnyExpression::new),
+ new NamedWriteableRegistry.Entry(RoleMapperExpression.class, FieldExpression.NAME, FieldExpression::new),
+ new NamedWriteableRegistry.Entry(RoleMapperExpression.class, ExceptExpression.NAME, ExceptExpression::new),
+ // watcher
+ new NamedWriteableRegistry.Entry(MetaData.Custom.class, WatcherMetaData.TYPE, WatcherMetaData::new),
+ new NamedWriteableRegistry.Entry(NamedDiff.class, WatcherMetaData.TYPE, WatcherMetaData::readDiffFrom),
+ new NamedWriteableRegistry.Entry(XPackFeatureSet.Usage.class, XPackField.WATCHER, WatcherFeatureSetUsage::new),
+ // licensing
+ new NamedWriteableRegistry.Entry(MetaData.Custom.class, LicensesMetaData.TYPE, LicensesMetaData::new),
+ new NamedWriteableRegistry.Entry(NamedDiff.class, LicensesMetaData.TYPE, LicensesMetaData::readDiffFrom)
+ );
+ }
+
+ @Override
+ public List getNamedXContent() {
+ return Arrays.asList(
+ // ML - Custom metadata
+ new NamedXContentRegistry.Entry(MetaData.Custom.class, new ParseField("ml"),
+ parser -> MlMetadata.METADATA_PARSER.parse(parser, null).build()),
+ new NamedXContentRegistry.Entry(MetaData.Custom.class, new ParseField(PersistentTasksCustomMetaData.TYPE),
+ PersistentTasksCustomMetaData::fromXContent),
+ // ML - Persistent action requests
+ new NamedXContentRegistry.Entry(PersistentTaskParams.class, new ParseField(StartDatafeedAction.TASK_NAME),
+ StartDatafeedAction.DatafeedParams::fromXContent),
+ new NamedXContentRegistry.Entry(PersistentTaskParams.class, new ParseField(OpenJobAction.TASK_NAME),
+ OpenJobAction.JobParams::fromXContent),
+ // ML - Task statuses
+ new NamedXContentRegistry.Entry(Task.Status.class, new ParseField(DatafeedState.NAME), DatafeedState::fromXContent),
+ new NamedXContentRegistry.Entry(Task.Status.class, new ParseField(JobTaskStatus.NAME), JobTaskStatus::fromXContent),
+ // watcher
+ new NamedXContentRegistry.Entry(MetaData.Custom.class, new ParseField(WatcherMetaData.TYPE),
+ WatcherMetaData::fromXContent),
+ // licensing
+ new NamedXContentRegistry.Entry(MetaData.Custom.class, new ParseField(LicensesMetaData.TYPE),
+ LicensesMetaData::fromXContent)
+ );
+ }
+
+ @Override
+ public Map> getTransports(
+ final Settings settings,
+ final ThreadPool threadPool,
+ final BigArrays bigArrays,
+ final PageCacheRecycler pageCacheRecycler,
+ final CircuitBreakerService circuitBreakerService,
+ final NamedWriteableRegistry namedWriteableRegistry,
+ final NetworkService networkService) {
+ // this should only be used in the transport layer, so do not add it if it is not in transport mode or we are disabled
+ if (XPackPlugin.transportClientMode(settings) == false || XPackSettings.SECURITY_ENABLED.get(settings) == false) {
+ return Collections.emptyMap();
+ }
+ final SSLService sslService;
+ try {
+ sslService = new SSLService(settings, null);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ return Collections.singletonMap(SecurityField.NAME4, () -> new SecurityNetty4Transport(settings, threadPool,
+ networkService, bigArrays, namedWriteableRegistry, circuitBreakerService, sslService));
+ }
+
+}
diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/XpackField.java b/plugin/core/src/main/java/org/elasticsearch/xpack/XPackField.java
similarity index 92%
rename from plugin/core/src/main/java/org/elasticsearch/xpack/XpackField.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/XPackField.java
index 850898273fc..520b38380ec 100644
--- a/plugin/core/src/main/java/org/elasticsearch/xpack/XpackField.java
+++ b/plugin/core/src/main/java/org/elasticsearch/xpack/XPackField.java
@@ -5,7 +5,7 @@
*/
package org.elasticsearch.xpack;
-public final class XpackField {
+public final class XPackField {
// These should be moved back to XPackPlugin once its moved to common
public static final String NAME = "x-pack";
/** Name constant for the security feature. */
@@ -27,9 +27,9 @@ public final class XpackField {
// inside of YAML settings we still use xpack do not having handle issues with dashes
public static final String SETTINGS_NAME = "xpack";
- private XpackField() {}
+ private XPackField() {}
public static String featureSettingPrefix(String featureName) {
- return XpackField.SETTINGS_NAME + "." + featureName;
+ return XPackField.SETTINGS_NAME + "." + featureName;
}
}
diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/XPackPlugin.java b/plugin/core/src/main/java/org/elasticsearch/xpack/XPackPlugin.java
new file mode 100644
index 00000000000..354f4f76d4c
--- /dev/null
+++ b/plugin/core/src/main/java/org/elasticsearch/xpack/XPackPlugin.java
@@ -0,0 +1,238 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+package org.elasticsearch.xpack;
+
+import org.apache.lucene.util.SetOnce;
+import org.bouncycastle.operator.OperatorCreationException;
+import org.elasticsearch.SpecialPermission;
+import org.elasticsearch.action.ActionRequest;
+import org.elasticsearch.action.ActionResponse;
+import org.elasticsearch.action.GenericAction;
+import org.elasticsearch.action.support.ActionFilter;
+import org.elasticsearch.client.Client;
+import org.elasticsearch.client.transport.TransportClient;
+import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
+import org.elasticsearch.cluster.node.DiscoveryNodes;
+import org.elasticsearch.cluster.service.ClusterService;
+import org.elasticsearch.common.inject.Binder;
+import org.elasticsearch.common.inject.Module;
+import org.elasticsearch.common.inject.multibindings.Multibinder;
+import org.elasticsearch.common.inject.util.Providers;
+import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
+import org.elasticsearch.common.settings.ClusterSettings;
+import org.elasticsearch.common.settings.IndexScopedSettings;
+import org.elasticsearch.common.settings.Settings;
+import org.elasticsearch.common.settings.SettingsFilter;
+import org.elasticsearch.common.xcontent.NamedXContentRegistry;
+import org.elasticsearch.env.Environment;
+import org.elasticsearch.env.NodeEnvironment;
+import org.elasticsearch.license.LicenseService;
+import org.elasticsearch.license.Licensing;
+import org.elasticsearch.license.XPackLicenseState;
+import org.elasticsearch.plugins.ExtensiblePlugin;
+import org.elasticsearch.plugins.ScriptPlugin;
+import org.elasticsearch.rest.RestController;
+import org.elasticsearch.rest.RestHandler;
+import org.elasticsearch.script.ScriptService;
+import org.elasticsearch.threadpool.ThreadPool;
+import org.elasticsearch.watcher.ResourceWatcherService;
+import org.elasticsearch.xpack.action.TransportXPackInfoAction;
+import org.elasticsearch.xpack.action.TransportXPackUsageAction;
+import org.elasticsearch.xpack.action.XPackInfoAction;
+import org.elasticsearch.xpack.action.XPackUsageAction;
+import org.elasticsearch.xpack.extensions.XPackExtension;
+import org.elasticsearch.xpack.extensions.XPackExtensionsService;
+import org.elasticsearch.xpack.rest.action.RestXPackInfoAction;
+import org.elasticsearch.xpack.rest.action.RestXPackUsageAction;
+import org.elasticsearch.xpack.security.authc.AuthenticationServiceField;
+import org.elasticsearch.xpack.security.authc.support.UsernamePasswordToken;
+import org.elasticsearch.xpack.ssl.SSLConfigurationReloader;
+import org.elasticsearch.xpack.ssl.SSLService;
+
+import javax.security.auth.DestroyFailedException;
+import java.io.IOException;
+import java.nio.file.Path;
+import java.security.AccessController;
+import java.security.GeneralSecurityException;
+import java.security.PrivilegedAction;
+import java.time.Clock;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.function.Supplier;
+import java.util.stream.Collectors;
+
+public class XPackPlugin extends XPackClientPlugin implements ScriptPlugin, ExtensiblePlugin {
+
+ // TODO: clean up this library to not ask for write access to all system properties!
+ static {
+ // invoke this clinit in unbound with permissions to access all system properties
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null) {
+ sm.checkPermission(new SpecialPermission());
+ }
+ try {
+ AccessController.doPrivileged(new PrivilegedAction() {
+ @Override
+ public Void run() {
+ try {
+ Class.forName("com.unboundid.util.Debug");
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException(e);
+ }
+ return null;
+ }
+ });
+ // TODO: fix gradle to add all security resources (plugin metadata) to test classpath
+ // of watcher plugin, which depends on it directly. This prevents these plugins
+ // from being initialized correctly by the test framework, and means we have to
+ // have this leniency.
+ } catch (ExceptionInInitializerError bogus) {
+ if (bogus.getCause() instanceof SecurityException == false) {
+ throw bogus; // some other bug
+ }
+ }
+ }
+
+ protected final Settings settings;
+ //private final Environment env;
+ protected boolean transportClientMode;
+ protected final Licensing licensing;
+ // These should not be directly accessed as they cannot be overriden in tests. Please use the getters so they can be overridden.
+ private static final SetOnce licenseState = new SetOnce<>();
+ private static final SetOnce sslService = new SetOnce<>();
+ private static final SetOnce licenseService = new SetOnce<>();
+
+ public XPackPlugin(
+ final Settings settings,
+ final Path configPath) throws IOException, DestroyFailedException, OperatorCreationException, GeneralSecurityException {
+ super(settings);
+ this.settings = settings;
+ this.transportClientMode = transportClientMode(settings);
+ Environment env = transportClientMode ? null : new Environment(settings, configPath);
+
+ setSslService(new SSLService(settings, env));
+ setLicenseState(new XPackLicenseState());
+
+ this.licensing = new Licensing(settings);
+ }
+
+ // For tests only
+ public Collection> getExtensions() {
+ return Collections.emptyList();
+ }
+
+ // overridable by tests
+ protected Clock getClock() {
+ return Clock.systemUTC();
+ }
+
+ protected SSLService getSslService() { return getSharedSslService(); }
+ protected LicenseService getLicenseService() { return getSharedLicenseService(); }
+ protected XPackLicenseState getLicenseState() { return getSharedLicenseState(); }
+ protected void setSslService(SSLService sslService) { XPackPlugin.sslService.set(sslService); }
+ protected void setLicenseService(LicenseService licenseService) { XPackPlugin.licenseService.set(licenseService); }
+ protected void setLicenseState(XPackLicenseState licenseState) { XPackPlugin.licenseState.set(licenseState); }
+ public static SSLService getSharedSslService() { return sslService.get(); }
+ public static LicenseService getSharedLicenseService() { return licenseService.get(); }
+ public static XPackLicenseState getSharedLicenseState() { return licenseState.get(); }
+
+ @Override
+ public Collection createGuiceModules() {
+ ArrayList modules = new ArrayList<>();
+ //modules.add(b -> b.bind(Clock.class).toInstance(getClock()));
+ // used to get core up and running, we do not bind the actual feature set here
+ modules.add(b -> XPackPlugin.createFeatureSetMultiBinder(b, EmptyXPackFeatureSet.class));
+
+ if (transportClientMode) {
+ modules.add(b -> b.bind(XPackLicenseState.class).toProvider(Providers.of(null)));
+ }
+ return modules;
+ }
+
+ @Override
+ public Collection
*
- * The allowable settings for each realm-type are determined by calls to {@link InternalRealms#getSettings()} and
+ * The allowable settings for each realm-type are determined by calls to {@link InternalRealmsSettings#getSettings()} and
* {@link XPackExtension#getRealmSettings()}
*/
public class RealmSettings {
@@ -119,10 +119,10 @@ public class RealmSettings {
/**
* @return A map from realm-type to a collection of Setting objects.
- * @see InternalRealms#getSettings()
+ * @see InternalRealmsSettings#getSettings()
*/
private static Map>> getSettingsByRealm(List extensions) {
- final Map>> settingsByRealm = new HashMap<>(InternalRealms.getSettings());
+ final Map>> settingsByRealm = new HashMap<>(InternalRealmsSettings.getSettings());
if (extensions != null) {
extensions.forEach(ext -> {
final Map>> extSettings = ext.getRealmSettings();
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/TokenMetaData.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/TokenMetaData.java
similarity index 86%
rename from plugin/src/main/java/org/elasticsearch/xpack/security/authc/TokenMetaData.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/TokenMetaData.java
index b00a3f58e30..77e79d0ddab 100644
--- a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/TokenMetaData.java
+++ b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/TokenMetaData.java
@@ -24,17 +24,26 @@ public final class TokenMetaData extends AbstractNamedDiffable keys;
- final byte[] currentKeyHash;
+ private final List keys;
- TokenMetaData(List keys, byte[] currentKeyHash) {
+ public List getKeys() {
+ return keys;
+ }
+
+ private final byte[] currentKeyHash;
+
+ public byte[] getCurrentKeyHash() {
+ return currentKeyHash;
+ }
+
+ public TokenMetaData(List keys, byte[] currentKeyHash) {
this.keys = keys;
this.currentKeyHash = currentKeyHash;
}
public TokenMetaData(StreamInput input) throws IOException {
currentKeyHash = input.readByteArray();
- keys = Collections.unmodifiableList(input.readList(TokenService.KeyAndTimestamp::new));
+ keys = Collections.unmodifiableList(input.readList(KeyAndTimestamp::new));
}
@Override
diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/esnative/NativeRealmSettings.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/esnative/NativeRealmSettings.java
new file mode 100644
index 00000000000..7865053983d
--- /dev/null
+++ b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/esnative/NativeRealmSettings.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+package org.elasticsearch.xpack.security.authc.esnative;
+
+import org.elasticsearch.common.settings.Setting;
+import org.elasticsearch.xpack.security.authc.support.CachingUsernamePasswordRealmSettings;
+
+import java.util.Set;
+
+public final class NativeRealmSettings {
+ public static final String TYPE = "native";
+
+ private NativeRealmSettings() {}
+
+ /**
+ * @return The {@link Setting setting configuration} for this realm type
+ */
+ public static Set> getSettings() {
+ return CachingUsernamePasswordRealmSettings.getCachingSettings();
+ }
+}
diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/file/FileRealmSettings.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/file/FileRealmSettings.java
new file mode 100644
index 00000000000..9da479c018e
--- /dev/null
+++ b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/file/FileRealmSettings.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+package org.elasticsearch.xpack.security.authc.file;
+
+import org.elasticsearch.common.settings.Setting;
+import org.elasticsearch.xpack.security.authc.support.CachingUsernamePasswordRealmSettings;
+
+import java.util.Set;
+
+public final class FileRealmSettings {
+ public static final String TYPE = "file";
+
+ private FileRealmSettings() {}
+
+ /**
+ * @return The {@link Setting setting configuration} for this realm type
+ */
+ public static Set> getSettings() {
+ return CachingUsernamePasswordRealmSettings.getCachingSettings();
+ }
+}
diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/ldap/ActiveDirectorySessionFactorySettings.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/ldap/ActiveDirectorySessionFactorySettings.java
new file mode 100644
index 00000000000..0c9f1f6ad27
--- /dev/null
+++ b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/ldap/ActiveDirectorySessionFactorySettings.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+package org.elasticsearch.xpack.security.authc.ldap;
+
+import org.elasticsearch.common.settings.Setting;
+import org.elasticsearch.xpack.security.authc.ldap.support.SessionFactorySettings;
+
+import java.util.HashSet;
+import java.util.Set;
+
+public final class ActiveDirectorySessionFactorySettings {
+ static final String AD_DOMAIN_NAME_SETTING = "domain_name";
+ static final String AD_GROUP_SEARCH_BASEDN_SETTING = "group_search.base_dn";
+ static final String AD_GROUP_SEARCH_SCOPE_SETTING = "group_search.scope";
+ static final String AD_USER_SEARCH_BASEDN_SETTING = "user_search.base_dn";
+ static final String AD_USER_SEARCH_FILTER_SETTING = "user_search.filter";
+ static final String AD_UPN_USER_SEARCH_FILTER_SETTING = "user_search.upn_filter";
+ static final String AD_DOWN_LEVEL_USER_SEARCH_FILTER_SETTING = "user_search.down_level_filter";
+ static final String AD_USER_SEARCH_SCOPE_SETTING = "user_search.scope";
+ static final Setting POOL_ENABLED = Setting.boolSetting("user_search.pool.enabled",
+ settings -> Boolean.toString(PoolingSessionFactorySettings.BIND_DN.exists(settings)), Setting.Property.NodeScope);
+
+ private ActiveDirectorySessionFactorySettings() {}
+
+ public static Set> getSettings() {
+ Set> settings = new HashSet<>();
+ settings.addAll(SessionFactorySettings.getSettings());
+ settings.add(Setting.simpleString(AD_DOMAIN_NAME_SETTING, Setting.Property.NodeScope));
+ settings.add(Setting.simpleString(AD_GROUP_SEARCH_BASEDN_SETTING, Setting.Property.NodeScope));
+ settings.add(Setting.simpleString(AD_GROUP_SEARCH_SCOPE_SETTING, Setting.Property.NodeScope));
+ settings.add(Setting.simpleString(AD_USER_SEARCH_BASEDN_SETTING, Setting.Property.NodeScope));
+ settings.add(Setting.simpleString(AD_USER_SEARCH_FILTER_SETTING, Setting.Property.NodeScope));
+ settings.add(Setting.simpleString(AD_UPN_USER_SEARCH_FILTER_SETTING, Setting.Property.NodeScope));
+ settings.add(Setting.simpleString(AD_DOWN_LEVEL_USER_SEARCH_FILTER_SETTING, Setting.Property.NodeScope));
+ settings.add(Setting.simpleString(AD_USER_SEARCH_SCOPE_SETTING, Setting.Property.NodeScope));
+ settings.add(POOL_ENABLED);
+ settings.addAll(PoolingSessionFactorySettings.getSettings());
+ return settings;
+ }
+}
diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/ldap/LdapRealmSettings.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/ldap/LdapRealmSettings.java
new file mode 100644
index 00000000000..cac8144b731
--- /dev/null
+++ b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/ldap/LdapRealmSettings.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+package org.elasticsearch.xpack.security.authc.ldap;
+
+import org.elasticsearch.common.settings.Setting;
+import org.elasticsearch.common.unit.TimeValue;
+import org.elasticsearch.xpack.security.authc.ldap.support.LdapMetaDataResolverSettings;
+import org.elasticsearch.xpack.security.authc.support.CachingUsernamePasswordRealmSettings;
+import org.elasticsearch.xpack.security.authc.support.mapper.CompositeRoleMapperSettings;
+
+import java.util.HashSet;
+import java.util.Set;
+
+public final class LdapRealmSettings {
+ public static final String LDAP_TYPE = "ldap";
+ public static final String AD_TYPE = "active_directory";
+ static final Setting EXECUTION_TIMEOUT =
+ Setting.timeSetting("timeout.execution", TimeValue.timeValueSeconds(30L), Setting.Property.NodeScope);
+
+ private LdapRealmSettings() {}
+
+ /**
+ * @param type Either {@link #AD_TYPE} or {@link #LDAP_TYPE}
+ * @return The {@link Setting setting configuration} for this realm type
+ */
+ public static Set> getSettings(String type) {
+ Set> settings = new HashSet<>();
+ settings.addAll(CachingUsernamePasswordRealmSettings.getCachingSettings());
+ settings.addAll(CompositeRoleMapperSettings.getSettings());
+ settings.add(LdapRealmSettings.EXECUTION_TIMEOUT);
+ if (AD_TYPE.equals(type)) {
+ settings.addAll(ActiveDirectorySessionFactorySettings.getSettings());
+ } else {
+ assert LDAP_TYPE.equals(type) : "type [" + type + "] is unknown. expected one of [" + AD_TYPE + ", " + LDAP_TYPE + "]";
+ settings.addAll(LdapSessionFactorySettings.getSettings());
+ settings.addAll(LdapUserSearchSessionFactorySettings.getSettings());
+ }
+ settings.addAll(LdapMetaDataResolverSettings.getSettings());
+ return settings;
+ }
+}
diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/ldap/LdapSessionFactorySettings.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/ldap/LdapSessionFactorySettings.java
new file mode 100644
index 00000000000..c5a0a973c46
--- /dev/null
+++ b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/ldap/LdapSessionFactorySettings.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+package org.elasticsearch.xpack.security.authc.ldap;
+
+import org.elasticsearch.common.settings.Setting;
+import org.elasticsearch.xpack.security.authc.ldap.support.SessionFactorySettings;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.function.Function;
+
+public final class LdapSessionFactorySettings {
+
+ public static final Setting> USER_DN_TEMPLATES_SETTING = Setting.listSetting("user_dn_templates",
+ Collections.emptyList(), Function.identity(), Setting.Property.NodeScope);
+
+ public static Set> getSettings() {
+ Set> settings = new HashSet<>();
+ settings.addAll(SessionFactorySettings.getSettings());
+ settings.add(USER_DN_TEMPLATES_SETTING);
+ return settings;
+ }
+}
diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/ldap/LdapUserSearchSessionFactorySettings.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/ldap/LdapUserSearchSessionFactorySettings.java
new file mode 100644
index 00000000000..1e93e1f0f33
--- /dev/null
+++ b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/ldap/LdapUserSearchSessionFactorySettings.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+package org.elasticsearch.xpack.security.authc.ldap;
+
+import org.elasticsearch.common.settings.Setting;
+import org.elasticsearch.xpack.security.authc.ldap.support.LdapSearchScope;
+import org.elasticsearch.xpack.security.authc.ldap.support.SessionFactorySettings;
+
+import java.util.HashSet;
+import java.util.Set;
+import java.util.function.Function;
+
+public final class LdapUserSearchSessionFactorySettings {
+ static final Setting SEARCH_ATTRIBUTE = new Setting<>("user_search.attribute",
+ LdapUserSearchSessionFactorySettings.DEFAULT_USERNAME_ATTRIBUTE,
+ Function.identity(), Setting.Property.NodeScope, Setting.Property.Deprecated);
+ static final Setting SEARCH_BASE_DN = Setting.simpleString("user_search.base_dn", Setting.Property.NodeScope);
+ static final Setting SEARCH_FILTER = Setting.simpleString("user_search.filter", Setting.Property.NodeScope);
+ static final Setting SEARCH_SCOPE = new Setting<>("user_search.scope", (String) null,
+ s -> LdapSearchScope.resolve(s, LdapSearchScope.SUB_TREE), Setting.Property.NodeScope);
+ static final Setting POOL_ENABLED = Setting.boolSetting("user_search.pool.enabled", true, Setting.Property.NodeScope);
+ private static final String DEFAULT_USERNAME_ATTRIBUTE = "uid";
+
+ private LdapUserSearchSessionFactorySettings() {}
+
+ public static Set> getSettings() {
+ Set> settings = new HashSet<>();
+ settings.addAll(SessionFactorySettings.getSettings());
+ settings.addAll(PoolingSessionFactorySettings.getSettings());
+ settings.add(SEARCH_BASE_DN);
+ settings.add(SEARCH_SCOPE);
+ settings.add(SEARCH_ATTRIBUTE);
+ settings.add(POOL_ENABLED);
+ settings.add(SEARCH_FILTER);
+
+ settings.addAll(SearchGroupsResolverSettings.getSettings());
+ settings.addAll(UserAttributeGroupsResolverSettings.getSettings());
+
+ return settings;
+ }
+}
diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/ldap/PoolingSessionFactorySettings.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/ldap/PoolingSessionFactorySettings.java
new file mode 100644
index 00000000000..b1f2704bce5
--- /dev/null
+++ b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/ldap/PoolingSessionFactorySettings.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+package org.elasticsearch.xpack.security.authc.ldap;
+
+import org.elasticsearch.common.settings.Setting;
+import org.elasticsearch.common.unit.TimeValue;
+import org.elasticsearch.common.util.set.Sets;
+
+import java.util.Optional;
+import java.util.Set;
+
+public final class PoolingSessionFactorySettings {
+ static final TimeValue DEFAULT_HEALTH_CHECK_INTERVAL = TimeValue.timeValueSeconds(60L);
+ static final Setting BIND_DN = Setting.simpleString("bind_dn", Setting.Property.NodeScope, Setting.Property.Filtered);
+ static final Setting BIND_PASSWORD = Setting.simpleString("bind_password", Setting.Property.NodeScope,
+ Setting.Property.Filtered);
+ static final int DEFAULT_CONNECTION_POOL_INITIAL_SIZE = 0;
+ static final Setting POOL_INITIAL_SIZE = Setting.intSetting("user_search.pool.initial_size",
+ DEFAULT_CONNECTION_POOL_INITIAL_SIZE, 0, Setting.Property.NodeScope);
+ static final int DEFAULT_CONNECTION_POOL_SIZE = 20;
+ static final Setting POOL_SIZE = Setting.intSetting("user_search.pool.size",
+ DEFAULT_CONNECTION_POOL_SIZE, 1, Setting.Property.NodeScope);
+ static final Setting HEALTH_CHECK_INTERVAL = Setting.timeSetting("user_search.pool.health_check.interval",
+ DEFAULT_HEALTH_CHECK_INTERVAL, Setting.Property.NodeScope);
+ static final Setting HEALTH_CHECK_ENABLED = Setting.boolSetting("user_search.pool.health_check.enabled",
+ true, Setting.Property.NodeScope);
+ static final Setting> HEALTH_CHECK_DN = new Setting<>("user_search.pool.health_check.dn", (String) null,
+ Optional::ofNullable, Setting.Property.NodeScope);
+
+ private PoolingSessionFactorySettings() {}
+
+ public static Set> getSettings() {
+ return Sets.newHashSet(POOL_INITIAL_SIZE, POOL_SIZE, HEALTH_CHECK_ENABLED, HEALTH_CHECK_INTERVAL, HEALTH_CHECK_DN, BIND_DN,
+ BIND_PASSWORD);
+ }
+}
diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/ldap/SearchGroupsResolverSettings.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/ldap/SearchGroupsResolverSettings.java
new file mode 100644
index 00000000000..2493743ccc1
--- /dev/null
+++ b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/ldap/SearchGroupsResolverSettings.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+package org.elasticsearch.xpack.security.authc.ldap;
+
+import org.elasticsearch.common.settings.Setting;
+import org.elasticsearch.xpack.security.authc.ldap.support.LdapSearchScope;
+
+import java.util.HashSet;
+import java.util.Set;
+import java.util.function.Function;
+
+public final class SearchGroupsResolverSettings {
+ static final Setting BASE_DN = Setting.simpleString("group_search.base_dn",
+ Setting.Property.NodeScope);
+ static final Setting SCOPE = new Setting<>("group_search.scope", (String) null,
+ s -> LdapSearchScope.resolve(s, LdapSearchScope.SUB_TREE), Setting.Property.NodeScope);
+ static final Setting USER_ATTRIBUTE = Setting.simpleString(
+ "group_search.user_attribute", Setting.Property.NodeScope);
+ private static final String GROUP_SEARCH_DEFAULT_FILTER = "(&" +
+ "(|(objectclass=groupOfNames)(objectclass=groupOfUniqueNames)" +
+ "(objectclass=group)(objectclass=posixGroup))" +
+ "(|(uniqueMember={0})(member={0})(memberUid={0})))";
+ static final Setting FILTER = new Setting<>("group_search.filter",
+ GROUP_SEARCH_DEFAULT_FILTER, Function.identity(), Setting.Property.NodeScope);
+
+ private SearchGroupsResolverSettings() {}
+
+ public static Set> getSettings() {
+ Set> settings = new HashSet<>();
+ settings.add(BASE_DN);
+ settings.add(FILTER);
+ settings.add(USER_ATTRIBUTE);
+ settings.add(SCOPE);
+ return settings;
+ }
+}
diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/ldap/UserAttributeGroupsResolverSettings.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/ldap/UserAttributeGroupsResolverSettings.java
new file mode 100644
index 00000000000..0f08e7bd91d
--- /dev/null
+++ b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/ldap/UserAttributeGroupsResolverSettings.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+package org.elasticsearch.xpack.security.authc.ldap;
+
+import org.elasticsearch.common.settings.Setting;
+
+import java.util.Collections;
+import java.util.Set;
+import java.util.function.Function;
+
+public final class UserAttributeGroupsResolverSettings {
+ static final Setting ATTRIBUTE = new Setting<>("user_group_attribute", "memberOf",
+ Function.identity(), Setting.Property.NodeScope);
+
+ private UserAttributeGroupsResolverSettings() {}
+
+ public static Set> getSettings() {
+ return Collections.singleton(ATTRIBUTE);
+ }
+}
diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapLoadBalancingSettings.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapLoadBalancingSettings.java
new file mode 100644
index 00000000000..dcb9057597f
--- /dev/null
+++ b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapLoadBalancingSettings.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+package org.elasticsearch.xpack.security.authc.ldap.support;
+
+import org.elasticsearch.common.settings.Setting;
+
+import java.util.HashSet;
+import java.util.Set;
+
+public final class LdapLoadBalancingSettings {
+ public static final String LOAD_BALANCE_SETTINGS = "load_balance";
+ public static final String LOAD_BALANCE_TYPE_SETTING = "type";
+ public static final String CACHE_TTL_SETTING = "cache_ttl";
+
+ private LdapLoadBalancingSettings() {}
+
+ public static Set> getSettings() {
+ Set> settings = new HashSet<>();
+ settings.add(Setting.simpleString(LOAD_BALANCE_SETTINGS + "." + LOAD_BALANCE_TYPE_SETTING, Setting.Property.NodeScope));
+ settings.add(Setting.simpleString(LOAD_BALANCE_SETTINGS + "." + CACHE_TTL_SETTING, Setting.Property.NodeScope));
+ return settings;
+ }
+}
diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapMetaDataResolverSettings.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapMetaDataResolverSettings.java
new file mode 100644
index 00000000000..f8c7965cf49
--- /dev/null
+++ b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapMetaDataResolverSettings.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+package org.elasticsearch.xpack.security.authc.ldap.support;
+
+import org.elasticsearch.common.settings.Setting;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.function.Function;
+
+public final class LdapMetaDataResolverSettings {
+ public static final Setting> ADDITIONAL_META_DATA_SETTING = Setting.listSetting(
+ "metadata", Collections.emptyList(), Function.identity(), Setting.Property.NodeScope);
+
+ private LdapMetaDataResolverSettings() {}
+
+ public static List> getSettings() {
+ return Collections.singletonList(ADDITIONAL_META_DATA_SETTING);
+ }
+}
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapSearchScope.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapSearchScope.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapSearchScope.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapSearchScope.java
diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/ldap/support/SessionFactorySettings.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/ldap/support/SessionFactorySettings.java
new file mode 100644
index 00000000000..0ff0526a995
--- /dev/null
+++ b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/ldap/support/SessionFactorySettings.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+package org.elasticsearch.xpack.security.authc.ldap.support;
+
+import org.elasticsearch.common.settings.Setting;
+import org.elasticsearch.common.unit.TimeValue;
+import org.elasticsearch.xpack.ssl.SSLConfigurationSettings;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.function.Function;
+
+public final class SessionFactorySettings {
+ public static final String URLS_SETTING = "url";
+ public static final String TIMEOUT_TCP_CONNECTION_SETTING = "timeout.tcp_connect";
+ public static final String TIMEOUT_TCP_READ_SETTING = "timeout.tcp_read";
+ public static final String TIMEOUT_LDAP_SETTING = "timeout.ldap_search";
+ public static final String HOSTNAME_VERIFICATION_SETTING = "hostname_verification";
+ public static final String FOLLOW_REFERRALS_SETTING = "follow_referrals";
+ public static final Setting IGNORE_REFERRAL_ERRORS_SETTING = Setting.boolSetting(
+ "ignore_referral_errors", true, Setting.Property.NodeScope);
+ public static final TimeValue TIMEOUT_DEFAULT = TimeValue.timeValueSeconds(5);
+
+ private SessionFactorySettings() {}
+
+ public static Set> getSettings() {
+ Set> settings = new HashSet<>();
+ settings.addAll(LdapLoadBalancingSettings.getSettings());
+ settings.add(Setting.listSetting(URLS_SETTING, Collections.emptyList(), Function.identity(),
+ Setting.Property.NodeScope));
+ settings.add(Setting.timeSetting(TIMEOUT_TCP_CONNECTION_SETTING, TIMEOUT_DEFAULT, Setting.Property.NodeScope));
+ settings.add(Setting.timeSetting(TIMEOUT_TCP_READ_SETTING, TIMEOUT_DEFAULT, Setting.Property.NodeScope));
+ settings.add(Setting.timeSetting(TIMEOUT_LDAP_SETTING, TIMEOUT_DEFAULT, Setting.Property.NodeScope));
+ settings.add(Setting.boolSetting(HOSTNAME_VERIFICATION_SETTING, true, Setting.Property.NodeScope, Setting.Property.Filtered));
+ settings.add(Setting.boolSetting(FOLLOW_REFERRALS_SETTING, true, Setting.Property.NodeScope));
+ settings.add(IGNORE_REFERRAL_ERRORS_SETTING);
+ settings.addAll(SSLConfigurationSettings.withPrefix("ssl.").getAllSettings());
+ return settings;
+ }
+}
diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/pki/PkiRealmSettings.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/pki/PkiRealmSettings.java
new file mode 100644
index 00000000000..bf90dd986c7
--- /dev/null
+++ b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/pki/PkiRealmSettings.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+package org.elasticsearch.xpack.security.authc.pki;
+
+import org.elasticsearch.common.settings.Setting;
+import org.elasticsearch.xpack.security.authc.support.mapper.CompositeRoleMapperSettings;
+import org.elasticsearch.xpack.ssl.SSLConfigurationSettings;
+
+import java.util.HashSet;
+import java.util.Set;
+import java.util.regex.Pattern;
+
+public final class PkiRealmSettings {
+ public static final String TYPE = "pki";
+ static final String DEFAULT_USERNAME_PATTERN = "CN=(.*?)(?:,|$)";
+ static final Setting USERNAME_PATTERN_SETTING = new Setting<>("username_pattern", DEFAULT_USERNAME_PATTERN,
+ s -> Pattern.compile(s, Pattern.CASE_INSENSITIVE), Setting.Property.NodeScope);
+ static final SSLConfigurationSettings SSL_SETTINGS = SSLConfigurationSettings.withoutPrefix();
+
+ private PkiRealmSettings() {}
+
+ /**
+ * @return The {@link Setting setting configuration} for this realm type
+ */
+ public static Set> getSettings() {
+ Set> settings = new HashSet<>();
+ settings.add(USERNAME_PATTERN_SETTING);
+
+ settings.add(SSL_SETTINGS.truststorePath);
+ settings.add(SSL_SETTINGS.truststorePassword);
+ settings.add(SSL_SETTINGS.legacyTruststorePassword);
+ settings.add(SSL_SETTINGS.truststoreAlgorithm);
+ settings.add(SSL_SETTINGS.caPaths);
+
+ settings.addAll(CompositeRoleMapperSettings.getSettings());
+
+ return settings;
+ }
+}
diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/support/CachingUsernamePasswordRealmSettings.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/support/CachingUsernamePasswordRealmSettings.java
new file mode 100644
index 00000000000..897d9245dd5
--- /dev/null
+++ b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/support/CachingUsernamePasswordRealmSettings.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+package org.elasticsearch.xpack.security.authc.support;
+
+import org.elasticsearch.common.settings.Setting;
+import org.elasticsearch.common.unit.TimeValue;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+public final class CachingUsernamePasswordRealmSettings {
+ public static final Setting CACHE_HASH_ALGO_SETTING = Setting.simpleString("cache.hash_algo", Setting.Property.NodeScope);
+ private static final TimeValue DEFAULT_TTL = TimeValue.timeValueMinutes(20);
+ public static final Setting CACHE_TTL_SETTING = Setting.timeSetting("cache.ttl", DEFAULT_TTL, Setting.Property.NodeScope);
+ private static final int DEFAULT_MAX_USERS = 100_000; //100k users
+ public static final Setting CACHE_MAX_USERS_SETTING = Setting.intSetting("cache.max_users", DEFAULT_MAX_USERS,
+ Setting.Property.NodeScope);
+
+ private CachingUsernamePasswordRealmSettings() {}
+
+ /**
+ * Returns the {@link Setting setting configuration} that is common for all caching realms
+ */
+ public static Set> getCachingSettings() {
+ return new HashSet<>(Arrays.asList(CACHE_HASH_ALGO_SETTING, CACHE_TTL_SETTING, CACHE_MAX_USERS_SETTING));
+ }
+}
diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/support/DnRoleMapperSettings.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/support/DnRoleMapperSettings.java
new file mode 100644
index 00000000000..66cd84df170
--- /dev/null
+++ b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/support/DnRoleMapperSettings.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+package org.elasticsearch.xpack.security.authc.support;
+
+import org.elasticsearch.common.settings.Setting;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.function.Function;
+
+public final class DnRoleMapperSettings {
+
+ private static final String DEFAULT_FILE_NAME = "role_mapping.yml";
+ public static final Setting ROLE_MAPPING_FILE_SETTING = new Setting<>("files.role_mapping", DEFAULT_FILE_NAME,
+ Function.identity(), Setting.Property.NodeScope);
+ public static final Setting USE_UNMAPPED_GROUPS_AS_ROLES_SETTING =
+ Setting.boolSetting("unmapped_groups_as_roles", false, Setting.Property.NodeScope);
+
+ public static List> getSettings() {
+ return Arrays.asList(USE_UNMAPPED_GROUPS_AS_ROLES_SETTING, ROLE_MAPPING_FILE_SETTING);
+ }
+}
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/support/UsernamePasswordToken.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/support/UsernamePasswordToken.java
similarity index 98%
rename from plugin/src/main/java/org/elasticsearch/xpack/security/authc/support/UsernamePasswordToken.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/support/UsernamePasswordToken.java
index fddfec9758f..39c745ee420 100644
--- a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/support/UsernamePasswordToken.java
+++ b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/support/UsernamePasswordToken.java
@@ -18,9 +18,8 @@ import static org.elasticsearch.xpack.security.support.Exceptions.authentication
public class UsernamePasswordToken implements AuthenticationToken {
+ public static final String BASIC_AUTH_PREFIX = "Basic ";
public static final String BASIC_AUTH_HEADER = "Authorization";
- private static final String BASIC_AUTH_PREFIX = "Basic ";
-
private final String username;
private final SecureString password;
@@ -29,6 +28,24 @@ public class UsernamePasswordToken implements AuthenticationToken {
this.password = password;
}
+ public static String basicAuthHeaderValue(String username, SecureString passwd) {
+ CharBuffer chars = CharBuffer.allocate(username.length() + passwd.length() + 1);
+ byte[] charBytes = null;
+ try {
+ chars.put(username).put(':').put(passwd.getChars());
+ charBytes = CharArrays.toUtf8Bytes(chars.array());
+
+ //TODO we still have passwords in Strings in headers. Maybe we can look into using a CharSequence?
+ String basicToken = Base64.getEncoder().encodeToString(charBytes);
+ return "Basic " + basicToken;
+ } finally {
+ Arrays.fill(chars.array(), (char) 0);
+ if (charBytes != null) {
+ Arrays.fill(charBytes, (byte) 0);
+ }
+ }
+ }
+
@Override
public String principal() {
return username;
@@ -101,21 +118,4 @@ public class UsernamePasswordToken implements AuthenticationToken {
context.putHeader(BASIC_AUTH_HEADER, basicAuthHeaderValue(token.username, token.password));
}
- public static String basicAuthHeaderValue(String username, SecureString passwd) {
- CharBuffer chars = CharBuffer.allocate(username.length() + passwd.length() + 1);
- byte[] charBytes = null;
- try {
- chars.put(username).put(':').put(passwd.getChars());
- charBytes = CharArrays.toUtf8Bytes(chars.array());
-
- //TODO we still have passwords in Strings in headers. Maybe we can look into using a CharSequence?
- String basicToken = Base64.getEncoder().encodeToString(charBytes);
- return "Basic " + basicToken;
- } finally {
- Arrays.fill(chars.array(), (char) 0);
- if (charBytes != null) {
- Arrays.fill(charBytes, (byte) 0);
- }
- }
- }
}
diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/support/mapper/CompositeRoleMapperSettings.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/support/mapper/CompositeRoleMapperSettings.java
new file mode 100644
index 00000000000..25b3e03630a
--- /dev/null
+++ b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/support/mapper/CompositeRoleMapperSettings.java
@@ -0,0 +1,19 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+package org.elasticsearch.xpack.security.authc.support.mapper;
+
+import org.elasticsearch.common.settings.Setting;
+import org.elasticsearch.xpack.security.authc.support.DnRoleMapperSettings;
+
+import java.util.Collection;
+
+public final class CompositeRoleMapperSettings {
+ private CompositeRoleMapperSettings() {}
+
+ public static Collection extends Setting>> getSettings() {
+ return DnRoleMapperSettings.getSettings();
+ }
+}
diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/support/mapper/ExpressionRoleMapping.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/support/mapper/ExpressionRoleMapping.java
index 2ee3e2963f1..bc8b0a4544b 100644
--- a/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/support/mapper/ExpressionRoleMapping.java
+++ b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/support/mapper/ExpressionRoleMapping.java
@@ -166,7 +166,7 @@ public class ExpressionRoleMapping implements ToXContentObject, Writeable {
return toXContent(builder, params, false);
}
- XContentBuilder toXContent(XContentBuilder builder, Params params, boolean includeDocType) throws IOException {
+ public XContentBuilder toXContent(XContentBuilder builder, Params params, boolean includeDocType) throws IOException {
builder.startObject();
builder.field(Fields.ENABLED.getPreferredName(), enabled);
builder.startArray(Fields.ROLES.getPreferredName());
diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/support/mapper/expressiondsl/AllExpression.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/support/mapper/expressiondsl/AllExpression.java
index eef037288db..66d925fdc54 100644
--- a/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/support/mapper/expressiondsl/AllExpression.java
+++ b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/support/mapper/expressiondsl/AllExpression.java
@@ -21,7 +21,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
*/
public final class AllExpression implements RoleMapperExpression {
- static final String NAME = "all";
+ public static final String NAME = "all";
private final List elements;
@@ -30,7 +30,7 @@ public final class AllExpression implements RoleMapperExpression {
this.elements = elements;
}
- AllExpression(StreamInput in) throws IOException {
+ public AllExpression(StreamInput in) throws IOException {
this(ExpressionParser.readExpressionList(in));
}
diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/support/mapper/expressiondsl/AnyExpression.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/support/mapper/expressiondsl/AnyExpression.java
index 2c35c090d1e..f64a9813474 100644
--- a/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/support/mapper/expressiondsl/AnyExpression.java
+++ b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/support/mapper/expressiondsl/AnyExpression.java
@@ -21,7 +21,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
*/
public final class AnyExpression implements RoleMapperExpression {
- static final String NAME = "any";
+ public static final String NAME = "any";
private final List elements;
@@ -30,7 +30,7 @@ public final class AnyExpression implements RoleMapperExpression {
this.elements = elements;
}
- AnyExpression(StreamInput in) throws IOException {
+ public AnyExpression(StreamInput in) throws IOException {
this(ExpressionParser.readExpressionList(in));
}
diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/support/mapper/expressiondsl/ExceptExpression.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/support/mapper/expressiondsl/ExceptExpression.java
index 7118a8a17c0..4c697816641 100644
--- a/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/support/mapper/expressiondsl/ExceptExpression.java
+++ b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/support/mapper/expressiondsl/ExceptExpression.java
@@ -20,7 +20,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
*/
public final class ExceptExpression implements RoleMapperExpression {
- static final String NAME = "except";
+ public static final String NAME = "except";
private final RoleMapperExpression expression;
@@ -29,7 +29,7 @@ public final class ExceptExpression implements RoleMapperExpression {
this.expression = expression;
}
- ExceptExpression(StreamInput in) throws IOException {
+ public ExceptExpression(StreamInput in) throws IOException {
this(ExpressionParser.readExpression(in));
}
diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/support/mapper/expressiondsl/ExpressionParser.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/support/mapper/expressiondsl/ExpressionParser.java
index 174846e7603..2395cf585da 100644
--- a/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/support/mapper/expressiondsl/ExpressionParser.java
+++ b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/support/mapper/expressiondsl/ExpressionParser.java
@@ -25,13 +25,6 @@ import org.elasticsearch.xpack.watcher.support.xcontent.XContentSource;
*/
public final class ExpressionParser {
- public static final NamedWriteableRegistry.Entry[] NAMED_WRITEABLES = {
- new NamedWriteableRegistry.Entry(RoleMapperExpression.class, AllExpression.NAME, AllExpression::new),
- new NamedWriteableRegistry.Entry(RoleMapperExpression.class, AnyExpression.NAME, AnyExpression::new),
- new NamedWriteableRegistry.Entry(RoleMapperExpression.class, FieldExpression.NAME, FieldExpression::new),
- new NamedWriteableRegistry.Entry(RoleMapperExpression.class, ExceptExpression.NAME, ExceptExpression::new)
- };
-
public static RoleMapperExpression readExpression(StreamInput in) throws IOException {
return in.readNamedWriteable(RoleMapperExpression.class);
}
diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/support/mapper/expressiondsl/FieldExpression.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/support/mapper/expressiondsl/FieldExpression.java
index 33873e11beb..ae72a6b2b99 100644
--- a/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/support/mapper/expressiondsl/FieldExpression.java
+++ b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/support/mapper/expressiondsl/FieldExpression.java
@@ -28,7 +28,7 @@ import java.util.function.Predicate;
*/
public final class FieldExpression implements RoleMapperExpression {
- static final String NAME = "field";
+ public static final String NAME = "field";
private final String field;
private final List values;
@@ -44,7 +44,7 @@ public final class FieldExpression implements RoleMapperExpression {
this.values = values;
}
- FieldExpression(StreamInput in) throws IOException {
+ public FieldExpression(StreamInput in) throws IOException {
this(in.readString(), in.readList(FieldPredicate::readFrom));
}
diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/AuthorizationServiceField.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/AuthorizationServiceField.java
new file mode 100644
index 00000000000..c091c3ea79d
--- /dev/null
+++ b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/AuthorizationServiceField.java
@@ -0,0 +1,12 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+package org.elasticsearch.xpack.security.authz;
+
+public final class AuthorizationServiceField {
+ public static final String INDICES_PERMISSIONS_KEY = "_indices_permissions";
+
+ private AuthorizationServiceField() {}
+}
diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/IndicesAndAliasesResolverField.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/IndicesAndAliasesResolverField.java
new file mode 100644
index 00000000000..da2a55b2d03
--- /dev/null
+++ b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/IndicesAndAliasesResolverField.java
@@ -0,0 +1,14 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+package org.elasticsearch.xpack.security.authz;
+
+public final class IndicesAndAliasesResolverField {
+ //placeholder used in the security plugin to indicate that the request is authorized knowing that it will yield an empty response
+ public static final String NO_INDEX_PLACEHOLDER = "-*";
+
+ private IndicesAndAliasesResolverField() {}
+
+}
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authz/accesscontrol/DocumentSubsetReader.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/accesscontrol/DocumentSubsetReader.java
similarity index 98%
rename from plugin/src/main/java/org/elasticsearch/xpack/security/authz/accesscontrol/DocumentSubsetReader.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/accesscontrol/DocumentSubsetReader.java
index 5318164a03e..2a122e69e24 100644
--- a/plugin/src/main/java/org/elasticsearch/xpack/security/authz/accesscontrol/DocumentSubsetReader.java
+++ b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/accesscontrol/DocumentSubsetReader.java
@@ -31,7 +31,7 @@ public final class DocumentSubsetReader extends FilterLeafReader {
return new DocumentSubsetDirectoryReader(in, bitsetFilterCache, roleQuery);
}
- static final class DocumentSubsetDirectoryReader extends FilterDirectoryReader {
+ public static final class DocumentSubsetDirectoryReader extends FilterDirectoryReader {
private final Query roleQuery;
private final BitsetFilterCache bitsetFilterCache;
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authz/accesscontrol/FieldExtractor.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/accesscontrol/FieldExtractor.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/xpack/security/authz/accesscontrol/FieldExtractor.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/accesscontrol/FieldExtractor.java
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authz/accesscontrol/FieldSubsetReader.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/accesscontrol/FieldSubsetReader.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/xpack/security/authz/accesscontrol/FieldSubsetReader.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/accesscontrol/FieldSubsetReader.java
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authz/accesscontrol/IndicesAccessControl.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/accesscontrol/IndicesAccessControl.java
similarity index 97%
rename from plugin/src/main/java/org/elasticsearch/xpack/security/authz/accesscontrol/IndicesAccessControl.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/accesscontrol/IndicesAccessControl.java
index aa7a4884f80..1b5e6833ea1 100644
--- a/plugin/src/main/java/org/elasticsearch/xpack/security/authz/accesscontrol/IndicesAccessControl.java
+++ b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/accesscontrol/IndicesAccessControl.java
@@ -7,7 +7,7 @@ package org.elasticsearch.xpack.security.authz.accesscontrol;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.bytes.BytesReference;
-import org.elasticsearch.xpack.security.authz.IndicesAndAliasesResolver;
+import org.elasticsearch.xpack.security.authz.IndicesAndAliasesResolverField;
import org.elasticsearch.xpack.security.authz.permission.FieldPermissions;
import java.util.Collections;
@@ -21,7 +21,7 @@ public class IndicesAccessControl {
public static final IndicesAccessControl ALLOW_ALL = new IndicesAccessControl(true, Collections.emptyMap());
public static final IndicesAccessControl ALLOW_NO_INDICES = new IndicesAccessControl(true,
- Collections.singletonMap(IndicesAndAliasesResolver.NO_INDEX_PLACEHOLDER,
+ Collections.singletonMap(IndicesAndAliasesResolverField.NO_INDEX_PLACEHOLDER,
new IndicesAccessControl.IndexAccessControl(true, new FieldPermissions(), null)));
private final boolean granted;
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authz/accesscontrol/OptOutQueryCache.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/accesscontrol/OptOutQueryCache.java
similarity index 98%
rename from plugin/src/main/java/org/elasticsearch/xpack/security/authz/accesscontrol/OptOutQueryCache.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/accesscontrol/OptOutQueryCache.java
index 695a8c93222..73083cdc9c0 100644
--- a/plugin/src/main/java/org/elasticsearch/xpack/security/authz/accesscontrol/OptOutQueryCache.java
+++ b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/accesscontrol/OptOutQueryCache.java
@@ -13,7 +13,7 @@ import org.elasticsearch.index.AbstractIndexComponent;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.cache.query.QueryCache;
import org.elasticsearch.indices.IndicesQueryCache;
-import org.elasticsearch.xpack.security.authz.AuthorizationService;
+import org.elasticsearch.xpack.security.authz.AuthorizationServiceField;
import java.util.HashSet;
import java.util.Objects;
@@ -50,7 +50,7 @@ public final class OptOutQueryCache extends AbstractIndexComponent implements Qu
@Override
public Weight doCache(Weight weight, QueryCachingPolicy policy) {
IndicesAccessControl indicesAccessControl = context.getTransient(
- AuthorizationService.INDICES_PERMISSIONS_KEY);
+ AuthorizationServiceField.INDICES_PERMISSIONS_KEY);
if (indicesAccessControl == null) {
logger.debug("opting out of the query cache. current request doesn't hold indices permissions");
return weight;
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authz/accesscontrol/SetSecurityUserProcessor.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/accesscontrol/SetSecurityUserProcessor.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/xpack/security/authz/accesscontrol/SetSecurityUserProcessor.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/accesscontrol/SetSecurityUserProcessor.java
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authz/permission/ClusterPermission.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/permission/ClusterPermission.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/xpack/security/authz/permission/ClusterPermission.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/permission/ClusterPermission.java
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authz/permission/FieldPermissions.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/permission/FieldPermissions.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/xpack/security/authz/permission/FieldPermissions.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/permission/FieldPermissions.java
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authz/permission/FieldPermissionsCache.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/permission/FieldPermissionsCache.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/xpack/security/authz/permission/FieldPermissionsCache.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/permission/FieldPermissionsCache.java
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authz/permission/FieldPermissionsDefinition.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/permission/FieldPermissionsDefinition.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/xpack/security/authz/permission/FieldPermissionsDefinition.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/permission/FieldPermissionsDefinition.java
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authz/permission/IndicesPermission.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/permission/IndicesPermission.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/xpack/security/authz/permission/IndicesPermission.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/permission/IndicesPermission.java
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authz/permission/Role.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/permission/Role.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/xpack/security/authz/permission/Role.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/permission/Role.java
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authz/permission/RunAsPermission.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/permission/RunAsPermission.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/xpack/security/authz/permission/RunAsPermission.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/permission/RunAsPermission.java
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authz/privilege/ClusterPrivilege.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/privilege/ClusterPrivilege.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/xpack/security/authz/privilege/ClusterPrivilege.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/privilege/ClusterPrivilege.java
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authz/privilege/HealthAndStatsPrivilege.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/privilege/HealthAndStatsPrivilege.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/xpack/security/authz/privilege/HealthAndStatsPrivilege.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/privilege/HealthAndStatsPrivilege.java
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authz/privilege/IndexPrivilege.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/privilege/IndexPrivilege.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/xpack/security/authz/privilege/IndexPrivilege.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/privilege/IndexPrivilege.java
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authz/privilege/Privilege.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/privilege/Privilege.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/xpack/security/authz/privilege/Privilege.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/privilege/Privilege.java
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authz/privilege/SystemPrivilege.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/privilege/SystemPrivilege.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/xpack/security/authz/privilege/SystemPrivilege.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/privilege/SystemPrivilege.java
diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/store/ClientReservedRoles.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/store/ClientReservedRoles.java
deleted file mode 100644
index b31777d2e6a..00000000000
--- a/plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/store/ClientReservedRoles.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-package org.elasticsearch.xpack.security.authz.store;
-
-import org.elasticsearch.xpack.security.SecurityExtension;
-import org.elasticsearch.xpack.security.authz.RoleDescriptor;
-import org.elasticsearch.xpack.security.support.MetadataUtils;
-import org.elasticsearch.xpack.security.user.UsernamesField;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.ServiceLoader;
-
-public class ClientReservedRoles {
-
- public static final RoleDescriptor SUPERUSER_ROLE_DESCRIPTOR = new RoleDescriptor("superuser",
- new String[] { "all" },
- new RoleDescriptor.IndicesPrivileges[] {
- RoleDescriptor.IndicesPrivileges.builder().indices("*").privileges("all").build()},
- new String[] { "*" },
- MetadataUtils.DEFAULT_RESERVED_METADATA);
- static final Map RESERVED_ROLES = initializeReservedRoles();
-
- static Map initializeReservedRoles() {
- Map roles = new HashMap<>();
-
- roles.put("superuser", SUPERUSER_ROLE_DESCRIPTOR);
-
- // Services are loaded through SPI, and are defined in their META-INF/services
- for(SecurityExtension ext : ServiceLoader.load(SecurityExtension.class, SecurityExtension.class.getClassLoader())) {
- roles.putAll(ext.getReservedRoles());
- }
-
- return Collections.unmodifiableMap(roles);
- }
-
- public static boolean isReserved(String role) {
- return RESERVED_ROLES.containsKey(role) || UsernamesField.SYSTEM_ROLE.equals(role) || UsernamesField.XPACK_ROLE.equals(role);
- }
-}
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authz/store/FileRolesStore.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/store/FileRolesStore.java
similarity index 98%
rename from plugin/src/main/java/org/elasticsearch/xpack/security/authz/store/FileRolesStore.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/store/FileRolesStore.java
index 9dd9b97b1fb..41145af6f1a 100644
--- a/plugin/src/main/java/org/elasticsearch/xpack/security/authz/store/FileRolesStore.java
+++ b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/store/FileRolesStore.java
@@ -73,7 +73,7 @@ public class FileRolesStore extends AbstractComponent {
permissions = parseFile(file, logger, settings, licenseState);
}
- Set roleDescriptors(Set roleNames) {
+ public Set roleDescriptors(Set roleNames) {
Set descriptors = new HashSet<>();
roleNames.forEach((name) -> {
RoleDescriptor descriptor = permissions.get(name);
@@ -105,7 +105,7 @@ public class FileRolesStore extends AbstractComponent {
return usageStats;
}
- void addListener(Runnable runnable) {
+ public void addListener(Runnable runnable) {
Objects.requireNonNull(runnable);
synchronized (this) {
listeners.add(runnable);
@@ -143,7 +143,7 @@ public class FileRolesStore extends AbstractComponent {
for (String segment : roleSegments) {
RoleDescriptor descriptor = parseRoleDescriptor(segment, path, logger, resolvePermission, settings);
if (descriptor != null) {
- if (ClientReservedRoles.isReserved(descriptor.getName())) {
+ if (ReservedRolesStore.isReserved(descriptor.getName())) {
logger.warn("role [{}] is reserved. the relevant role definition in the mapping file will be ignored",
descriptor.getName());
} else if (flsDlsLicensed == false && descriptor.isUsingDocumentOrFieldLevelSecurity()) {
diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/store/ReservedRolesStore.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/store/ReservedRolesStore.java
new file mode 100644
index 00000000000..7e324db7f68
--- /dev/null
+++ b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/store/ReservedRolesStore.java
@@ -0,0 +1,133 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+package org.elasticsearch.xpack.security.authz.store;
+
+import org.elasticsearch.common.collect.MapBuilder;
+import org.elasticsearch.xpack.monitoring.action.MonitoringBulkAction;
+import org.elasticsearch.xpack.security.authz.RoleDescriptor;
+import org.elasticsearch.xpack.security.authz.permission.Role;
+import org.elasticsearch.xpack.security.support.MetadataUtils;
+import org.elasticsearch.xpack.security.user.KibanaUser;
+import org.elasticsearch.xpack.security.user.UsernamesField;
+import org.elasticsearch.xpack.watcher.execution.TriggeredWatchStoreField;
+import org.elasticsearch.xpack.watcher.history.HistoryStoreField;
+import org.elasticsearch.xpack.watcher.watch.Watch;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Set;
+
+public class ReservedRolesStore {
+
+ public static final RoleDescriptor SUPERUSER_ROLE_DESCRIPTOR = new RoleDescriptor("superuser",
+ new String[] { "all" },
+ new RoleDescriptor.IndicesPrivileges[] {
+ RoleDescriptor.IndicesPrivileges.builder().indices("*").privileges("all").build()},
+ new String[] { "*" },
+ MetadataUtils.DEFAULT_RESERVED_METADATA);
+ public static final Role SUPERUSER_ROLE = Role.builder(SUPERUSER_ROLE_DESCRIPTOR, null).build();
+ private static final Map RESERVED_ROLES = initializeReservedRoles();
+
+ private static Map initializeReservedRoles() {
+ return MapBuilder.newMapBuilder()
+ .put("superuser", new RoleDescriptor("superuser", new String[] { "all" },
+ new RoleDescriptor.IndicesPrivileges[] {
+ RoleDescriptor.IndicesPrivileges.builder().indices("*").privileges("all").build()},
+ new String[] { "*" },
+ MetadataUtils.DEFAULT_RESERVED_METADATA))
+ .put("transport_client", new RoleDescriptor("transport_client", new String[] { "transport_client" }, null, null,
+ MetadataUtils.DEFAULT_RESERVED_METADATA))
+ .put("kibana_user", new RoleDescriptor("kibana_user", null, new RoleDescriptor.IndicesPrivileges[] {
+ RoleDescriptor.IndicesPrivileges.builder().indices(".kibana*").privileges("manage", "read", "index", "delete")
+ .build() }, null, MetadataUtils.DEFAULT_RESERVED_METADATA))
+ .put("monitoring_user", new RoleDescriptor("monitoring_user", null, new RoleDescriptor.IndicesPrivileges[] {
+ RoleDescriptor.IndicesPrivileges.builder()
+ .indices(".monitoring-*").privileges("read", "read_cross_cluster").build()
+ },
+ null, MetadataUtils.DEFAULT_RESERVED_METADATA))
+ .put("remote_monitoring_agent", new RoleDescriptor("remote_monitoring_agent",
+ new String[] {
+ "manage_index_templates", "manage_ingest_pipelines", "monitor",
+ "cluster:monitor/xpack/watcher/watch/get",
+ "cluster:admin/xpack/watcher/watch/put",
+ "cluster:admin/xpack/watcher/watch/delete",
+ },
+ new RoleDescriptor.IndicesPrivileges[] {
+ RoleDescriptor.IndicesPrivileges.builder().indices(".monitoring-*").privileges("all").build() },
+ null, MetadataUtils.DEFAULT_RESERVED_METADATA))
+ .put("ingest_admin", new RoleDescriptor("ingest_admin", new String[] { "manage_index_templates", "manage_pipeline" },
+ null, null, MetadataUtils.DEFAULT_RESERVED_METADATA))
+ // reporting_user doesn't have any privileges in Elasticsearch, and Kibana authorizes privileges based on this role
+ .put("reporting_user", new RoleDescriptor("reporting_user", null, null,
+ null, MetadataUtils.DEFAULT_RESERVED_METADATA))
+ .put("kibana_dashboard_only_user", new RoleDescriptor(
+ "kibana_dashboard_only_user",
+ null,
+ new RoleDescriptor.IndicesPrivileges[] {
+ RoleDescriptor.IndicesPrivileges.builder()
+ .indices(".kibana*").privileges("read", "view_index_metadata").build()
+ },
+ null,
+ MetadataUtils.DEFAULT_RESERVED_METADATA))
+ .put(KibanaUser.ROLE_NAME, new RoleDescriptor(KibanaUser.ROLE_NAME,
+ new String[] { "monitor", "manage_index_templates", MonitoringBulkAction.NAME },
+ new RoleDescriptor.IndicesPrivileges[] {
+ RoleDescriptor.IndicesPrivileges.builder().indices(".kibana*", ".reporting-*").privileges("all").build(),
+ RoleDescriptor.IndicesPrivileges.builder()
+ .indices(".monitoring-*").privileges("read", "read_cross_cluster").build()
+ },
+ null, MetadataUtils.DEFAULT_RESERVED_METADATA))
+ .put("logstash_system", new RoleDescriptor("logstash_system", new String[] { "monitor", MonitoringBulkAction.NAME},
+ null, null, MetadataUtils.DEFAULT_RESERVED_METADATA))
+ .put("machine_learning_user", new RoleDescriptor("machine_learning_user", new String[] { "monitor_ml" },
+ new RoleDescriptor.IndicesPrivileges[] { RoleDescriptor.IndicesPrivileges.builder().indices(".ml-anomalies*",
+ ".ml-notifications").privileges("view_index_metadata", "read").build() },
+ null, MetadataUtils.DEFAULT_RESERVED_METADATA))
+ .put("machine_learning_admin", new RoleDescriptor("machine_learning_admin", new String[] { "manage_ml" },
+ new RoleDescriptor.IndicesPrivileges[] {
+ RoleDescriptor.IndicesPrivileges.builder().indices(".ml-*").privileges("view_index_metadata", "read")
+ .build() }, null, MetadataUtils.DEFAULT_RESERVED_METADATA))
+ .put("watcher_admin", new RoleDescriptor("watcher_admin", new String[] { "manage_watcher" },
+ new RoleDescriptor.IndicesPrivileges[] {
+ RoleDescriptor.IndicesPrivileges.builder().indices(Watch.INDEX, TriggeredWatchStoreField.INDEX_NAME,
+ HistoryStoreField.INDEX_PREFIX + "*").privileges("read").build() },
+ null, MetadataUtils.DEFAULT_RESERVED_METADATA))
+ .put("watcher_user", new RoleDescriptor("watcher_user", new String[] { "monitor_watcher" },
+ new RoleDescriptor.IndicesPrivileges[] {
+ RoleDescriptor.IndicesPrivileges.builder().indices(Watch.INDEX)
+ .privileges("read")
+ .build(),
+ RoleDescriptor.IndicesPrivileges.builder().indices(HistoryStoreField.INDEX_PREFIX + "*")
+ .privileges("read")
+ .build() }, null, MetadataUtils.DEFAULT_RESERVED_METADATA))
+ .put("logstash_admin", new RoleDescriptor("logstash_admin", null, new RoleDescriptor.IndicesPrivileges[] {
+ RoleDescriptor.IndicesPrivileges.builder().indices(".logstash*")
+ .privileges("create", "delete", "index", "manage", "read").build() },
+ null, MetadataUtils.DEFAULT_RESERVED_METADATA))
+ .immutableMap();
+ }
+
+ public static boolean isReserved(String role) {
+ return RESERVED_ROLES.containsKey(role) || UsernamesField.SYSTEM_ROLE.equals(role) || UsernamesField.XPACK_ROLE.equals(role);
+ }
+
+ public Map usageStats() {
+ return Collections.emptyMap();
+ }
+
+ public RoleDescriptor roleDescriptor(String role) {
+ return RESERVED_ROLES.get(role);
+ }
+
+ public Collection roleDescriptors() {
+ return RESERVED_ROLES.values();
+ }
+
+ public static Set names() {
+ return RESERVED_ROLES.keySet();
+ }
+}
\ No newline at end of file
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/client/SecurityClient.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/client/SecurityClient.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/xpack/security/client/SecurityClient.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/security/client/SecurityClient.java
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/rest/RestRequestFilter.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/rest/RestRequestFilter.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/xpack/security/rest/RestRequestFilter.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/security/rest/RestRequestFilter.java
diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/security/support/Exceptions.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/support/Exceptions.java
index 5995cda0386..8499e3bae21 100644
--- a/plugin/core/src/main/java/org/elasticsearch/xpack/security/support/Exceptions.java
+++ b/plugin/core/src/main/java/org/elasticsearch/xpack/security/support/Exceptions.java
@@ -7,7 +7,7 @@ package org.elasticsearch.xpack.security.support;
import org.elasticsearch.ElasticsearchSecurityException;
import org.elasticsearch.rest.RestStatus;
-import org.elasticsearch.xpack.XpackField;
+import org.elasticsearch.xpack.XPackField;
public class Exceptions {
@@ -16,13 +16,13 @@ public class Exceptions {
public static ElasticsearchSecurityException authenticationError(String msg, Throwable cause, Object... args) {
ElasticsearchSecurityException e = new ElasticsearchSecurityException(msg, RestStatus.UNAUTHORIZED, cause, args);
- e.addHeader("WWW-Authenticate", "Basic realm=\"" + XpackField.SECURITY + "\" charset=\"UTF-8\"");
+ e.addHeader("WWW-Authenticate", "Basic realm=\"" + XPackField.SECURITY + "\" charset=\"UTF-8\"");
return e;
}
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\"");
+ e.addHeader("WWW-Authenticate", "Basic realm=\"" + XPackField.SECURITY + "\" charset=\"UTF-8\"");
return e;
}
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/support/NoOpLogger.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/support/NoOpLogger.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/xpack/security/support/NoOpLogger.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/security/support/NoOpLogger.java
diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/security/support/Validation.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/support/Validation.java
index e5ce013aed8..7566ff0d6b8 100644
--- a/plugin/core/src/main/java/org/elasticsearch/xpack/security/support/Validation.java
+++ b/plugin/core/src/main/java/org/elasticsearch/xpack/security/support/Validation.java
@@ -8,7 +8,7 @@ package org.elasticsearch.xpack.security.support;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.set.Sets;
import org.elasticsearch.xpack.security.authc.esnative.ClientReservedRealm;
-import org.elasticsearch.xpack.security.authz.store.ClientReservedRoles;
+import org.elasticsearch.xpack.security.authz.store.ReservedRolesStore;
import java.util.Locale;
import java.util.Set;
@@ -99,7 +99,7 @@ public final class Validation {
if (!isValidUserOrRoleName(roleName)) {
return new Error(String.format(Locale.ROOT, INVALID_NAME_MESSAGE, "Role"));
}
- if (allowReserved == false && ClientReservedRoles.isReserved(roleName)) {
+ if (allowReserved == false && ReservedRolesStore.isReserved(roleName)) {
return new Error("Role [" + roleName + "] is reserved and may not be used.");
}
return null;
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/transport/SSLExceptionHelper.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/transport/SSLExceptionHelper.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/xpack/security/transport/SSLExceptionHelper.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/security/transport/SSLExceptionHelper.java
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/transport/netty4/SecurityNetty4Transport.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/transport/netty4/SecurityNetty4Transport.java
similarity index 93%
rename from plugin/src/main/java/org/elasticsearch/xpack/security/transport/netty4/SecurityNetty4Transport.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/security/transport/netty4/SecurityNetty4Transport.java
index 50893e52aab..fd420fc8fb9 100644
--- a/plugin/src/main/java/org/elasticsearch/xpack/security/transport/netty4/SecurityNetty4Transport.java
+++ b/plugin/core/src/main/java/org/elasticsearch/xpack/security/transport/netty4/SecurityNetty4Transport.java
@@ -22,6 +22,7 @@ import org.elasticsearch.transport.TcpChannel;
import org.elasticsearch.transport.TcpTransport;
import org.elasticsearch.transport.netty4.Netty4Transport;
import org.elasticsearch.xpack.XPackSettings;
+import org.elasticsearch.xpack.security.transport.SSLExceptionHelper;
import org.elasticsearch.xpack.ssl.SSLConfiguration;
import org.elasticsearch.xpack.ssl.SSLService;
@@ -34,9 +35,6 @@ import java.util.HashMap;
import java.util.Map;
import static org.elasticsearch.xpack.security.SecurityField.setting;
-import static org.elasticsearch.xpack.security.transport.SSLExceptionHelper.isCloseDuringHandshakeException;
-import static org.elasticsearch.xpack.security.transport.SSLExceptionHelper.isNotSslRecordException;
-import static org.elasticsearch.xpack.security.transport.SSLExceptionHelper.isReceivedCertificateUnknownException;
/**
* Implementation of a transport that extends the {@link Netty4Transport} to add SSL and IP Filtering
@@ -114,7 +112,7 @@ public class SecurityNetty4Transport extends Netty4Transport {
if (!lifecycle.started()) {
// just close and ignore - we are already stopped and just need to make sure we release all resources
TcpChannel.closeChannel(channel, false);
- } else if (isNotSslRecordException(e)) {
+ } else if (SSLExceptionHelper.isNotSslRecordException(e)) {
if (logger.isTraceEnabled()) {
logger.trace(
new ParameterizedMessage("received plaintext traffic on an encrypted channel, closing connection {}", channel), e);
@@ -122,14 +120,14 @@ public class SecurityNetty4Transport extends Netty4Transport {
logger.warn("received plaintext traffic on an encrypted channel, closing connection {}", channel);
}
TcpChannel.closeChannel(channel, false);
- } else if (isCloseDuringHandshakeException(e)) {
+ } else if (SSLExceptionHelper.isCloseDuringHandshakeException(e)) {
if (logger.isTraceEnabled()) {
logger.trace(new ParameterizedMessage("connection {} closed during ssl handshake", channel), e);
} else {
logger.warn("connection {} closed during handshake", channel);
}
TcpChannel.closeChannel(channel, false);
- } else if (isReceivedCertificateUnknownException(e)) {
+ } else if (SSLExceptionHelper.isReceivedCertificateUnknownException(e)) {
if (logger.isTraceEnabled()) {
logger.trace(new ParameterizedMessage("client did not trust server's certificate, closing connection {}", channel), e);
} else {
@@ -141,10 +139,10 @@ public class SecurityNetty4Transport extends Netty4Transport {
}
}
- class SslChannelInitializer extends ServerChannelInitializer {
+ public class SslChannelInitializer extends ServerChannelInitializer {
private final SSLConfiguration configuration;
- SslChannelInitializer(String name, SSLConfiguration configuration) {
+ public SslChannelInitializer(String name, SSLConfiguration configuration) {
super(name);
this.configuration = configuration;
}
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/user/BuiltinUserInfo.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/user/BuiltinUserInfo.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/xpack/security/user/BuiltinUserInfo.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/security/user/BuiltinUserInfo.java
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/user/ElasticUser.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/user/ElasticUser.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/xpack/security/user/ElasticUser.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/security/user/ElasticUser.java
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/user/InternalUserSerializationHelper.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/user/InternalUserSerializationHelper.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/xpack/security/user/InternalUserSerializationHelper.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/security/user/InternalUserSerializationHelper.java
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/user/KibanaUser.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/user/KibanaUser.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/xpack/security/user/KibanaUser.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/security/user/KibanaUser.java
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/user/LogstashSystemUser.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/user/LogstashSystemUser.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/xpack/security/user/LogstashSystemUser.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/security/user/LogstashSystemUser.java
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/user/SystemUser.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/user/SystemUser.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/xpack/security/user/SystemUser.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/security/user/SystemUser.java
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/user/XPackSecurityUser.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/user/XPackSecurityUser.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/xpack/security/user/XPackSecurityUser.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/security/user/XPackSecurityUser.java
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/user/XPackUser.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/user/XPackUser.java
similarity index 93%
rename from plugin/src/main/java/org/elasticsearch/xpack/security/user/XPackUser.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/security/user/XPackUser.java
index a085f6d8cbb..d5001c564d5 100644
--- a/plugin/src/main/java/org/elasticsearch/xpack/security/user/XPackUser.java
+++ b/plugin/core/src/main/java/org/elasticsearch/xpack/security/user/XPackUser.java
@@ -5,7 +5,7 @@
*/
package org.elasticsearch.xpack.security.user;
-import org.elasticsearch.xpack.security.audit.index.IndexAuditTrail;
+import org.elasticsearch.xpack.security.audit.index.IndexAuditTrailField;
import org.elasticsearch.xpack.security.authz.RoleDescriptor;
import org.elasticsearch.xpack.security.authz.permission.Role;
import org.elasticsearch.xpack.security.support.MetadataUtils;
@@ -20,7 +20,8 @@ public class XPackUser extends User {
public static final Role ROLE = Role.builder(new RoleDescriptor(ROLE_NAME, new String[] { "all" },
new RoleDescriptor.IndicesPrivileges[] {
RoleDescriptor.IndicesPrivileges.builder().indices("/@&~(\\.security.*)/").privileges("all").build(),
- RoleDescriptor.IndicesPrivileges.builder().indices(IndexAuditTrail.INDEX_NAME_PREFIX + "-*").privileges("read").build()
+ RoleDescriptor.IndicesPrivileges.builder().indices(IndexAuditTrailField.INDEX_NAME_PREFIX + "-*")
+ .privileges("read").build()
},
new String[] { "*" },
MetadataUtils.DEFAULT_RESERVED_METADATA), null).build();
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ssl/CertUtils.java b/plugin/core/src/main/java/org/elasticsearch/xpack/ssl/CertUtils.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/xpack/ssl/CertUtils.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/ssl/CertUtils.java
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ssl/CertificateGenerateTool.java b/plugin/core/src/main/java/org/elasticsearch/xpack/ssl/CertificateGenerateTool.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/xpack/ssl/CertificateGenerateTool.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/ssl/CertificateGenerateTool.java
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ssl/CertificateTool.java b/plugin/core/src/main/java/org/elasticsearch/xpack/ssl/CertificateTool.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/xpack/ssl/CertificateTool.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/ssl/CertificateTool.java
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ssl/CertificateTrustRestrictions.java b/plugin/core/src/main/java/org/elasticsearch/xpack/ssl/CertificateTrustRestrictions.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/xpack/ssl/CertificateTrustRestrictions.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/ssl/CertificateTrustRestrictions.java
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ssl/DefaultJDKTrustConfig.java b/plugin/core/src/main/java/org/elasticsearch/xpack/ssl/DefaultJDKTrustConfig.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/xpack/ssl/DefaultJDKTrustConfig.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/ssl/DefaultJDKTrustConfig.java
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ssl/KeyConfig.java b/plugin/core/src/main/java/org/elasticsearch/xpack/ssl/KeyConfig.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/xpack/ssl/KeyConfig.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/ssl/KeyConfig.java
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ssl/PEMKeyConfig.java b/plugin/core/src/main/java/org/elasticsearch/xpack/ssl/PEMKeyConfig.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/xpack/ssl/PEMKeyConfig.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/ssl/PEMKeyConfig.java
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ssl/PEMTrustConfig.java b/plugin/core/src/main/java/org/elasticsearch/xpack/ssl/PEMTrustConfig.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/xpack/ssl/PEMTrustConfig.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/ssl/PEMTrustConfig.java
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ssl/RestrictedTrustConfig.java b/plugin/core/src/main/java/org/elasticsearch/xpack/ssl/RestrictedTrustConfig.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/xpack/ssl/RestrictedTrustConfig.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/ssl/RestrictedTrustConfig.java
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ssl/RestrictedTrustManager.java b/plugin/core/src/main/java/org/elasticsearch/xpack/ssl/RestrictedTrustManager.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/xpack/ssl/RestrictedTrustManager.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/ssl/RestrictedTrustManager.java
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ssl/SSLConfiguration.java b/plugin/core/src/main/java/org/elasticsearch/xpack/ssl/SSLConfiguration.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/xpack/ssl/SSLConfiguration.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/ssl/SSLConfiguration.java
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ssl/SSLConfigurationReloader.java b/plugin/core/src/main/java/org/elasticsearch/xpack/ssl/SSLConfigurationReloader.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/xpack/ssl/SSLConfigurationReloader.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/ssl/SSLConfigurationReloader.java
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ssl/SSLService.java b/plugin/core/src/main/java/org/elasticsearch/xpack/ssl/SSLService.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/xpack/ssl/SSLService.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/ssl/SSLService.java
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ssl/StoreKeyConfig.java b/plugin/core/src/main/java/org/elasticsearch/xpack/ssl/StoreKeyConfig.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/xpack/ssl/StoreKeyConfig.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/ssl/StoreKeyConfig.java
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ssl/StoreTrustConfig.java b/plugin/core/src/main/java/org/elasticsearch/xpack/ssl/StoreTrustConfig.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/xpack/ssl/StoreTrustConfig.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/ssl/StoreTrustConfig.java
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ssl/TLSLicenseBootstrapCheck.java b/plugin/core/src/main/java/org/elasticsearch/xpack/ssl/TLSLicenseBootstrapCheck.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/xpack/ssl/TLSLicenseBootstrapCheck.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/ssl/TLSLicenseBootstrapCheck.java
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ssl/TrustAllConfig.java b/plugin/core/src/main/java/org/elasticsearch/xpack/ssl/TrustAllConfig.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/xpack/ssl/TrustAllConfig.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/ssl/TrustAllConfig.java
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ssl/TrustConfig.java b/plugin/core/src/main/java/org/elasticsearch/xpack/ssl/TrustConfig.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/xpack/ssl/TrustConfig.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/ssl/TrustConfig.java
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ssl/action/TransportGetCertificateInfoAction.java b/plugin/core/src/main/java/org/elasticsearch/xpack/ssl/action/TransportGetCertificateInfoAction.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/xpack/ssl/action/TransportGetCertificateInfoAction.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/ssl/action/TransportGetCertificateInfoAction.java
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ssl/rest/RestGetCertificateInfoAction.java b/plugin/core/src/main/java/org/elasticsearch/xpack/ssl/rest/RestGetCertificateInfoAction.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/xpack/ssl/rest/RestGetCertificateInfoAction.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/ssl/rest/RestGetCertificateInfoAction.java
diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/upgrade/IndexUpgradeCheckVersion.java b/plugin/core/src/main/java/org/elasticsearch/xpack/upgrade/IndexUpgradeCheckVersion.java
new file mode 100644
index 00000000000..50c35df1c36
--- /dev/null
+++ b/plugin/core/src/main/java/org/elasticsearch/xpack/upgrade/IndexUpgradeCheckVersion.java
@@ -0,0 +1,13 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+package org.elasticsearch.xpack.upgrade;
+
+public final class IndexUpgradeCheckVersion {
+ public static final int UPRADE_VERSION = 6;
+
+ private IndexUpgradeCheckVersion() {}
+
+}
diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/upgrade/UpgradeField.java b/plugin/core/src/main/java/org/elasticsearch/xpack/upgrade/UpgradeField.java
new file mode 100644
index 00000000000..c558360dd27
--- /dev/null
+++ b/plugin/core/src/main/java/org/elasticsearch/xpack/upgrade/UpgradeField.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+package org.elasticsearch.xpack.upgrade;
+
+import org.elasticsearch.cluster.metadata.IndexMetaData;
+
+public final class UpgradeField {
+ // this is the required index.format setting for 6.0 services (watcher and security) to start up
+ // this index setting is set by the upgrade API or automatically when a 6.0 index template is created
+ private static final int EXPECTED_INDEX_FORMAT_VERSION = 6;
+
+ private UpgradeField() {}
+
+ /**
+ * Checks the format of an internal index and returns true if the index is up to date or false if upgrade is required
+ */
+ public static boolean checkInternalIndexFormat(IndexMetaData indexMetaData) {
+ return indexMetaData.getSettings().getAsInt(IndexMetaData.INDEX_FORMAT_SETTING.getKey(), 0) == EXPECTED_INDEX_FORMAT_VERSION;
+ }
+}
diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/upgrade/actions/IndexUpgradeInfoAction.java b/plugin/core/src/main/java/org/elasticsearch/xpack/upgrade/actions/IndexUpgradeInfoAction.java
index 9a77165d35a..2076ebca294 100644
--- a/plugin/core/src/main/java/org/elasticsearch/xpack/upgrade/actions/IndexUpgradeInfoAction.java
+++ b/plugin/core/src/main/java/org/elasticsearch/xpack/upgrade/actions/IndexUpgradeInfoAction.java
@@ -49,7 +49,7 @@ public class IndexUpgradeInfoAction extends Action actions;
- protected Response() {
+ public Response() {
}
diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/watcher/WatcherFeatureSetUsage.java b/plugin/core/src/main/java/org/elasticsearch/xpack/watcher/WatcherFeatureSetUsage.java
new file mode 100644
index 00000000000..27cdb827d23
--- /dev/null
+++ b/plugin/core/src/main/java/org/elasticsearch/xpack/watcher/WatcherFeatureSetUsage.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+package org.elasticsearch.xpack.watcher;
+
+import org.elasticsearch.common.io.stream.StreamInput;
+import org.elasticsearch.common.io.stream.StreamOutput;
+import org.elasticsearch.common.xcontent.XContentBuilder;
+import org.elasticsearch.xpack.XPackFeatureSet;
+import org.elasticsearch.xpack.XPackField;
+
+import java.io.IOException;
+import java.util.Map;
+
+public class WatcherFeatureSetUsage extends XPackFeatureSet.Usage {
+
+ private final Map stats;
+
+ public WatcherFeatureSetUsage(StreamInput in) throws IOException {
+ super(in);
+ stats = in.readMap();
+ }
+
+ public WatcherFeatureSetUsage(boolean available, boolean enabled, Map stats) {
+ super(XPackField.WATCHER, available, enabled);
+ this.stats = stats;
+ }
+
+ public Map stats() {
+ return stats;
+ }
+
+ @Override
+ protected void innerXContent(XContentBuilder builder, Params params) throws IOException {
+ super.innerXContent(builder, params);
+ if (enabled) {
+ for (Map.Entry entry : stats.entrySet()) {
+ builder.field(entry.getKey(), entry.getValue());
+ }
+ }
+ }
+
+ @Override
+ public void writeTo(StreamOutput out) throws IOException {
+ super.writeTo(out);
+ out.writeMap(stats);
+ }
+}
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/client/WatcherClient.java b/plugin/core/src/main/java/org/elasticsearch/xpack/watcher/client/WatcherClient.java
similarity index 100%
rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/client/WatcherClient.java
rename to plugin/core/src/main/java/org/elasticsearch/xpack/watcher/client/WatcherClient.java
diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/watcher/execution/TriggeredWatchStoreField.java b/plugin/core/src/main/java/org/elasticsearch/xpack/watcher/execution/TriggeredWatchStoreField.java
new file mode 100644
index 00000000000..15d812d0665
--- /dev/null
+++ b/plugin/core/src/main/java/org/elasticsearch/xpack/watcher/execution/TriggeredWatchStoreField.java
@@ -0,0 +1,12 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+package org.elasticsearch.xpack.watcher.execution;
+
+public final class TriggeredWatchStoreField {
+
+ public static final String INDEX_NAME = ".triggered_watches";
+ public static final String DOC_TYPE = "doc";
+}
diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/watcher/execution/WatchExecutionContext.java b/plugin/core/src/main/java/org/elasticsearch/xpack/watcher/execution/WatchExecutionContext.java
index 0fb2bcd7385..b72e4fcf250 100644
--- a/plugin/core/src/main/java/org/elasticsearch/xpack/watcher/execution/WatchExecutionContext.java
+++ b/plugin/core/src/main/java/org/elasticsearch/xpack/watcher/execution/WatchExecutionContext.java
@@ -202,13 +202,13 @@ public abstract class WatchExecutionContext {
return Collections.unmodifiableMap(actionsResults);
}
- WatchRecord abortBeforeExecution(ExecutionState state, String message) {
+ public WatchRecord abortBeforeExecution(ExecutionState state, String message) {
assert !phase.sealed();
phase = ExecutionPhase.ABORTED;
return new WatchRecord.MessageWatchRecord(id, triggerEvent, state, message, getNodeId());
}
- WatchRecord abortFailedExecution(String message) {
+ public WatchRecord abortFailedExecution(String message) {
assert !phase.sealed();
phase = ExecutionPhase.ABORTED;
long executionTime = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - relativeStartTime);
@@ -217,7 +217,7 @@ public abstract class WatchExecutionContext {
return new WatchRecord.MessageWatchRecord(this, result, message);
}
- WatchRecord abortFailedExecution(Exception e) {
+ public WatchRecord abortFailedExecution(Exception e) {
assert !phase.sealed();
phase = ExecutionPhase.ABORTED;
long executionTime = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - relativeStartTime);
@@ -235,7 +235,7 @@ public abstract class WatchExecutionContext {
return new WatchRecord.MessageWatchRecord(this, result);
}
- WatchExecutionSnapshot createSnapshot(Thread executionThread) {
+ public WatchExecutionSnapshot createSnapshot(Thread executionThread) {
return new WatchExecutionSnapshot(this, executionThread.getStackTrace());
}
}
diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/watcher/history/HistoryStoreField.java b/plugin/core/src/main/java/org/elasticsearch/xpack/watcher/history/HistoryStoreField.java
new file mode 100644
index 00000000000..6b59981c041
--- /dev/null
+++ b/plugin/core/src/main/java/org/elasticsearch/xpack/watcher/history/HistoryStoreField.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+package org.elasticsearch.xpack.watcher.history;
+
+import org.elasticsearch.xpack.watcher.support.WatcherIndexTemplateRegistryField;
+import org.joda.time.DateTime;
+import org.joda.time.format.DateTimeFormat;
+import org.joda.time.format.DateTimeFormatter;
+
+public final class HistoryStoreField {
+
+ public static final String INDEX_PREFIX = ".watcher-history-";
+ public static final String INDEX_PREFIX_WITH_TEMPLATE = INDEX_PREFIX + WatcherIndexTemplateRegistryField.INDEX_TEMPLATE_VERSION + "-";
+ static final DateTimeFormatter indexTimeFormat = DateTimeFormat.forPattern("YYYY.MM.dd");
+
+ /**
+ * Calculates the correct history index name for a given time
+ */
+ public static String getHistoryIndexNameForTime(DateTime time) {
+ return INDEX_PREFIX_WITH_TEMPLATE + indexTimeFormat.print(time);
+ }
+}
diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/watcher/input/none/NoneInput.java b/plugin/core/src/main/java/org/elasticsearch/xpack/watcher/input/none/NoneInput.java
index 4aa8e012d5a..e7a14a53874 100644
--- a/plugin/core/src/main/java/org/elasticsearch/xpack/watcher/input/none/NoneInput.java
+++ b/plugin/core/src/main/java/org/elasticsearch/xpack/watcher/input/none/NoneInput.java
@@ -49,7 +49,7 @@ public class NoneInput implements Input {
public static class Result extends Input.Result {
- static final Result INSTANCE = new Result();
+ public static final Result INSTANCE = new Result();
private Result() {
super(TYPE, Payload.EMPTY);
diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/watcher/support/WatcherIndexTemplateRegistryField.java b/plugin/core/src/main/java/org/elasticsearch/xpack/watcher/support/WatcherIndexTemplateRegistryField.java
new file mode 100644
index 00000000000..7329a717aa9
--- /dev/null
+++ b/plugin/core/src/main/java/org/elasticsearch/xpack/watcher/support/WatcherIndexTemplateRegistryField.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+package org.elasticsearch.xpack.watcher.support;
+
+public final class WatcherIndexTemplateRegistryField {
+ // history (please add a comment why you increased the version here)
+ // version 1: initial
+ // version 2: added mappings for jira action
+ // version 3: include watch status in history
+ // version 6: upgrade to ES 6, removal of _status field
+ // version 7: add full exception stack traces for better debugging
+ // Note: if you change this, also inform the kibana team around the watcher-ui
+ public static final String INDEX_TEMPLATE_VERSION = "7";
+ public static final String HISTORY_TEMPLATE_NAME = ".watch-history-" + INDEX_TEMPLATE_VERSION;
+ public static final String TRIGGERED_TEMPLATE_NAME = ".triggered_watches";
+ public static final String WATCHES_TEMPLATE_NAME = ".watches";
+ public static final String[] TEMPLATE_NAMES = new String[] {
+ HISTORY_TEMPLATE_NAME, TRIGGERED_TEMPLATE_NAME, WATCHES_TEMPLATE_NAME
+ };
+
+ private WatcherIndexTemplateRegistryField() {}
+}
diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/watcher/transport/actions/get/GetWatchResponse.java b/plugin/core/src/main/java/org/elasticsearch/xpack/watcher/transport/actions/get/GetWatchResponse.java
index 61b1fa23438..80f100509b4 100644
--- a/plugin/core/src/main/java/org/elasticsearch/xpack/watcher/transport/actions/get/GetWatchResponse.java
+++ b/plugin/core/src/main/java/org/elasticsearch/xpack/watcher/transport/actions/get/GetWatchResponse.java
@@ -22,7 +22,7 @@ public class GetWatchResponse extends ActionResponse {
private boolean found = false;
private XContentSource source;
- GetWatchResponse() {
+ public GetWatchResponse() {
}
/**
diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/watcher/transport/actions/put/PutWatchResponse.java b/plugin/core/src/main/java/org/elasticsearch/xpack/watcher/transport/actions/put/PutWatchResponse.java
index 4ae3c1ac821..16da3b4ed26 100644
--- a/plugin/core/src/main/java/org/elasticsearch/xpack/watcher/transport/actions/put/PutWatchResponse.java
+++ b/plugin/core/src/main/java/org/elasticsearch/xpack/watcher/transport/actions/put/PutWatchResponse.java
@@ -20,7 +20,7 @@ public class PutWatchResponse extends ActionResponse {
private long version;
private boolean created;
- PutWatchResponse() {
+ public PutWatchResponse() {
}
public PutWatchResponse(String id, long version, boolean created) {
diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/watcher/transport/actions/service/WatcherServiceRequest.java b/plugin/core/src/main/java/org/elasticsearch/xpack/watcher/transport/actions/service/WatcherServiceRequest.java
index 6b30b413042..e20acdc8939 100644
--- a/plugin/core/src/main/java/org/elasticsearch/xpack/watcher/transport/actions/service/WatcherServiceRequest.java
+++ b/plugin/core/src/main/java/org/elasticsearch/xpack/watcher/transport/actions/service/WatcherServiceRequest.java
@@ -16,7 +16,7 @@ import java.util.Locale;
public class WatcherServiceRequest extends MasterNodeRequest {
- enum Command { START, STOP }
+ public enum Command { START, STOP }
private Command command;
@@ -39,7 +39,7 @@ public class WatcherServiceRequest extends MasterNodeRequest snapshots;
private List queuedWatches;
- Node() {
+ public Node() {
}
- Node(DiscoveryNode node) {
+ public Node(DiscoveryNode node) {
super(node);
}
@@ -108,7 +108,7 @@ public class WatcherStatsResponse extends BaseNodesResponse snapshots) {
+ public void setSnapshots(List snapshots) {
this.snapshots = snapshots;
}
diff --git a/plugin/src/main/plugin-metadata/plugin-security.policy b/plugin/core/src/main/plugin-metadata/plugin-security.policy
similarity index 100%
rename from plugin/src/main/plugin-metadata/plugin-security.policy
rename to plugin/core/src/main/plugin-metadata/plugin-security.policy
diff --git a/plugin/src/main/resources/logstash-index-template.json b/plugin/core/src/main/resources/logstash-index-template.json
similarity index 100%
rename from plugin/src/main/resources/logstash-index-template.json
rename to plugin/core/src/main/resources/logstash-index-template.json
diff --git a/plugin/src/main/resources/monitoring-alerts.json b/plugin/core/src/main/resources/monitoring-alerts.json
similarity index 100%
rename from plugin/src/main/resources/monitoring-alerts.json
rename to plugin/core/src/main/resources/monitoring-alerts.json
diff --git a/plugin/src/main/resources/monitoring-beats.json b/plugin/core/src/main/resources/monitoring-beats.json
similarity index 100%
rename from plugin/src/main/resources/monitoring-beats.json
rename to plugin/core/src/main/resources/monitoring-beats.json
diff --git a/plugin/src/main/resources/monitoring-es.json b/plugin/core/src/main/resources/monitoring-es.json
similarity index 100%
rename from plugin/src/main/resources/monitoring-es.json
rename to plugin/core/src/main/resources/monitoring-es.json
diff --git a/plugin/src/main/resources/monitoring-kibana.json b/plugin/core/src/main/resources/monitoring-kibana.json
similarity index 100%
rename from plugin/src/main/resources/monitoring-kibana.json
rename to plugin/core/src/main/resources/monitoring-kibana.json
diff --git a/plugin/src/main/resources/monitoring-logstash.json b/plugin/core/src/main/resources/monitoring-logstash.json
similarity index 100%
rename from plugin/src/main/resources/monitoring-logstash.json
rename to plugin/core/src/main/resources/monitoring-logstash.json
diff --git a/plugin/src/main/resources/security-index-template.json b/plugin/core/src/main/resources/security-index-template.json
similarity index 100%
rename from plugin/src/main/resources/security-index-template.json
rename to plugin/core/src/main/resources/security-index-template.json
diff --git a/plugin/src/main/resources/security_audit_log.json b/plugin/core/src/main/resources/security_audit_log.json
similarity index 100%
rename from plugin/src/main/resources/security_audit_log.json
rename to plugin/core/src/main/resources/security_audit_log.json
diff --git a/plugin/src/main/resources/triggered-watches.json b/plugin/core/src/main/resources/triggered-watches.json
similarity index 100%
rename from plugin/src/main/resources/triggered-watches.json
rename to plugin/core/src/main/resources/triggered-watches.json
diff --git a/plugin/src/main/resources/watch-history.json b/plugin/core/src/main/resources/watch-history.json
similarity index 100%
rename from plugin/src/main/resources/watch-history.json
rename to plugin/core/src/main/resources/watch-history.json
diff --git a/plugin/src/main/resources/watches.json b/plugin/core/src/main/resources/watches.json
similarity index 100%
rename from plugin/src/main/resources/watches.json
rename to plugin/core/src/main/resources/watches.json
diff --git a/plugin/src/main/resources/org/elasticsearch/xpack/security/crypto/migrate.help b/plugin/core/src/main/resources/xpack/security/crypto/migrate.help
similarity index 100%
rename from plugin/src/main/resources/org/elasticsearch/xpack/security/crypto/migrate.help
rename to plugin/core/src/main/resources/xpack/security/crypto/migrate.help
diff --git a/plugin/src/main/resources/org/elasticsearch/xpack/security/crypto/tool/syskey-generate.help b/plugin/core/src/main/resources/xpack/security/crypto/tool/syskey-generate.help
similarity index 100%
rename from plugin/src/main/resources/org/elasticsearch/xpack/security/crypto/tool/syskey-generate.help
rename to plugin/core/src/main/resources/xpack/security/crypto/tool/syskey-generate.help
diff --git a/plugin/src/test/java/org/elasticsearch/action/MockIndicesRequest.java b/plugin/core/src/test/java/org/elasticsearch/action/MockIndicesRequest.java
similarity index 100%
rename from plugin/src/test/java/org/elasticsearch/action/MockIndicesRequest.java
rename to plugin/core/src/test/java/org/elasticsearch/action/MockIndicesRequest.java
diff --git a/plugin/src/test/java/org/elasticsearch/action/admin/indices/stats/IndicesStatsResponseTestUtils.java b/plugin/core/src/test/java/org/elasticsearch/action/admin/indices/stats/IndicesStatsResponseTestUtils.java
similarity index 100%
rename from plugin/src/test/java/org/elasticsearch/action/admin/indices/stats/IndicesStatsResponseTestUtils.java
rename to plugin/core/src/test/java/org/elasticsearch/action/admin/indices/stats/IndicesStatsResponseTestUtils.java
diff --git a/plugin/src/test/java/org/elasticsearch/http/netty4/Netty4HttpMockUtil.java b/plugin/core/src/test/java/org/elasticsearch/http/netty4/Netty4HttpMockUtil.java
similarity index 100%
rename from plugin/src/test/java/org/elasticsearch/http/netty4/Netty4HttpMockUtil.java
rename to plugin/core/src/test/java/org/elasticsearch/http/netty4/Netty4HttpMockUtil.java
diff --git a/plugin/src/test/java/org/elasticsearch/license/AbstractLicenseServiceTestCase.java b/plugin/core/src/test/java/org/elasticsearch/license/AbstractLicenseServiceTestCase.java
similarity index 100%
rename from plugin/src/test/java/org/elasticsearch/license/AbstractLicenseServiceTestCase.java
rename to plugin/core/src/test/java/org/elasticsearch/license/AbstractLicenseServiceTestCase.java
diff --git a/plugin/src/test/java/org/elasticsearch/license/AbstractLicensesIntegrationTestCase.java b/plugin/core/src/test/java/org/elasticsearch/license/AbstractLicensesIntegrationTestCase.java
similarity index 85%
rename from plugin/src/test/java/org/elasticsearch/license/AbstractLicensesIntegrationTestCase.java
rename to plugin/core/src/test/java/org/elasticsearch/license/AbstractLicensesIntegrationTestCase.java
index 3c2d8768bc0..efea851e73c 100644
--- a/plugin/src/test/java/org/elasticsearch/license/AbstractLicensesIntegrationTestCase.java
+++ b/plugin/core/src/test/java/org/elasticsearch/license/AbstractLicensesIntegrationTestCase.java
@@ -5,11 +5,6 @@
*/
package org.elasticsearch.license;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.concurrent.CountDownLatch;
-
import org.elasticsearch.analysis.common.CommonAnalysisPlugin;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.ClusterStateUpdateTask;
@@ -19,32 +14,29 @@ import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.test.ESIntegTestCase;
-import org.elasticsearch.xpack.XPackPlugin;
+import org.elasticsearch.xpack.LocalStateCompositeXPackPlugin;
+import org.elasticsearch.xpack.XPackClientPlugin;
import org.elasticsearch.xpack.XPackSettings;
-import org.elasticsearch.xpack.ml.MachineLearning;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.concurrent.CountDownLatch;
public abstract class AbstractLicensesIntegrationTestCase extends ESIntegTestCase {
@Override
protected Settings nodeSettings(int nodeOrdinal) {
- return Settings.builder()
- .put(XPackSettings.SECURITY_ENABLED.getKey(), false)
- .put(XPackSettings.MONITORING_ENABLED.getKey(), false)
- .put(XPackSettings.WATCHER_ENABLED.getKey(), false)
- .put(XPackSettings.GRAPH_ENABLED.getKey(), false)
- .put(XPackSettings.MACHINE_LEARNING_ENABLED.getKey(), false)
- .put(MachineLearning.AUTODETECT_PROCESS.getKey(), false)
- .build();
+ return Settings.builder().put(XPackSettings.SECURITY_ENABLED.getKey(), false).build();
}
@Override
protected Collection> nodePlugins() {
- return Arrays.asList(XPackPlugin.class, CommonAnalysisPlugin.class);
+ return Arrays.asList(LocalStateCompositeXPackPlugin.class, CommonAnalysisPlugin.class);
}
@Override
protected Collection> transportClientPlugins() {
- return nodePlugins();
+ return Arrays.asList(XPackClientPlugin.class, CommonAnalysisPlugin.class);
}
@Override
diff --git a/plugin/src/test/java/org/elasticsearch/license/ExpirationCallbackTests.java b/plugin/core/src/test/java/org/elasticsearch/license/ExpirationCallbackTests.java
similarity index 100%
rename from plugin/src/test/java/org/elasticsearch/license/ExpirationCallbackTests.java
rename to plugin/core/src/test/java/org/elasticsearch/license/ExpirationCallbackTests.java
diff --git a/plugin/src/test/java/org/elasticsearch/license/LicenseClusterChangeTests.java b/plugin/core/src/test/java/org/elasticsearch/license/LicenseClusterChangeTests.java
similarity index 100%
rename from plugin/src/test/java/org/elasticsearch/license/LicenseClusterChangeTests.java
rename to plugin/core/src/test/java/org/elasticsearch/license/LicenseClusterChangeTests.java
diff --git a/plugin/src/test/java/org/elasticsearch/license/LicenseOperationModeTests.java b/plugin/core/src/test/java/org/elasticsearch/license/LicenseOperationModeTests.java
similarity index 100%
rename from plugin/src/test/java/org/elasticsearch/license/LicenseOperationModeTests.java
rename to plugin/core/src/test/java/org/elasticsearch/license/LicenseOperationModeTests.java
diff --git a/plugin/src/test/java/org/elasticsearch/license/LicenseOperationModeUpdateTests.java b/plugin/core/src/test/java/org/elasticsearch/license/LicenseOperationModeUpdateTests.java
similarity index 100%
rename from plugin/src/test/java/org/elasticsearch/license/LicenseOperationModeUpdateTests.java
rename to plugin/core/src/test/java/org/elasticsearch/license/LicenseOperationModeUpdateTests.java
diff --git a/plugin/src/test/java/org/elasticsearch/license/LicenseRegistrationTests.java b/plugin/core/src/test/java/org/elasticsearch/license/LicenseRegistrationTests.java
similarity index 100%
rename from plugin/src/test/java/org/elasticsearch/license/LicenseRegistrationTests.java
rename to plugin/core/src/test/java/org/elasticsearch/license/LicenseRegistrationTests.java
diff --git a/plugin/src/test/java/org/elasticsearch/license/LicenseScheduleTests.java b/plugin/core/src/test/java/org/elasticsearch/license/LicenseScheduleTests.java
similarity index 100%
rename from plugin/src/test/java/org/elasticsearch/license/LicenseScheduleTests.java
rename to plugin/core/src/test/java/org/elasticsearch/license/LicenseScheduleTests.java
diff --git a/plugin/src/test/java/org/elasticsearch/license/LicenseSerializationTests.java b/plugin/core/src/test/java/org/elasticsearch/license/LicenseSerializationTests.java
similarity index 100%
rename from plugin/src/test/java/org/elasticsearch/license/LicenseSerializationTests.java
rename to plugin/core/src/test/java/org/elasticsearch/license/LicenseSerializationTests.java
diff --git a/plugin/src/test/java/org/elasticsearch/license/LicenseServiceClusterNotRecoveredTests.java b/plugin/core/src/test/java/org/elasticsearch/license/LicenseServiceClusterNotRecoveredTests.java
similarity index 92%
rename from plugin/src/test/java/org/elasticsearch/license/LicenseServiceClusterNotRecoveredTests.java
rename to plugin/core/src/test/java/org/elasticsearch/license/LicenseServiceClusterNotRecoveredTests.java
index b16244419fc..dc19e7ab5a6 100644
--- a/plugin/src/test/java/org/elasticsearch/license/LicenseServiceClusterNotRecoveredTests.java
+++ b/plugin/core/src/test/java/org/elasticsearch/license/LicenseServiceClusterNotRecoveredTests.java
@@ -11,7 +11,7 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.transport.Netty4Plugin;
-import org.elasticsearch.xpack.XPackPlugin;
+import org.elasticsearch.xpack.LocalStateCompositeXPackPlugin;
import java.util.Arrays;
import java.util.Collection;
@@ -37,7 +37,7 @@ public class LicenseServiceClusterNotRecoveredTests extends AbstractLicensesInte
@Override
protected Collection> nodePlugins() {
- return Arrays.asList(XPackPlugin.class, CommonAnalysisPlugin.class, Netty4Plugin.class);
+ return Arrays.asList(LocalStateCompositeXPackPlugin.class, CommonAnalysisPlugin.class, Netty4Plugin.class);
}
@Override
diff --git a/plugin/src/test/java/org/elasticsearch/license/LicenseServiceClusterTests.java b/plugin/core/src/test/java/org/elasticsearch/license/LicenseServiceClusterTests.java
similarity index 97%
rename from plugin/src/test/java/org/elasticsearch/license/LicenseServiceClusterTests.java
rename to plugin/core/src/test/java/org/elasticsearch/license/LicenseServiceClusterTests.java
index 44ed4f0d8e2..acd4df85262 100644
--- a/plugin/src/test/java/org/elasticsearch/license/LicenseServiceClusterTests.java
+++ b/plugin/core/src/test/java/org/elasticsearch/license/LicenseServiceClusterTests.java
@@ -13,6 +13,7 @@ import org.elasticsearch.env.Environment;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.transport.Netty4Plugin;
+import org.elasticsearch.xpack.LocalStateCompositeXPackPlugin;
import org.elasticsearch.xpack.XPackPlugin;
import java.nio.charset.StandardCharsets;
@@ -43,7 +44,7 @@ public class LicenseServiceClusterTests extends AbstractLicensesIntegrationTestC
@Override
protected Collection> nodePlugins() {
- return Arrays.asList(XPackPlugin.class, CommonAnalysisPlugin.class, Netty4Plugin.class);
+ return Arrays.asList(LocalStateCompositeXPackPlugin.class, CommonAnalysisPlugin.class, Netty4Plugin.class);
}
@Override
diff --git a/plugin/src/test/java/org/elasticsearch/license/LicenseUtilsTests.java b/plugin/core/src/test/java/org/elasticsearch/license/LicenseUtilsTests.java
similarity index 100%
rename from plugin/src/test/java/org/elasticsearch/license/LicenseUtilsTests.java
rename to plugin/core/src/test/java/org/elasticsearch/license/LicenseUtilsTests.java
diff --git a/plugin/src/test/java/org/elasticsearch/license/LicensesAcknowledgementTests.java b/plugin/core/src/test/java/org/elasticsearch/license/LicensesAcknowledgementTests.java
similarity index 100%
rename from plugin/src/test/java/org/elasticsearch/license/LicensesAcknowledgementTests.java
rename to plugin/core/src/test/java/org/elasticsearch/license/LicensesAcknowledgementTests.java
diff --git a/plugin/src/test/java/org/elasticsearch/license/LicensesManagerServiceTests.java b/plugin/core/src/test/java/org/elasticsearch/license/LicensesManagerServiceTests.java
similarity index 96%
rename from plugin/src/test/java/org/elasticsearch/license/LicensesManagerServiceTests.java
rename to plugin/core/src/test/java/org/elasticsearch/license/LicensesManagerServiceTests.java
index 3d0c7f94de4..53043e2d636 100644
--- a/plugin/src/test/java/org/elasticsearch/license/LicensesManagerServiceTests.java
+++ b/plugin/core/src/test/java/org/elasticsearch/license/LicensesManagerServiceTests.java
@@ -11,9 +11,9 @@ import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.plugins.Plugin;
-import org.elasticsearch.xpack.XPackPlugin;
+import org.elasticsearch.test.ESSingleNodeTestCase;
+import org.elasticsearch.xpack.LocalStateCompositeXPackPlugin;
import org.elasticsearch.xpack.XPackSettings;
-import org.elasticsearch.xpack.XPackSingleNodeTestCase;
import org.junit.Before;
import java.util.Collection;
@@ -24,11 +24,11 @@ import java.util.concurrent.atomic.AtomicBoolean;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.not;
-public class LicensesManagerServiceTests extends XPackSingleNodeTestCase {
+public class LicensesManagerServiceTests extends ESSingleNodeTestCase {
@Override
protected Collection> getPlugins() {
- return Collections.singletonList(XPackPlugin.class);
+ return Collections.singletonList(LocalStateCompositeXPackPlugin.class);
}
@Override
diff --git a/plugin/src/test/java/org/elasticsearch/license/LicensesMetaDataSerializationTests.java b/plugin/core/src/test/java/org/elasticsearch/license/LicensesMetaDataSerializationTests.java
similarity index 100%
rename from plugin/src/test/java/org/elasticsearch/license/LicensesMetaDataSerializationTests.java
rename to plugin/core/src/test/java/org/elasticsearch/license/LicensesMetaDataSerializationTests.java
diff --git a/plugin/src/test/java/org/elasticsearch/license/LicensesTransportTests.java b/plugin/core/src/test/java/org/elasticsearch/license/LicensesTransportTests.java
similarity index 96%
rename from plugin/src/test/java/org/elasticsearch/license/LicensesTransportTests.java
rename to plugin/core/src/test/java/org/elasticsearch/license/LicensesTransportTests.java
index 9a986218387..f5ba41f6abd 100644
--- a/plugin/src/test/java/org/elasticsearch/license/LicensesTransportTests.java
+++ b/plugin/core/src/test/java/org/elasticsearch/license/LicensesTransportTests.java
@@ -12,9 +12,9 @@ import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.node.Node;
import org.elasticsearch.plugins.Plugin;
-import org.elasticsearch.xpack.XPackPlugin;
+import org.elasticsearch.test.ESSingleNodeTestCase;
+import org.elasticsearch.xpack.LocalStateCompositeXPackPlugin;
import org.elasticsearch.xpack.XPackSettings;
-import org.elasticsearch.xpack.XPackSingleNodeTestCase;
import java.nio.charset.StandardCharsets;
import java.util.Collection;
@@ -27,7 +27,7 @@ import static org.elasticsearch.license.TestUtils.generateSignedLicense;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.not;
-public class LicensesTransportTests extends XPackSingleNodeTestCase {
+public class LicensesTransportTests extends ESSingleNodeTestCase {
@Override
protected boolean resetNodeAfterTest() {
@@ -36,7 +36,7 @@ public class LicensesTransportTests extends XPackSingleNodeTestCase {
@Override
protected Collection> getPlugins() {
- return Collections.singletonList(XPackPlugin.class);
+ return Collections.singletonList(LocalStateCompositeXPackPlugin.class);
}
@Override
@@ -44,8 +44,8 @@ public class LicensesTransportTests extends XPackSingleNodeTestCase {
Settings.Builder newSettings = Settings.builder();
newSettings.put(super.nodeSettings());
newSettings.put(XPackSettings.SECURITY_ENABLED.getKey(), false);
- newSettings.put(XPackSettings.MONITORING_ENABLED.getKey(), false);
- newSettings.put(XPackSettings.WATCHER_ENABLED.getKey(), false);
+// newSettings.put(XPackSettings.MONITORING_ENABLED.getKey(), false);
+// newSettings.put(XPackSettings.WATCHER_ENABLED.getKey(), false);
newSettings.put(Node.NODE_DATA_SETTING.getKey(), true);
return newSettings.build();
}
diff --git a/plugin/src/test/java/org/elasticsearch/license/OperationModeFileWatcherTests.java b/plugin/core/src/test/java/org/elasticsearch/license/OperationModeFileWatcherTests.java
similarity index 100%
rename from plugin/src/test/java/org/elasticsearch/license/OperationModeFileWatcherTests.java
rename to plugin/core/src/test/java/org/elasticsearch/license/OperationModeFileWatcherTests.java
diff --git a/plugin/src/test/java/org/elasticsearch/license/PutLicenseResponseTests.java b/plugin/core/src/test/java/org/elasticsearch/license/PutLicenseResponseTests.java
similarity index 100%
rename from plugin/src/test/java/org/elasticsearch/license/PutLicenseResponseTests.java
rename to plugin/core/src/test/java/org/elasticsearch/license/PutLicenseResponseTests.java
diff --git a/plugin/src/test/java/org/elasticsearch/license/SelfGeneratedLicenseTests.java b/plugin/core/src/test/java/org/elasticsearch/license/SelfGeneratedLicenseTests.java
similarity index 100%
rename from plugin/src/test/java/org/elasticsearch/license/SelfGeneratedLicenseTests.java
rename to plugin/core/src/test/java/org/elasticsearch/license/SelfGeneratedLicenseTests.java
diff --git a/plugin/src/test/java/org/elasticsearch/license/TestUtils.java b/plugin/core/src/test/java/org/elasticsearch/license/TestUtils.java
similarity index 100%
rename from plugin/src/test/java/org/elasticsearch/license/TestUtils.java
rename to plugin/core/src/test/java/org/elasticsearch/license/TestUtils.java
diff --git a/plugin/src/test/java/org/elasticsearch/license/UpgradeToTrialTests.java b/plugin/core/src/test/java/org/elasticsearch/license/UpgradeToTrialTests.java
similarity index 92%
rename from plugin/src/test/java/org/elasticsearch/license/UpgradeToTrialTests.java
rename to plugin/core/src/test/java/org/elasticsearch/license/UpgradeToTrialTests.java
index 7326e4d7e25..6268a9170be 100644
--- a/plugin/src/test/java/org/elasticsearch/license/UpgradeToTrialTests.java
+++ b/plugin/core/src/test/java/org/elasticsearch/license/UpgradeToTrialTests.java
@@ -14,7 +14,8 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.transport.Netty4Plugin;
-import org.elasticsearch.xpack.XPackPlugin;
+import org.elasticsearch.xpack.LocalStateCompositeXPackPlugin;
+import org.elasticsearch.xpack.XPackClientPlugin;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
@@ -37,12 +38,12 @@ public class UpgradeToTrialTests extends AbstractLicensesIntegrationTestCase {
@Override
protected Collection> nodePlugins() {
- return Arrays.asList(XPackPlugin.class, Netty4Plugin.class);
+ return Arrays.asList(LocalStateCompositeXPackPlugin.class, Netty4Plugin.class);
}
@Override
protected Collection> transportClientPlugins() {
- return nodePlugins();
+ return Arrays.asList(XPackClientPlugin.class, Netty4Plugin.class);
}
public void testUpgradeToTrial() throws Exception {
diff --git a/plugin/src/test/java/org/elasticsearch/script/MockMustacheScriptEngine.java b/plugin/core/src/test/java/org/elasticsearch/script/MockMustacheScriptEngine.java
similarity index 95%
rename from plugin/src/test/java/org/elasticsearch/script/MockMustacheScriptEngine.java
rename to plugin/core/src/test/java/org/elasticsearch/script/MockMustacheScriptEngine.java
index 98a80890f12..4f9b125a9fd 100644
--- a/plugin/src/test/java/org/elasticsearch/script/MockMustacheScriptEngine.java
+++ b/plugin/core/src/test/java/org/elasticsearch/script/MockMustacheScriptEngine.java
@@ -6,7 +6,6 @@
package org.elasticsearch.script;
import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.xpack.watcher.common.text.TextTemplateEngine;
import java.util.Collection;
import java.util.Collections;
@@ -15,7 +14,7 @@ import java.util.function.Function;
/**
* A mock script engine that registers itself under the 'mustache' name so that
- * {@link TextTemplateEngine}
+ * TextTemplateEngine (watcher)
* uses it and adds validation that watcher tests don't rely on mustache templating/
*/
public class MockMustacheScriptEngine extends MockScriptEngine {
diff --git a/plugin/core/src/test/java/org/elasticsearch/test/SecuritySettingsSourceField.java b/plugin/core/src/test/java/org/elasticsearch/test/SecuritySettingsSourceField.java
new file mode 100644
index 00000000000..12082b77043
--- /dev/null
+++ b/plugin/core/src/test/java/org/elasticsearch/test/SecuritySettingsSourceField.java
@@ -0,0 +1,15 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+package org.elasticsearch.test;
+
+import org.elasticsearch.common.settings.SecureString;
+
+public final class SecuritySettingsSourceField {
+ public static final SecureString TEST_PASSWORD_SECURE_STRING = new SecureString("x-pack-test-password".toCharArray());
+ public static final String TEST_PASSWORD = "x-pack-test-password";
+
+ private SecuritySettingsSourceField() {}
+}
diff --git a/plugin/src/test/java/org/elasticsearch/test/TestMatchers.java b/plugin/core/src/test/java/org/elasticsearch/test/TestMatchers.java
similarity index 100%
rename from plugin/src/test/java/org/elasticsearch/test/TestMatchers.java
rename to plugin/core/src/test/java/org/elasticsearch/test/TestMatchers.java
diff --git a/plugin/src/test/java/org/elasticsearch/test/http/Headers.java b/plugin/core/src/test/java/org/elasticsearch/test/http/Headers.java
similarity index 100%
rename from plugin/src/test/java/org/elasticsearch/test/http/Headers.java
rename to plugin/core/src/test/java/org/elasticsearch/test/http/Headers.java
diff --git a/plugin/src/test/java/org/elasticsearch/test/http/MockRequest.java b/plugin/core/src/test/java/org/elasticsearch/test/http/MockRequest.java
similarity index 100%
rename from plugin/src/test/java/org/elasticsearch/test/http/MockRequest.java
rename to plugin/core/src/test/java/org/elasticsearch/test/http/MockRequest.java
diff --git a/plugin/src/test/java/org/elasticsearch/test/http/MockResponse.java b/plugin/core/src/test/java/org/elasticsearch/test/http/MockResponse.java
similarity index 100%
rename from plugin/src/test/java/org/elasticsearch/test/http/MockResponse.java
rename to plugin/core/src/test/java/org/elasticsearch/test/http/MockResponse.java
diff --git a/plugin/src/test/java/org/elasticsearch/test/http/MockWebServer.java b/plugin/core/src/test/java/org/elasticsearch/test/http/MockWebServer.java
similarity index 100%
rename from plugin/src/test/java/org/elasticsearch/test/http/MockWebServer.java
rename to plugin/core/src/test/java/org/elasticsearch/test/http/MockWebServer.java
diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ClientHelperTests.java b/plugin/core/src/test/java/org/elasticsearch/xpack/ClientHelperTests.java
similarity index 100%
rename from plugin/src/test/java/org/elasticsearch/xpack/ClientHelperTests.java
rename to plugin/core/src/test/java/org/elasticsearch/xpack/ClientHelperTests.java
diff --git a/plugin/core/src/test/java/org/elasticsearch/xpack/LocalStateCompositeXPackPlugin.java b/plugin/core/src/test/java/org/elasticsearch/xpack/LocalStateCompositeXPackPlugin.java
new file mode 100644
index 00000000000..eaec05a8a22
--- /dev/null
+++ b/plugin/core/src/test/java/org/elasticsearch/xpack/LocalStateCompositeXPackPlugin.java
@@ -0,0 +1,385 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+package org.elasticsearch.xpack;
+
+import org.elasticsearch.action.ActionRequest;
+import org.elasticsearch.action.ActionResponse;
+import org.elasticsearch.action.support.ActionFilter;
+import org.elasticsearch.bootstrap.BootstrapCheck;
+import org.elasticsearch.client.Client;
+import org.elasticsearch.cluster.ClusterState;
+import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
+import org.elasticsearch.cluster.metadata.IndexTemplateMetaData;
+import org.elasticsearch.cluster.node.DiscoveryNode;
+import org.elasticsearch.cluster.node.DiscoveryNodes;
+import org.elasticsearch.cluster.service.ClusterService;
+import org.elasticsearch.common.inject.Module;
+import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
+import org.elasticsearch.common.network.NetworkService;
+import org.elasticsearch.common.settings.ClusterSettings;
+import org.elasticsearch.common.settings.IndexScopedSettings;
+import org.elasticsearch.common.settings.Setting;
+import org.elasticsearch.common.settings.Settings;
+import org.elasticsearch.common.settings.SettingsFilter;
+import org.elasticsearch.common.util.BigArrays;
+import org.elasticsearch.common.util.PageCacheRecycler;
+import org.elasticsearch.common.util.concurrent.ThreadContext;
+import org.elasticsearch.common.xcontent.NamedXContentRegistry;
+import org.elasticsearch.env.Environment;
+import org.elasticsearch.env.NodeEnvironment;
+import org.elasticsearch.http.HttpServerTransport;
+import org.elasticsearch.index.IndexModule;
+import org.elasticsearch.index.analysis.TokenizerFactory;
+import org.elasticsearch.indices.analysis.AnalysisModule;
+import org.elasticsearch.indices.breaker.CircuitBreakerService;
+import org.elasticsearch.ingest.Processor;
+import org.elasticsearch.license.LicenseService;
+import org.elasticsearch.license.XPackLicenseState;
+import org.elasticsearch.plugins.ActionPlugin;
+import org.elasticsearch.plugins.AnalysisPlugin;
+import org.elasticsearch.plugins.ClusterPlugin;
+import org.elasticsearch.plugins.DiscoveryPlugin;
+import org.elasticsearch.plugins.IngestPlugin;
+import org.elasticsearch.plugins.MapperPlugin;
+import org.elasticsearch.plugins.NetworkPlugin;
+import org.elasticsearch.plugins.Plugin;
+import org.elasticsearch.plugins.ScriptPlugin;
+import org.elasticsearch.rest.RestController;
+import org.elasticsearch.rest.RestHandler;
+import org.elasticsearch.script.ScriptContext;
+import org.elasticsearch.script.ScriptService;
+import org.elasticsearch.threadpool.ExecutorBuilder;
+import org.elasticsearch.threadpool.ThreadPool;
+import org.elasticsearch.transport.Transport;
+import org.elasticsearch.transport.TransportInterceptor;
+import org.elasticsearch.watcher.ResourceWatcherService;
+import org.elasticsearch.xpack.ssl.SSLService;
+
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.function.BiConsumer;
+import java.util.function.Function;
+import java.util.function.Predicate;
+import java.util.function.Supplier;
+import java.util.function.UnaryOperator;
+import java.util.stream.Collectors;
+
+public class LocalStateCompositeXPackPlugin extends XPackPlugin implements ScriptPlugin, ActionPlugin, IngestPlugin, NetworkPlugin,
+ ClusterPlugin, DiscoveryPlugin, MapperPlugin, AnalysisPlugin {
+
+ private XPackLicenseState licenseState;
+ private SSLService sslService;
+ private LicenseService licenseService;
+ protected List plugins = new ArrayList<>();
+
+ public LocalStateCompositeXPackPlugin(final Settings settings, final Path configPath) throws Exception {
+ super(settings, configPath);
+ }
+
+ //Get around all the setOnce nonsense in the plugin
+ @Override
+ protected SSLService getSslService() {
+ return sslService;
+ }
+
+ @Override
+ protected void setSslService(SSLService sslService) {
+ this.sslService = sslService;
+ }
+
+ @Override
+ protected LicenseService getLicenseService() {
+ return licenseService;
+ }
+
+ @Override
+ protected void setLicenseService(LicenseService licenseService) {
+ this.licenseService = licenseService;
+ }
+
+ @Override
+ protected XPackLicenseState getLicenseState() {
+ return licenseState;
+ }
+
+ @Override
+ protected void setLicenseState(XPackLicenseState licenseState) {
+ this.licenseState = licenseState;
+ }
+
+ @Override
+ public Collection createGuiceModules() {
+ ArrayList modules = new ArrayList<>();
+ modules.addAll(super.createGuiceModules());
+ filterPlugins(Plugin.class).stream().forEach(p ->
+ modules.addAll(p.createGuiceModules())
+ );
+ return modules;
+ }
+
+ @Override
+ public Collection createComponents(Client client, ClusterService clusterService, ThreadPool threadPool,
+ ResourceWatcherService resourceWatcherService, ScriptService scriptService,
+ NamedXContentRegistry xContentRegistry, Environment environment,
+ NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry) {
+ List components = new ArrayList<>();
+ components.addAll(super.createComponents(client, clusterService, threadPool, resourceWatcherService, scriptService,
+ xContentRegistry, environment, nodeEnvironment, namedWriteableRegistry));
+
+ filterPlugins(Plugin.class).stream().forEach(p ->
+ components.addAll(p.createComponents(client, clusterService, threadPool, resourceWatcherService, scriptService,
+ xContentRegistry, environment, nodeEnvironment, namedWriteableRegistry))
+ );
+ return components;
+ }
+
+ @Override
+ public Collection getRestHeaders() {
+ List headers = new ArrayList<>();
+ headers.addAll(super.getRestHeaders());
+ filterPlugins(ActionPlugin.class).stream().forEach(p -> headers.addAll(p.getRestHeaders()));
+ return headers;
+ }
+
+ @Override
+ public List> getSettings() {
+ ArrayList> settings = new ArrayList<>();
+ settings.addAll(super.getSettings());
+
+ filterPlugins(Plugin.class).stream().forEach(p ->
+ settings.addAll(p.getSettings())
+ );
+ return settings;
+ }
+
+ @Override
+ public List getSettingsFilter() {
+ List filters = new ArrayList<>();
+ filters.addAll(super.getSettingsFilter());
+ filterPlugins(Plugin.class).stream().forEach(p ->
+ filters.addAll(p.getSettingsFilter())
+ );
+ return filters;
+ }
+
+ @Override
+ public List> getActions() {
+ List> actions = new ArrayList<>();
+ actions.addAll(super.getActions());
+ filterPlugins(ActionPlugin.class).stream().forEach(p ->
+ actions.addAll(p.getActions())
+ );
+ return actions;
+ }
+
+ @Override
+ public List getActionFilters() {
+ List filters = new ArrayList<>();
+ filters.addAll(super.getActionFilters());
+ filterPlugins(ActionPlugin.class).stream().forEach(p ->
+ filters.addAll(p.getActionFilters())
+ );
+ return filters;
+ }
+
+ @Override
+ public List getRestHandlers(Settings settings, RestController restController, ClusterSettings clusterSettings,
+ IndexScopedSettings indexScopedSettings, SettingsFilter settingsFilter,
+ IndexNameExpressionResolver indexNameExpressionResolver,
+ Supplier nodesInCluster) {
+ List handlers = new ArrayList<>();
+ handlers.addAll(super.getRestHandlers(settings, restController, clusterSettings, indexScopedSettings, settingsFilter,
+ indexNameExpressionResolver, nodesInCluster));
+ filterPlugins(ActionPlugin.class).stream().forEach(p ->
+ handlers.addAll(p.getRestHandlers(settings, restController, clusterSettings, indexScopedSettings,
+ settingsFilter, indexNameExpressionResolver, nodesInCluster))
+ );
+ return handlers;
+ }
+
+ @Override
+ public List getNamedWriteables() {
+ List entries = new ArrayList<>();
+ entries.addAll(super.getNamedWriteables());
+ for (Plugin p : plugins) {
+ entries.addAll(p.getNamedWriteables());
+ }
+ return entries;
+ }
+
+ @Override
+ public List getNamedXContent() {
+ List entries = new ArrayList<>();
+ entries.addAll(super.getNamedXContent());
+ for (Plugin p : plugins) {
+ entries.addAll(p.getNamedXContent());
+ }
+ return entries;
+ }
+
+ // End of the XPackPlugin overrides
+
+ @Override
+ public Settings additionalSettings() {
+ Settings.Builder builder = Settings.builder();
+ builder.put(super.additionalSettings());
+ filterPlugins(Plugin.class).stream().forEach(p ->
+ builder.put(p.additionalSettings())
+ );
+ return builder.build();
+ }
+
+
+ @Override
+ public List getContexts() {
+ List contexts = new ArrayList<>();
+ contexts.addAll(super.getContexts());
+ filterPlugins(ScriptPlugin.class).stream().forEach(p -> contexts.addAll(p.getContexts()));
+ return contexts;
+ }
+
+ @Override
+ public Map getProcessors(Processor.Parameters parameters) {
+ Map processors = new HashMap<>();
+ filterPlugins(IngestPlugin.class).stream().forEach(p -> processors.putAll(p.getProcessors(parameters)));
+ return processors;
+ }
+
+ @Override
+ public List getTransportInterceptors(NamedWriteableRegistry namedWriteableRegistry, ThreadContext threadContext) {
+ List interceptors = new ArrayList<>();
+ filterPlugins(NetworkPlugin.class).stream().forEach(p -> interceptors.addAll(p.getTransportInterceptors(namedWriteableRegistry,
+ threadContext)));
+ return interceptors;
+ }
+
+ @Override
+ public Map> getTransports(Settings settings, ThreadPool threadPool, BigArrays bigArrays,
+ PageCacheRecycler pageCacheRecycler,
+ CircuitBreakerService circuitBreakerService,
+ NamedWriteableRegistry namedWriteableRegistry,
+ NetworkService networkService) {
+ Map> transports = new HashMap<>();
+ transports.putAll(super.getTransports(settings, threadPool, bigArrays, pageCacheRecycler,
+ circuitBreakerService, namedWriteableRegistry, networkService));
+ filterPlugins(NetworkPlugin.class).stream().forEach(p -> transports.putAll(p.getTransports(settings, threadPool, bigArrays,
+ pageCacheRecycler, circuitBreakerService, namedWriteableRegistry, networkService)));
+ return transports;
+
+
+ }
+
+ @Override
+ public Map> getHttpTransports(Settings settings, ThreadPool threadPool, BigArrays bigArrays,
+ CircuitBreakerService circuitBreakerService,
+ NamedWriteableRegistry namedWriteableRegistry,
+ NamedXContentRegistry xContentRegistry,
+ NetworkService networkService,
+ HttpServerTransport.Dispatcher dispatcher) {
+ Map> transports = new HashMap<>();
+ filterPlugins(NetworkPlugin.class).stream().forEach(p -> transports.putAll(p.getHttpTransports(settings, threadPool, bigArrays,
+ circuitBreakerService, namedWriteableRegistry, xContentRegistry, networkService, dispatcher)));
+ return transports;
+ }
+
+ @Override
+ public List getBootstrapChecks() {
+ List checks = new ArrayList<>();
+ filterPlugins(Plugin.class).stream().forEach(p -> checks.addAll(p.getBootstrapChecks()));
+ return Collections.unmodifiableList(checks);
+ }
+
+ @Override
+ public UnaryOperator getRestHandlerWrapper(ThreadContext threadContext) {
+
+ // There can be only one.
+ List> items = filterPlugins(ActionPlugin.class).stream().map(p ->
+ p.getRestHandlerWrapper(threadContext)).filter(Objects::nonNull).collect(Collectors.toList());
+
+ if (items.size() > 1) {
+ throw new UnsupportedOperationException("Only the security ActionPlugin should override this");
+ } else if (items.size() == 1) {
+ return items.get(0);
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ public List> getExecutorBuilders(final Settings settings) {
+ List> builders = new ArrayList<>();
+ filterPlugins(Plugin.class).stream().forEach(p -> builders.addAll(p.getExecutorBuilders(settings)));
+ return builders;
+ }
+ @Override
+ public UnaryOperator